Shop OBEX P1 Docs P2 Docs Learn Events
Communicating two props to each other — Parallax Forums

Communicating two props to each other

demketdemket Posts: 8
edited 2011-06-21 14:45 in Propeller 1
I'm trying to communicate two props with each other. Rx pin connected to Tx pin of other. And I uploaded the code which is below, both of them. When I sent some characters from computer with keyborad, sometimes it's working, sometimes silence intrudes

Where am I doing wrong?

Thanks,


OBJ
UART : "pcFullDuplexSerial4FC" ' 4 port serial driver in one cog.

PUB Main | io_data, pcal
UART.AddPort(0,31,30,-1,-1,0,0,1200)
UART.AddPort(1,3,2,-1,-1,0,0,1200)
UART.Start ' start the object
UART.Start ' start the object
waitcnt(clkfreq + cnt)

repeat
if uart.rxcheck(0)
pcal := uart.rx(0)
uart.tx(1,pcal)

if UART.rxcheck(1)
io_data := UART.rx(1)
uart.tx(0,io_data)

Comments

  • Kirk FraserKirk Fraser Posts: 364
    edited 2011-06-21 06:39
    What is your specific goal? I posted a request for information leading to a Prop network and received the idea of using two regular pins, one for the signal and one for the clear to send for duplex communication. There are variations in packet content documented in other posts. But if you are using the Rx and Tx trying to program a Prop from another Prop, that's another project.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-06-21 07:14
    Try this:
    CON
      _CLKMODE = XTAL1 + PLL16X
      _CLKFREQ = 80_000_000
     
    OBJ
      UART : "pcFullDuplexSerial4FC" ' 4 port serial driver in one cog.
    PUB Main | io_data, pcal
      UART.AddPort(0,31,30,-1,-1,0,0,1200) 
      UART.AddPort(1,3,2,-1,-1,0,0,1200) 
      UART.Start ' start the object      [B]only once[/B]
      'UART.Start ' start the object
      waitcnt(clkfreq + cnt)
     
      repeat
        pcal := uart.rxcheck(0)
        if pcal <> -1
          uart.tx(1,pcal)
        io_data := UART.rxcheck(1)
        if io_data <> -1
          uart.tx(0,io_data)
    
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-06-21 07:17
    demket wrote: »
    I'm trying to communicate two props with each other....

    attachment.php?attachmentid=78421&d=1297987572
  • demketdemket Posts: 8
    edited 2011-06-21 09:30
    I am not trying to program a Prop from another Prop. Just, I'll send data from one computer to an other, or I'll type from one and it would be able to seen on screen of other computer.
  • demketdemket Posts: 8
    edited 2011-06-21 09:46
    Thanks, İt works well. Why doesn't my code work? Could you explain, please.

    Also, When I disconnect cable which was pluged to rx (pin 3), İt receive "?" and absurd characters. Is this normal.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-06-21 13:00
    rxcheck doesn't just check to see if there was a character received, it also returns the first character in the buffer if there is one.

    Your code used rxcheck without saving the value so you'd lose the first character in the buffer and have the program sit and wait for the next character with the rx method.

    The main difference between rx and rxcheck is rx waits for a character if there isn't one there and rxcheck returns -1 if there isn't a character. They both return the first character from the buffer if there is one.

    Duane
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-06-21 13:05
    demket wrote: »
    Also, When I disconnect cable which was pluged to rx (pin 3), İt receive "?" and absurd characters. Is this normal.

    Yes, it's normal. The driver is trying to interpret the noise as characters. The most frequent error character I receive is the infinity sign (character 255).
  • demketdemket Posts: 8
    edited 2011-06-21 14:45
    Duane Degn wrote: »
    Yes, it's normal. The driver is trying to interpret the noise as characters. The most frequent error character I receive is the infinity sign (character 255).

    What is the source of noise? What should we do to prevent the noise?
Sign In or Register to comment.