Shop OBEX P1 Docs P2 Docs Learn Events
Simple Propeller to propeller communications — Parallax Forums

Simple Propeller to propeller communications

HughHugh Posts: 362
edited 2008-12-07 15:04 in Propeller 1
Hi Folks,

Can someone please commend to me a simple method of sending data (strings) from one Propeller to another? I've played with FullDuplexSerial, but without success.

Any pointers (excuse the pun) gratefully received!

Thanks
Hugh

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-30 19:49
    FullDuplexSerial is the simplest way. What have you tried so far and what happened? How did you connect the two? Show a simple example, not a large complex program.
  • CannibalRoboticsCannibalRobotics Posts: 535
    edited 2008-11-30 19:56
    What about setting up a synchronos serial scenario. Use 4 pins on each prop: Data Input, Data Output, Clock OUT, Clock IN.
    Clock out clocks Data Output, Clock IN clocks the input line. You cross the IN's and OUTs between the two props and you've got something much faster and more reliable than an async connection. Let me know if this makes sense. If not, I'll be glad to elaborate.
    Jim-

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Signature space for rent, only $1.
    Send cash and signature to CannibalRobotics.
  • HughHugh Posts: 362
    edited 2008-12-02 20:09
    Sorry, forgot to check the 'Notify me of postings' checkbox!

    I think Jim may be thinking above my head, but any elaboration might get me started.

    Mike,

    I have tried some more intricate approaches, but at the most 'simple end' of things tried the following as a receiver:

    CON

    _clkmode = xtal1 + pll16x
    _xinfreq = 5_000_000


    OBJ

    text : "vga_Drive"
    serial : "FullDuplexSerial"


    PUB main | gmt
    serial.start(2, 1, 1, 4800)
    text.start(16)

    repeat
    text.out(00)
    text.str(serial.rx)
    waitcnt(1_000_000_0 + cnt)


    with something similar at the other end, but with the Tx on one going to the Rx pin of the other and vice versa.

    I have also used the gps_vga spin code from the ObEx (i.e., something which I know works) and sent a GPS NMEA sentence from the other prop.

    Thanks

    Hugh
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-02 20:22
    Why do you have the mode value = 1? This inverts one I/O pin, but doesn't invert the other. I'd use mode = 0.
  • HughHugh Posts: 362
    edited 2008-12-02 20:33
    Thanks, I'll give that a go...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Hugh - the thinking woman's Geoffrey Pyke.
  • HughHugh Posts: 362
    edited 2008-12-03 18:01
    OK, this is as simple as I think I could make it as a starting point:

    SENDER SIDE:

    OBJ
    serial : "FullDuplexSerial"

    PUB main
    serial.start(2, 3, 0, 4800)

    repeat
    serial.tx(88)
    waitcnt(1_000_000 + cnt)


    RECEIVER SIDE:

    OBJ

    text : "vga_Drive"
    serial : "FullDuplexSerial"


    pub main
    serial.start(2, 3, 0, 4800)
    text.start(16)

    text.out(00)


    repeat
    text.str(serial.rx)
    text.str(string("*"))


    Pin 3 on the first prop is connected to pin 3 on the other and vice versa.

    What I see is just the string of asterisks propagating down the page...

    Have I omitted a FullDuplex Serial method or someting silly like that?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Hugh - the thinking woman's Geoffrey Pyke.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-03 18:38
    You have to connect Rx on one Propeller to Tx on the other. If you've connected pin 3 to pin 3 and pin 2 to pin 2, then you have to reflect that in your calls to serial.start. On the transmit side use "serial.start(2, 3, 0, 4800)" and on the receive side use "serial.start(3, 2, 0, 4800)".

    The problem with the asterisks is that "text.str" expects the address of a string. You want to use "text.out(serial.rx)". It may be that, because you have Rx connected to RX, that FullDuplexSerial is just seeing noise on the Rx line and interpreting that as garbage. You don't see the garbage because "text.str(serial.rx)" is interpreting the resulting value as an address and there's nothing displayable at that address (hopefully zero bytes which terminate the "string").
  • SapiehaSapieha Posts: 2,964
    edited 2008-12-03 18:40
    Hi Hugh

    You said "Pin 3 on the first prop is connected to pin 3 on the other and vice versa"

    It must be Pin 3 on the first prop is connected to pin 2 on the other and vice versa

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nothing is impossible, there are only different degrees of difficulty.
    For every stupid question there is at least one intelligent answer.
    Don't guess - ask instead.
    If you don't ask you won't know.
    If your gonna construct something, make it·as simple as·possible yet as versatile as posible.


    Sapieha
  • HughHugh Posts: 362
    edited 2008-12-03 19:27
    Thanks chaps,

    Data is moving across, but I will have to think about what is happening:

    Sending '128' results in reverse video 'A' being displayed by text.out
    Sending '129' results in reverse video 'B' being displayed, etc.,...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Hugh - the thinking woman's Geoffrey Pyke.
  • HughHugh Posts: 362
    edited 2008-12-03 21:10
    Aha...

    Only seven least significant bits get sent. Should have twigged that earlier!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Hugh - the thinking woman's Geoffrey Pyke.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-03 21:14
    All 8 bits are being sent from one Propeller to the other, but the display driver uses the most significant bit to signify reversed video.
  • HughHugh Posts: 362
    edited 2008-12-05 19:02
    Nearly there!

    If I send data via:

    Serial.tx(1)
    Serial.tx(2)
    Serial.tx(3)
    Serial.tx(4)

    Then the data is correctly sent. However, my attempt to send a 'Long' named 'pt' as follows does not

    Serial.tx(pt[noparse][[/noparse] 0 ])
    Serial.tx(pt[noparse][[/noparse] 1 ])
    Serial.tx(pt[noparse][[/noparse] 2 ])
    Serial.tx(pt[noparse][[/noparse] 3 ])

    Can a 'Long' not be ripped apart as bytes in this way?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Hugh - the thinking woman's Geoffrey Pyke.
  • HughHugh Posts: 362
    edited 2008-12-06 18:35
    All sorted. smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Hugh - the thinking woman's Geoffrey Pyke.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-06 19:24
    If you want to send a long as individual bytes you could do
    serial.tx(pt.byte[noparse][[/noparse] 0 ])
    serial.tx(pt.byte[noparse][[/noparse] 1 ])
    serial.tx(pt.byte[noparse][[/noparse] 2 ])
    serial.tx(pt.byte[noparse][[/noparse] 3 ])
    


    or
    serial.tx(pt)
    serial.tx(pt >> 8)
    serial.tx(pt >> 16)
    serial.tx(pt >> 24)
    
  • grasshoppergrasshopper Posts: 438
    edited 2008-12-07 06:25
    just thinking while reading this post and I came up with a question. I do hope it is not considered off topic.

    Can one use usb communication between two propellers using FTDI IC'c. I picture this
    connector.JPG

    The reason I ask is that I am skeptical about the USB A connectors and the FTDI ic.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-07 15:04
    FWIW, I think it's off topic.

    You can't do USB communications that way. USB is a master-slave or host-client protocol. All USB devices are normally clients and two clients won't do anything if they're hooked together. You could hook two Propellers together, but you'd need to use something like the Parallax Memory Stick Datalogger on one side (because that's a USB host) and an FTDI USB to serial adapter on the other side (which is a USB client).

    The Wikipedia article on USB (en.wikipedia.org/wiki/USB) is a good introduction to the protocol.
Sign In or Register to comment.