Shop OBEX P1 Docs P2 Docs Learn Events
Communicating with a BS2 — Parallax Forums

Communicating with a BS2

cplattcplatt Posts: 55
edited 2007-07-09 16:28 in BASIC Stamp
Dear Kind Sirs:

I need some help from you great experts out there!

I have a Windows 2000 VBbasic program processing information for control and need to communicate a command number 1-512 or greater to six seperate BS2 stamps which will then inturn process a feedback loop input from pots and an PWM output loop to control six 12V soleniod coils. What is the best way to communicate with the stamp the control information??? I could use the com port probably somehow correct? Or the serial? The PWM and input feedback portions are no problem using Matts Gilliand(sp?) great project book I.

Thank you for your time.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-09 16:28
    There is not a simple answer to this. The main complication is that the Stamps can only do one thing at a time. When they're "listening" to a serial port, they can't do anything else and, when they're doing something else, they're not listening to any serial port and will miss anything that's sent to them.

    The most straightforward solution is to use some kind of hardware buffer between the PC and the Stamp. If you're going to use USB anyway for your communication port, you could use something like FTDI's USB to TTL Serial Adapter (www.ftdichip.com/Products/EvaluationKits/TTL-232R-WE.htm). This would allow you to access the handshake lines (RTS and CTS). RTS tells the Stamp that the adapter has data for it while CTS is a signal to the adapter that the Stamp is ready for the data to be sent. The CTS line would be used for the SERIN handshake line while the Stamp would use some other pin for RTS which it would check periodically.

    The PC would just send a command from time to time or perhaps a zero to indicate no command. The VB program would have to be able to check for the serial port being "full". I'm not sure, but there may be some kind of timeout available. If a timeout occurs, the VB program would just resend the command.

    The command could be sent most simply as some kind of sync character (like "!") followed by a decimal command code, then a return. The Stamp would look for the "!", then use the DEC formatter to read the command and the return would be the delimiter at the end of the number.

    Read the section in the PBasic manual on the SERIN command.
Sign In or Register to comment.