Servers by jDrones

UAVCAN: CANbus for the rest of us

(mike kelly) #1

CANbus has been used by DJI from nearly their beginnings but it has not been available for Ardupilot users. What is CANbus? It is a network to connect smart devices that is message-based. You can think of it as a little internet for the multirotor.

I did a comparison of Mini-Pixhawks and found every one had different pin-outs for each connector, even when they were using the same physical connector and it was being used for the same device, like GPS. No wonder users have problems buying and connecting simple required accessories for a multirotor build. It is absurd and a pain.

CANbus can eliminate all that pain. CANbus was designed by Robert Bosch for the automotive industry decades ago. The new implementation for unmanned vehicles by Pavel Kirienko called UAVCAN brings CANbus to the Pixhawk community and OlliW’s UC4H project brings it to the DIY community with low-cost adapters to interface commonly used M8N based GPS/Mags, a beautiful UAVCAN Power module with Hall sensor for accurate voltage and current measurements, and he has added UAVCAN to his STorM32 gimbal controller board.

UAVCAN can bring to DIY a standard way to connect all your devices to your flight controller. One connector, the JST-GH, is easy to click into place and remove and it won’t fall out. The cables are all the same four-wire configuration for all your devices and they are daisy chained together. No more having to have all the cables to all the devices go all the way back to the flight controller.

Even more importantly, each device on the UAVCAN bus is a smart device. They send out messages that can be monitored by a bus sniffer called a SLCAN. This allows you to monitor, configure and test every device on your UAVCAN network from one utility, Pavels UAVCAN GUI.

So let’s take a look at UAVCAN GUI. UAVCAN GUI is available for Windows, Linux and MAC.

First, you need a SLCAN sniffer. Like the one OlliW designed for his UC4H, UAVCAN for Hobbyists project or Pavel’s own Babel.

These usb devices attach to your UAVCAN bus as just another device. UAVCAN wiring is composed of 4 wires, two canbus signal wires and 5v power and ground. But there can only be one device on the bus that supplies the bus 5v. In our case it is usually the flight controller but when you are configuring maybe a single device with your SLCAN, OlliW’s SLCAN be jumpered to be a supplier for the bus power.

The UAVCAN GUI is a powerful tool but don’t let it intimidate you. We will just use the features we need one at a time. Plug in your SLCAN to a usb port on your computer. Next, start UAVCAN and it will pop up a dialog box that allows you to set the com port your SLCAN is assigned and what speed you want to talk to the SLCAN. If you are unsure what com port your operating system assigned, simply look at the available ports in the drop-down. Note the com ports it lists, then unplug your SLCAN. The port that disappears from the list is the one you want to use. Plug your SLCAN back in and choose that port.

Next choose 1000000 as the speed in both of the next two boxes.

When you hit ok the main window of UAVAN GUI will appear.

Click on the button for “Local node ID” and leave it at 127

Note that now the descriptions of the nodes on the bus are displayed.

First notice that each node has an ID. The Pixhawk is 10 and the GPSMAg node is 44. The Zubax Orel ESC comes configured for an auto node assignment. But Ardupilot cannot assign dynamic node IDs. They won’t show up until they get a node ID. You must set the node IDs manually for the ESCs. For the ZUBAX OREL UAVCAN ESCs you can click on the main panel’s “Dynamic Node ID Server” in the lower right and it will assign a temporary node ID for the ESCs. Then you you can set static node IDs that will be the permanent IDs for the ESCs.

In the illustration above I clicked on the “io.px4.sapog” which is the name of the ESC. This opens the node properties window for the ESC. I have only one ESC connected in this example and you will see more if you have them all connected, like 4 with a QUAD.

If you click on “Fetch All” the tool will query the ESC for all its parameters. One of those parameters is called “uavcan_node_ID”. Click on this and set the value to a unique ID for each ESC. I choose 100,101,102 and 103 for the four ESCs for my Solo quad. But I could have chosen 52,87,105 and 22. They just must not be used by any other device. Click on “Store All” to save your settings. Some changes may require a reboot of the device.

The node IDs don’t have any relation to the position of the ESC in the multirotor geometry. That is set by esc_index. Set the index of each ESC to match their position in the motor order of the multirotor. In the case of an ArduCopter quad, that would be starting from the forward right motor 1,4,2,3 around clockwise.

