Thread Tools
Jun 10, 2018, 08:03 AM
Registered User
MGeo's Avatar
Thread OP
Mini-HowTo

DIY UAVCAN: STM32 (F1, F3) step-by-step


I'm interested in CAN bus communication between flight controllers, actuators and ESCs. UAVCAN (http://uavcan.org/) is an open standard that has a loose association with Ardupilot and PX4 open source projects. OlliW had done considerable work to making a working libcanard (https://github.com/UAVCAN/libcanard) based implementation available (http://www.olliw.eu/2017/uavcan-for-...terescactuator), along with valuable documentation on his site on how to duplicate nodes, a low cost DIY SLCAN based bus interface to PC. He has a thread running on use of his work here https://www.rcgroups.com/forums/show...-for-Hobbyists.

I'm attempting to follow with my own test setup to gain some experience with UAVCAN. As I've done a few times before here, I'll document my steps here so I can remember and reconstruct my steps. I hope others find the info useful and we can all make progress on moving from analog to more digital, low cost and open interfaces for our equipment.

See post #16 below for working STM32F103C8 FreeRTOS based demo details https://www.rcgroups.com/forums/show...5&postcount=16

See post #22 below for working STM32F103C8 Arduino based demo details https://www.rcgroups.com/forums/show...5&postcount=22



Last edited by MGeo; Feb 17, 2019 at 02:50 PM.
Sign up now
to remove ads between posts
Jun 10, 2018, 08:06 AM
Registered User
MGeo's Avatar
Thread OP
First thing we need is a decent USB to TTL adapater for our PC. We want to talk over a USB serial connection at 1Mbps or so to keep up with high speed CAN traffic. A cheap FTDI or Silabs based adapter sounds good, but we have to watch out for cheap counterfeit parts on ebay that might work fine at 115200 baud but can't keep up at 1Mbps.

Based on warnings I spent some time reworking my FT232RL USB to TTL adapters to use real a FTDI chip. Pretty much per this guy's post https://syonyk.blogspot.com/2017/03/...ters-ssop.html.

