UC4H: UAVCAN for Hobbyists

The UAVCAN for Hobbyists (UC4H) project aims at connecting things like a GPS or magnetometer module to a ArduPilot/Pixhawk drone via the CAN bus, UAVCAN specifically.

UAVCAN has been made available quite some time ago, in order to bring CAN to drones. CAN is renowned for it’s extreme reliability and is thus attractive for application in drones. However, to the day I think it is fair to say that only few UAVCAN devices have become available, and those which are, are clearly for the professional market, at least price-wise. So, I set out to change that, and started the UAVCAN for Hobbyists project. The initial driving force was in fact that I wanted to get rid of this dammed I2C, which we use for connecting an external magnetometer. Soo annoying. Thus, I thought, let’s build a UAVCAN-to-I2C adapter and connect that to the magnetometer, so that the long wires would be CAN now. The project however quickly went farther than this.

The project presented me with challenges which made me considering to quit more than once. At this point I want to express my deepest thanks to Pavel, for the tremendous work he put into UAVCAN, and especially for not giving up answering my questions. Thank you so much, sir! 🙂

The project consists of several pieces, which I will present, and make available, below.

Useful Links

0. Usage Information

The UC4H nodes are working well. There are of course little things which still could be improved and changed, but overall I’m very satisfied. It’s working, I like my UC4H-ized copter, and in this sense the project has accomplished its goals. I’d like to leave some comments on its applicability.

In principle, the UC4H nodes can be used in any UAVCAN network. That’s the idea of UAVCAN. However, in practice the options boil down to ArduPilot, with these additional restrictions (to the best of my knowledge!):

ArduPilot master:
You need to flash at minimum from master. The stable firmware versions do not work (to the best of my knowledge). This is so because the „new“ UAVCAN support is only in master so far. As much as I know this holds true for both Copter and Plane. However, master only supports the GPS and magnetometer UAVCAN messages, but not the UC4H power brick. Thus, with ArduPilot master you can use the UC4H gps-magnetometer node.

