Servers by jDrones

Libcanard based UAVCAN node demo for STM32 on Arduino

uavcan

(George Small) #1


I’m excited to get this “Hello World” example working. I’ve documented the work here to remember what I did and so that others can follow if so desired. I’m a big fan of Pavel Kirienko’s open UAVCAN work (https://uavcan.org/) and OlliW’s awesome work to make it more accessible to hobbyists (http://www.olliw.eu/2017/uavcan-for-hobbyists/).

What was missing for me was a means to bring the UAVCAN based software implementations down to my amateur software developer level. My goal was to develop my own UAVCAN compliant custom sensor and actuator nodes based on whatever I can dream up. I found the learning curve for the combination of STM32 and UAVCAN to be pretty steep. I finally discovered this post (https://forum.uavcan.org/t/libcanard-on-freertos-successfull/238) with this GitHub project (https://github.com/skyyuzhang/UAVCAN_NODE_FreeRTOS) and things started moving forward. With help from several very helpful folks I was eventually able to get a first “Hello World” demo working. I’ve documented a bunch of that journey over here (https://www.rcgroups.com/forums/showthread.php?3090897-DIY-UAVCAN-STM32F1-step-by-step).

I eventually was able to get my demo working in Arduino IDE (v1.8.5 on Win10 in my case) running on eBay sourced low cost STM32F1 hardware, and thought I would share it here. UAVCAN for STM32 Arduino is a simple UAVCAN libcanard (https://github.com/UAVCAN/libcanard) example for the Arduino IDE (https://www.arduino.cc/) running on STM32 development boards.

The example is compiled for and running on a low cost bluepill mini development board (https://wiki.stm32duino.com/index.php?title=Blue_Pill) on Arduino IDE.

This example requires the use of Arduino STM32 core package (https://github.com/stm32duino/Arduino_Core_STM32).

It has been tested on STM32F103C8 development board, using Arduino IDE v1.8.5 with Arduino Core STM32 v1.4.0. CAN bus commands were generated using UAVCAN GUI (https://uavcan.org/GUI_Tool/Overview/) v0.9.0 running on 64 bit Win 10.

I’m using OlliW’s great low cost SLCAN adapter (http://www.olliw.eu/2017/uavcan-for-hobbyists/#chapterslcanadapter) as a bridge to the PC based GUI.

Mike Kelly’s blog post here (https://discuss.ardupilot.org/t/uavcan-canbus-for-the-rest-of-us/22743) was super helpful for understanding how to configure test setups and use the GUI.

My GitHub repo for this project can be found here: https://github.com/geosmall/UAVCAN-for-STM32-Arduino

Test setup pictorial schematic and pics attached below.

test_rig


(Khancyr) #2

Very nice! Thanks for sharing this!


(George Small) #3

Also, important for those of us that source low cost development electronics from global supply chains:

Both my FTDI USB to serial adapter and my SN65HVD230 based can transceiver development boards were sourced from eBay. Everything was attractively low cost, but I should warn people that I had counterfeit issues on both of these boards.

The low cost FTDI FT232RL based adapters can often have counterfeit FTDI chips on them. They work fine at 115200 baud most people use but do not work at the higher 1M baud we really need for UAVCAN work. The SN65HVD230 based adapters I bought just plain out did not function.

In each case replacing the suspect chip with Mouser sourced known good parts fixed the issue.


(rmackay9) #4

Great stuff. I hope you don’t mind but I moved one of the images to the top of the blog. This makes it appear on ardupilot.org which is a bit prettier. Thanks!


(George Small) #5

Thanks rmackay9. I’m still new to the forum learning my way around!


(jpkh) #6

@MGeo it’s always great to see more people getting interested on UAVCAN stuff. If you ever need those ready made UC4H boards for your tests. jDrones have them in stock and more is coming.

You can find them in here


(ppoirier) #7

Yep, confirmed I had half of my modules defect, as described here:

Great Job, I will test your code and report


(ppoirier) #8

Yep, it works , I had to build from my UBUNTU based Arduino as the STM32 Lib was troublesome on my WIN 10. Put my name on the node :wink: and speeded up the display (main.c interval to 300 msec).

Thanks, for opening a new playfield


(George Small) #9

I find PRs in work on various multiple CAN interfaces (ToshibaCAN https://github.com/ArduPilot/ardupilot/pull/10249, KDECAN https://github.com/ArduPilot/ardupilot/pull/9619). Some with license restrictions that imply closed ownership of the underlying protocol interfaces (https://cdn.shopify.com/s/files/1/0496/8205/files/KDECAN_Bus_Protocol_1.0.1.pdf?13717775047538201376), etc. Most seem aimed as ESCs.

  1. Intellectual Property. The KDECAN Protocol Software, documentation, images, content, interfaces, fonts and any other data accompanying this License whether pre-installed on the KDE UVC Series ESC hardware, on disk, in read only memory, on any other media or in any other form (“KDECAN Protocol Software”) are licensed, not sold, to you by KDE Direct for use only under the terms of this License. KDE Direct retains ownership of the KDECAN Protocol Software itself and reserve all rights not expressly granted to you.

Is there a community consensus on the use of closed restricted rights protocols within the Ardupilot project?
Closed protocols dedicated to one particular type of component peripheral such as an ESC would seem at odds with the fundamental benefits that a bidirectional general purpose bus transport might bring to the project


(ppoirier) #10

I think this license has been discussed there KDECAN - a new CAN protocol, first in ArduPilot

May I suggest that we keep this thread on DIY work on Arduino


(George Small) #11

Ok will do, best taken somewhere else (hopefully). Please do realize that incentives for all to put collective effort into DIY solutions will be heavily influenced by community direction.


(George Small) #12

Added an example running on a NUCLEO-F303RE based board here https://github.com/geosmall/UAVCAN-for-STM32-Arduino/tree/master/STM32F303CC/libcanard_example_F3

Blue board on the left is the STM32F103 based SLCAN serial to CAN adapter, with white board to the right being the NUCLEO-F303RE board. Functionally the same as F103 demo, but now we have an FPU and some better peripherals than F103.


(davidbitton) #13

i just ordered the uavcan starter pack myself.


(davidbitton) #14

@MGeo
what’s available in the general codebase — not @olliw42’s Beta code — that can give me mavlink-esque data?


(George Small) #15

Hi David,

I’m still climbing the Ardupilot learning curve, got my hands full with UAVCAN so not really sure at this point.

George


(davidbitton) #16

I’ve been working through this over here:

@tridge has some goodies awaiting a PR.