User Tools

Site Tools


can_communication_with_controllers

CAN communication with controllers

CAN bus basics

The Controller Area Network bus is a broadcast real-time bus which is widely used in industrial or automotive applications. It has the following characteristics:

  • its physical layer used a differential signal pair, which make the bus more robust against electromagnetic noises ;
  • the protocol includes by default a CRC on each message to ensure integrity.
  • the bus is a broadcast medium to allow efficient communication between multiple nodes (e.g. implementing producer/consumer scheme);
  • it works upto 1Mbps bitrate,
  • each message on the bus has a strict priority;
  • each message is at most 8-bytes long to ensure real-time reactiveness on the bus
The QuimBox uses the CAN protocol internally to allow communication between the embedded Linux and the controller boards. It also offers an external CAN connection to the bus to extend the system with CAN-compliant modules.

CANopen principles

On top of the physical CAN bus, devices and applications have to agree on a high-level protocol to exchange data. A popular choice is CANopen which defines a standard way to access CAN nodes on a bus. It typically defines how to format the messages and what interfaces to expose on the bus.

An interesting concept is the Object Dictionary (OD). The OD is a standardized way to describe a device through a list of entries. Each entry has a specific semantic and can be read or written by another node. Once you know the layout of a particular node OD, you know how to communicate with it.

The QuimBox controllers implement a subset of the CANopen protocol. Namely the message layout is completely compatible and the OD concept is reused.

SDO CAN frame structure

An SDO can frame is structured as follow:

Can id Command byte OD Idx OD subidx data
16 bits 8 bits 16 bits 8 bits 32 bits

The can id is composed of the RX/TX identifier and the board identifier. (can id = RX/TX-id + Node-id)

TX-id = 600
RX-id = 580

Note: RX/TX from host point of view. On board the convention is opposite.

The command byte is either 0x23 for 32bits writing request, 0x2f for 8bits writing request or 0x40 for reading request (always 32bits response).

One can test the connection with a linux host using can-utils tools with cansend and candump commands.

ex. A request to enter a QuimDC in operational mode. (32bits write request) (Node-id = 7)

Can id Command byte OD idx OD subidx data
607 23 3333 00 01 00 00 00
cansend 607#23.3333.00.01.00.00.00

QuimDC OD

See The QuimDC Object Dictionary for more information.

Control Loop Modes

Name Value
SPEED_CLOSED_LOOP 0
POSITION_SPEED_DOUBLE_CLOSED_LOOP 1
CURRENT_CLOSED_LOOP 2
ESTIMATE_CURRENT_CLOSED_LOOP 3
SPEED_CURRENT_DOUBLE_CLOSED_LOOP 4

QuimIO OD

