communication help
seadog13
Posts: 9
hey all, I'm stuck and getting frustrated, I am trying to get communication between two propellers. trying to go wired, as simple as possible.
Using full duplex serial obj, I believe I am receiving an ascii character from a decimal number being transmitted, although when converted to decimal it's no where close to what i was sending. I have read over all the posts in the forums, it seems like I am doing everything correct, I don't know where I am going wrong. As far as circuit side, I have them running into two different pins, ie not tx pin = 3 on both props, and a common ground between the two propellers. Below is a copy of the code that i have.
any help is greatly appreciated.
CON
· _CLKMODE = XTAL1 + PLL16X
· _XINFREQ = 5_000_000
OBJ
serial : "FullDuplexSerial"
debug· : "FullDuplexSerial"
fs··· :···· "FloatString"
var
· long rx
·
pub main
··· debug.start(31,30,0100,19200)
··· serial.start(3, 26, 0000, 9600)
···························· 'rx pin, txpin, baud
··
···
··· repeat
······
····· serial.dec(1)······················· '·transmit side
····· debug.str(string("sent"))
····· debug.tx(13)
··· ·waitcnt(clkfreq + cnt)··········· ' receive side
····· rx := serial.rx
····· 'debug.tx(13)
····· debug.tx(rx)
I·am running the PE propeller and I·changed the computer tx, rx pins from 31,30 to something else, and it wouldn't·work, is there something fundamentally that I am missing?
····· debug.tx(13)
·····
···
Post Edited (seadog13) : 1/4/2009 3:24:04 AM GMT
Using full duplex serial obj, I believe I am receiving an ascii character from a decimal number being transmitted, although when converted to decimal it's no where close to what i was sending. I have read over all the posts in the forums, it seems like I am doing everything correct, I don't know where I am going wrong. As far as circuit side, I have them running into two different pins, ie not tx pin = 3 on both props, and a common ground between the two propellers. Below is a copy of the code that i have.
any help is greatly appreciated.
CON
· _CLKMODE = XTAL1 + PLL16X
· _XINFREQ = 5_000_000
OBJ
serial : "FullDuplexSerial"
debug· : "FullDuplexSerial"
fs··· :···· "FloatString"
var
· long rx
·
pub main
··· debug.start(31,30,0100,19200)
··· serial.start(3, 26, 0000, 9600)
···························· 'rx pin, txpin, baud
··
···
··· repeat
······
····· serial.dec(1)······················· '·transmit side
····· debug.str(string("sent"))
····· debug.tx(13)
··· ·waitcnt(clkfreq + cnt)··········· ' receive side
····· rx := serial.rx
····· 'debug.tx(13)
····· debug.tx(rx)
I·am running the PE propeller and I·changed the computer tx, rx pins from 31,30 to something else, and it wouldn't·work, is there something fundamentally that I am missing?
····· debug.tx(13)
·····
···
Post Edited (seadog13) : 1/4/2009 3:24:04 AM GMT
Comments
Anyway, for debug purposes it is far better to represent the incoming debug stream as hex characters.
debug.tx(" ")
debug.hex(rx,2)
*Peter*
debug.start(31,30,0100,19200)
should be
debug.start(31,30,0,19200)
*Peter*
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Prop Tools under Development or Completed (Index)
http://forums.parallax.com/showthread.php?p=753439
cruising][noparse][[/noparse]url=http://www.bluemagic.biz]cruising[noparse][[/noparse]/url][/url]
This is a [noparse][[/noparse]b]bold[noparse][[/noparse]/b] test.
prop A
prop B
Post Edited (grasshopper) : 1/8/2009 3:50:20 AM GMT
We wouldn't always receive what was being sent, the string would get mixed up, but then after a couple of transmissions, or even the next transmission, it would correct itself. I was thinking of some sort of forward error correction.
We also noticed that it got better when we played with the timing. We built an array for each bit to write to, and then displayed them individual. was wondering if there was any tricks of the trade on getting the rx side correct. Below is a copy of the rx code, the tx code is what grasshoper posted above. We are sending !sentX, using the ! as the check, and the X as the terminate.
}
CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000
OBJ
ser : "FullDuplexSerial"
debug : "FullDuplexSerial"
VAR
byte rxdata[noparse][[/noparse]7]
pub main |i,j
ser.start(12, 11, 0, 19200)
debug.start(31,30,0100,19200)
repeat j from 0 to 5
rxData[noparse][[/noparse]j] := j
rxData[noparse][[/noparse]6] := 0
repeat
waitcnt(500_000_000/5 + cnt)
'waitcnt(clkfreq+cnt)
'debug.str(string("check"))
IF (ser.rxcheck == "!")
getcom
else
debug.str(string("Noooo"))
debug.tx(13)
repeat i from 0 to 3
'
debug.dec(rxdata)
debug.tx(13)
Pub Getcom | stringCount,i
StringCount~
debug.str(string("ok!!!!!!!"))
debug.tx(13)
Repeat UNTIL (RxData[noparse][[/noparse]StringCount] := SER.rx ) == "X"
StringCount ++
IF (rxData[noparse][[/noparse]0] == "s")&(rxData == "X")
{{light led}}
debug.str(string("yay"))
debug.tx(13)
repeat i from 0 to 4
'
debug.dec(rxdata)
debug.tx(13)
'waitcnt(clkfreq*2+cnt)
'debug.tx(16)
This is wrong or at least looks wrong. Try this
Also in other parts of the code the variables are incorrect rxData == "X". rxdata is an array and each byte fills that array. So the letter "X" is one byte, or a slice of the rxdata[noparse][[/noparse] 0 ] array. So if the other propeller is looking in rxdata[noparse][[/noparse] 1 ] for an "X" and you give it just rxdata its not going to be consistent.
edited I posted the code wrong the other day, well the website hates the [noparse][[/noparse] ] so I had to do a [noparse][[/noparse] 1 ] for example. Sorry!
Post Edited (grasshopper) : 1/8/2009 3:51:37 AM GMT