Shop OBEX P1 Docs P2 Docs Learn Events
Is there a better way to network multiple propeller boards? — Parallax Forums

Is there a better way to network multiple propeller boards?

I have been building a large hexapod for the last 4 years and it uses one propeller board for each leg. I plan on using a separate propeller as a master computer to control the 6 leg computers and another prop board for accessory control. Right now I'm using a 4 port serial object but wanted to explore some other methods of control. The 4 port serial object has each slave prop wired to its own dedicated Tx and Rx line on the master for communications. This method requires 1 cog for every 4 lines, not a problem on the slave boards but I'm running out of cogs on the master.

Before I commit to a specific design, wanted to see what other methods have been used successfully. The speed of the Rx/Tx is not critical since the transmitted commands cause DC motor movement (much slower process) although faster is nice. I've searched and seen several items along this line in the past but the new forum makes it difficult to do the same type of searches in just the prop forum.

Any suggestions are welcome!

Bob Sweeney

Comments

  • This post from Beau might contain some useful ideas.

    http://forums.parallax.com/discussion/134641/demo-high-speed-multi-prop-to-prop-communication/p1

    Really looking forward to seeing the roving hexapod. Sounds fantastic.
  • +1 for Beaus driver. Exactly what you need.

    @DiverBob,

    I played around with @Beaus code. You need two cogs for each board and the propeller boards are basically connected as a ring. One pin in, one pin out.

    If one fails the whole communication behind that one fails. Your master can detect the failure and stop moving.

    The basic idea is to 'share' a common HUB buffer between all Propeller Chips. It gets just send around and around. Each Propeller can read or write any location in the buffer. But it makes more sense to set up certain areas inside the buffer as dedicated to one Propeller.

    In a sense like a usual 'mailbox' address works with assembler COGs.

    Instead of sending commands serial your master just writes in his own hub and Beaus driver runs this over to all the other ones. And as fast as props can.

    I think this is very useful for multi Prop communication.

    But you need two COGs and two pins per Propeller and enough HUB ram left in all of them for the common buffer.

    As for the programming it is as cool as possible. Your master writes some command in his HUB and all clients can read it out of their own HUB.

    The common buffer is a HUB memory part shared between Propeller Chips like the normal HUB is shared between COGs.

    Enjoy!

    Mike




  • JonnyMacJonnyMac Posts: 9,105
    edited 2015-09-27 04:37
    Have you considered RS-485 or something else that would allow you to multi-drop to a lot of nodes without using so many IO pins? Using a standard architecture would allow you add other nodes as needed.
  • VonSzarvas wrote: »

    Sorry but, where is the source ? I can't find it on the thread nor on obex...
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2015-09-27 11:28
    Just use a half-duplex serial over a single I/O pin using nothing more than a current limit resistor in the pin to join up multiple Props provided that they are not scattered over a great distance or else you might need RS485 drivers. So all these lines are tied together in a single-wire multidrop network. I've used this type of network for systems where the processors are within several metres of each other and in a relatively protected environment but that doesn't mean it can't run the same way of much longer distances either.

    Even if you use simple 8-bit data you can use some of those as address and control especially from $80-$FF codes if all data is encoded as ASCII characters. Software simply looks for an address character that matches its address and accepts the rest of the stream up until another address or special control character. KISS.

    If you avoid FDS and use a serial driver that either transmits or receives then you can easily achieve baud rates >1M baud with nice clean timing. I can clean up a serial driver I have and post it here but I will be very tied up for the next couple of days though before I can get around to it.

    BTW, that could just as easily have 9-bit mode so you can still send any 8-bit character as data or whatever whenever the 9-bit is set which looks like a stop bit to any 8-bit device but if the 9-bit is low then we can interpret the 8-bits as and address or control character.
  • macca wrote: »
    Sorry but, where is the source ? I can't find it on the thread nor on obex...

    Youll find it in that thread. Just read on through a bit.

  • macca wrote: »

    Sorry but, where is the source ? I can't find it on the thread nor on obex...

    I believe the attached file is what you are looking for.

  • All the prop boards are within 1 foot of each other so distance is not a problem. The slave boards only have 1 cog available, don't have any means of freeing up 2 so that puts Beau's code out.

    The communications protocol right now is pretty basic, I transmit and receive the following string sequence, '$,leg number, command, value'. An example would be '$,1,2,305' means for leg 1 tibia motor to move to 30.5 degrees. A common return value from a slave would be '$,2,3,20'. This tells the master that leg 2 coxa completed a move.

    With the current configuration the master is the center of a star network with independent lines to each slave. I was thinking of 2 possible methods. One is using separate TX and RX lines that either daisy chain through each slave where if the message is sent to the 3rd slave, the first 2 slaves push the string down the chain until the requested slave gets the command. Another method could be to have each slave read the output command at the same time over a bus. I can think of some pluses and minuses for each method so wondered how other people solved this kind of problem and their results.

    Time to get away from programming for an afternoon, the lake is calm so off for some shipwreck diving!
  • As mentioned before, go for a multidrop network using the single direct I/O method, this works very well as I have used this in fire control systems successfully. You only need one cog for this driver as it is half-duplex and capable of high speeds. The address "characters" can also include ones for global and groups so that you can talk to an individual node or broadcast to all of them at the same time. The protocol is very simple, much like I2C in that once a device has detected its own address it continues to accept all commands and data up until it receives a "stop" or senses a new "start" which is any address character.

    Of course each slave could just receive everything that is sent from the master but you will still need an address field either way.
  • Why not just use I2C?
  • kwinnkwinn Posts: 8,697
    I would recommend going with Peter's suggestion for this. It's simple and easy to implement. One of the half duplex objects can be used so you only need to decide on the communication and command protocol, and what you have now could be modified to do most of that.
  • PublisonPublison Posts: 12,366
    edited 2015-09-27 17:12
    VonSzarvas wrote: »
    macca wrote: »
    Sorry but, where is the source ? I can't find it on the thread nor on obex...

    Youll find it in that thread. Just read on through a bit.

    I think the new forum software stirred it up a bit. I posted the original zip.

    EDIT:I also emailed Parallax to add it to the OBEX under the Perry Parallax name.
  • As mentioned before, go for a multidrop network using the single direct I/O method, this works very well as I have used this in fire control systems successfully. You only need one cog for this driver as it is half-duplex and capable of high speeds. The address "characters" can also include ones for global and groups so that you can talk to an individual node or broadcast to all of them at the same time. The protocol is very simple, much like I2C in that once a device has detected its own address it continues to accept all commands and data up until it receives a "stop" or senses a new "start" which is any address character.

    Of course each slave could just receive everything that is sent from the master but you will still need an address field either way.

    That sounds interesting, do you know where I can review some code using this setup?

  • jmgjmg Posts: 15,173
    DiverBob wrote: »
    I have been building a large hexapod for the last 4 years and it uses one propeller board for each leg. ..... This method requires 1 cog for every 4 lines, not a problem on the slave boards but I'm running out of cogs on the master.

    Depending on what 'large' means here, you may like to get a little ground-tolerance with motor power involved.

    As well as RS485 mentioned above, CAN bus transceivers give similar ground tolerance, but have a simpler termination scheme as their threshold is offset.

    Half duplex is likely fine for your messages, as you send a small packet, and get back an ACK packet.
    A simple timeout can sense no-slave cases.


  • I was searching for examples of half-duplex comms with multiple props but the new search engine gives results from all forums, not just the prop forum. That makes it much harder to locate good examples. Without an example I'm not sure how the command and control works when you are sharing a single line from the master to several props. What method works for detecting if the line is open and available to transmit?
  • jmgjmg Posts: 15,173
    DiverBob wrote: »
    Without an example I'm not sure how the command and control works when you are sharing a single line from the master to several props. What method works for detecting if the line is open and available to transmit?
    That's usually by inference, and with a single master is fairly simple.
    The master knows slaves only echo a reply in response to a query, so if the BUS is free, it is free to talk.
    After a message is done, the master does have to receive the expected number of bytes, or wait a minimum time, to keep in phase with the packets ping-pong.

    Multi-Master is trickier, and a transceiver like CAN can show contention.
    The TX routine checks the RX pin, and if the pin is <> Expected, thensomething else is driving the BUS.
  • AribaAriba Posts: 2,690
    Some ideas:

    You can use FullDuplexSerial.spin for the Master and the Slaves. The mode parameter lets you set open-drain mode, so you can just connect all together on a single wire.
    Another mode bit allows to ignore the self sent data, which makes it easier.

    So the connection is:
    3.3V
                                    |
                                   [R] 4k7
                                    |
      --+-----------+-----------+---+--
        |           |           |   
     .--+--.     .--+--.     .--+--.
     | pin |     | pin |     | pin |
     |     |     |     |     |     |
     '-----'     '-----'     '-----'
      Master      Slave       Slave
    
    The FulldupexSerial start:
    
      fds.start(pin, pin, %1100, 38400)
    
    
    This uses the same pin for rx and tx. 38.4 kBaud is just an example.

    Now you need to add a Slave Address to your little serial packets:
    '$, slave addr, leg number, command, value'

    All slaves will receive all packets and check the slave-address to know if the packet has to be processed or not.

    To prevent several slave sending at the same time, the master can send a query, for example:
    '!, slaveAddr'
    Then only the addressed slave sends its status, and only if he got the query from the master.

    -Andy
  • Thanks for the write up Andy, that was a very clear explanation and example. I will have to try it out and see how well that works out. I believe I can use the leg number as the address as each slave runs only its specific leg so the packets are unique. I set up the packet this way just in case I wanted/needed to do something like this in the future.
    In your example the master initiates all communications by either sending the specific packets or requesting feedback from a specific location, the slaves do not independently initiate communication back to the master. Since I want the slaves to report back when error conditions are identified (such as a leg is not moving or encounters an obstacle) I could set up where the master continuously queries the slaves one at a time for a report whenever the master isn't sending out commands. Hmmmm, something to think about. Thank you for some insights!

    Bob
  • AribaAriba Posts: 2,690
    You're welcome

    If you want that Slaves can send without a query from the Master, here is another insight:

    If you don't set the mode-bit 3 at FDS start, then a slave receives the packet back that just was sent. If two slaves send at the same time the serial packets get corrupted. Because the rx part gets the signal from the bus wire, the received back data is also corrupted. So you can compare the sent and received bytes. If they are identical there was no other slave sending at the same time.
    If the data is corrupted, you have to send it again after a short delay. These delays must be different for the different slaves, otherwise they just try again and again at the same time.
    The master must also recognize that the data is corrupted, for that you can add a checksum. Just add all bytes together and send the result as additional byte in the packet for example.

    Now we are close to real fieldbus...

    Andy
Sign In or Register to comment.