Basic Serin Serout question
Jason Short
Posts: 21
I am playing around with Serin and Serout and everything seems to be working except the characters I see in my terminal program are not correct. For example an 'f' appears as a '4' every time.
My setup:
Mac OS X Tiger,
BS2 on a INEX-1000 training board
Keyspan serial adapter - 19HS
I've used Xterm, GoSerial, and MacBS2 with the same results.
Debug calls work fine. I can see my Debug "Hello World!" , but when I do a serout from a pin, I get ...H#EbDo...
Here is the code:
SEROUT 6, 16468,[noparse][[/noparse]"Hello World!"]
I tried to echo back the characters with this
SERIN 7, 16468, [noparse][[/noparse]inFromSerial]
SEROUT 6, 16468, [noparse][[/noparse]inFromSerial]
and I just got back oddly mapped characters.
I poked around Zterm's options but I'm overwhelmed by them all. like what is the difference between VT100 and PC-ANSI BBS? Who knows.
This should be a simple fix,
thanks anyone for the help.
Jason
My setup:
Mac OS X Tiger,
BS2 on a INEX-1000 training board
Keyspan serial adapter - 19HS
I've used Xterm, GoSerial, and MacBS2 with the same results.
Debug calls work fine. I can see my Debug "Hello World!" , but when I do a serout from a pin, I get ...H#EbDo...
Here is the code:
SEROUT 6, 16468,[noparse][[/noparse]"Hello World!"]
I tried to echo back the characters with this
SERIN 7, 16468, [noparse][[/noparse]inFromSerial]
SEROUT 6, 16468, [noparse][[/noparse]inFromSerial]
and I just got back oddly mapped characters.
I poked around Zterm's options but I'm overwhelmed by them all. like what is the difference between VT100 and PC-ANSI BBS? Who knows.
This should be a simple fix,
thanks anyone for the help.
Jason
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
You're transmitting at 9600, 8, no parity. Double check that your terminal program is set the same. A common problem is to have it set for 9600, 7, even.
Your echo back test won't work because you're listening with the SERIN before you're sending with the SEROUT.
Even if you change the order, you probably won't see anything intelligent. The Stamp can only do one thing at a time.
Also, 9600 is pretty fast for the BS2. Drop down to 2400 until you get things working.
To see the Stamp receive things, set up a SERIN with the WAIT parameter. ( see the Help files)Then, from the terminal program type a few characters including the one the Stamp is watching for and the Stamp will grab it.
This stuff will work reliably......keep at it!
Tom Sisk
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I've double checked the Zterm program and it's set to 8N1 with no flow control.
I got out the binary calc to investigate and noticed my 'f' was coming in as a 6.
f = 102= 0110 0110
6 = 54 = 0011 0110
here is what delete does:
del = 127 = 0111 1111
x = 120 = 0111 1000
! = 33 = 1000 0100
H = 72 = 0100 1000
ok, well I thought I was on to something there but there's no pattern.
Im not clear on why the order mattered on my Serin vs Serout
I want to listen for a character from the term program and when I get it fire it back. Why won't that work? I'm actually counting on the fact that the BS2 can only do one thing at a time. I assumed serin would just sit there waiting for some input and not continue further execution. In fact it appears to be behaving this way in my loop:
inFromSerial VAR BYTE
main:
SEROUT 6, 16468,[noparse][[/noparse]"Hello"]
SERIN 7, 16468, [noparse][[/noparse]inFromSerial]
PAUSE 100
SEROUT 6, 16468,[noparse][[/noparse]inFromSerial]
GOTO main
I just wish there was some other way to investigate my problem. I feel rather silly.
Jason
All BASIC Stamps (including the BS1) can also transmit RS-232 data through any of their I/O pins (Tpin = 0 - 7 for BS1, Tpin = 0 - 15 on all other BASIC Stamps). The I/O pins only provide a 0 to +5 volt swing (outside of RS-232 specs) and may need to be connected through a line driver for proper operation with all serial ports. Most serial ports are able to recognize a 0 to +5 volt swing, however. See the figure below sample wiring.
There are schematics there as well discussing your issue.
Did you also try Jon's suggestion of trying a baudrate of 84 to get TRUE instead of the INVERTED that you are currently using?
Can you verify that you have leveled the voltages from 0 to 5v (for proper communication with a Stamp) rather than the standard RS232 voltage levels of (possibly) -15v all the way to +15v?
(Just for fun:
Ever notice that every serial port on your PC is male and every modem serial port is female? RS-232-C standard states that DTE port connectors are all male and all DCE port connections will be female~
Standard RS232 uses +3v to -3v as a 'noise' zone- above +3 is 'space', below -3 is 'mark'- )
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
rclarke@parallax.com
Post Edited (Ryan Clarke (Parallax)) : 8/25/2005 4:49:32 PM GMT
I'm also getting persistent results and I assumed any voltage issues would show up as some random noise.
Thanks,
Jason
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
rclarke@parallax.com
The solution...
main:
SEROUT 6, 84, [noparse][[/noparse]"Hello World!",10,13]
PAUSE 100
GOTO main
Thanks so much!
Jason
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax