Shop OBEX P1 Docs P2 Docs Learn Events
SERIN - Page 2 — Parallax Forums

SERIN

2»

Comments

  • I'm back. I've finally got every thing working again with the BS2p40 but I haven't had a lot of time to work on my problem. I've had a little progress. I've been able to get the STR array to work and I can get a position feedback using SERIN 1, 240, [DEC1 pos, SKIP 2,  DEC4 pos]. But I can't tell if the axis move is completed or not. (upper case P = move finished, lower case p = axis still moving). I really need to get the WAIT(",P"), SPSTR  statement to working because I don't have any variables left in my program so I can't use the STR array. I'm doing something wrong on the WAIT statement because it just keeps waiting. To refresh everyone's memory, the kangaroo (position control module) returns a string of data after seeing a request for position feedback. the string is: 1, Pxxxx,CR. The 1 is the axis number followed by a comma, then an uppercase P or a lowercase p, followed by the position( in this case, always 4 bytes) followed by a carriage return, linefeed. I'm planning on using the statement:  SERIN 1, 240, [WAIT("1,"),SPSTR 5]  This way address 0 will contain the P data byte.
    After I get the  WAIT SPSTR statement working, is there a way to use the rest of scratch pad RAM for variables space?
    Thanks for everyone's help, Arnold
  • Chris,
    That's odd about the arbitrary timing.  FDS4p should not do that and I can't think of why it would misbehave in that way.  Can you share your program so I can check it out too? 
  • Arnold,
    Sure thing, the SPRAM will be available for temporary variable storage.  Use PUT value or GET value.  The value is a byte.  You can also use PUT WORD value or GET WORD value.  It is up to you to organize the memory map in SPRAM the way you want. 

    Note that you also have lots of space in EEPROM for slowing changing variables and parameters.   You have 8 program slots and a program running in one slot can access EEPROM in other slots by using the STORE n command.

    About the kangaroo, I forget what elicits the "1, Pxxxx,CR".
  • After sending a command to go to a position (serout 1, 240, 10, [ "1,p50s 20",CR] ) I send a command (serout 1, 240, 10, ["1,getp",CR] ). The control module transmits the string (1,P0050CR). I need to use the position at times in my program but I usually just need to know if the axis has completed it's move. If it has, it transmits an upper case P along with the rest of the string. If it is still moving, it transmits a lower case p.
    This is my first time with a BS2p40 so I'm about lost when it comes to using the different slots. How do you know when to switch to the next slot when writing the program? Does the declared variables in slot 1 cover the program that spills over into slot 2? Please explain how it all works, if you would. Thanks, Arnold
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    Chris,
    That's odd about the arbitrary timing.  FDS4p should not do that and I can't think of why it would misbehave in that way.  Can you share your program so I can check it out too? 


    Tracy,
    When I get on the PC I am working on that code on I will post it.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    This is my first time with a BS2p40 so I'm about lost when it comes to using the different slots. How do you know when to switch to the next slot when writing the program? Does the declared variables in slot 1 cover the program that spills over into slot 2? Please explain how it all works, if you would.


    Arnold,
    I don't know if you need to use slots or not in your program. I assumed no, since your switch wasn't about program size, but rather timing and the SPSTR function/capability.
    Nonetheless there are a few simple guidelines. If you declare your pin constants and variables the same in each program the variables will be maintained. The I/O pins don't change states during a switch either unless something in the new program tells them to.
  • There are a lot of ways to use the extra slots.  Often a program can be broken up into functional units, such an initialization section where a user can fiddle with the settings, and a main loop that operates using those settings.  I can imagine that your program might have something like that.  It is a natural break point between slots.  The settings can either be stored in EEPROM (using the store command to cross slot boundaries if necessary) or in the SPRAM or in regular RAM.   My programs are heavy on data logging and sensors.  Some sensors such as the SHT temperature/humidity and the MS barometer take a bunch of code, so I have those broken off into separate slots.  I have a stack-like mechanism that allows a main program to call a routine in another slot and then return to where it left off.  That mechanism also serves for code that records and reads back data to flash memory or USB flash vdrive.  Those have their own slots. The data that needs to be logged is held in a buffer in the SPRAM, and the program header specifies how many bytes and the format, so that each slot has access.   Another slot may hold a calculation of sunrise and sunset times through the year, and that slot only gets called at midnight each day.

  • Tracy, I though I was confused before but now I'm really confused. I read about 0STORE, 1STORE, and 2STORE but didn't get it. It looks like STOREALL might be what I need. I need a lot of program space because my program is one long program that doesn't have logical break points. Did I understand STOREALL right? If so then how would I set up my program using STOREALL? My program will be large enough that I'm not sure it will all fit in a BS2p. I'm hoping it will.
    Thanks for taking your time to help straighten me out. Arnold
  • A few days ago I found instructions on how to set up multiple slots when a program took more than one slot but now I can't find those instructions. My memory is very bad and I find it hard to function now days. That makes it very hard to learn anything. If I don't write it down I can't remember it.
    I would prefer to have a program that continues page after page as one program. Is that possible with the BS2p? It looks to me like STOREALL will make it possible but I'm not sure how to make it work. I've read and reread about STORE0. STORE1, AND STORE2 but I can't figure them out. I guess its true, "You can't teach an old dog new tricks", but I've got to keep trying.
    Thanks again, Arnold
  • STORE doesn't have to do with running the program from slot to slot.  What you want are the RUN commands.  That is RUN 0, RUN 1 and so forth.  Do you have the BASIC Stamp manual?

    There is the article by Jon Williams that Chris linked to above.  I have ramblings about multi-slot programming on my web site too, http://emesystems.com/BS2SX.htm.
  • Sorry I've taken so long to respond. I've been working night and day on my sawmill and the program to run it. With everyone's help I've been able to almost finish debugging the program. I'm using SERIN 1, 240, [Skip 3, Dec4 temp1] to obtain the position feedback and I've figured out, to a small degree, how to use multi slot programming. Thanks to everyone.
    Arnold.
    p.s. I've started another thread with another problem I'm having with my program.
Sign In or Register to comment.