Index Sub-index Attribute Type Name Values
0x1000 0 RO UINT32 Device type
0x1018 0 RO UINT32 Vendor ID
0x6000 0 RO UINT32 Digital input (all) 0x00-0xFF
1 RO UINT32 Digital input value 1 (8-bit) 0-1
2 RO UINT32 Digital input value 2 (8-bit) 0-1
3 RO UINT32 Digital input value 3 (8-bit) 0-1
4 RO UINT32 Digital input value 4 (8-bit) 0-1
5 RO UINT32 Digital input value 5 (8-bit) 0-1
6 RO UINT32 Digital input value 6 (8-bit) 0-1
7 RO UINT32 Digital input value 7 (8-bit) 0-1
8 RO UINT32 Digital input value 8 (8-bit) 0-1
0x6200 0 RW UINT32 Digital output (all) (8-bit) 0x00-0xff
1 RW UINT32 Digital output value 1 (8-bit) 0-1
2 RW UINT32 Digital output value 2 (8-bit) 0-1
3 RW UINT32 Digital output value 3 (8-bit) 0-1
4 RW UINT32 Digital output value 4 (8-bit) 0-1
5 RW UINT32 Digital output value 5 (8-bit) 0-1
6 RW UINT32 Digital output value 6 (8-bit) 0-1
7 RW UINT32 Digital output value 7 (8-bit) 0-1
8 RW UINT32 Digital output value 8 (8-bit) 0-1
0x6201 0 WO UINT32 Digital output pin configuration (all) 1
1 WO UINT32 Digital output configuration pin 1 1
2 WO UINT32 Digital output configuration pin 2 1
3 WO UINT32 Digital output configuration pin 3 1
4 WO UINT32 Digital output configuration pin 4 1
5 WO UINT32 Digital output configuration pin 5 1
6 WO UINT32 Digital output configuration pin 6 1
7 WO UINT32 Digital output configuration pin 7 1
8 WO UINT32 Digital output configuration pin 8 1
0x6300 0 RO UINT32 Analog input table length (=8)
1 RO UINT32 Analog input value 1
2 RO UINT32 Analog input value 2
3 RO UINT32 Analog input value 3
4 RO UINT32 Analog input value 4
5 RO UINT32 Analog input value 5
6 RO UINT32 Analog input value 6
7 RO UINT32 Analog input value 7
8 RO UINT32 Analog input value 8
0x6310 0 RO UINT32 Analog input voltage table length (=8)
1 RO UINT32 Analog input voltage value 1
2 RO UINT32 Analog input voltage value 2
3 RO UINT32 Analog input voltage value 3
4 RO UINT32 Analog input voltage value 4
5 RO UINT32 Analog input voltage value 5
6 RO UINT32 Analog input voltage value 6
7 RO UINT32 Analog input voltage value 7
8 RO UINT32 Analog input voltage value 8
0x6320 0 RO UINT32 Analog input current table length (=8)
1 RO UINT32 Analog input current value 1
2 RO UINT32 Analog input current value 2
3 RO UINT32 Analog input current value 3
4 RO UINT32 Analog input current value 4
5 RO UINT32 Analog input current value 5
6 RO UINT32 Analog input current value 6
7 RO UINT32 Analog input current value 7
8 RO UINT32 Analog input current value 8
0x6400 0 WO UINT32 PWM output (all) param 1 (8-bit) param 2 (24-bit) 0-255(duty), 6-466k (freq)
1 WO UINT32 PWM output param 1 (8-bit) param 2 (24-bit) 0-255(duty), 6-466k (freq.1)
2 WO UINT32 PWM output param 1 (8-bit) param 2 (24-bit) 0-255(duty), 6-466k (freq.1)
3 WO UINT32 PWM output param 1 (8-bit) param 2 (24-bit) 0-255(duty), 6-466k (freq.1)
4 WO UINT32 PWM output param 1 (8-bit) param 2 (24-bit) 0-255(duty), 6-466k (freq.1)
5 WO UINT32 PWM output param 1 (8-bit) param 2 (24-bit) 0-255(duty), 6-466k (freq.2)
6 WO UINT32 PWM output param 1 (8-bit) param 2 (24-bit) 0-255(duty), 6-466k (freq.2)
7 WO UINT32 PWM output param 1 (8-bit) param 2 (24-bit) 0-255(duty), 6-466k (freq.2)
8 WO UINT32 PWM output param 1 (8-bit) param 2 (24-bit) 0-255(duty), 6-466k (freq.2)
0x6401 0 WO UINT32 Pwm output pin configuration (all) 1
1 WO UINT32 Pwm configuration pin 1 1
2 WO UINT32 Pwm configuration pin 2 1
3 WO UINT32 Pwm configuration pin 3 1
4 WO UINT32 Pwm configuration pin 4 1
5 WO UINT32 Pwm configuration pin 5 1
6 WO UINT32 Pwm configuration pin 6 1
7 WO UINT32 Pwm configuration pin 7 1
8 WO UINT32 Pwm configuration pin 8 1
0x6410 0 WO UINT32 Output filter (all) (8-bit) 0-1
1 WO UINT32 Output filter value 1 (8-bit) 0-1
2 WO UINT32 Output filter value 2 (8-bit) 0-1
3 WO UINT32 Output filter value 3 (8-bit) 0-1
4 WO UINT32 Output filter value 4 (8-bit) 0-1
5 WO UINT32 Output filter value 5 (8-bit) 0-1
6 WO UINT32 Output filter value 6 (8-bit) 0-1
7 WO UINT32 Output filter value 7 (8-bit) 0-1
8 WO UINT32 Output filter value 8 (8-bit) 0-1
0x6500 0 WO UINT32 Input voltage config (all) - 24V/5V 0x00-0xff
1 WO UINT32 Input voltage config 1 (8-bit) 0 (5V), 1 (24V)
2 WO UINT32 Input voltage config 2 (8-bit) 0 (5V), 1 (24V)
3 WO UINT32 Input voltage config 3 (8-bit) 0 (5V), 1 (24V)
4 WO UINT32 Input voltage config 4 (8-bit) 0 (5V), 1 (24V)
5 WO UINT32 Input voltage config 5 (8-bit) 0 (5V), 1 (24V)
6 WO UINT32 Input voltage config 6 (8-bit) 0 (5V), 1 (24V)
7 WO UINT32 Input voltage config 7 (8-bit) 0 (5V), 1 (24V)
8 WO UINT32 Input voltage config 8 (8-bit) 0 (5V), 1 (24V)
0x6510 0 WO UINT32 Input voltage/current config (all) 0 (voltage), 1 (current)
1 WO UINT32 Input voltage/current config 1 (8-bit) 0 (voltage), 1 (current)
2 WO UINT32 Input voltage/current config 2 (8-bit) 0 (voltage), 1 (current)
3 WO UINT32 Input voltage/current config 3 (8-bit) 0 (voltage), 1 (current)
4 WO UINT32 Input voltage/current config 4 (8-bit) 0 (voltage), 1 (current)
5 WO UINT32 Input voltage/current config 5 (8-bit) 0 (voltage), 1 (current)
6 WO UINT32 Input voltage/current config 6 (8-bit) 0 (voltage), 1 (current)
7 WO UINT32 Input voltage/current config 7 (8-bit) 0 (voltage), 1 (current)
8 WO UINT32 Input voltage/current config 8 (8-bit) 0 (voltage), 1 (current)
0x6520 0 WO UINT32 Output mode config (all) - PWM/Analog 0x00-0xff
1 WO UINT32 Output mode config 1 (8-bit) 0 (no filter), 1 (filtered)
2 WO UINT32 Output mode config 2 (8-bit) 0 (no filter), 1 (filtered)
3 WO UINT32 Output mode config 3 (8-bit) 0 (no filter), 1 (filtered)
4 WO UINT32 Output mode config 4 (8-bit) 0 (no filter), 1 (filtered)
5 WO UINT32 Output mode config 5 (8-bit) 0 (no filter), 1 (filtered)
6 WO UINT32 Output mode config 6 (8-bit) 0 (no filter), 1 (filtered)
7 WO UINT32 Output mode config 7 (8-bit) 0 (no filter), 1 (filtered)
8 WO UINT32 Output mode config 8 (8-bit) 0 (no filter), 1 (filtered)
can_communication_with_controllers.txt · Last modified: 2019/02/15 14:35 by llibert