serin serout problem, please help
4ish
Posts: 24
hey everyone...
I'm trying to do something for a class but I'm not getting anywhere, I was hoping someone could give me some pointers...
basically I have two BS2 and I want to establish communication between them... the first one (TX) is hooked up to a transmitter, and the second (RX) is obviously hooked up to a receiver, both parallax products..
now what I want is to basically transmit a string say "will this work?" and receive it on the other end... from my understanding, since they are on two different STAMPS I cannot use the flow control for confirmation...
so I have
running on the TX stamp and
on the RX stamp...
but the problem is I recieve a lot of undesired characters as well, as though it was a parity issue or something, I really dont know... but it doesnt give me the string... I'm using 2400 as my baudrate
does anyone know how to solve this problem? perhaps by using a byte array, some other sort of synchronization etc... any help would be much appreciated... thank you
I'm trying to do something for a class but I'm not getting anywhere, I was hoping someone could give me some pointers...
basically I have two BS2 and I want to establish communication between them... the first one (TX) is hooked up to a transmitter, and the second (RX) is obviously hooked up to a receiver, both parallax products..
now what I want is to basically transmit a string say "will this work?" and receive it on the other end... from my understanding, since they are on two different STAMPS I cannot use the flow control for confirmation...
so I have
LoopThis: SEROUT TxPin, BaudR, [noparse][[/noparse]"send this sentence"] GOTO LoopThis
running on the TX stamp and
Loop2: SERIN RxPin, BaudR, [noparse][[/noparse]variable] DEBUG variable GOTO Loop2
on the RX stamp...
but the problem is I recieve a lot of undesired characters as well, as though it was a parity issue or something, I really dont know... but it doesnt give me the string... I'm using 2400 as my baudrate
does anyone know how to solve this problem? perhaps by using a byte array, some other sort of synchronization etc... any help would be much appreciated... thank you
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
here's what I did to modify my code...
and
basically I removed the debug and the loop on the reciever end and replaced by the WAIT and I'm now outputting into the LCD
now this seems to work fine, so unless you guys can find any faults in it, then its good...
now my other question is this... I dont know how long the sentence being sent is going to be, so how can I modify my receiver code to accept any N-size sentence? (right now the array is set to 17)
thanks again
so that my code could become like this
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
' {$STAMP BS2}
' {$PBASIC 2.5}
String1 DATA "Hello There",0
StringLoc VAR Word· ' 1..2000
MyByte··· VAR Byte
I9600·· CON 16468 '16384 + 84
MAIN:
· SEROUT 16, I9600, [noparse][[/noparse]String1,13]· ' BAD!· Only sends first byte of 'String1'
· '****** Below is what you want... *****
· StringLoc = String1
· GOSUB SendString
· PAUSE 200
· GOTO MAIN
SendString:
· READ StringLoc, MyByte
· DO WHILE MyByte <> 0
··· SEROUT 16, I9600, [noparse][[/noparse]MyByte]
··· StringLoc = StringLoc + 1
··· GOTO SendString
· LOOP
· RETURN
·
allan, I tried your way, and it works... however I've decided to give each byte from the keyboard itself... so it just transmits what I type, letter for letter...
so here's my current code...
and
I receive the FIRST byte correct ALWAYS but after that, its random... like the 6th works, then suddenly 11th and 18th, and the next run its other random bytes...
I'm just using different baud rates, codes etc, trial and error kind of, hopefully I can get it to work soon..