Announcement

Collapse
No announcement yet.

Serial com with SK-43DT

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    atoi converts a string to a number, the way I read what you asked you asked for the reverse.

    Anyway here's an example.

    I'd Rather send a binary number over serial as you 'almost' just read it in, and it's only 2 bytes to read 32,000, as opposed to 5 bytes to read it as a string.

    If you are going to be using strings much, make sure you read http://www.4dsystems.com.au/appnote/4D-AN-00056/

    Code:
    func main()
        var data[20];
        var n;
        var i ;
        to(data) ;
        print(12345) ;
        print("As a string:", [STR] data,"\n\n") ;
    
        i := str_Ptr(data) ;            // need a string pointer
        str_GetW(&i, &n) ;              // see if we can convert this to a number
    
        print("As a number:",n) ;      // replace with your code
    
        repeat                      // maybe replace
        forever                     // this as well
    
    endfunc
    Mark

    Comment


    • #17
      Thanks Mark,

      I have this working except I forgot we have some variables that range up to 999999. I need to use long integers.

      How do I declare a long?

      I need to pass a long to my edit function and then return a long. I will also have to convert the string to a long and back?

      I will read the link. If I can get past this long stuff the rest of this project should be fairly easy.

      Thanks Mark, Al

      Comment


      • #18
        Longs are 2 element arrays, depending on what you have to do to manipulate them, you may have to do some stuff in 'longhand'
        Mark

        Comment


        • #19
          I have the editor running with range checking. That was a pain. The serial is running too. Now I just have to create all the menus that call the serial and editor. That is easy.

          One more question, how do I get the program to start when it is powered up not connected to the computer?

          Comment


          • #20
            Project, Destination, Flash
            Mark

            Comment


            • #21
              Hi Mark,

              My app will exceed 32K soon. I will need to debug from flash. My question is about the 6 banks of 32K flash. Will the compiler automatically manage those or is there something I will have to do when I exceed 32K?

              The project is gong very well now. Next I will be using an aux serial port so I can connect to the target and debug at the same time. We will be designing a mating card for the display with a power supply and RS422 drivers. I will use the aux serial port for comm. to our target.

              I may have a question if I get stumped configuring the aux serial port.

              This is working out very well. Thanks much for all your help.

              Al

              Comment


              • #22
                You will need to start putting some of your functions (preferably the larger ones) into separate banks and call them from the main bank. There are examples in these forums, as well as in the file, samples, Diablo designer, folders.

                Somehow I got the impression your program wasn't going to be that big. What's in that 32kb? Can you post the project here, or maybe send it to me? mark at 4dsystems dot com dot au
                Mark

                Comment


                • #23
                  Hi Mark,

                  I'm not sure it will exceed 32K but I suspect it will. There are 13 menu pages yet to be added, a keypad editor with ranging. I pass variable to it to select the number of digits and decimal points as well as the data and title messages. There is also a list editor. The serial drivers to talk to our host control, and a main run screen that updates the status and has a control panel. The control is for a very high speed servo controlled label applier.

                  I have the buffered com1 working OK.

                  My editor is not the most efficient use of code. I could go back and put some things in functions. I am in a bit of a hurry to get this done. I'm working too many hours and getting behind. I'll be 71 soon, I need some rest.

                  Would you be so kind to tell me the exact file that is a sample for putting functions in banks? There are a lot of files and I have no idea which one to look for.

                  I attached my program. It is not elegant but it will work. There is some temp code in there for debugging. Tomorrow I am going to connect it to our host control. I slowed it to 9600 for debugging. I'm not really a programmer, my main forte is designing servo control systems. In a small company you do a lot of things.

                  Al
                  Attached Files

                  Comment


                  • #24
                    FlashCalled and FlashExec are the two samples.

                    The last post here shows a good way of calling functions in other banks http://forum.4dsystems.com.au/forum/...pe-environment
                    Mark

                    Comment


                    • #25
                      Thanks Mark, I'll cross that bridge when, or if, I come to it. I think I'll optimize some of the code I have already done.

                      FYI: We use the Rabbit CPU for a number of things. It is an 8 bit CPU with a lot of features for the control world. Would NOT be good for graphics. from their data sheet.

                      The task of the memory mapping unit is to accept 16-bit addresses and translate them to 20-bit addresses. The
                      memory interface unit accepts the 20-bit addresses and generates control signals applied
                      directly to the memory chips.

                      Comment


                      • #26
                        I am about ¾ of the way done. It is working very well and talking to my target with no issues at all. I have optimized the code quite a bit and it appears I may get it all in 32K.

                        Our distributors have asked if the software for all three models could be in the hand held terminal and it would detect what it is plugged into. The software is very similar, just different setup parameters and a few features added.

                        My question is this. Can I put three different programs in three different banks and have the main program detect and then transfer to the appropriate bank? It would never come back again until power is off.

                        Does it always start in bank 0? I assume so.

                        I read the documents and am really confused with the bank stuff. This is not an easy feature to use. I would like a simple explanation of how a program in bank 0 could jump to bank 1 and never come back. No values need to be passed.

                        Thanks Mark.

                        Al

                        Comment


                        • #27
                          A reboot/power up/restart always starts in bank 0.

                          flash_Run() is how you transfer control to another bank 'never to return'
                          Mark

                          Comment


                          • #28
                            I am about finished and I will have about 28K.

                            If I use flash_called and the program in bank 2 never returns form main will that work? When I get time I can play with this.

                            Comment


                            • #29
                              Well, you can do that and it will work that way.

                              The 'downside' is a slightly smaller RAM space as the stack will contain 'return to bank 0' information and any variables allcated in bank 0
                              Mark

                              Comment


                              • #30
                                Thanks Mark,

                                I am only using 600 bytes of RAM so That should be fine. This is working out very well. Great product for our APP. Thanks for all the support of my dumb questions. I think I have learned everything I need to know.

                                Al

                                Comment

                                Working...
                                X