Shop OBEX P1 Docs P2 Docs Learn Events
Using BS2 as a pass-thru from PC to serial device — Parallax Forums

Using BS2 as a pass-thru from PC to serial device

I have students in a high school class that are driving a robot arm right now successfully using SEROUT commands on a BS2 (lifted from boe-bots).

Unfortunately, the programs they'd like to write won't fit in the BS2 nor does the BS2 have easy handling of real numbers, especially with division.

So, we came up with a scheme for them to program on a PC. Obviously, it would be better to drive the robot arm directly from the PC, but there are no serial ports on most modern PCs. We would use the BS2 as a pass-thru device to talk to the robot arm (since that works well right now). The BS2 would do a DEBUGIN to get data from the PC usb port and pass to the arm using to the serout command.

Students would send characters to the BS2 10 bytes at a time with the final 'packet' of up to 10 bytes with a CR. Students would pause some amount of time between sending packets to allow the bs2 to send the data to the arm. Within reason, longer delays won't be a problem. The BS2 code we might use:

someBytes var Byte(10)
i var Byte
do
for i = 0 to 9
someBytes(i) = 0
debugin STR someBytes\10\13 'a CR is the end of the command string for the robot arm
seqout xxxxxx 'as appropriate for the robot arm
loop

Does anyone see a problem with this scheme? Is there a better way?

Thanks in advance for any help.

Comments

  • DEBUGIN STR will zero the remaining bytes after it sees the CR. So you don't need to fill someBytes with zeroes (you are missing the NEXT).

    I don't see why the scheme won't work. Try it and see.
Sign In or Register to comment.