Shop OBEX P1 Docs P2 Docs Learn Events
Getting two props to talk — Parallax Forums

Getting two props to talk

EnriqueEnrique Posts: 90
edited 2008-07-30 11:50 in Propeller 1
I’m trying to have two Propellers talk to each other using FullDuplexSerial. In both cases I have set pin 17 for receiving the data and pin 16 for transmitting it. I connect directly with a wire pin 16 from one Propeller to pin 17 of the other.
·
The receiving propeller is behaving as if it is receiving data when none is being transmitted. I checked with a logic probe and I see no signals on the line. Do I need some kind of pull-up or pull-down resistors?
·
·
Enrique

Comments

  • AleAle Posts: 2,363
    edited 2008-07-29 12:25
    Either pull-ups or pull-down are a good idea, but if NRZ or similar algorithms are used it may not be necessary. What may happen is that the receptor is waiting and some noise is on the line due to the transmitter to not to be initialized at that point. You may want to wait on the receiver some prudential time before acknowledging the reception. (Some start bytes could also help). Beau Schwabe's sender/transmitter (high-speed, no async) communication routines either 1 bit or 4 (can be extended to 8) are very nice and work quite reliably.
  • EnriqueEnrique Posts: 90
    edited 2008-07-29 12:32
    I’m using the FullDuplexSerial object so it sets the algorithm.
  • hippyhippy Posts: 1,981
    edited 2008-07-29 12:35
    Did you also connect the 0V's of each board together ?
  • Mike HuseltonMike Huselton Posts: 746
    edited 2008-07-29 13:41
    Hippy, do you mean Signal Grounds connected together?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH
  • Cluso99Cluso99 Posts: 18,069
    edited 2008-07-29 14:26
    Ground (i.e. 0 volts). Hippy has presumed (as have I) that you may have the 2 propellers with independant power supplies. If so, you will need to connect the ground lines.
  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2008-07-29 14:47
    Enrique·-

    The FullDuplexSerial Object sets the algorithm for clocking in and out data, but it doesn't set the protocol for the data.· A protocol would described a data packet of how information is sent.· Having a data packet format may help transmission because you could setup a start byte of $FF.· The receiving Propeller would watch the line for $FF and when it sees $FF then the Propeller would clock in the next number of bytes.· Implementing a state machine or similar architecture for receiving data is on top of the serial object.· Make sense?

    I also second that you need to tie the grounds together of two different boards if you are in fact using two different boards.· Further to this idea, how far apart of the processors?· If they are a couple feet away then you·may need to do some converting of signals from CMOS (3.3V) level to another means like RS232/422/485 or other.· Distance can bite you here if you are not careful.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter, E.I.

    www.brilldea.com·- Prop Blade, LED Painter, RGB LEDs, uOLED-IOC, eProto fo SunSPOT, BitScope
    www.sxmicro.com - a blog·exploring the SX micro
    www.tdswieter.com
  • LeonLeon Posts: 7,620
    edited 2008-07-29 16:14
    If the data are important it might be a good idea to use CRC error-checking. I implemented a simple protocol using CRC for an application running on an ARM controller and sending data to a PC via RS-232. The ARM sent an STX control code followed by the block of data (ASCII hex), the CRC, and an ETX control code. The PC returned an ACK if the CRC was OK, and a NAK if it wasn't. If the ARM received a NAK it resent the data. We've never had any errors, according to the error log. smile.gif

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-07-29 17:10
    This may be a dumb question, but did you set the DDR for your TX pin?· You said you probed with it and saw no signals.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • BaggersBaggers Posts: 3,019
    edited 2008-07-29 18:27
    Enrique, what is it receiving? -1? ( that's $ffffffff not 255 ) if so that's OK, just means there's no data [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

    ·
  • EnriqueEnrique Posts: 90
    edited 2008-07-29 21:00
    What's DDR
  • ColeyColey Posts: 1,110
    edited 2008-07-29 21:16
    I recently developed for a twin prop application and I used the serial mirror object with great success

    I suspect that your problem may be in the initialisation of the serial object, here is how I started serial mirror object.

    uart.start(Rx, Tx ,%0000, Baud)
    



    It would help if you posted your code and we may just be able to help you further.

    Regards,

    Coley

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PropGFX Forums - The home of the Hybrid Development System and PropGFX Lite
  • EnriqueEnrique Posts: 90
    edited 2008-07-29 21:38
    First let me explain that my objective right now is to make sure I understand how to get the two Propellers to talk to each other. Once I am past this basic stage I’ll implement all the handshaking.
    ·
    I am running all the tests using a breadboard; the two microcontrollers share a power supply so I am sure there is a common ground.
    ·
    I am using a logic probe to trace the program execution. I am sampling the transmit and receive signals as well as pins 18 and 19 which I use for tracing purposes.
    ·
    I see on the probe pin 18 pulsing constantly. Before the data is transmitted pin 19 pulses every now and then. While the data is being transmitted pin 19 pulses once, after it is transmitted it pulses again and the it doesn’t pulse any more until I reset the transmitting Propeller.
    ·
    Transmitter code
    ·
    {{File TwoPropsCommTrans.spin
    Transmiter side
    }}
    con
      _xinfreq=5_000_000
      _clkmode=xtal1+pll16x
      transPin=16                                           'transmision pin
      recPin=17                                             'receiving pin
      baudRate=300                                          '300 bauds
      mode=0                                                'comm mode
    obj
      comm:"FullDuplexSerial"                               'The comm object
    pub main
      dira[noparse][[/noparse]0]~~                                             '**********************************************************
      outa[noparse][[/noparse]0]~                                              '**********************************************************
      outa[noparse][[/noparse]0]~~                                             '**********************************************************
      outa[noparse][[/noparse]0]~                                              '**********************************************************
      outa[noparse][[/noparse]0]~~                                             '**********************************************************
      comm.Start(recPin, transPin, mode, baudRate)
      comm.tx($02)
      
    

    Receiving code
    {{File: TwoPropsRec.spin
    }}
    con
      transPin=16                                           'transmision pin
      recPin=17                                             'receiving pin
      baudRate=300                                          '300 bauds
      mode=0                                                'comm mode
      _xinfreq=5_000_000
      _clkmode=xtal1+pll16x
      motorPin=0                                            'first motor pin
    obj
      comm:"FullDuplexSerial"                               'The comm object
      motor:"StepperDriver"                                 'Motor driver
    pub main | byteReceived
      dira[noparse][[/noparse]18]~~                                            '************************************************************
      dira[noparse][[/noparse]19]~~                                            '************************************************************
      outa[noparse][[/noparse]18]~                                             '************************************************************
      outa[noparse][[/noparse]19]~                                             '************************************************************
      motor.start(0)
      comm.Start(recPin, transPin, mode, baudRate)
      comm.rxflush
      repeat
        byteReceived:=comm.rxcheck
        outa[noparse][[/noparse]18]~~                                          '*************************************************************
        outa[noparse][[/noparse]18]~                                           '*************************************************************
        if byteReceived <> -1
          outa[noparse][[/noparse]19]~~                                        '*************************************************************
          outa[noparse][[/noparse]19]~                                         '*************************************************                       
          case byteReceived
            $01:
              motor.Halt
            $02:
              motor.GoUp
            $03:
              motor.GoDown
                
    

    ·
  • ColeyColey Posts: 1,110
    edited 2008-07-29 22:11
    Enrique, is there a reason why you are using 300 baud? have you tried a higher setting such as 9600.

    I can't remember exactly and I don't have my rig set up to test it but I'm sure I had the same problem at low speeds.
    I solved it by putting a pullup resistor on the comms lines.

    Regards,

    Coley

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PropGFX Forums - The home of the Hybrid Development System and PropGFX Lite
  • LeonLeon Posts: 7,620
    edited 2008-07-29 22:20
    Enrique said...
    What's DDR

    Data Direction Register?

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • EnriqueEnrique Posts: 90
    edited 2008-07-30 07:07
    At first I used a higher baud rate and I thought that by lowering it I would solve the problem. I'll try with with a 10K pull up resistor in each line.
  • EnriqueEnrique Posts: 90
    edited 2008-07-30 07:39
    The pullups didn't help.


    Enrique
  • EnriqueEnrique Posts: 90
    edited 2008-07-30 08:29
    I GOT IT TO WORK!!!
    ·
    First, no need for pull-up or pull-down resistors.
    ·
    I had to change the code on the transmitting prop, this is the final code.
    {{File TwoPropsCommTrans.spin
    Transmiter side
    }}
    con
      _xinfreq=5_000_000
      _clkmode=xtal1+pll16x
      transPin=16                                           'transmision pin
      recPin=17                                             'receiving pin
      baudRate=9600                                         '9600 bauds
      mode=0                                                'comm mode
    obj
      comm:"FullDuplexSerial"                               'The comm object
    pub main
      comm.Start(recPin, transPin, mode, baudRate)
      waitcnt(clkfreq+cnt)                                  'wait for comm cog to initalize
      repeat
        comm.tx($02)                                        'have the motor go up
        waitcnt(clkfreq*3+cnt)                              'wait 3 secs
        comm.tx($03)                                        'reverse direction
        waitcnt(clkfreq*3+cnt)                              'wait again
        
    

    ·
    You will notice that I added a 1 sec wait (it could also be 100msec) after the comm.Start sentence; this gives the communications cog time to start up. Most probably when I sent the comm.tx command the other cog was not ready yet.
    ·
    ·
    Thanks for those answers,
    ·
    Enrique
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-07-30 11:50
    DDR = DIRA Sorry. DDR is a general term, DIRA is specific to the Prop.

    Glad to see that you were successful!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sign In or Register to comment.