Recommendation for USB to CAN converter

1,559 views
Skip to first unread message

Samuel Dudley

unread,
Aug 10, 2015, 9:09:16 PM8/10/15
to UAVCAN
Hi,
Can anyone give a recommendation for a reliable USB to CAN converter which works under Linux for use on a UAVCAN bus? I'm currently using a Pixhawk + Zubax GNSS and would like to
utilise the uavcan_monitor tool from a Linux based laptop (Ubuntu 14.04LTS) by connecting into the bus.
Cheers,
Sam

Pavel Kirienko

unread,
Aug 10, 2015, 10:29:15 PM8/10/15
to Samuel Dudley, UAVCAN
Hi Sam,

I'd recommend 8devices USB2CAN adapter. I own a couple of them and they seem to perform decently; also their driver is included in the upstream Linux kernel.

Pavel.

--
You received this message because you are subscribed to the Google Groups "UAVCAN" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uavcan+un...@googlegroups.com.
To post to this group, send email to uav...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/uavcan/c01c9342-b183-4467-ac46-93d093711421%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Auvidea

unread,
Aug 26, 2015, 3:06:09 AM8/26/15
to UAVCAN, dudley...@gmail.com
Hi Pavel,

I am designing a carrier board for the Raspberry Pi compute module, which I would like to integrate in the UAVCAN eco system. Now, the RPi does not have a CAN interface. I am looking at adding this via USB with an on-board USB to CAN converter. Hardware wise the STM32F105 seems to be a good fit. It features one USB OTG port and 2 CAN interfaces. But what about the software. I only have limited software development resources available for this project. Is there an out of the box firmware solution available? 

Jurgen.


Lorenz Meier

unread,
Aug 26, 2015, 3:21:21 AM8/26/15
to Auvidea, UAVCAN, dudley...@gmail.com
Hi Jurgen,

Ben Dyer has designed a USB <-> CAN converter and reported some success on the software development side last weekend. I’ve CC’ed him and he can provide you further feedback.

@Ben: Have you considered yet how to upgrade the Firmware on the converter?

-Lorenz


--
You received this message because you are subscribed to the Google Groups "UAVCAN" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uavcan+un...@googlegroups.com.
To post to this group, send email to uav...@googlegroups.com.

Pavel Kirienko

unread,
Aug 26, 2015, 3:23:26 AM8/26/15
to Auvidea, UAVCAN, Lorenz Meier
Hi Jurgen,

There seems to be a number of open source solutions on Github that address this issue: https://github.com/search?utf8=%E2%9C%93&q=usb2can
Personally I don't have any experience with any of them.

Alternatively, you could try to reproduce 8devices USB2CAN hardware on your board, since it's an open hardware, open source design.
Note that I don't have any affiliation with 8devices, therefore I recommend you to ask them directly whether it is acceptable to reproduce their design on your custom hardware.

If you chose to go with your own firmware, I'd recommend to resort to SLCAN tunneling over a CDC/ACM port. The most common SLCAN commands are summarized in this document (by Oliver Hartkopp): https://github.com/linux-can/can-misc/blob/master/docs/SLCAN-API.pdf.
Lorenz has already mentioned Ben's design, which also uses the SLCAN approach.

Pavel.

Ben Dyer

unread,
Aug 26, 2015, 3:59:06 AM8/26/15
to Auvidea, UAVCAN, dudley...@gmail.com, Lorenz Meier
Hi Jurgen,

My USB to CAN board is based on the STM32F042C6U6 and the TJA1051 transceiver. It's a very low-cost, low-part-count solution; embedded into a carrier board providing 3V3 and 5V supplies, the footprint would be less than 200 mm^2 and the BOM would be around $2.30 @ 1ku. I have attached the schematic.

