Shop OBEX P1 Docs P2 Docs Learn Events
communication help — Parallax Forums

communication help

seadog13seadog13 Posts: 9
edited 2009-01-08 03:46 in Propeller 1
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

Comments

  • grasshoppergrasshopper Posts: 438
    edited 2009-01-04 03:17
    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 JakackiPeter Jakacki Posts: 10,193
    edited 2009-01-04 03:19
    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*
  • seadog13seadog13 Posts: 9
    edited 2009-01-04 03:36
    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 JakackiPeter Jakacki Posts: 10,193
    edited 2009-01-04 03:56
    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*
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-01-04 04:00
    you are using different speed. debug is 19200 and serial is 9600. smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    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.
  • grasshoppergrasshopper Posts: 438
    edited 2009-01-04 04:48
    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 [noparse][[/noparse] 6 ] 
    
    pub main
        ser.start(31, 30, 0, 9600)
    
        repeat     
            IF (ser.rxcheck == "s")                                                                                                                          
            getcom
    
    Pub Getcom | stringCount
       
      StringCount~
                       
      Repeat UNTIL (RxData[noparse][[/noparse]StringCount] := SER.rx ) == "t"
              StringCount ++     
                   
       IF (rxData[noparse][[/noparse] 0 ] == "e")&(rxData[noparse][[/noparse] 1 ] == "n") '  fixed 
            {{light led}}   
    
    

    Post Edited (grasshopper) : 1/8/2009 3:50:20 AM GMT
  • seadog13seadog13 Posts: 9
    edited 2009-01-08 03:29
    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[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)
  • grasshoppergrasshopper Posts: 438
    edited 2009-01-08 03:46
    Yea the code is not right
    IF (rxData[noparse][[/noparse] 0 ] == "s")&(rxData == "X")
    
    



    This is wrong or at least looks wrong. Try this
    IF (rxData[noparse][[/noparse] 0 ] == "s")&(rxData[noparse][[/noparse] 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[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
Sign In or Register to comment.