BetaCopter 3.6dev:
This is a fork of ArduCopter master of 12. Aug. 2017, and has compiled binaries for v2 (Pixhawk) and v4 (Pixracer) flight controllers. It has full support for the UC4H gps-magnetometer and UC4H power brick nodes (as well as for the STorM32 gimbal controller). Thus, if you want to make use of the full potential of the UC4H project, you want to flash BetaCopter3.6dev-v005 (download the .px4 binaries from here: https://github.com/olliw42/storm32bgc/tree/master/betacopter/betacopter36dev-v005/ArduCopter). The limitation is that this is only for Copter and for v2 and v4 flight controllers.

The UC4H SLCAN adapter is of course independent on any flight controller support and in fact UAVCAN, and thus can be used in any CAN bus network.

I. UC4H GPS-Magnetometer Node

The UC4H GPS-magnetometer node provides a bridge for connecting any of the widely and relatively cheaply available GPS modules to the CAN bus. If the GPS module also has a magnetometer on-board, which is often the case, then also the magnetometer can be connected to the UC4H GPS-magnetometer node.

You may ask: Why should one want to do this? I did it for several reasons:

  • I really was annoyed by the I2C wires. I found them to be the most unreliable connections, repeatedly causing me troubles.
  • No issues with running out of UART ports on the flight controller anymore. For instance, if one wants to make use of the latest dual-GPS support of ArduCopter, and also wants to connect a gimbal controller, e.g. a STorM32, via UART to the flight controller, then three UARTs are consumed (2 x GPS + 1 x gimbal).
  • It leads to a cleaner wiring. Instead of 7 wires only 4 are needed. Also, fewer wires go to the flight controller, especially if more UAVCAN units are used. This can help with damping flight controller vibrations.
  • It’s just cool. 🙂

Good and cheap GPS modules are for instance the Hobbyking UBLOX Micro M8N GPS Compass or the Drotek Ublox NEO-M8N GPS + HMC5983 Compass modules.

The connection diagram for the Hobbyking module looks as this:

uc4h gps magnetometer board olliw

However, from the scheme it should be clear that any GPS or GPS+compass module can be turned into a full-fletched UAVCAN GPS+compass module. And this at very modest costs. That is what DIY is about, right.

In the above scheme I was using a little PCB, which I layouted. The module may look difficult to build, and for those who never have done SMD soldering it probably is, but when using solder paste and a hot-air station (good ones, such as the 858D, are available for ca $35) it is really much simpler to do than you might think now.

The module can also be build using cheaply and widely available STM32F103C8/CB and CAN transceiver modules. The result of course doesn’t look as snugly, but it is incredibly simple, and cheap, and works equally well. For instance, I’ve ordered this STM32F103C8 development board for $1.80, and this SN65HVD230 CAN transceiver module for $1.89. The cost for converting a GPS module into a UC4H GPS-magnetometer node can thus be as low as $3.70. Cool, eh.

Depending on the GPS magnetometer module it can be necessary to add two pull-up resistors to the I2C lines. This is e.g. the case for the mentioned Hobbyking module. A general scheme and a practical build is shown here:

uc4h gps magnetometer diy olliw
uc4h gps magnetometer diy build v01 olliw

II. UC4H Power Brick

The UC4H power brick is a substitute for modules such as the common 3DR power module, or the ACSP4/5/7 modules by AUAV/mRo. It combines measuring the voltage and current of the battery, and a 5.3 V/3 A power source for powering the copter electronics.

uc4h powerbrick board olliw

The UC4H power brick has some top-notch features:

  • Uavcan: Well, obviously, that’s its major point. It emits the uavcan.equipment.power.CircuitStatus or, even better, the UC4H-specifc GenericBatteryInfo message at adjustable intervals.
  • Low-noise Switch Regulator: I use the LT8610A which is good for 42 V and 3.5 A. It’s a member of the LT8610 family of regulators, which is also used by the ACSP series of AUAV/mRo.
  • Hall Current Sensor: No lousy resistor shunt, Hall sensors should be state-of-the art. I use the ACS770, which is the successor of the ACS758, which has been widely used in the drones area (see e.g. here), and offer slightly better specs. The ACS780/1 could also be worth a consideration, but it is a bit „trickier“.
  • LDO Stabilized Voltage for the Hall Current Sensor: This is actually a point which I think has been overlooked in the design of available power modules using the ACS7xx sensors (e.g. here and here): The ACS7xx sensors are ratiometric. This means that when its supply voltage varies also the current sensor output signal varies proportionally. Thus, if the ACS7xx is directly powered from the 5.3 V source, as it is usually done, then any significant power drawn from the 5.3 V source will result in a drop of the measured current value, since the voltage will drop. In my tests a draw of 2 A led to a drop from 5.3 V to 5.0 V or 6%, and the current on the main line will be measured incorrectly by 6% – which is quite a lot. In the UC4H power brick this is overcome by using an extra LDO regulator for sourcing the ACS7xx sensor, ensuring most precise current measurement.
  • Precise Charge Calculation: This is another unique feature. Since the UC4H power brick has it’s own microcontroller, it can determined the consumed charge (mAh) much more precisely than would be possible otherwise. This is so because it can measure the current at a much higher rate and thus track current fluctuations much more precisely. Specifically, the node’s firmware measures the current at 1 kHz, which is several 100 times faster than with the currently available power bricks.

III. SLCAN Adapter

The SLCAN adapter is an indispensable tool for checking and debugging the proper functioning of a UAVCAN network. Currently it is also required for setting node parameters.

In simple terms, it is a USB-CAN adapter, which is connected to the CAN bus on the one side and via USB to a PC on the other side. On the PC the Uavcan GUI Tool, which is freely available as part of the UAVCAN project, provides a nice software for doing a lot of things, such as spying the messages on the CAN bus, plotting data, setting node parameters, and so on.

Within the UC4H project, the SLCAN adapter can be build in two ways. Firstly, I’ve designed a simple PCB board, which is relatively compact, and quite handy. It also allows one to select different powering schemes for the CAN bus, and provides the fuse & diode protection in accordance with the standard.

uc4h slcan adapter board v01 olliw

Alternatively, the SLCAN adapter can be build using cheaply available standard components. For instance, I’ve bought this: STM32F103C8 development board at $1.80, CAN transceiver module at $1.89, USB-TTL adapter at $1.02. Total cost: $4.71. That’s very acceptable, IMHO. The connection scheme is:

uc4h slcan adapter diy v01 olliw

IV. Materials

I’ve reworked the layouts of the print boards of the GPS-mag node, power brick and SLCAN adapter, removing some tiny bugs and generally making them „better“. So I could promote them to version v1.0.

UC4H GPS-Magnetometer Node v1.0

uc4h gps mag node v103 scheme olliw

uc4h node v10 top olliw

UC4H Power Brick v1.0

uc4h powerbrick v102 scheme1 olliw uc4h powerbrick v102 scheme2 olliw

uc4h powerbrick v102 top olliw uc4h powerbrick v102 bot olliw

uc4h powerbrick powerleads olliw

UC4H SLCAN Adapter v1.0

uc4h slcan adapter v100 scheme olliw

uc4h slcan adapter v100 top olliw


Go to the github repository: github repository.

Hinterlasse einen Kommentar