SERIN Newbie Questions
Ok I give up! I can not get SERIN to work any help would be greatly
appriciated.
Here my setup, I can two PCs one for programing the other for
sending data. I can connected the two with the same cables I am
using in my project and the comminicate fine.
In my project I can as BS2 with PC1 connected for programing. PC2
is connected with DB9 #2 to P1 (pin6) and DB9 #5 to VSS (pin22).
Here the code...
inData VAR BYTE
DEBUG "Start",CR
:Main
SERIN 1,188,[noparse][[/noparse]inData]
DEBUG ? inData
Goto Main
the output of "hello world" being typed.
Start
inData = 9
inData = 77
inData = 18
inData = 18
inData = 72
inData = 3
inData = 68
inData = 72
inData = 35
inData = 18
inData = 19
Thanks for the help!
Philip Kubat
appriciated.
Here my setup, I can two PCs one for programing the other for
sending data. I can connected the two with the same cables I am
using in my project and the comminicate fine.
In my project I can as BS2 with PC1 connected for programing. PC2
is connected with DB9 #2 to P1 (pin6) and DB9 #5 to VSS (pin22).
Here the code...
inData VAR BYTE
DEBUG "Start",CR
:Main
SERIN 1,188,[noparse][[/noparse]inData]
DEBUG ? inData
Goto Main
the output of "hello world" being typed.
Start
inData = 9
inData = 77
inData = 18
inData = 18
inData = 72
inData = 3
inData = 68
inData = 72
inData = 35
inData = 18
inData = 19
Thanks for the help!
Philip Kubat
Comments
You're closer than you may think to getting this right. If you
squint and hold your tongue just right, you can sort of see your
desired text present in the data stream:
A B C D
inData = 9 0000_1001 1111_0110 0110_???? h = 0110_1000
inData = 77 0100_1101 1011_0010 0110_010? e = 0110_0101
inData = 18 0001_0010 1110_1101 0110_1??? l = 0110_1100
inData = 18 0001_0010 1110_1101 0110_1??? l = 0110_1100
inData = 72 0100_1000 1011_0111 0110_111? o = 0110_1111
inData = 3 0000_0011 1111_1100 00??_???? = 0010_0000
inData = 68 0100_0100 1011_1011 0111_011? w = 0111_0111
inData = 72 0100_1000 1011_0111 0110_111? o = 0111_0111
inData = 35 0010_0011 1101_1100 0111_00?? r = 0111_0010
inData = 18 0001_0010 1110_1101 0110_1??? l = 0110_1100
inData = 19 0001_0011 1110_1100 0110_0??? d = 0110_0100
Column A is a binary representation of what your DEBUG statement
says you received. Column B is the 1's complement of Column A.
Column C is the binary pattern present when you ignore everything
prior to the first 0 found in Column B. Column D is the desired
ASCII code for the text stream you are sending. Columns C and D
differ only in the final bit positions, and could be made identical
by substituting the target bit patterns for the '?' in each
representation found in Column C.
What this suggests to me:
1. Your data is inverted, which makes sense if it is coming straight
off your PC. Use an inverted baud mode to fix this. SEE THE
MANUAL to learn how to safely connect your PC's serial port to a
general purpose I/O pin on your Stamp without making smoke.
2. Your Stamp is sampling the bit stream out of phase with the
transmission. The inverted data is not helping this problem, plus
adding a DEBUG statement after each byte is received may be
preventing your Stamp from keeping pace with the incoming data. Try
capturing the entire text string and then showing it via DEBUG:
text VAR BYTE(11)
i VAR BYTE
SERIN 1,16572, [noparse][[/noparse] STR text\11 ]
DEBUG STR text\11
(Untested but probably not too far off the mark)
Regards,
Steve
Thanks for the complete answer. I did not understand the "inverted"
baud rate in the manual. I make sense now, but I think the manual
is leaves a bit to imagination the on connecting directly to the
serial port. And then in trouble shooting it I place the debug
statement, which just made it worse.
Change to inverted and it works fine.
Again thanks for the well documented answer.
--- In basicstamps@y..., "S Parkis" <parkiss@e...> wrote:
> Philip-
>
> You're closer than you may think to getting this right. If you
> squint and hold your tongue just right, you can sort of see your
> desired text present in the data stream:
>
> ... <cut>...
>
> Steve