Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The single servo module has the same CAN circuit and the same STM chip installed as the ones on the 6s Servo Module. So there will be a large overlap on the firmware of the two. 6s Servo Module has external additional facilities for voltage sensing and more Neopixel LEDs.

...

CAN Transmit Logic on Nucleo L5

Inc drawio
tbstyle
zoom1
simple0
zoomcustContentId12823028745
pageId2822504451
custContentIdlbox28230287451
diagramDisplayNameCAN_Servo_Transmit.drawio
lboxcontentVer1
hiResPreview0contentVer1
revision1
baseUrlhttps://uwarg-docs.atlassian.net/wiki
diagramNameCAN_Servo_Transmit.drawio
pCenter0
aspectKZEmeW6ik9zgDR8Vevgk 1
width747
linksauto
tbstyletop
isUpload1
topheight432

X_Hz Frequency Task: This is the task that runs at a certain frequency in our program. This type of task can send the node or servo status. The message you want to send will be added to a TX queue instead of transmitted right away. Due to the nature of the CAN protocol, one node is only allowed to transmit a message when the bus is idle.

...

CAN Receive Logic on Nucleo L5

Inc drawio
tbstyle
zoom1
simple0
zoomcustContentId12822406150
pageId2822504451
custContentIdlbox28224061501
diagramDisplayNameCAN_Servo_Receive.drawio
lboxcontentVer1
hiResPreview0contentVer1
revision1
baseUrlhttps://uwarg-docs.atlassian.net/wiki
diagramName1730957683144-CAN_Servo_Receive.drawio
pCenter0
aspectwxSuO_NSNZJ_IJMocyB- 1
width317
linksauto
tbstyletop
isUpload1
topheight712

CAN Filter: This is the identifier filter for the message on the CAN bus. It examines the identifier of every CAN message it receives and rejects the message that violates the configuration. The filter can be configured by changing the fields in FDCAN_FiltertypeDef.

...

Should Accept & On Reception: These are the functions passed to a Canard instance when it is created. should_accept is another filter for the message on their DroneCAN data type. on_reception takes the custom action to handle the received DroneCAN message.

CAN Circuit

Inc drawio
zoom1
simple0
zoomcustContentId12822569993
pageId2822504451
custContentIdlbox28225699931
diagramDisplayNameCAN_Servo_Circuit.drawio
lboxcontentVer1
hiResPreview0
contentVer1
revision1
baseUrlhttps://uwarg-docs.atlassian.net/wiki
diagramNameCAN_Servo_Circuit.drawio
pCenter0
aspectOflj_X5h2sT3B_4ZjYKE 1
width762
linksauto
tbstyletop
isUpload1tbstyletop
height521

This is how you want to set up the circuit to test your CAN node firmware with a Nucleo board. Using a PCB can be easier because they have the CAN transceiver circuit on board.

Ardupilot Configuration

Ardupilot is the firmware running on the Pixhawk. Ardupilot can be configured using Mission Planner software. Ardupilot allows very specific configurations to the CAN port and flight controller software behaviour. You can follow the steps below to configure the CAN port.

  1. Connect Pixhawk to mission planner: https://ardupilot.org/planner/docs/common-connect-mission-planner-autopilot.html

  2. Go to the Config tab, open Full Parameter List, and search for the CAN-related Parameter you are interested in.

    1. CAN enable, bitrate setting - https://ardupilot.org/copter/docs/common-canbus-setup-advanced.html

    2. Enable Servo control over CAN - https://ardupilot.org/plane/docs/parameters.html#can-d1-uc-srv-bm

  3. Control Servo over Mission Planner - https://ardupilot.org/copter/docs/common-servo.html

Sources:

https://dronecan.github.io/

https://github.com/dronecan/libcanard/blob/master/examples/ESCNode/esc_node.c

CAN - Controller Area Network

Ideas for Firmware Improvement

  1. Shorten the ISR time. The time spent in each ISR when processing RX messages is very long. This can hurt our firmware performance as we all know the best practice when designing firmware is to keep the interrupt callback short and sweet. In the future, we might be able to add a rx message queue. The interrupt is only responsible for adding the received message to a queue. And then we process the message in the main loop.

  2. Adding CAN bitrate sensing feature on the firmware. Currently, the bitrate if fixed once the firmware is flashed. If the bitrate on the pixhawk is changed, then our can node won’t respond to flight controller. It could be a cool feature if our board senses the bitrate on the line so we won’t need to update the firmware every time when the bitrate is changed on the pixhawk.