0
\$\begingroup\$

PROBLEM

I'm building a robot control board to attach to a Raspberry Pi as an hobby. I like to have specialized boards for various functions, and I'm exploring solutions for the communication bus. In the past I tried:

  • 5V UART: problems with noise
  • I2C: just doesn't work with noise
  • POF Plastic Optic Fibers: Cool but expensive and large
  • RS485 over audio cables with 3.5mm jack connectors with custom protocol: Works like a charm. I like how inexpensive the connectors and the cables are.

Below an image for reference of one of the robot I made in the past using a RS485 bus with custom protocol over audio cables with 3.5mm jack.

Motor boards with RS485 bus using 3.5mm audio jacks

Below an image for reference of my latest iteration of the Raspberry Pi robot hat. I want to add display and connectors for a communication bus, add a better power regulator and move motor and servo controls over to slave boards.

enter image description here

IDEAS

I'm thinking of either implementing a CAN bus or a RS485 bus with a less custom protocol that has some use in the market.
Here an example of a slave that uses CAN bus
Here an example of a slave that uses RS485 bus with their custom protocols.

Specifications:

  • Three wires (two data + one shield), so I can use audio cables and 3.5mm jacks for my slaves
  • I want the bus to be less custom, so that I can attach it to existing add on boards
  • 1Mb/s bandwidth
  • Resilient to noise

QUESTION

I'd like suggestions on which bus you would use in this application, in particular if there is a bus that I have not taken into consideration, suggestion on a standard protocol over the RS485 bus or your reasons you would choose a CAN bus. Thanks for your inputs!

SOLUTION

There are no dominant protocols used with RS485 and CAN has a large data frame overhead.
I decided to implement two 3 pins 3.5mm Jack connectors with a RS485 transceiver connected to an AT4809 for the hardware. Over the RS485 bus I will reuse my custom master-slave protocol.

Below an schematics and initial placement of components. Schematics and Initial Placement

\$\endgroup\$
4
  • 2
    \$\begingroup\$ RS-485 only requires a transceiver on the rpi, CAN requires a controller over spi/i2c. Pick RS-485, goes directly on the gpio header. Also, both busses still require a "common-ish" ground, so theoretically 3-wire, optional shield. Yet, this is a question better suited for a forum, like EEVblog. \$\endgroup\$
    – Jeroen3
    Commented Jul 19, 2021 at 11:35
  • 1
    \$\begingroup\$ You can still use CAN PHY and transmit UART data on it, theres no requirement for a CAN controller unless there is nees for using CAN protocol. Same way, RS-485 does not necessarily equal to UART protocol even if it is usually used with it. \$\endgroup\$
    – Justme
    Commented Jul 19, 2021 at 12:51
  • 1
    \$\begingroup\$ I would ask why there is so much noise that all the other comms protocols wouldn't work? Motors, sure, but the effect can be reduced with snubbers and filtering. And good filtering and screening should reduce the effect of noise on the comms signal lines. Otherwise you may be masking a problem with industrial grade comms, only for the noise to cause issues in other places. \$\endgroup\$
    – Oliver
    Commented Jul 19, 2021 at 15:37
  • \$\begingroup\$ Arriving late to the party, but one of the reasons you have problems with noise is that the wiring job is awful. Some cable ducts where cables are kept away from power- and motor drive electronics would improve EMC a lot. What you have currently is basically some ~20 yellow-colored antennas picking up all EMI from the boards and motors. But then I'm not sure how good Rasp Pi is for EMI-intensive applications in the first place (it might need a pi filter? har har...). RS-485 or CAN is the right way to go, however. \$\endgroup\$
    – Lundin
    Commented Aug 9, 2021 at 9:46

1 Answer 1

2
\$\begingroup\$

I'm afraid you are comparing apples to oranges.

RS-485 is simply a way of driving a bus. You take your UART output, translate it via an RS-485 transmitter, receive it with a receiver, and then feed that into the destination UART. Easy peasy.

CANBus is a much more complicated proposition. You have to feed a CAN controller with data packets. The controller then drives the physical bus with a far more complicated protocol to the receiver, and the receiver produces a reconstructed packet. In effect, the two controllers would replace your UARTs.

As for reliability, CANBus is better. All the extra garbage that a CANBus uses go toward two things: selecting one out of a number of units which are all connected to the bus, and error detection and correction.

When you say you want 1 Mb/s bandwidth, you will never get that from CANBus. It's true that you can drive CANBus at 1 MHz, but if you send 1 byte at a time you'll only get an effect 140 kb/s. It takes 58 clock cycles to send a 1-byte CANBus frame. It's true that it's possible to drive the bus at 5 MHz, but that only gets you up to an effective 700 kb/s.

Although, to be fair, a UART driven at 1 MHz will only have a throughput of a 700 - 800 kb/s, depending on your choice of frame setup, but you can readily drive it faster than that.

See https://en.wikipedia.org/wiki/CAN_bus for an overview.

It's also normal for a single CANBus source to provide the 5 volt power for all the other units. This means you need 4 signals on your bus, and an audio wire won't cut it.

\$\endgroup\$
4
  • \$\begingroup\$ Your explaination is clear. I dislike providing power alongside com because it burdens the master's power requirement and slaves have very different power requirements. I would be fine with about 1MHzs being the signaling rate, and not having 1Mb/s of effective bandwidth (that's a lot of overhead for CAN!) \$\endgroup\$ Commented Jul 20, 2021 at 10:42
  • \$\begingroup\$ My GD32VF103 has both UART and CAN pheriperals. Would you advise using CAN or would you advise a protocol to use on the RS485? \$\endgroup\$ Commented Jul 20, 2021 at 10:43
  • \$\begingroup\$ @05032MendicantBias - The 5V from the CANBus master is only used to drive the transceiver part of the CANBus controller. As a result, power draw is directly proportional to the number of transceivers connected to the bus. \$\endgroup\$ Commented Jul 20, 2021 at 18:58
  • \$\begingroup\$ @05032MendicantBias - I can't really make a recommendation. I don't know your metrics. For instance, does your UART peripheral have RS485 capability? Some do, some don't. If not, how big a deal is providing the physical layer? You won't get 1 Mbps from CANBus. How much do you actually need? If it's over about 140 kbs, CANBus is out unless you can get a 5 Mbps unit. CANBus is specified with a 120 ohm TWP bus - how close is this to your audio cable? There are lots of other issues, but I simply don't know enough to advise you. \$\endgroup\$ Commented Jul 20, 2021 at 19:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.