View Full Version : Ive got problems with serial communications using serin
04-13-2007, 01:09 AM
Hello again, Ive got problems with serial communications using serin. I'm communicating with a PC and can send data from the BS2 to the PC's debug page using serout 16,84, [var] Var held hello. This message was displayed within the debug window on the PC. I use a serial to USB adaptor. All is fine with serout, but I cannot for the life of me get serin to pick up a value sent from my web site. It sends a C or F to make the BS2 calculate centigrade or farenheit temperatures.
Is the baud mode required the same in for both directions, i.e does the PC send data in the same format as the BS2. having major problems please respond.
[Moderator Added Subject]
Post Edited By Moderator (Chris Savage (Parallax)) : 4/12/2007 7:38:57 PM GMT
04-13-2007, 01:23 AM
Yes, the baud-mode value needs to be the same in both directions.
However, you need to be aware that the BS2 does NOT have a serial input buffer. Thus, if the BS2 is not 'waiting' in a SERIN statement for data to arrive, it won't get it.
Note also, because of the BS2 hardware, anything sent to it (from a PC, say) will be echoed back out the RX pin (so the PC gets an echo of what it sent). You need to 'filter' out this returned echo in the PC's software.
Oh, and you might try adding the "Inverted" flag value to the baud-mode value.
04-13-2007, 01:29 AM
The Baud mode should be the same for both the SERIN and SEROUT and is limited to 9600 Baud only. One of the peculiarities of the "pin 16" port is that any data sent from the PC is echoed back to the PC, but this may not affect what you're doing.
The Stamps are single execution thread devices. That just means that they can only do one thing at a time. If your program is not waiting at a SERIN when the PC sends the command, it will be missed. Usually what people do is to have a SEROUT or DEBUG that displays a prompt message and an immediate SERIN or DEBUGIN that receives the information. When the Stamp is driven by a PC program, the prompt serves as a signal to the PC program that it's ok to send the information.