BS2P24 to computer connection
spaine
Posts: 51
I see SOUT and SIN on the BS2P24, and I understand that those are used to attach the BS2P to a computer for programming (and debugging).
However, during run-time, what do I use to communicate with a PC? Can I just use any I/O pin, and connect it to something like a Max232 device for connection to a computer?
Basically, my Stamp will be receiving sensor data, and then forwarding this data on to my PC (which if my above is correct will use one I/O pin), but then my PC will process the data, and then send updated data back to the Stamp (would this use another I/O pin)?
Thanks for the help.
However, during run-time, what do I use to communicate with a PC? Can I just use any I/O pin, and connect it to something like a Max232 device for connection to a computer?
Basically, my Stamp will be receiving sensor data, and then forwarding this data on to my PC (which if my above is correct will use one I/O pin), but then my PC will process the data, and then send updated data back to the Stamp (would this use another I/O pin)?
Thanks for the help.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
almost need a separate forum channel for it.
or maybe a pdf or doc file to refer people to.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
**************
daniel woolston
Teksystems Inc.
www.danwoolston.com
**************
·· You can also talk back to the computer through the programming port by using SERIN/SEROUT and using 16 for the pin number.· This will depend on how much data you need to process.· You will also have to filter out data sent to the Stamp, since it will be echoed back.· But you can use it if you don't want to add extra hardware.· However, the suggestion above is less problematic.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Post Edited (Chris Savage (Parallax)) : 5/4/2005 9:42:46 PM GMT
SERIN 16, 84 + 16384, [noparse][[/noparse]DEC MyVal] will recieve the string "10" <CR>, and put the value 10 into 'MyVal'.
Now, you do need to be aware that anything you send to the BS2 will be echoed back, so you'll have to 'toss' those echo'ed bytes with your PC program. But otherwise, you can use the SIN/SOUT port this way with no other hardware needed.
Oh, and you need to set DTR_Enable to FALSE -- otherwise the DTR signal will hold your BS2 in reset. Actually, the BOE board has two capacitors that let the BS2 run anyway -- look at the schematic for that board to see.
After seeing your reply, I have a PBasic programming question. I would like to receive GPS data from my Garmin eTrex on P8, and I want the entire line of data if that line starts with $GPGLL. The entire line would be placed in a Variable and then sent out another pin (possible 16, like you showed).
Would it look like this:
myPos var word
SERIN 8, 84 + 16572,[noparse][[/noparse]WAIT("$GPRMC"),dec myPos]
SEROUT 16, 84 + 16384 [noparse][[/noparse]myPos]
Also, you DO have to wire the TX signal from your PC, because the SIN/SOUT pins use the RS232 voltage from that pin when they send back. You don't have to send any messages on that line from the PC, just make sure you do connect it.
And remember the BS2 is a single-tasking processor -- so when you are waiting to recieve data, it 'pends' until the data gets there (or you have a timeout). When you are sending data, the BS2 will ignore anything coming in pin 8.
I saw that you said that you mentioned BS2 being "single-tasking." However, what if I have other sensors that are transmitting data to other "receive-only" pins. That is, I might have an inclometer on pin 9, and a accelerometer on pin 10.
Although the BS2p24 is single-tasking, I can still have some loop that checks each of the pins for the expected data right? Or am I mistaken?
Thanks in advanced,
Stephen
If you are using SHIFTIN/SHIFTOUT to read sensors, then the sensor itself can store its state until you read it, not a problem.
If the pins are all using SERIN, then you'll probably miss some messages. If the messages come pretty often, this doesn't have to be a problem either.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
**************
daniel woolston
Teksystems Inc.
www.danwoolston.com
**************