I had a few FT232RLs I had received from Mouser, and some ChipQuik (https://www.amazon.com/ChipQuik-SMD1.../dp/B0019UZP7I) for rework. I'm a big fan of ChipQuik. I have a hot air rework station but to swap a single chip like this it is fast and easy using the ChipQuik and some desolder braid to clean the board up after.

I removed the clone chip and soldered in my Mouser sourced FT232RL. I looked at the output at 1Mbps, looks ok on my Saleae logic analyzer. On to the next step.
Last edited by MGeo; Jun 10, 2018 at 08:11 AM.
Jun 10, 2018, 08:07 AM
Registered User
MGeo's Avatar
Thread OP
Next up is to spend some time burning hex files onto my F103 based DIY SLCAN adapter and my intended ESC/actuator node.

The SLCAN is using an Open103C board (https://www.waveshare.com/wiki/Open103C), the ESC/actuator node is using an ebay LC Technology "Ugly Board" (http://wiki.stm32duino.com/index.php?title=Ugly_board). Schematics for both these boards are available so that helps.

I'm using the built in STM32F1 serial bootloader to load hex files, with binaries retrieved from Github at https://github.com/olliw42/uavcan4hobbyists. The SLCAN adapter gets its binary burned directly via the serial bootloader. The ESC/actuator node gets a CAN based bootloader burned direct. It is all documented pretty well on OlliW's site at http://www.olliw.eu/2017/uavcan-for-hobbyists/

The actual node application software will get loaded later via the UAVCAN GUI interface. A bit of extra pain, but this will be very handy later for development. Once we have a number of nodes connected up we do not want to have to keep unplugging nodes and reburning every time we have a change to node firmware.

I'm using http://www.st.com/en/development-too...her-stm32.html as my front end for the serial load. I've burned uc4h-bootloader-v002.hex to the intended ESC/actuator node, and uc4h-slcan-v007-pcb-v1x-f103t8c8cb.hex ) to the SLCAN adapter. Binaries located here https://github.com/olliw42/uavcan4ho...are%20binaries

I've attached a wiring guide I put together and a pic of my simple hello world setup. You can make out my DIY SLCAN interface wired up to a single ESC/actuator node, with a pair of small CAN transceiver boards connecting the two. You can also see the red FTDI adapter and the attached USB cable heading off to my Win 10 laptop.

I also have a Ubuntu 16.04 linux laptop I will try eventually for interface as well. The UAVCAN devs are Linux first folks, I've read that some of the releases are more up-to-date on Linux with Win releases lagging so I'll try both.
Last edited by MGeo; Jun 16, 2018 at 06:07 AM.
Jun 10, 2018, 08:12 AM
Registered User
MGeo's Avatar
Thread OP
I've plugged it into my Win 10 laptop running UAVCAN GUI. Enter 1000000 for the adapter baud rate in the config dialog and click 'OK'.

After you hit OK the main window of UAVAN GUI will appear.

Some documentation here:
http://uavcan.org/GUI_Tool/Overview/
http://uavcan.org/GUI_Tool/User_guide/

And a very helpful blog post here:
https://www.rcgroups.com/forums/show...the-rest-of-us
Last edited by MGeo; Jun 16, 2018 at 06:10 AM.
Jun 11, 2018, 04:09 AM
Registered User
MGeo's Avatar
Thread OP
Click on the [check] button for "Local node ID", leaving it set at 127.
Last edited by MGeo; Jun 16, 2018 at 06:13 AM.
Jun 11, 2018, 04:21 AM
Registered User
MGeo's Avatar
Thread OP
Now click the Dynamic Node ID Server [rocket] button. This should give us a new online UAVCAN node.
Last edited by MGeo; Jun 21, 2018 at 12:18 PM.
Jun 21, 2018, 12:22 PM
Registered User
MGeo's Avatar
Thread OP
As we have only a bootloader in our node, we see "MAINTENANCE" for mode and "ERROR" for status on our node candidate .

Double-click on the node line item to get to the Node Properties dialog box. Here you can see an "Update Firmware" button. Click it and select your node firmware hex file. In my case this is "uc4h-escactuator-v014-node-v1x-f103t8c8cb-wobl.hex".
Last edited by MGeo; Jun 21, 2018 at 12:29 PM.
Jun 21, 2018, 12:27 PM
Registered User
MGeo's Avatar
Thread OP
If all goes well your node now shows "OPERATIONAL" for mode and "OK" for status.
Jun 22, 2018, 02:55 AM
Registered User
MGeo's Avatar
Thread OP
A check of the bus monitor (Ctrl-Shift-B) shows traffic going back and forth...the setup is now up and running!

Open the ESC management panel and set the output sliders to non-zero values. You should see increased bus traffic in the monitor due to extra ESC commands issued.

I hooked up my logic analyzer to capture the first four outputs based on the UC4H ESC-Actuator DIY build schematic. So PB6, PB7, PB0, PB1. With default settings you should be seeing dshot output on A1 (PB6) and the other 3 show no activity.
Jun 29, 2018, 12:14 PM
UAV Flight Operations Manager
This is an excellent write up and I'm very interested to see how you get along with this. I'm particularly interested in UAVCAN myself, due to the CAN architecture inherent stability.

Larger, more complex, and more mission critical UAVs are being developed regularly and in my mind, the perfect world would have all internal systems communicating over CAN (preferably UAVCAN, but even just the modern automotive CANBUS is an amazing transfer protocol...)

Anyway, keep up the good work and thanks for sharing!
Jul 05, 2018, 03:44 PM
Registered User
MGeo's Avatar
Thread OP

Use CANable open source CAN bus adapter???


I've been looking around for an affordable open USB to CAN bridge, I came across this project http://canable.io/

It is a nice little open source design HW/SW, derived from this project: http://linklayer.github.io/cantact/

$24 on tindie.com, thought I would give it a try. https://www.tindie.com/products/prot...n-bus-adapter/

I'll see if I can get it up and running with UAVCAN GUI. I run UBUNTU 18.04 LTS dual boot with Win 10 on my laptop. I'll start on Linux as the net tools are more likely to work I think.

I found this post where someone gave it a go previous, but it is not clear if it worked out for them:
https://groups.google.com/forum/#!to...an/m9LRyHXKmdI
Last edited by MGeo; Jul 06, 2018 at 09:20 AM.
Jul 05, 2018, 06:06 PM
Registered User
MGeo's Avatar
Thread OP
When I pull up the UAVCAN GUI the CANable adapter shows up as an option. I select this, change the adapter baud to 1000000 bps, and click OK. I get an error message that the GUI can not initialize the UAVCAN node.
Last edited by MGeo; Jul 06, 2018 at 09:07 AM.
Jul 06, 2018, 09:04 AM
Registered User
MGeo's Avatar
Thread OP
OK maybe I need to read the documentation. The getting started page (http://canable.io/getting-started.html) indicates you need to do the following in Linux:
Code:
Just run slcand with the proper arguments for your bus speed, and a new CAN device should show up on your system.
Don't forget to bring the interface up with ifconfig after running slcand!
Now you can use any of the standard Linux CAN utilities to interact with the bus.
To get this to work, I needed to install can-utils and net-tools packages:
Code:
[email protected]:~$ sudo apt install can-utils
[email protected]:~$ sudo apt install net-tools
Then I need to find the name of my CANable adapter. In Linux you can plug it in and look in /dev/serial/by-id for the adapter name.

With the adapter name known, we can run slcand (a special daemon that will link this serial interface with a virtual CAN device we will call can0):
Code:
[email protected]:~$ sudo slcand -o -s8 /dev/serial/by-id/usb-CANtact_CANtact_dev_00000000001A-if00 can0
Next run ifconfig (ifconfig stands for "interface configuration". It is used to view and change the configuration of the network interfaces on your system.) to bring up can0 we defined with slcand
Code:
[email protected]:~$ sudo ifconfig can0 up
Last edited by MGeo; Jul 06, 2018 at 09:12 AM.
Jul 06, 2018, 09:14 AM
Registered User
MGeo's Avatar
Thread OP
Now when we bring up UAVCAN GUI we get a new option of CAN0. Adapter buad rate is already taken care of, just click OK.
Jul 06, 2018, 09:17 AM
Registered User
MGeo's Avatar
Thread OP
Success!

CANable adapter is now talking to my DIY UC4H ESC/Actuator node.
Last edited by MGeo; Jul 06, 2018 at 09:52 AM.


Quick Reply
Message:

Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Mini-HowTo Step by step guide for Flashing Turnigy 400W v2 with Open-Source Firmware RadMulRot Batteries and Chargers 11 Feb 21, 2018 02:42 AM
Build Log HobbyKing™ EZ Master step by step guide - picture and manuals EekTheFlyingCat Electric Plane Talk 1 Feb 19, 2016 03:41 PM
Question Step-by-step PID tuning guide? (Luxfloat / Betaflight) xoxota Beginner Multirotor Drones 10 Jan 24, 2016 02:15 PM
Build Log My DIY FPV quadcopter step by step build up salamala Scratchbuilt Multirotor Drones 2 May 24, 2014 03:39 PM