Serial input
Archiver
Posts: 46,084
Try changing CPbaudcode to 16884. It appears you are using a
BSIISX, which has slightly different values for baud rate selection.
Grab Ver 1.5 of the BSIISX Addendum Manual from the Parallax site for
further info.
Regards,
Steve Parkis
BSIISX, which has slightly different values for baud rate selection.
Grab Ver 1.5 of the BSIISX Addendum Manual from the Parallax site for
further info.
Regards,
Steve Parkis
Comments
4800 baud, 8N1, over a serial line, 0 to +4.5 volts (not the RS232
standard +/- 12). The strings all start with "$", are about 45 chars
long, and are terminated with a CR,LF pair. I can grab these strings
and display them on my PC using a standard terminal program and a
normal serial port (COM2). Everything works fine using the PC. The
strings display correctly, and contain only normal ascii characters,
always less than < dec 128 bytes, as they should be.
However, I can't grab these bytes using my BS2X and the program code
below. I thought it should have been pretty easy, since it looks
like electrically the signal is just standard TTL logic signals,
which I presume can be directly input to a BS2X input pin, using
the "non-inverted/direct connection" baud mode value. The + signal
line from the gauge is connected to pin 0 thru a 22K resistor; the
ground signal line is connected to Vss.
The code is only test code, and I am only trying to grab any old 10
bytes that come in. Characters are, in fact, grabbed and displayed
but none of them are what they should be, and in fact are often ascii
extended characters. It never seems to get 10 chars either,
typically only about 6.
I also tried the other 3 baud mode values for 4800 baud, including
the non-inverted ones. Results were much the same, same characters
displayed except that now typically only 1 or 2 each time, instead of
6 or so.
If anyone can help me out with this I will greatly appreciate it.
Thanks, Steve.
CPpin CON 0 ' Serial in connected to pin 0
CPbaudcode CON 16572 ' 4800 baud, 8N1, inverted/direct
CPtimout CON 2000 ' Max time to wait for data (ms)
CPstr VAR BYTE(11) ' 10 chars + terminating null
OUTS = %0000000000000000
DIRS = %0000000000000000
CPstr(10) = 0 ' Null-terminate string
GetChars:
SERIN CPpin, CPbaudcode, CPtimout, Timout, [noparse][[/noparse]STR CPstr\10]
DEBUG HOME, STR CPstr
PAUSE 500 ' Wait 1/2 second
GOTO GetChars
Timout:
DEBUG "No activity on pin 0. Program terminated."
END
>I have a gauge that sends out ascii data strings once a second at
>4800 baud, 8N1, over a serial line, 0 to +4.5 volts (not the RS232
>standard +/- 12). The strings all start with "$", are about 45 chars
>long, and are terminated with a CR,LF pair. I can grab these strings
>and display them on my PC using a standard terminal program and a
>normal serial port (COM2). Everything works fine using the PC. The
>strings display correctly, and contain only normal ascii characters,
>always less than < dec 128 bytes, as they should be.
>
>However, I can't grab these bytes using my BS2X and the program code
>below. I thought it should have been pretty easy, since it looks
>like electrically the signal is just standard TTL logic signals,
>which I presume can be directly input to a BS2X input pin, using
>the "non-inverted/direct connection" baud mode value. The + signal
>line from the gauge is connected to pin 0 thru a 22K resistor; the
>ground signal line is connected to Vss.
>
>The code is only test code, and I am only trying to grab any old 10
>bytes that come in. Characters are, in fact, grabbed and displayed
>but none of them are what they should be, and in fact are often ascii
>extended characters. It never seems to get 10 chars either,
>typically only about 6.
>
>I also tried the other 3 baud mode values for 4800 baud, including
>the non-inverted ones. Results were much the same, same characters
>displayed except that now typically only 1 or 2 each time, instead of
>6 or so.
>
>If anyone can help me out with this I will greatly appreciate it.
>Thanks, Steve.
>
>
>CPpin CON 0 ' Serial in connected to pin 0
>CPbaudcode CON 16572 ' 4800 baud, 8N1, inverted/direct
Steve -
These are the updated values for baudmode extracted from the UPDATED BS-2SX
document as found on the Parallax web site.
Data Direct Through ata Speed Direct Conn
Speed ectiConnectionon ThrorLine DriverD
4800 16884 25076 500 8692
Regards,
Bruce Bates