The current firmware implements SLCAN, so you can use it without drivers on OS X and Linux (I'm not sure about Windows). On Linux, you can also use the SocketCAN interface, which can be nicer than using the SLCAN protocol directly.

Firmware update (and initial programming) is handled via the USB DFU bootloader built in to the STM32F042. The firmware version can be queried via the SLCAN interface, and there is a non-standard SLCAN command to restart the device in DFU mode.

Regards,
Ben

USBCAN.pdf

Auvidea

unread,
Aug 26, 2015, 4:58:48 AM8/26/15
to UAVCAN, j...@auvidea.com, dudley...@gmail.com, l...@qgroundcontrol.org
Hi Ben,

this is great. I love it. Great job. This is exactly, what I am looking for. 

How does the licensing work? I would like to integrate this in a commercial product. 

Pavel recommends a dual CAN bus for UAVCAN. Does this support UAVCAN? And can it be ported to the STM32F105, to get 2 CAN busses?

How does this work on the RPi (Raspberry compute module side)? Can the RPi upgrade the firmware via USB? Are drivers available for the RPi so it can implement UAVCAN?

I do work with Altium as well. Can you please send me the design files to my email address. Thank you very much.

Regards,

Jurgen


Pavel Kirienko

unread,
Aug 26, 2015, 5:13:50 AM8/26/15
to Auvidea, UAVCAN, dudley...@gmail.com, Lorenz Meier
Hi Jurgen,

> Pavel recommends a dual CAN bus for UAVCAN.
It's not quite what I recommend.
Redundant interface may or may not make sense, depending on the requirements of your application.
What I DO recommend, however, is to have two CLIK-Mate connectors per interface. See http://uavcan.org/Specification/7._Hardware_design_recommendations.html#connectors.

> And can it be ported to the STM32F105, to get 2 CAN busses?
If you're concerned about redundancy, I suggest to consider implementing two fully independent USB-CAN adapters on your board, which implies two independent MCUs.

> How does this work on the RPi (Raspberry compute module side)? 
An SLCAN adapter will be visible as a serial port, so it will work virtually anywhere.

> Are drivers available for the RPi so it can implement UAVCAN?
As long as you're running Linux, the hardware is irrelevant. Anyway, I learned that some people were able to run libuavcan on RPi successfully.
There are UAVCAN implementations that work on Linux - libuavcan (reference implementation) and pyuavcan (documentation should be available soon).

Pavel.

--
You received this message because you are subscribed to the Google Groups "UAVCAN" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uavcan+un...@googlegroups.com.
To post to this group, send email to uav...@googlegroups.com.

Ben Dyer

unread,
Aug 26, 2015, 5:19:09 AM8/26/15
to Auvidea, UAVCAN, dudley...@gmail.com, l...@qgroundcontrol.org
Hi Jurgen,

Currently the firmware is based on a mix of BSD and MCD-ST Liberty SW License Agreement V2 code. The ST license cannot be considered free software, but is generally suitable for integrating into a commercial product, provided that product uses ST processors.

Theoretically the code could be ported to the F105, however that chip would result in a more complex and expensive hardware design so I'm not going to pursue it. Others are of course welcome, once the firmware is published, but I would suggest following Pavel's recommendation in his other email and embedding two independent MCUs for the USB-CAN connection—in practice this will be cheaper than using an F105 as well, and will probably take about the same board area.

Regards,
Ben
> --
> You received this message because you are subscribed to the Google Groups "UAVCAN" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to uavcan+un...@googlegroups.com.
> To post to this group, send email to uav...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/uavcan/3bfe6b09-bf19-4f06-9c04-16d91a87edd0%40googlegroups.com.

Auvidea

unread,
Aug 26, 2015, 5:39:12 AM8/26/15
to UAVCAN, j...@auvidea.com, dudley...@gmail.com, l...@qgroundcontrol.org
Hi Ben and Pavel,

thanks you very much for your feedback. This sounds very promising and it makes a lot of sense. I agree with Pavel, that for best fault tolerance, it would be best to replicate the complete USB to CAN adapter. Ben, therefore your design would be perfect. One question remains. I though the 2 wire interface for programming the STM device needs to be brought out on a connector to connect to a ST/LINK programmer. Your schematics indicate, that this may not be necessary as the unprogrammed STM device already contains a USB boot loader. Or does this STM device need to be pre-programmed before it is soldered onto the PCB?

Are there any off the shelf products available so I can test your design?

I guess your design could also be a good starting point for a CAN sensor adapter. So a little module with 2 Clik-Mate connectors for UAVCAN on one side and a couple of sensors on the other side. I would like to integrate the Invensense 9-axis sensor, and altimeter and maybe analog inputs to measure current and voltages.

Another CAN peripheral could be a CAN to PWM adapter to connect servos or ESCs. ESCs maybe by I2C to get a return channel.

Or a CAN to S-Bus, PPM, or Spektrum receiver, to connect those via CAN to the CAN based autopilot (like Pixhawk).

What do you think?

Regards,

Jurgen

Ben Dyer

unread,
Aug 26, 2015, 6:38:05 AM8/26/15
to Auvidea, UAVCAN, dudley...@gmail.com, l...@qgroundcontrol.org
Hi Jurgen,

Your schematics indicate, that this may not be necessary as the unprogrammed STM device already contains a USB boot loader. Or does this STM device need to be pre-programmed before it is soldered onto the PCB?

The device starts in DFU mode when it is unprogrammed, so you can program it via USB using the firmware update tool. As a result, I have only broken out the SWD signals in the development versions of the board.

I guess your design could also be a good starting point for a CAN sensor adapter. So a little module with 2 Clik-Mate connectors for UAVCAN on one side and a couple of sensors on the other side. I would like to integrate the Invensense 9-axis sensor, and altimeter and maybe analog inputs to measure current and voltages.

The issue with this design as a starting point for standalone sensors is that it uses the F042's clock recovery system to trim the internal 48 MHz oscillator to the accuracy required for CAN; since the clock recovery system works by locking on to the 1 kHz USB SOF packets, the CAN interface should not be used unless USB is connected and active.

Peripheral designs would need to include an external oscillator or crystal to achieve the required accuracy, and at that point you're better off going for an STM32F1, F2, F3 or F4 device so that you can use the existing UAVCAN bootloader to get firmware update support.

As an example, here's an airspeed sensor board I made based on a 32-pin QFN version of the STM32F3.

Another CAN peripheral could be a CAN to PWM adapter to connect servos or ESCs. ESCs maybe by I2C to get a return channel.

I think it'd be better to use a UAVCAN ESC :) But CAN to PWM has a number of applications; when I get around to it, I'm going to do a CAN to RS485 interface to drive Dynamixel servos.

Or a CAN to S-Bus, PPM, or Spektrum receiver, to connect those via CAN to the CAN based autopilot (like Pixhawk).

That could be useful, although it could potentially be quite complex to integrate cleanly since the Pixhawk already has such an input.

Regards,
Ben


On 26 Aug 2015, at 19:39 , Auvidea <j...@auvidea.com> wrote:

--
You received this message because you are subscribed to the Google Groups "UAVCAN" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uavcan+un...@googlegroups.com.
To post to this group, send email to uav...@googlegroups.com.

Auvidea

unread,
Aug 26, 2015, 7:13:48 AM8/26/15
to UAVCAN, j...@auvidea.com, dudley...@gmail.com, l...@qgroundcontrol.org
Hi Ben,

thank you for your very helpful feedback.

It looks like a great little board. Is that commercially available? Or can I license it and manufacture it? I have a small SMD manufacturing facility here in Germany for prototypes and small to medium production runs for fine pitch BGAs, QTFPs and QFNs. This equipment includes:
  - automatic stencil printer to apply the solder paste
  - dual head automatic pick&place machine (very fast and precise)
  - vapor-phase soldering at 230°C (ideal for BGAs and sensitive components)

CAN ESC:
Yes, this would be perfect. But there seems to be just one available today, the ESC32 by Autoquad. Pavel's PX4ESC seems to take a another couple of months. Also ESCs seem to be a very political issue: some seem to like one brand and others another brand. So I believe there is an intermediate need by a small CAN to PWM or I2C converter for the ESCs available today.

I can imagine, that in the future the flight controller or autopilot system may just just have a CAN interface and no on-board sensors. In this way there is flexibility where to place the sensors and how to mount them. Also different sensors may be combined with different flight controllers. Or you use redundant sensors. So in my mind a little CAN based sensor module does make a lot of sense. Like your little airspeed sensor.

Regards,

Jurgen




Auvidea

unread,
Aug 27, 2015, 2:07:42 AM8/27/15
to UAVCAN, j...@auvidea.com, dudley...@gmail.com, l...@qgroundcontrol.org
Hi Ben,

I have studied your schematics. I noticed that you use the STM32F042C6U6, which is the 48 pin LQFP device with 32k Flash. This device does not seem to be in stock at Mouser or Digikey. The 32 pin version (STM32F042K6T6) is in stock. I guess it is more common. Also it does save me a little board space. So I would prefer the 32 pin version.

Are there any issues in using the smaller chip? Looking at the data sheet, it supports the same interfaces (USB and CAN). 

Would this require code changes? Or are there any differences with the boot loader (via USB)?

Thank you for your help.

Jurgen

Ben Dyer

unread,
Aug 27, 2015, 2:10:29 AM8/27/15
to Auvidea, UAVCAN, dudley...@gmail.com, l...@qgroundcontrol.org
Hi Jurgen,

The STM32F042C6U6 is the smallest part that supports USB and CAN simultaneously.


Regards,
Ben

--
You received this message because you are subscribed to the Google Groups "UAVCAN" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uavcan+un...@googlegroups.com.
To post to this group, send email to uav...@googlegroups.com.

Auvidea

unread,
Aug 27, 2015, 12:08:52 PM8/27/15
to UAVCAN, j...@auvidea.com, dudley...@gmail.com, l...@qgroundcontrol.org
Hi Ben,

I have just completed the design for the USB to CAN converter using the STM32F042C6U6 device. It is unfortunate that the pin multiplexing of the 32 pin chip does not allow to bring out the USB and the CAN bus at the same time. 

This is a simple 2 layer board. I will order some PCBs tomorrow so I can build up a couple of samples. The USB connector on the bottom is a USB A type male socket for PCB mount. So this little module can directly be plugged into a USB port. 

Size: 18 x 27.5 mm (without USB connector)

There will be 2 build options:
1. with a single Molex Clik-Mate connector and 120 Ohm onboard termination
2. with two Molex Clik-Mate connectors (without termination)

Would be like to have a sample of this board?

Best regards,

Jurgen
38159 USB 2 CAN Adapter.png

Ben Dyer

unread,
Aug 27, 2015, 8:48:44 PM8/27/15
to Auvidea, UAVCAN, dudley...@gmail.com, l...@qgroundcontrol.org
Hi Jurgen,

Yes, the multiplexing is a pain, particularly since the alternate CAN_RX pin is available in all packages: it's just the alternate CAN_TX pin that's not available in the smaller ones.

Your board looks good—I like the USB connector idea, it's a convenient size for that sort of application. I still have a few of my own, so I don't need samples just at the moment, but if you have any issues with the software then you can send one through and I'll help port it. That said, assuming the only changes between your board and my original design are the decoupling and USB filtering, the software should run unmodified. I'll clean it up a little and push a release this weekend so you can test.

I'm planning to start limited production of these units shortly so I'll let you know when they're available.

Regards,
Ben

--
You received this message because you are subscribed to the Google Groups "UAVCAN" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uavcan+un...@googlegroups.com.
To post to this group, send email to uav...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
<38159 USB 2 CAN Adapter.png>

Auvidea

unread,
Aug 28, 2015, 5:46:11 AM8/28/15
to UAVCAN, j...@auvidea.com, dudley...@gmail.com, l...@qgroundcontrol.org
Hi Ben,

I have optimized the design a little. I have changed the CAN transceiver to the smaller package (HSVON-8) and I have added 5V power to the CAN bus. In this manner the module can power sensor modules which are connected.

Also I have started a design of a CAN to UART, I2C and PWM converter. Thank you for your input on the clock. So I have added a crystal. Should I use 8 MHz or 24 MHz? The footprint can take both - the STM32F042 and the STM32F103. I kind of like the STM32F042, because it is less expensive and I has USB. 

In your reply above you stated: "Peripheral designs would need to include an external oscillator or crystal to achieve the required accuracy, and at that point you're better off going for an STM32F1, F2, F3 or F4 device so that you can use the existing UAVCAN bootloader to get firmware update support."

I do not quite understand this. Why does only the STM32F1 support the UAVCAN bootloader? And the STM32F042 does not? 

I have attached the layout of the new CAN converter. There are 3 Molex PicoBlade connectors:
- the 4 pin on top is USB
- the 4 pin on the bottom is 5V. GND and the PA2 and PA3 pins (for PWM)
- the 6 pin on the bottom is UART1 and I2C2 (plus 5V and GND)

In the last reply you stated that you plan to start limited production shortly. I have a SMD production facility in-house which I mainly use for the Auvidea products. It is designed for prototypes and small to medium production runs. The fully automated equipment supports fine pitch components down to 0.4mm pitch, 0402 devices and fine pitch BGAs. I have attached 2 pictures of this equipment. If I can assist you with production just let me know.

Regards, 

Jurgen
38159 USB2CAN.png
38160 CAN2UART.png
pickplace.jpg
vapor_phase_soldering.jpg

Ben Dyer

unread,
Sep 3, 2015, 9:54:13 AM9/3/15
to Auvidea, UAVCAN, dudley...@gmail.com
Hi Jurgen,

> Should I use 8 MHz or 24 MHz?

I use 8 MHz, purely because it appears somewhat more commonly used in STM32 designs than 24 MHz.

> Why does only the STM32F1 support the UAVCAN bootloader? And the STM32F042 does not?

The UAVCAN bootloader has not been ported to Cortex-M0 devices like the STM32F0 series, as the Cortex-M0 does not support remapping the interrupt vector to another location in flash. It's certainly possible to write a UAVCAN-compatible bootloader for the STM32F0, but nobody has done so yet.

Of course it's not mandatory to use the UAVCAN bootloader in a UAVCAN device, it's just a convenience as it saves you the trouble of implementing your own firmware upgrade procedure, and it enables users to update all devices in their system at once via the Pixhawk. For devices intended to be accessible via USB, DFU is probably an entirely workable solution.

> In the last reply you stated that you plan to start limited production shortly. I have a SMD production facility in-house which I mainly use for the Auvidea products. … If I can assist you with production just let me know.

Thanks, will do. I didn't get a chance to clean up the firmware last weekend but hope to do so this weekend. Will send an update to the list once it's done.

Regards,
Ben
> --
> You received this message because you are subscribed to the Google Groups "UAVCAN" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to uavcan+un...@googlegroups.com.
> To post to this group, send email to uav...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/uavcan/193e25c6-c653-4bb5-bed1-b6d68987f810%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> <38159 USB2CAN.png><38160 CAN2UART.png><pickplace.jpg><vapor_phase_soldering.jpg>

Auvidea

unread,
Sep 26, 2015, 6:56:40 AM9/26/15
to UAVCAN, j...@auvidea.com, dudley...@gmail.com
I have now received the PCBs. Next week I plan to build up the first prototypes.

From left to right:
38159: USB to CAN converter
38162: CAN to ESP8266 converter - it is designed for the ESP-07 Wifi to UART module
38161: CAN to sensor with MPU8250 and MS5611 sensors
38160: CAN to UART, I2C and PWM (e.g. to connect to I2C based ESCs)

Regards,

Jurgen
38159_panel.jpg

Auvidea

unread,
Oct 29, 2015, 5:59:47 PM10/29/15
to UAVCAN, j...@auvidea.com, dudley...@gmail.com
Hi Ben,

now the first prototypes ave been build up and successfully flashed. dfu-utils version 0.8 was required. Do you have a recommendation how to test them? Can I connect it to a Pixhawk for test. 

Regards,

Jurgen
38159_USB2CAN_800x337.jpg

Ben Dyer

unread,
Oct 29, 2015, 8:53:48 PM10/29/15
to Auvidea, UAVCAN, dudley...@gmail.com
Hi Jurgen,

Nice!

Yes, you can connect it to a Pixhawk to test—as a very basic starting point, ensure UAVCAN is enabled on the Pixhawk by running "uavcan start" at the nsh prompt, then follow these instructions:
http://uavcan.org/Implementations/Pyuavcan/Tutorials/1._Basic_setup/

You should see messages like the following appearing roughly every second:

DEBUG:root:Node._recv_frame(): received Transfer(id=1, source_node_id=1, dest_node_id=None, transfer_priority=16, payload=uavcan.protocol.NodeStatus(uptime_sec=1, health=0, mode=0, sub_mode=0, vendor_specific_status_code=0))

Regards,
Ben
> --
> You received this message because you are subscribed to the Google Groups "UAVCAN" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to uavcan+un...@googlegroups.com.
> To post to this group, send email to uav...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/uavcan/01122244-0b0f-4ba6-bbf0-a2f9365a00f9%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> <38159_USB2CAN_800x337.jpg>

Samuel Dudley

unread,
Oct 30, 2015, 1:57:12 AM10/30/15
to UAVCAN
Hi Jurgen,
Any chance you will have a sample for sale?

Thanks,
Sam

Reply all
Reply to author
Forward
0 new messages