Using CAN communication using an external microcontroller

Hi,

I’d like to setup a microcontroller as master and 2 oDrives as slaves to control 4 motors at the same time. I want to use CAN for this purpose, but I’m a bit lost on what I should do.

I see some instructions on your documentation about how to setup CAN nodes from Python. I’d like to know

  1. If setting up nodes with Python allows me to then later communicate with the motors from any CAN master (i.e., I’m not bound to Python/PC anymore, but the drives remain as standalone CAN slaves).
  2. I’m getting confused with denomination of CAN names. I see you call your protocol CAN simple, and say it is compatible with CAN open, but not completely? Would I be able to steer an oDrive using CAN Open once properly configured? Are there limitations?
  3. On the same lines as the previous point, I’m confused about the CAN PHY hardware configuration. I don’t find information about it on the internet, and would like to have it working with my external microcontroller. Are there instructions about it? Or maybe a reference to other projects/past quesitons I might have missed?
  4. At last, my device supports CAN-FD. Is that compatible with oDrive?

Sorry for the long question. Thanks in advance!

I’m hardly the expert nor the definitive voice, but this is my understanding. Bear in mind that CAN only exists in a devel branch right now, so much is subject to change before any “official” release.

  1. I don’t see why not. You can definitely set the unit up with python and then odrv0.save_configuration() then control it with one of the other interfaces after reboot. (I’ve done it with UART)
  2. I don’t know enough about CAN Open to give a useful answer here. My understanding is they selected IDs such as to not conflict with CAN Open.
  3. The CAN PHY is part of the microcontroller, as such you need to be looking at the ST datasheets if you want to do something out of the ordinary with it. There is also a line driver on the ODrive board. So when CAN Data leaves the ODrive pcb it is CAN H and CAN L. If you want to communicate over CAN with another micro, you will also need a PHY (can be part of the micro, or separate chip) and a line driver (almost always a separate chip) and probably a termination resistor.
  4. CAN-FD is something that has to be built into the PHY, to my knowledge the microcontroller used on the ODrive does not have that capability.

Is there a specific reason you want to use CAN to do this? It’s easy enough to control multiple units with the UART interface. Here’s an example of twelve motors http://www.xrobots.co.uk/open-dog-the-open-source-robot/

Hi Desterline,

Thanks for your answer. I understand a little bit more about CAN now, although I feel not enough.

May I ask, about point 1), how precisely you used UART with multiple slaves? I thought UART went through the USB cable, and that is a 1-to-1 connection. I understand from a quick look at your link and videos that you used an Arduino with multiple serial connections? So, separately wired master-to-slave?

This said, how would you communicate to the ODrive via UART? What kind of commands do you send? What I like about their CAN “support” is that they already worked out a protocol of messages, so I just have to use what they already programmed. Is it the same for UART? I could not find info about it.

Thanks in advance!

Whoa there - that isn’t my project, just something relevant to the conversation.

There are multiple communication channels on the processor used in ODrive. In this context, when someone says UART, they generally do not mean the USB port. You can configure GPIO pins 1 and 2 as TX/RX for UART control.
On my desk at them moment I have an ODrive connected via USB and running the Python tool and a USB - Serial adapter plugged into the GPIO pins and running terminal software on the PC. I can send it
commands on either channel.

Here’s the page that details the other interfaces:


and that links to the ASCII protocol document here:

The project I linked was controlling the ODrives with multiple Arduino MEGAs specifically because they have multiple hardware serial ports. From memory, I believe he had a master Arduino communicating with 2-3 slaves and each of those communicating with multiple ODrives.

Yes. In fact this is how it is intended to be used.

ODrive cannot currently be controlled with a CANOpen master. I intended to show that the user can put CAN Simple and CANOpen nodes on the same network without them colliding.

ODrive contains a CAN Controller inside the STM32 chip, and a CAN Transceiver connected to the CANH and CANL lines on one of the headers. I believe there is also a termination resistor on a switch in newer versions of ODrive.

On your master side, you would use a microcontroller, a CAN controller (either embedded inside the microcontroller, or a separate one like an MCP2515), and a CAN transceiver. You daisy-chain the CAN lines for all three devices (CANH to CANH and CANL to CANL).

Sorry, the CAN controller in the STM32 does not support CAN FD.

3 Likes