DEMO: UAVCAN node servo pwm control

How to send PWM signal using CAN bus

The idea is to control a servo motor or ESC via the CAN board using the UAVCAN protocol. This is useful to decentralize the processing from the FMU to multiple CAN boards in case of having multiple PWM units.

Next, we will show how to connect a CAN board to the Ubuntu 22.04 PC and send PWM commands.

Hardware setup

  • (1) UCANS32K1SIC board

  • (3) USB-TTL-3V3: the GND black wire should be mounted at the top when the serial debug connector is on the left.

  • (2) Adapter board

  • (4) CAN to USB adapter board

  • (5) debug cable: to be able to communicate with the board via nutshell cmdline.

  • (6) CAN cable: mount the CAN cable at the top right connector.

  • (7) A resistor board: mount this board below the CAN cable connector

  • (8) Power supply: make sure to not exceed 5 Volts

  • (9) Servo motor for testing

Software setup

Install drone_can_gui tool:

sudo apt-get install -y python3-pip python3-setuptools python3-wheel 
sudo apt-get install -y python3-numpy python3-pyqt5 python3-pyqt5.qtsvg git-core 
sudo pip3 install git+https://github.com/DroneCAN/gui_tool@master 

Usage

  • Set up can interface

Open a terminal and type these two lines

sudo ip link set can0 type can bitrate 1000000 
sudo ip link set up can0
  • Verify can interface

Check whether can0 interface figures in network interfaces list:

ifconfig  

Double check by dumping CAN bus traffic

candump can0 
  • Verify pwm status

In a nutshell, check the status of PWM in your board

pwm_out status 
  • Start drone gui tool

dronecan_gui_tool 

Press ok

You should see your ucans32 device in the list of nodes:

  • Arm the vehicle

Arm the vehicle (using QGC or RC transmitter depending on your setup):

[1] GitHub pull request

[2] https://github.com/DroneCAN/gui_tool

Last updated