Help with parsing SERIN data
Kevin Harris
Posts: 15
I'm using a BS2 to receive coordinate data to drive servos for a color tracking program I've written.· I'm trying to figure out what the best way to send from the computer and receive to the BS2 in one shot an X and Y coordinate, both signed.· I need to formulate a good SERIN statement that can split up one piece of data into two signed coordinates.· I can make my computer send it in any format.· Anyone have any ideas?·· Thanks, Kevin Harris
Comments
· SERIN Sio, Baud, [noparse][[/noparse]xCoord.BYTE0, xCoord.BYTE1, yCoord.BYTE0, yCoord.BYTE1]
If you can send the data as a sting, like:
· "-34, +27"
... then you can do something like this:
· SERIN Sio, Baud, [noparse][[/noparse]SDEC xCoord, SDEC yCoord]
The SDEC modifier converts a signed number sent as a string to a value.· You can add a WAIT modifier for synchronization if you need.· If your string was:
· "Heading = -34, +27"
... then you could do this:
· SERIN Sio, Baud, [noparse][[/noparse]WAIT ("ding ="), SDEC xCoord, SDEC yCoord]
Note that the WAIT string is limited to six characters, hence the truncation.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax