PDA

View Full Version : communication help



seadog13
01-04-2009, 11:07 AM
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

grasshopper
01-04-2009, 11:17 AM
I dont not look like you have the receive code displayed. Perhaps your sending it ok but I see no receive code for the other prop to run. If you still need help P.M. me otherwise I am sure others will post something.

Peter Jakacki
01-04-2009, 11:19 AM
For starters what is the decimal value 100 doing as the mode value in debug.start? Even if you made it binary it still wouldn't be right, this value for most purposes is simply zero.

Anyway, for debug purposes it is far better to represent the incoming debug stream as hex characters.

debug.tx(" ")
debug.hex(rx,2)

*Peter*

seadog13
01-04-2009, 11:36 AM
the debug.start is for my parallax serial terminal program. The serial.start is what I am trying to send. When i would receive the ascii i would get 254, when i received the hex, i got 254 as well. so that didn't really do anything. I also tried to transmit the data in hex, and got the same response.

Peter Jakacki
01-04-2009, 11:56 AM
You only want to see the hex representation of the binary character that is received, don't transmit it in hex. The important thing is to get rid of the 0100 in your debug mode setting.

debug.start(31,30,0100,19200)

should be

debug.start(31,30,0,19200)

*Peter*

Cluso99
01-04-2009, 12:00 PM
you are using different speed. debug is 19200 and serial is 9600. http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Prop Tools under Development or Completed (Index)
http://forums.parallax.com/showthread.php?p=753439

cruising (http://www.bluemagic.biz)]cruising[/url]

This is a bold test.

grasshopper
01-04-2009, 12:48 PM
Try this

prop A




CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000

OBJ
serial : "FullDuplexSerial"

pub main
ser.start(3, 26, 0, 9600)
repeat
serl.str(string("sent"))




prop B




CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000

OBJ
ser : "FullDuplexSerial"
var
Byte Rxdata [ 6 ]

pub main
ser.start(31, 30, 0, 9600)

repeat
IF (ser.rxcheck == "s")
getcom

Pub Getcom | stringCount

StringCount~

Repeat UNTIL (RxData[StringCount] := SER.rx ) == "t"
StringCount ++

IF (rxData[ 0 ] == "e")&(rxData[ 1 ] == "n") ' fixed
{{light led}}


Post Edited (grasshopper) : 1/8/2009 3:50:20 AM GMT

seadog13
01-08-2009, 11:29 AM
Hey all, grasshoper thanks for the help. We were able to send data across and rx it, but still had afew problems.

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[7]

pub main |i,j
ser.start(12, 11, 0, 19200)
debug.start(31,30,0100,19200)


repeat j from 0 to 5
rxData[j] := j
rxData[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[StringCount] := SER.rx ) == "X"
StringCount ++

IF (rxData[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)

grasshopper
01-08-2009, 11:46 AM
Yea the code is not right



IF (rxData[ 0 ] == "s")&(rxData == "X")




This is wrong or at least looks wrong. Try this



IF (rxData[ 0 ] == "s")&(rxData[ 1 ] == "X")




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[ 0 ] array. So if the other propeller is looking in rxdata[ 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 [ ] so I had to do a [ 1 ] for example. Sorry!

Post Edited (grasshopper) : 1/8/2009 3:51:37 AM GMT