CAN - Controller Area Network
CAN Protocol and Bus
Intro: CAN Bus: Serial Communication - How It Works?
Another intro: Learn How The CAN Bus Works (Controller Area Network) | Embedded Systems Explained
Wikipedia: CAN bus
CAN 2.0 (Classical) vs CAN FD: Can 2.0 Vs. Can Fd: The Evolution of Controller Area Network
More details on CAN FD: CAN FD
Components
These are just examples
CAN transceiver (CANH/L to CAN TX/RX): SN65HVD230 CAN Board
CAN controller (CANH/L to SPI TX/RX): Arduino MCP2515 CAN Bus Interface Tutorial
STM32 CAN Bus
DroneCAN
ArduPilot DroneCAN Setup
CAN Bus: CAN Bus Setup — Copter documentation
DroneCAN: DroneCAN Setup — Copter documentation
ESCs: DroneCAN ESCs — Copter documentation
Servos: DroneCAN Servos — Plane documentation
Typos on ArduPilot Docs
The circled parameters should be CAN_D1_UC_SRV_BM
How does CAN Transceiver Work? TxD/RxD
CAN Transceivers enable communication between the microcontroller and the CAN bus. They act as an interface, translating the digital data from the microcontroller into differential signals that can be sent over the CAN bus and vice versa.
TxD (Transmit Data):
The TxD pin is used by the microcontroller to send data to the CAN transceiver
The microcontroller outputs a serial data stream to the TxD pin of the transceiver
The transceiver then converts this data into differential signals (CAN_H and CAN_L) that are sent onto the CAN bus.
RxD (Receive Data):
The RxD pin is used by the CAN transceiver to send CAN bus data to the microcontroller
The transceiver converts the differential signals from the CAN bus into a single-ended digital signal
The data is then output from the RxD pin to the microcontroller
How do we get it?
How to debug CAN Data
1. Use a CAN Analyzer
A CAN analyzer or CAN bus sniffer can be used to monitor/analyze CAN traffic.
Connect the CAN analyzer to the CAN bus
Use the analyzer software to monitor the CAN messages, allowing you to see all the data being transmitted on the bus
Example:
https://www.microchip.com/en-us/development-tool/apgdt002
Microchip CAN BUS Analyzer User’s Guide
2. Software Tools
PCAN-View (Peak System) - Free
Use Case: Monitoring and analyzing CAN traffic
How to Use:
Connect PCAN-USB adapter to CAN bus
Launch PCAN-View, set baud rate, and start monitoring
Apply filters, send messages, and log data for offline analysis
Kvaser CANlib (Kvaser) - Free SDK, but needs Kvaser hardware
Use Case: Developing custom CAN applications, monitoring, and analyzing traffic
How to Use:
Connect Kvaser hardware to CAN bus
Install CANlib SDK, use CANlib Visual for monitoring
Configure channels, send messages, and use scripting for automation
CANalyzer (Vector Informatik) - Paid
Use Case: Detailed analysis, simulation, and bus load measurement
How to Use:
Connect Vector CAN hardware to CAN bus
Launch CANalyzer, configure channels, and start monitoring
Use simulation features, log and replay traffic, and analyze bus load
https://www.vector.com/int/en/products/products-a-z/software/canalyzer/#
SocketCAN (Linux) - Free
Use Case: Open-source CAN interface for Linux with standard tools
How to Use:
Install
can-utils
and set up CAN interfaceUse
candump
to monitor,cansend
to send messages, andcanplayer
to replay logged traffic
How to decode CAN Data
Intro to using DBC files for manually decoding raw CAN data:
https://www.youtube.com/watch?v=jvYkFr96Nss
How to create DBC files:
General DBC file overview & creation: https://www.youtube.com/watch?v=Xnno4wTsi8Q
Good for sensors: https://www.youtube.com/watch?v=mAL1Xo2G9-4
Decent: https://www.youtube.com/watch?v=4USUH5chqnI
How is Pixhawk encoding the PWM Data
CAN with Pixhawk: https://docs.px4.io/main/en/can/
PX4 DroneCAN Firmware: https://docs.px4.io/main/en/dronecan/px4_cannode_fw.html
DroneCAN info & Configuration: https://docs.px4.io/main/en/dronecan/
DroneCAN Frame Format
DroneCAN uses only CAN 2.0B frame format (29 bits)
Contents of CAN ID field depend on message type. There are three types of messages
Actual data transferred is in the payload which consists of 2 parts. The transfer payload (holds the data we will convert to DShot/PWM) and the Tail Byte (contains auxiliary transport layer fields).
If the data being sent fits in a single CAN frame, then a single frame is used for payload transmission which is more efficient and thus more ideal. If the payload doesn’t fit in one data frame, a multi-frame transfer is required which introduces:
Transfer CRC
Error checking to ensure receiving payload matches original payload transmitted. Cannot verify data integrity/accuracy without the Transfer CRC
Computed from transfer payload, perpended with data type signature, little-endian order
Toggle Bit
Detect and avoid CAN frame duplicate errors
First frame toggle bit is 0, second frame toggle bit is 1, and alternates so on for each frame