There is another handy parameter for the ESCs and that is ctl_dir which allows you to change the rotation of the motor on that ESC.

As you can see, you get ultimate control, easily compared to traditional ESCs.

Next, we can test the ESCs and see if they are working on the ESC Panel. The smart ESCs get the throttle endpoints automatically from the flight controller.

We can use the Bus Monitor to see the devices in action and check the values in operation. Now you can actually see your devices working while installed in your multirotor or other UAV.

You can see messages above for the GPS (, the Compass (, and the ESC (

You start recording with the video camera icon in the upper left and you can pause at any point and check the value of the device you are interested in.

Not all the needed messages are currently in Ardupilot but hopefully they will be soon. OlliW has a fork of ArduCopter with the needed messages available now that he calls BetaCopter that allows his GPS/Mag interface, UAVCAN Power Module and UAVCAN to his STorM32 gimbal controller board to be used right now!

I think you can see that UAVCAN can give you a much more integrated multirotor build, with a common bus for all your devices and a common way to configure, test and troubleshoot them. OlliW brought UAVCAN to the DIY enthusiast with his UAVCAN 4 Hobbyist project UC4H. I have successfully used OlliW’s UAVCAN devices to convert a 3DR Solo to UAVCAN.

Introducing the AUAV X2.1 Flight Controller
(James Pattison) #2

Awesome! Great post.

3DR Solo as a platform to play with CANbus
(Jagger) #3

I agree.Thanks Mike.I’ve been reading of Olli’s battles in his thread for a while now.The pace of development is stunning.

(mike kelly) #4

I have to really really thank kd0aij for jumping on getting this restarted into Master.

WIP: initial merge of OlliW’s betacopter36dev-v005 into ardupilot master #7167

(Olivier Brousse) #5

Real nice. Thanks for this great post!

(mike kelly) #6

Actually Olivier it is a pleasure to finally be able to contribute, in a small way, rather than always being a “consumer” of all the hard work you folks have shared with the rest of us.

(Luis P.) #7

Mike, first of all I would like to recognize your efforts providing examples and documentation for UC4H implementations.

I’m replacing the PWM ESCs of my hobby PixHawk-based quadcopter with new DShot ones, just built build OlliW’s CAN adapter and ESC Actuator, and now configuring the actuator’s parameters via UAVCAN GUI… my primary objective is to eliminate the need for ESC calibration.

Are you familiar with OlliW’s actuator parameters, or where I would be able to find documentation? I want to ensure they are set with the highest DShot option available. I’m guessing the parameters OutA/OutB/OutC Mode would allow PWM, OneShot, DShot.

Any guidance would be much appreciated!


(mike kelly) #8

Hi Luis, In my original project I used Zubax ESC’. SInce then I have built OlliW’s UC4H ESC node, but the first version that did not support DShot. I have not built the second version yet. OllIW is really good about answering questions on his RCGroups forum so just write him a note and I am sure you will get an answer. I really like the new carrier he designed to make the ESC/Node a one piece unit.

It has been a great project for me and I really love the super clean build of using CANbus and OlliW’s inexpensive UC4H nodes. I really like being able to use UAVCAN GUI to troubleshoot and monitor. I have been bugging OlliW, unsuccessfully :), to build a UC4H Pixhawk with the SLCan adapter built in!

Well good luck and let us know how your project progresses.

(Jane) #9

Thanks for very helpful post!

@Anyone - is there a way of grabbing the mavlink telem data over UAVCAN? Seems like we’re pushing CAN more and more and I’m always short a serial port so would like to use the CAN connections on the PH to grab the telem stream if that’s an option?

(mike kelly) #10

The protocol is not really designed for continuous data transmissions. It is designed as a network between intelligent devices.

(Evan Williams) #11

@r4space1 That said, there is currently an open Pull Request to allow serial port tunneling (including MAVLINK) over UAVCAN.

(Jane) #12

More general UAVCAN q:

Does is have an acknowledge message like CAN?

I did try find the right docs but clearly am googling the wrong term sorry - just a link to correct place to look would be helpful.

(mike kelly) #13 has got everything you need

(Pavel Kirienko) #14

UAVCAN is CAN, one is layered on top of the other. Like HTTP over TCP over IP.