(Arduino_Core_STM32) Libcanard based UAVCAN node

What are you developing?
MGeo
Posts: 38
Joined: Thu Dec 19, 2019 10:29 am
Answers: 2

(Arduino_Core_STM32) Libcanard based UAVCAN node

Post by MGeo »

Here is a "Hello World" example working for libcanard based UAVCAN on Arduino_Core_STM32. 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/) for my needs, mostly UAVs and drones at present. Also, OlliW has done some 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 CAN learning curve to be pretty steep. With help from several very helpful folks I was eventually able to get my first "Hello World" demo working. I've documented a bunch of that journey over in another forum (https://www.rcgroups.com/forums/showthr ... ep-by-step).

I eventually was able to get my demo working in Arduino IDE 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.

The example has been tested on STM32F103C8 based bluepill 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've also tested compile on Ubuntu 16.04 LTS.

I'm using OlliW's low cost DIY SLCAN adapter (http://www.olliw.eu/2017/uavcan-for-hob ... canadapter) as a bridge to the PC based UAVCAN GUI. I also have some low end commercial CAN adapters I will test out over time.

Mike Kelly's blog post here (https://discuss.ardupilot.org/t/uavcan- ... f-us/22743) was super helpful for understanding how to configure test setups and use the somewhat cryptic UAVCAN GUI app.

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. Higher res pics are in the repo in the images folder.
Attachments
UAVCAN_NODE_libcanard_ino.jpg
UAVCAN_NODE_libcanard_ino.jpg (76.42 KiB) Viewed 11776 times
test_rig.jpg
test_rig.jpg (46.3 KiB) Viewed 11776 times
Last edited by MGeo on Fri Jan 31, 2020 9:52 am, edited 8 times in total.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Libcanard based UAVCAN node for STM32 on Arduino

Post by fpiSTM »

Thanks @MGeo for sharing.
MGeo
Posts: 38
Joined: Thu Dec 19, 2019 10:29 am
Answers: 2

Re: Libcanard based UAVCAN node for Arduino_Core_STM32

Post by MGeo »

I still have some test work to do on the F1 serial output and test of F3 variant before I will consider the example up to date, but F1 CAN traffic appears to be working as expected. I'll update here once I get a chance to complete testing.

For those looking to replicate, it is worth mentioning that my low cost eBay sourced FTDI and CAN adapters both had counterfeit issues where I ended up replacing the key chips with Mouser sourced alternatives. The FTDI chip was counterfeit and would not work reliably above 115,200 bps and the CAN adapter just plain would not work. This was pretty frustrating to debug, so buyer beware on lowest cost supply chains I guess.
MGeo
Posts: 38
Joined: Thu Dec 19, 2019 10:29 am
Answers: 2

Re: Libcanard based UAVCAN node for Arduino_Core_STM32

Post by MGeo »

F103 Bluepill end-to-end CAN testing now complete. ESC values input with UAVCAN GUI are sent over CAN bus to Bluepill node, which receives and retransmits those same ESC values out over Serial.

Below is a screen-cap. You can just make out the ESC input values in the "ESC Management Panel" input slider panel, repeated in the black serial output terminal in the top left. CAN bus message traffic monitor is in the lower left.
Attachments
2020-01-15 (2) (1).jpg
2020-01-15 (2) (1).jpg (85.89 KiB) Viewed 11736 times
MGeo
Posts: 38
Joined: Thu Dec 19, 2019 10:29 am
Answers: 2

Re: Libcanard based UAVCAN node (Arduino_Core_STM32)

Post by MGeo »

I've now completed testing of the F103C8 and F303CC UAVCAN based CAN examples in the repo, so now consider the repo to be up to date for v1.8 of core. I've used a Robotdyn F303CC black pill (https://robotdyn.com/stm32f303cct6-256- ... b3621.html) for the CAN node.
Attachments
Close-up of Robotdyn F303CC CAN node
Close-up of Robotdyn F303CC CAN node
rsz_img_1775.jpg (83.62 KiB) Viewed 11663 times
F303CC test setup
F303CC test setup
rsz_1img_1774.jpg (83.7 KiB) Viewed 11663 times
End-to-end F303CC test confirmation
End-to-end F303CC test confirmation
rsz_2020-01-19.jpg (76.29 KiB) Viewed 11663 times
MGeo
Posts: 38
Joined: Thu Dec 19, 2019 10:29 am
Answers: 2

Re: Libcanard based UAVCAN node (Arduino_Core_STM32)

Post by MGeo »

F303CC test pictorial schematic:
Attachments
rsz_uavcan_node_libcanard_f3_ino.jpg
rsz_uavcan_node_libcanard_f3_ino.jpg (83.54 KiB) Viewed 11660 times
Bingo600
Posts: 86
Joined: Sat Dec 21, 2019 3:56 pm

Re: Libcanard based UAVCAN node (Arduino_Core_STM32)

Post by Bingo600 »

Seems like a nice project , thank you for publishing.

The below url's are broken in your post:
https://www.rcgroups.com/forums/show...1-step-by-step
and
http://www.olliw.eu/2017/uavcan-for-...erslcanadapter
and
https://discuss.ardupilot.org/t/uavc...st-of-us/22743

I like your delay routine, using the cyclecounter :)
Where does : #include "stm32_def.h" come from ?? - the Arduino libs or some local stuff ??
I can't seem to find it

/Bingo
MGeo
Posts: 38
Joined: Thu Dec 19, 2019 10:29 am
Answers: 2

Re: Libcanard based UAVCAN node (Arduino_Core_STM32)

Post by MGeo »

Bingo600 wrote: Tue Jan 21, 2020 5:44 pm The below url's are broken in your post:
I like your delay routine, using the cyclecounter :)
Where does : #include "stm32_def.h" come from ?? - the Arduino libs or some local stuff ??
Thanks. I fixed the broken links above.

I borrowed the DWT based delay from the contributions of others via internet searches for microsecond delay :)

stm32_def.h is from Arduino_Core_STM32 here https://github.com/stm32duino/Arduino_C ... uino/stm32
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Libcanard based UAVCAN node (Arduino_Core_STM32)

Post by fpiSTM »

Thanks MGeo,

About DWT, note that the core is already based on it for delayMicroseconds() arduino API ;)

https://github.com/stm32duino/Arduino_C ... .h#L64-L70
MGeo
Posts: 38
Joined: Thu Dec 19, 2019 10:29 am
Answers: 2

Re: Libcanard based UAVCAN node (Arduino_Core_STM32)

Post by MGeo »

fpiSTM wrote: Wed Jan 22, 2020 10:39 am Thanks MGeo,

About DWT, note that the core is already based on it for delayMicroseconds() arduino API ;)
Ah thanks. Not sure how I missed that. I will migrate over to core delayMicroseconds() in place of my library implementation.
Post Reply

Return to “Projects”