Dynamesys Interfacing Guide Firmware 2.5.0

How to connect a vehicle, PLC or host computer to a Dynamesys controller: analog (ADC) inputs, RC PWM input and the CAN bus with every supported protocol.

1. Before you start

Every parameter in this guide has a name (for example input_opt) and a 16-bit id (for example 0x0309). Both are listed in the Parameter Reference, which the Workbench opens from the help button in the parameter list. Change parameters in the Workbench parameter list, the CAN view or the text terminal (set name value, then save). A change applies at once. It survives a reboot only after it is stored to flash.

Choosing an input

InputBest forSection
Analog (ADC1 to ADC4)Throttle grips, pedals, potentiometers, 0-5 V signals from a PLC, analog position sensors2
RC PWMRC receivers, flight controllers, servo testers (1000-2000 µs pulses)3
CANVehicle networks, PLCs, multi-axis systems, anything that also needs telemetry4 to 12
UART / USBThe Workbench and host scripts (on by default)

Enabling inputs (input_opt)

An input only drives the motor when its bit is set in input_opt (0x0309). Add the values of the inputs you want.

ValueInputNotes
1ADC1
2ADC2
4RC PWMBoards with a PWM capture timer only
8UART / USBThe default
16Killswitch pinBoards with a killswitch pin only; pin low blocks the motor
32, 64CAN ADC1, CAN ADC2Reserved, not implemented
128ADC1-ADC2 differentialReserved, not implemented
256CANRequired for any CAN setpoint, under every protocol
512ADC3Boards with four analog inputs only
1024ADC4Boards with four analog inputs only

Example: ADC1 as throttle, ADC2 as brake, plus USB for the Workbench: 1 + 2 + 8 = 11. CAN only: 256.

CAN setpoints are refused until you add 256. The default is 8 (UART only). The Dynamesys protocol answers a refused setpoint with error reason 6 (not allowed). Writing 0 to input_opt falls back to 8.

How inputs become a request

The controller reads the inputs 1000 times a second and adds them together. There is no priority between sources: two throttles at full give twice the request. Enable only the sources you really use.

The control mode (opt_cont_type, 0x0176: 0 current, 1 speed, 2 duty, 3 position, 6 voltage) sets what the sum means. A CAN command can also switch the mode (see Driving the motor over CAN).

ModeAnalog and PWM inputs (-1 to +1)CAN and UART
Current (torque)Iq = input × par_i_max (positive) or × |par_i_min| (negative)Current setpoints in amps are added
Speedspeed = input × speed_req_max_pos (positive) or × speed_req_max_neg (negative)Speed setpoints are added
Dutyduty = input, clamped to ±1Duty setpoints are added
PositionIgnoredPosition targets only
VoltageIgnoredUART only

With the Vehicle app (opt_app_type = 1) the controller only runs in current mode and starts in NEUTRAL. It goes to DRIVE when every input has been at rest for 10 ms and the Go to Drive input (start_input, 0x0CBB, default off) is pressed, if one is set: the brake, an analog input, RC PWM or a digital input. The Go to Neutral input (neutral_input, 0x0CBE), such as a side stand switch, holds NEUTRAL while it acts.

The throttle and the brake are smoothed: input_filter_mode (0x0CC6) 0 is Smoothed, 1 is Rate limited. input_filter (0x0CAC, default 0.1 s) is the response time as the throttle opens, input_filter_down (0x0CC7, default 0.05 s) as it is let go and for the brake. Set them in the Workbench under Setup Inputs > Vehicle, where graphs show what they do.

Top speed: speed_lim_max (0x0342, 0 = off), with the driving current fading out over speed_lim_delta (0x0343) below it. Overspeed braking, speed_lim_brake_band (0x034F, 0 = off), brakes above the top speed, fully this far above it, also with the throttle released.

Ride modes: ride_mode (0x0CCC) 1 is eco, 2 standard (default), 3 sport. Each mode takes its top speed, motor current and throttle response from the arrays ride_top_speed, ride_i_max, ride_filter_up and ride_filter_down (0x0CC8 to 0x0CCB, one value per mode); 0 uses the normal setting. A mode change applies at once and is not stored. speed_lim_now, ibat_max_now and ibat_regen_now (0x0CCD to 0x0CCF) show the limits in force.

Wheel lock: ride_mode 0 locks the vehicle. With lock_wheel (0x0CD0, default 1) the motor windings are shorted once the wheel has stood still for 1 s, so it is hard to push; never while driving. The current limit still trips the bridge. wheel_locked (0x0CD1) shows it.

current_req_min (0x0307, default 0.1 A) is the smallest current request that starts the motor.

Safety, faults and recovery

2. Analog inputs (ADC)

Hardware

Mapping a voltage to a request

Each channel goes through the same steps:

  1. Wire-break check. A reading below adcN_trip_low or above adcN_trip_high raises error 27. Both trips are off by default (0 and 1). Set them a little outside the real travel so a broken wire or a short is caught.
  2. Normalise. For one-direction types, adcN_min gives 0 and adcN_max gives 1. Readings below min give 0, readings above max give 1. For the two-direction type, adcN_center gives 0, max gives +1 and min gives -1. A centre of 0 means halfway between min and max.
  3. Deadband (two-direction only). Within ±adcN_dead of the centre the result is 0. Outside it, the rest of the travel still reaches ±1.
  4. Curve. A five-point smooth curve (adcN_cx0..4, adcN_cy0..4) shapes the response. The default is a straight line.
  5. Polarity. The result is multiplied by adcN_pol and clamped to ±1.
adcN_typeMeaningDefault curve
0One direction, positive (forward throttle)0 to +1
1One direction, negative (reverse or regen lever)0 to -1
2Two directions around a centre (joystick, wig-wag)-1 to +1
3Brake (see Brake channels)0 to 1 brake

Throttles whose voltage falls as they are pressed: keep adcN_min below adcN_max (min is the low voltage) and draw a falling curve, 100 % at point 0 and 0 % at point 4. A broken wire then reads as full throttle, so always set adcN_trip_low and adcN_trip_high for such a throttle.

The curve is not reset when you change adcN_type in the parameter list. The Workbench Setup Inputs window resets it for you. If you change the type elsewhere, set the curve points as well.

Parameters

Shown for ADC1. ADC2, ADC3 and ADC4 have the same set with their own ids (see the Parameter Reference).

NameIdUnitMeaning
adc1_type0x0C0E0-3Input type, see table above
adc1_min0x0C030-1Reading at zero throttle
adc1_max0x0C020-1Reading at full throttle
adc1_center0x0C0C0-1Rest position, two-direction type only (0 = midpoint)
adc1_dead0x0C100-0.5Deadband around the centre, two-direction type only
adc1_pol0x0C04-1 to 1Output multiplier
adc1_trip_low0x0C080-1Fault below this reading (0 = off)
adc1_trip_high0x0C090-1Fault above this reading (1 = off)
adc1_cx0..4, adc1_cy0..40x0C12-0x0C1B-1 to 1Curve points
adc1_range0x0CA1VFull-scale voltage at the connector, set by the board (expert)
adc10x0C720-1Signal: the reading now

The defaults for min and max differ per controller family and are only a starting point. Calibrate every throttle.

Calibrating in the Workbench

  1. Open Setup Inputs and choose the channel's tab (ADC1 to ADC4, or PWM).
  2. Click Calibrate. The wizard switches the channel's input off (not stored) so the motor cannot move.
  3. Choose the type and follow the steps: rest, then full for one direction; centre, full forward, full reverse for two directions. Each Capture averages the reading for 0.8 s.
  4. The wizard pulls each end in a little (0.1 V, or 20 µs for PWM) so full throttle is reliably reached. It can also set the wire-break trips for you.
  5. Adjust the curve by dragging its points. The green dot shows the live input. The ±100 % fields set the matching current or speed limit.
  6. Click Save. Tick the store option to keep it after a reboot.
  7. Switch the input back on with Activate <channel>. The Workbench warns if the throttle is not at rest.

Brake channels

A channel with type 3 feeds the brake request instead of the throttle. Above 5 % travel it brakes against the direction of motion, up to |par_i_min|. Braking fades out at low speed: it is 0 below brake_fade_low (0x0CB1) and full above brake_fade_high (0x0CAB, default 2.0 in speed units).

Analog position feedback

An analog channel can also be a position or speed sensor on the load (a potentiometer, a linear transducer, a tacho). Set fbk_pos_src (0x0529) and/or fbk_vel_src (0x0528) to 1. The reading is then sampled at the control frequency.

NameIdUnitMeaning
fbk_an_adc0x05321-4Which ADC channel
fbk_an_kind0x05330/10 = position sensor, 1 = speed sensor (tacho)
fbk_an_gain0x0534rad/V or m/VLoad movement per connector volt (per second for a tacho). Default 0: no feedback until set
fbk_an_offset0x0535rad or mLoad position at 0 V
fbk_an_fc0x0536HzLow-pass filter (0 = off)
fbk_an_value0x0537rad or mSignal: mapped reading, use it to check gain and offset

Do not also enable a feedback channel as a throttle in input_opt.

3. PWM input (RC servo)

The RC PWM input measures the high time of a servo pulse with 1 µs resolution. It is available on F405 and H7 boards that have a capture timer. U5 boards have no RC PWM input. Check your board's documentation for the pin.

Signal and validation

The mapping is the same as for analog inputs (type, centre, deadband, curve, polarity, trips), but in microseconds. The Setup Inputs window and the calibration wizard work for PWM too; the wizard also measures the frame rate and sets ic_dur_min/ic_dur_max to ±25 % around it. The plot preset PWM input shows ic_pulse, ic_duration and ic_req.

Parameters

NameIdUnitDefaultMeaning
ic_type0x0D060-320 one direction +, 1 one direction -, 2 two directions, 3 brake
ic_min0x0D01µs1000Zero throttle
ic_max0x0D00µs2000Full throttle
ic_center0x0D05µs1500Rest position (two directions)
ic_dead0x0D070-0.50.05Deadband (two directions)
ic_pol0x0D02-1 to 11Output multiplier
ic_trip_low0x0D03µs0 (off)Fault below this pulse
ic_trip_high0x0D04µs65535 (off)Fault above this pulse
ic_dur_min0x0506µs15000Shortest accepted frame period
ic_dur_max0x0505µs25000Longest accepted frame period
ic_cx0..4, ic_cy0..40x0D09-0x0D12-1 to 1straightCurve points
ic_pulse0x053AµsSignal: pulse width now
ic_duration0x053BµsSignal: frame period now
ic_req0x053C-1 to 1Signal: request after mapping
ic_rejects0x054FcountSignal: rejected frames since boot

Enable the input with bit 4 in input_opt.

PWM output and PWM encoders

4. CAN: overview

A Dynamesys controller has one classic CAN 2.0 port (no CAN FD, up to 8 data bytes per frame). On that one port it runs:

So you can drive a controller from a CANopen PLC and still configure it, plot it and update its firmware from the Workbench over the same two wires.

Wiring and bitrate

Wiring

Bitrate

can_baudrate (0x0405)Bitrate
0 (default)1 Mbit/s
1500 kbit/s
2250 kbit/s
3125 kbit/s
4100 kbit/s
550 kbit/s

The four layers on the bus

LayerCAN IDsWhat it doesSwitched by
Selected protocolIts own (see each section)Commands and telemetry for your PLC or vehiclecan_protocol
Presence announce0x000065nn extOne frame per second per node: who is on the bus, node ID clashes, who is the hostCAN_options ≥ 1
CAN tunnel0x000005nn / 0x000006nn extThe Workbench's full connection to node nn: parameters, plots, terminal, SD card, firmware updateCAN_options ≥ 1
Dynamesys status packets0x0000C0nn-0x0000C8nn extPeriodic telemetry: speed, position, voltages, currents, state, errors, temperaturesAlways under the Dynamesys protocol; under other protocols when CAN_options = 3

All Dynamesys layers use 29-bit extended IDs with the node ID in the low byte. Section Running next to any protocol explains how they share the bus with each protocol.

Selecting a protocol

can_protocol (0x0404)ProtocolIDsSection
0Disabled: CAN off, no layers at all
1 (default)Dynamesys29-bit7
2CANopen CiA 301 + CiA 40211-bit8
3Cyphal: reserved, not implemented
4DroneCAN29-bit11
5Custom (build-specific)12
9VESC29-bit9
10SAE J193929-bit10

Values 6 and 7 are reserved, and 8 is a customer-specific protocol. A new protocol applies immediately; store it to keep it.

CAN_options

CAN_options (0x0415) is a level. Each level includes everything below it.

ValueMeaning
0Dynamesys layers off. Only the selected protocol is on the bus. The node is invisible to the Workbench over CAN and does not check for node ID clashes.
1Presence announce and CAN tunnel. The node keeps its node ID even if another node uses it (the clash is still reported).
2As 1, and the node moves to a free ID when another node uses the same one.
3 (default)As 2, and the Dynamesys status packets are also sent under any other protocol.

Node IDs

Every device on the bus needs its own node ID from 1 to 127. That includes controllers, an RFLX-CONNECT and a PC CAN adapter.

The parameter

What each protocol does with it

ProtocolNode ID use
Dynamesys, status packets, presence, tunnelLow byte of every frame ID
CANopenCANopen node ID (SDO 0x600/0x580 + ID, PDOs, EMCY, heartbeat). Pin it: a moved ID moves every COB-ID. After changing it, reboot so the PDO COB-IDs follow.
VESCVESC controller ID
J1939Source address. The controller sends Address Claimed but does not arbitrate addresses with other ECUs.
DroneCANDroneCAN node ID (runs as node 10 until an ID is set). The ESC slot is can_esc_index (0x0407).

Clashes

Setting the ID in the Workbench

The Workbench refuses an ID that is already in use on the bus. You can change the ID of a node you are connected to over CAN: the connection, open plots and settings follow it to the new ID. When several parameters are written at once, the node ID is always written last.

Commissioning a fixed installation: connect one board at a time, give each a pinned ID from 1 to 127 and store it. Set CAN_options to 1 if IDs must never move on their own. Loading a saved configuration from another board also copies its node ID, so check the ID after an import.

Driving the motor over CAN

Trying frames from a PC

Every protocol section ends with examples: a list of frames, how to read them, and a short Python script that sends them.

Reading the example tables

Byte order

A value wider than one byte can go out lowest byte first or highest byte first. Take 10000, which is 0x00002710 in hex:

Byte orderOn the busUsed by
Little-endian: lowest byte first10 27 00 00Dynamesys, status packets, CANopen, J1939, DroneCAN
Big-endian: highest byte first00 00 27 10VESC

The name says which end comes first. Byte 0 of a little-endian value holds its lowest part.

Sending from Python

The scripts use python-can (pip install python-can) with any adapter it supports. Close the Workbench's connection to the adapter first: only one program can use it at a time.

import can, struct, time

bus = can.Bus(interface="pcan", channel="PCAN_USBBUS1", bitrate=1000000)
# CANable (slcan):  can.Bus(interface="slcan", channel="COM5", bitrate=1000000)

Use the controller's bitrate (can_baudrate, 1 Mbit/s by default). The other scripts assume this bus.

Running next to any protocol

Every received frame is first offered to the tunnel and presence layer and then to the selected protocol. All Dynamesys layers use 29-bit IDs whose bits 28-16 are 0, with only a few command values in bits 15-8. Each protocol installs hardware filters for its own frames, and the tunnel adds three of its own: downstream to this node (exact 0x05nn), presence (0x65xx, any sender), and upstream 0x06xx only while this node relays for a host.

ProtocolPresence + tunnelStatus packets (CAN_options 3)Advice
DynamesysYesAlways (native)Command values 0x05, 0x06 and 0x65 belong to the tunnel.
CANopenYesYesNo overlap: CANopen uses 11-bit IDs and our layers 29-bit. Fine to keep the default.
VESCYesYesTunnel IDs 0x05nn/0x06nn are VESC buffer packets addressed to node nn, so they never reach a VESC as long as every node ID on the bus is unique. Pin the IDs on a mixed bus.
J1939YesYesOur 29-bit IDs carry J1939 priority 0 and parse as PGN 0 (TSC1). Set CAN_options 0 on a bus with other J1939 ECUs.
DroneCANYesYesOur frames decode as highest-priority DroneCAN messages. Use CAN_options 0 on a bus with other DroneCAN nodes.
CustomYesYesSee the documentation of your custom protocol.
Disabled, CyphalNoNo

With CAN_options 2 the tunnel stays but the status packets stop; with 0 the bus carries only the selected protocol, and the Workbench can no longer reach the node over CAN (USB still works).

The CAN view in the Workbench

Open it from ≡ > Select Views > CAN. It shows only the fields the connected device has. Each change is written and stored at once. The CAN tab of Setup Inputs sets the same settings, saved with Save, and offers the CAN exports.

FieldParameter
Protocolcan_protocol
Baud Ratecan_baudrate
Status Ratecan_status_hz (empty = off)
Node IDcan_node_id
ESC Indexcan_esc_index (DroneCAN)
Timeoutcan_timeout (empty = no timeout)
CAN Modecan_control_mode
Enable CAN setpointsinput_opt bit 256

To describe the bus to another tool, use the CAN exports: a DBC for the Dynamesys protocol and status packets, a DBC for J1939, an EDS for CANopen.

5. The CAN tunnel

The CAN tunnel carries a controller's complete USB connection over the CAN bus. A node reached through it behaves in the Workbench like a board on a USB cable:

Audio is the only feature that needs USB. The tunnel works under every protocol (can_protocol 1, 2, 4, 5, 9, 10) as long as CAN_options is 1 or higher.

Presence announce

Every node with a node ID sends this frame once a second. nn in the ID is the sender's node ID, so every node announces on its own ID. Firmware before 2.5.0 sent 0x000065FF instead; current devices still accept that, so match 0x000065xx to see both.

IDDLCByteContent
0x000065nn ext701 = this sender relays for a host (it is the bridge), 0 = not
1Sender's node ID
2..532-bit hash of the sender's chip ID, big-endian
6Bit 0: the sender will not move its ID (CAN_options 1). Bit 1: the device sits behind an adapter, not on the bus

A node missing for 2 s is considered gone. The announce is the lowest-priority frame Dynamesys sends, and 10 nodes use about 0.02 % of a 500 kbit/s bus.

Example

ID          DLC  Data (hex)               Meaning
0x0000650A  7    00 0A 1A 2B 3C 4D 00     Node 10, not a bridge, chip-ID hash 0x1A2B3C4D, ID may move

Tunnel frames

IDDirectionContent
0x000005nn extHost to node nn1-8 bytes of the byte stream (DLC = number of bytes)
0x000006nn extNode nn to host1-8 bytes of the byte stream

Connecting through it

The host side needs a bridge between the PC and the bus. The bridge announces "host present", relays tunnel frames and is never itself the node you talk to.

BridgeHowBitrate
A controller on USBConnect the Workbench to any controller on the bus. It scans the bus and lists the other nodes.That controller's can_baudrate
RFLX-CONNECTUSB, WiFi (TCP port 3333) or Bluetooth. One client at a time; a new client replaces the old one.Set can_bitrate on the CONNECT to match
PC USB-CAN adapterPCAN, candleLight / gs_usb, CANable (slcan) or Ebyte ECAN-U01S. It appears as an adapter card in Connect to Device. The PC itself becomes the bus master.Bitrate row on the card: Auto listens first, a fixed rate connects at once

To add more nodes later use ≡ > Connect to Another Device. Device Overview (F12) shows every connected device, and Next Device (F2) switches between them.

From a controller's own text terminal, can_nodes lists the nodes on the bus and can_attach <id> opens another node's terminal over the tunnel (can_detach to return).

Bandwidth and limits

6. Dynamesys status packets

The status packets are periodic telemetry frames in a fixed format. A Dynamesys protocol node always sends them. With CAN_options 3 (the default) a node running any other protocol sends them too, so a logger, display or RFLX-CONNECT trip log can read every controller the same way. They are send-only: under another protocol the node does not answer Dynamesys commands.

At a glance

Sent byEvery Dynamesys protocol node, and with CAN_options 3 (default) a node running any other protocol
IDs29-bit 0x0000Cxnn: x is the frame (0 to 8), nn the sender's node ID
Byte orderLittle-endian. f32 is an IEEE-754 float.
Scalingi16 0.1: current in 0.1 A, voltage in 0.1 V, temperature in 0.1 °C. i16 1e-4: normalised values (duty, ADC, demand). Both saturate at ±32767.
RatesFast frames at can_status_hz (50 Hz), slow frames at can_status_slow_hz (10 Hz), STATE also on change. Both are held to each node's share of the bus: the nodes heard share about 40 % of it, e.g. 37 Hz for a drive alone at 50 kbit/s and about 9 Hz for each of three drives with an RFLX-CONNECT.
DirectionSend-only, nothing to answer
File≡ > CAN Exports > Dynamesys DBC, This Device; on a node with another protocol choose Status only (see CAN exports)

Frames

IDNameDLCBytesRateMask
0xC0nnMOTION8[0..3] f32 speed [speed_unit]
[4..7] f32 position [pos_unit]
fast0x001
0xC1nnBUS8[0..1] i16 battery current, 0.1 A
[2..3] i16 bus voltage, 0.1 V
[4..5] i16 duty, 1e-4 (-1..1)
[6..7] u16 electrical angle, 65536 = 360°
fast0x002
0xC2nnSTATE7 or 8[0] u8 motor state (table)
[1] u8 control mode: 0 torque, 1 speed, 2 duty, 3 position, 6 voltage
[2] u8 flags: bit 0 position armed, bit 1 E-STOP latched, bit 2 position reached, bit 3 moving
[3..6] u32 latched errors, bit N-1 = error N (table)
[7] u8 vehicle (only with the Vehicle app, DLC 8): bits 1:0 state (0 neutral, 1 drive, 2 locked), bits 3:2 ride mode, bit 4 reverse
slow + on change0x004
0xC3nnDQ8[0..1] i16 Id, 0.1 A
[2..3] i16 Iq, 0.1 A (both filtered)
[4..5] i16 Vd, 0.1 V
[6..7] i16 Vq, 0.1 V
fast0x008
0xC4nnHEALTH8[0..1] i16 MOSFET temperature, 0.1 °C
[2..3] i16 motor temperature, 0.1 °C
[4..5] u16 active limits (table)
[6..7] u16 key bits: 1 not initialised, 2 killswitch, 4 safe start, 8 app
slow0x010
0xC5nnCUST_A8[0..3] value of the parameter named by can_status_a1
[4..7] value of can_status_a2
fast0x020
0xC6nnCUST_B8[0..3] can_status_b1
[4..7] can_status_b2
fast0x040
0xC7nnINPUT8[0..1] i16 ADC1 reading, 1e-4
[2..3] i16 ADC2 reading, 1e-4
[4..5] i16 CAN duty setpoint, 1e-4
[6..7] i16 total input demand, 1e-4
fast0x080
0xC8nnODO8[0..3] u32 lifetime distance (m, or shaft revolutions for a rotary load)
[4..5] u16 trip energy, Wh
[6..7] u16 trip distance, per 100 m or 100 rev
slow0x100
ParameterIdDefaultMeaning
can_status_hz0x040A50 HzRate of the fast frames (0 = off)
can_status_slow_hz0x041B10 HzRate of STATE, HEALTH and ODO (0 = off)
can_status_mask0x041C0x1FF (all)Bit N enables frame 0xC0+N
can_status_a1, a2, b1, b20x0417-0x041A0 (empty)Parameter id shown in each custom slot

Examples

Node 10 with speed_unit 1 (RPM) and pos_unit 1 (rev):

ID          DLC  Data (hex)                Meaning
0x0000C00A  8    00 80 BB 44 00 00 44 41   MOTION: 1500 rpm, position 12.25 rev
0x0000C10A  8    7D 00 E0 01 88 13 00 40   BUS: 12.5 A, 48.0 V, duty 0.5, angle 90°
0x0000C20A  7    07 00 00 00 00 00 00      STATE: Run, torque mode, no flags, no errors

Reading the BUS frame

0x0000C10A   frame 0xC1 (BUS) from node 0x0A
7D 00        0x007D = 125    x 0.1 A         = 12.5 A
E0 01        0x01E0 = 480    x 0.1 V         = 48.0 V
88 13        0x1388 = 5000   x 1e-4          = 0.5 duty
00 40        0x4000 = 16384  x 360° / 65536  = 90°

In MOTION, 00 80 BB 44 is the f32 0x44BB8000, which is 1500.0.

Reading them in Python

NODE = 10
for msg in bus:                                   # runs until stopped
    if msg.arbitration_id == 0xC100 | NODE:       # BUS
        ibus, vbus, duty, angle = struct.unpack("<hhhH", msg.data)
        print(f"{ibus / 10} A  {vbus / 10} V  duty {duty / 1e4}  {angle * 360 / 65536:.0f} deg")
    elif msg.arbitration_id == 0xC000 | NODE:     # MOTION
        speed, pos = struct.unpack("<ff", msg.data)
        print(f"speed {speed}  position {pos}")

7. Dynamesys protocol

The Dynamesys protocol (can_protocol = 1, the default) is the house protocol: setpoints, position moves, parameter read/write and the status packets, all on 29-bit IDs.

At a glance

Selectcan_protocol = 1 (the default)
IDs29-bit: parameter id, command and node ID in one identifier (Frame IDs)
Node IDLow byte of the ID; 0 = broadcast
Byte orderLittle-endian; f32 values that are NaN or infinite are refused
SetpointsNeed input_opt bit 256; each one selects its own control mode
Command losscan_timeout (default 1000 ms) zeroes the CAN setpoints
RepliesParameter commands always answer (PARAM_VALUE or ERR); setpoints answer only when refused
TelemetryThe status packets
File≡ > CAN Exports > Dynamesys DBC

Setting it up

  1. In the CAN view, keep Protocol on Dynamesys and set the Baud Rate of your bus.
  2. Give each controller its own Node ID (1 to 127), or leave it at 0 to let nodes pick free IDs.
  3. Tick Enable CAN setpoints (adds 256 to input_opt).
  4. Choose a Timeout longer than your setpoint interval.
  5. Send a parameter read (PARAM_GET) to check that the node answers, then send setpoints.

Frame IDs

ID = (param_id & 0xFFF) << 16  |  command << 8  |  node
     bits 27-16  parameter id (0 for commands that are not about a parameter)
     bits 15-8   command
     bits  7-0   node ID (0 = broadcast)

Examples for node 10: SET_CURRENT 0x0000030A, STATUS_STATE 0x0000C20A, read can_timeout (0x0408) 0x0408210A.

Commands

"Needs CAN" means the frame is only accepted when input_opt has bit 256 set and no detection or update is running. Otherwise the node answers ERR reason 6. Setpoints restart can_timeout; position commands do not.

CmdNameDLCPayloadEffectNeeds CAN
0x00ESTOP0-1u8: 0 = release, anything else or empty = assertAssert latches the emergency stop (error 11) and drops the CAN setpoints. Release clears it.Release only
0x01STOPanyStops the motor, zeroes every request, disarms position controlNo
0x02SET_DUTY4f32 duty, -1..1Duty modeYes
0x03SET_CURRENT4f32 q-axis current, ACurrent (torque) modeYes
0x04SET_VELOCITY4f32 speed [speed_unit]Speed modeYes
0x07SET_POSITION4 or 8f32 target [pos_unit]; optional f32 speed limit [pos_unit/s]Sets the target only; arm with POS_ENABLE. With 4 bytes the speed limit is cleared.Yes
0x08POS_ENABLE1u8: 1 = arm, 0 = disarmArming selects position mode. Stage targets per node, then arm all axes together with one broadcast.Yes
0x11POS_ABS_CNT8i64 target, encoder counts (±2147483647)Absolute target in countsYes
0x12POS_REL4 or 8f32 distance [pos_unit]; optional f32 speed limitMoves relative to the current targetYes
0x13POS_REL_CNT8i64 distance, countsRelative move in countsYes
0x14POS_ZERO_HERE0The current position becomes 0Yes
0x15POS_HOLD_HERE0The target becomes the current positionYes
0x16POS_LIMITS8f32 min, f32 max [pos_unit]; 0, 0 = no limitsSoftware travel limitsYes
0x17POS_ACCEL4 or 8f32 acceleration; optional f32 deceleration [pos_unit/s²]; 0 = configured valueCan only lower the configured limit; not storedYes

Units: speed_unit (0x030F) is 0 rad/s, 1 RPM, 2 rev/s for a rotary load, or 0 m/s, 1 mm/s, 2 km/h for a linear one. pos_unit (0x0344) is 0 rad, 1 rev (rotary) or 0 m, 1 mm (linear).

To clear an error, write 1 to the parameter clear_error (0x0C48) with PARAM_SET. Like every command parameter (stop, emergency_stop, ride_mode) it needs CAN setpoints enabled in input_opt, or the node answers ERR reason 6.

Parameter access

The parameter id goes in ID bits 27-16. Parameter frames are never broadcast.

CmdNameDirectionDLCPayloadReply
0x20PARAM_SETto node4 (1 for bool)valuePARAM_VALUE with the new value. RAM only.
0x21PARAM_GETto node0PARAM_VALUE
0x22PARAM_VALUEfrom node4 (1 for bool)value
0x23PARAM_STOREto node4 (1 for bool)valueAs PARAM_SET, then stores that parameter to flash shortly after
0x24ERRfrom node2[0] refused command, [1] reason

Values are 4 bytes: integers as int32 or uint32, floats as f32. Booleans are 1 byte. Text and array parameters can only be reached through the tunnel. Out-of-range values are refused, not clamped.

ReasonMeaningReasonMeaning
1Unknown parameter6Not allowed now (enable CAN in input_opt, or the motor is busy)
2Read-only7Bad value (NaN or infinite)
3Wrong length8Out of range
4Not carried (text, array)9Not supported by this hardware
5Protected (can_protocol, can_baudrate, can_node_id)10Busy, store not queued; try again

A DBC with every command and status frame comes from ≡ > CAN Exports > Dynamesys DBC, This Device or Dynamesys DBC, Full Network. Parameter frames are not in the DBC, because their ID depends on the parameter.

Examples

A master driving node 10, starting from the default input_opt (UART only):

ID          DLC  Data (hex)                Meaning
0x0000030A  4    00 00 A0 40               SET_CURRENT 5.0 A
0x0000240A  2    03 06                     ERR from node 10: command 0x03 refused, reason 6 (CAN not enabled)
0x0309230A  4    08 01 00 00               PARAM_STORE input_opt (0x0309) = 264: UART 8 + CAN 256
0x0309220A  4    08 01 00 00               PARAM_VALUE from node 10: the new value
0x0000030A  4    00 00 A0 40               SET_CURRENT 5.0 A, now accepted (no reply)
0x0408210A  0                              PARAM_GET can_timeout (0x0408)
0x0408220A  4    E8 03 00 00               PARAM_VALUE: 1000 ms
0x0000070A  8    00 00 20 40 00 00 80 3F   SET_POSITION 2.5, speed limit 1.0 per s [pos_unit]
0x00000800  1    01                        POS_ENABLE to node 0: every node arms at once
0x00000000  0                              ESTOP to node 0: every node latches the emergency stop

Reading the frames

0x0309230A   = 0x0309 << 16   parameter input_opt
             | 0x23   << 8    command PARAM_STORE
             | 0x0A           node 10
08 01 00 00  = 0x00000108 = 264, lowest byte first
00 00 A0 40  = 0x40A00000 = 5.0 as an f32
03 06        = command 0x03 (SET_CURRENT) refused, reason 6 (not allowed now)

A PARAM_VALUE reply carries the parameter id and node ID of the request. An ERR reply has parameter id 0.

In Python

NODE = 10
def dnes_id(cmd, param=0, node=NODE):
    return (param & 0xFFF) << 16 | cmd << 8 | node

# Allow CAN setpoints: input_opt (0x0309) = 8 (UART) + 256 (CAN), and store it
bus.send(can.Message(arbitration_id=dnes_id(0x23, 0x0309), data=struct.pack("<I", 264),
                     is_extended_id=True))

# Read can_timeout (0x0408): listen for the PARAM_VALUE reply only
reply = dnes_id(0x22, 0x0408)
bus.set_filters([{"can_id": reply, "can_mask": 0x1FFFFFFF, "extended": True}])
bus.send(can.Message(arbitration_id=dnes_id(0x21, 0x0408), data=b"", is_extended_id=True))
msg = bus.recv(0.5)
print(struct.unpack("<I", msg.data)[0] if msg else "no reply")
bus.set_filters(None)

# 5 A for 2 s, sent every 20 ms so can_timeout never runs out
task = bus.send_periodic(can.Message(arbitration_id=dnes_id(0x03),
                                     data=struct.pack("<f", 5.0), is_extended_id=True), 0.02)
time.sleep(2)
task.stop()
bus.send(can.Message(arbitration_id=dnes_id(0x01), data=b"", is_extended_id=True))  # STOP

8. CANopen (CiA 301/402)

can_protocol = 2. The controller is a CiA 402 servo drive (device type 0x00020192) with an SDO server, 4 RPDOs and 4 TPDOs, EMCY, heartbeat and CiA 302-3 firmware download. Get the EDS from ≡ > CAN Exports > CANopen EDS File while the controller is connected.

Pin can_node_id (1 to 127) for CANopen. A node that picks or moves its ID moves every COB-ID. Set CAN_options to 1 so it never moves.

At a glance

Selectcan_protocol = 2
IDs11-bit COB-IDs: function code + node ID (table)
Node ID1 to 127, pinned
Byte orderLittle-endian, as CiA 301 specifies, in SDO data, PDOs and EMCY
SetpointsThrough the CiA 402 objects, usually by RPDO; need input_opt bit 256 (statusword bit 9 shows it)
Mode0x6060; velocity mode (2) after boot
Command lossHeartbeat consumer or RPDO deadline, both off by default (master loss); can_timeout does not apply
TelemetryTPDO1 every 100 ms, EMCY on errors, heartbeat every 1000 ms; status packets too with CAN_options 3
File≡ > CAN Exports > CANopen EDS File

Setting it up

  1. In the CAN view, set Protocol to CANopen, the Baud Rate of your bus and a fixed Node ID. Set CAN_options to 1 so the ID never moves.
  2. Tick Enable CAN setpoints (adds 256 to input_opt).
  3. Export the EDS and load it into your master.
  4. Configure master-loss detection: a heartbeat consumer (0x1016:1) or an RPDO deadline (0x1400:5).
  5. From the master, map the PDOs you need and store them (0x1010:1 = "save").
  6. Walk the drive through the CiA 402 state machine with the controlword: 0x06, 0x07, 0x0F.

COB-IDs, NMT, SDO

ObjectCOB-ID
NMT0x000
SYNC (consumer only)0x080 (0x1005)
EMCY0x080 + node
TPDO1..40x180 / 0x280 / 0x380 / 0x480 + node
RPDO1..40x200 / 0x300 / 0x400 / 0x500 + node
SDO request / response0x600 / 0x580 + node
Heartbeat0x700 + node

NMT

SDO

Object dictionary

IndexContent
0x1000Device type 0x00020192
0x1001Error register
0x1003Error history, 8 entries (write 0 to sub 0 to clear)
0x1005SYNC COB-ID
0x1008 / 0x1009Device name / hardware version (the firmware version is in 0x1018:3)
0x1010:1Write "save" (0x65766173) to store all parameters
0x1011:1Write "load" (0x64616F6C) to restore defaults, keeping the CAN settings; applies after a reset
0x1014 / 0x1015EMCY COB-ID / inhibit time (100 µs)
0x1016:1Heartbeat consumer, one entry: node << 16 | time in ms
0x1017Heartbeat producer time, default 1000 ms
0x1018Identity: vendor 0x00444E53, product 1, revision = firmware version, serial = chip ID
0x1029:1On bus-off or heartbeat loss: 0 pre-operational (default), 1 no change, 2 stopped
0x1200SDO server COB-IDs
0x1400-03, 0x1600-03RPDO communication / mapping
0x1800-03, 0x1A00-03TPDO communication / mapping
0x1F50:1, 0x1F51:1, 0x1F57:1Firmware download: data, control (0 stop, 1 start, 3 clear), status
0x2000 + idEvery Dynamesys parameter by its id (for example can_timeout 0x0408 at 0x2408), little-endian at its own width. Arrays as CiA ARRAY, text as strings.
0x3800 + idRead-only description of each parameter
0x5E00:1MOSFET temperature, INT16 °C
0x5F00Dynamesys identity: magic, schema hash, chip ID, build time, git hash, parameter list

CiA 402 drive profile

Supported modes (0x6502 = 0x0000038F): profile position (1), velocity (2, the default after boot), profile velocity (3), profile torque (4), cyclic synchronous position (8), velocity (9) and torque (10). No homing or interpolated position.

State machine

Standard controlword transitions. Statusword values:

Any latched controller error gives FAULT; a rising edge on controlword bit 7 resets it.

Statusword bits

Halt (controlword bit 8) stops at speed 0, current 0 or the current position.

IndexNameUnitMaps to
0x6040 / 0x6041Controlword / statusword
0x6060 / 0x6061Mode of operation / displayChanging the mode zeroes the targets
0x6042 / 0x6043 / 0x6044vl target / demand / actualrpm
0x6046:1/2vl min / maxrpmspeed_req_min, speed_req_max_pos
0x6048 / 0x6049vl acceleration / decelerationrpm per sspeed_ramp_up, speed_ramp_down
0x60FFTarget velocity (pv, csv)rpm
0x606CVelocity actualrpm
0x606D / 0x606EVelocity window / timerpm / msDefault 20 rpm / 0 ms
0x6071 / 0x6074 / 0x6077Target / demand / actual torque‰ of 0x6076
0x6075 / 0x6076Rated current / rated torquemA / mNmpar_i_max / ds402_rated_tq (0 = par_i_max × Kt)
0x6078Current actual‰ of rated current
0x607ATarget positioncountspp: taken on controlword bit 4 (bit 5 immediate, bit 6 relative); csp: followed directly
0x6064 / 0x60F4Position actual / following errorcounts
0x6065 / 0x6067Following error window / position windowcountspos_err_max / pos_reached_win
0x607D:1/2Software position limitscountspos_min / pos_max
0x6081 / 0x6083 / 0x6084Profile velocity / acceleration / decelerationcounts/s, counts/s²pos_vel_max, pos_acc_max, pos_dec_max
0x6007Abort connection option0-3See master loss
0x605AQuick stop option0-8Default 2
0x603FError code

Torque in ‰ of rated torque equals ‰ of rated current, because rated torque is rated current × Kt. Position objects return an SDO abort until the position sensor is scaled.

PDOs

PDOCOB-IDTypeDefault mapping
RPDO10x200 + node2550x6040 controlword (u16), 0x6042 vl target (i16 rpm)
TPDO10x180 + node255, every 100 ms0x6041 statusword (u16), 0x6044 vl actual (i16 rpm), 0x5E00:1 MOSFET temperature (i16 °C)
PDO2-4Disabled

RPDO mappable:

TPDO mappable:

The CANopen settings are also parameters, so the Workbench can set and store them:

ParameterIdObjectDefault
co_hb_ms0x0E900x10171000 ms
co_emcy_cob0x0E910x10140 (= 0x80 + node)
co_emcy_inh0x0E920x10150
co_hb_cons0x0E930x1016:10 (off)
co_sync_cob0x0E940x10050x080
ds402_rated_tq0x0E950x60760
ds402_abort_opt0x0E960x60071
ds402_qs_opt0x0E970x605A2
ds402_vel_win / _ms0x0E98 / 0x0E990x606D / 0x606E20 rpm / 0 ms
co_err_behav0x0E9A0x1029:10
canopen_autostart0x0CB9NMT1

PDO settings are parameters 0x0E10 to 0x0E8C (one block per PDO).

EMCY and master loss

EMCY frame: [0..1] error code (little-endian), [2] error register, [3..6] latched controller errors (u32), [7] 0. One is sent per new error, and code 0x0000 when all errors have cleared.

CodeCauseCodeCause
0x2310Overcurrent0x8100CAN node ID clash
0x2300Unbalanced current0x8110Control loop stall
0x3210 / 0x3220Over / undervoltage0x8120Input out of range
0x4210MOSFET overtemperature0x8130Heartbeat lost
0x4200Capacitor overtemperature0x8140Bus-off
0x4310Motor overtemperature0x8210RPDO too short
0x4000Temperature sensor0x8240SYNC with data
0x5000Memory or ADC fault0x8250RPDO deadline missed
0x6100Software, watchdog or app0x8611Following error
0x7100Hardware break input0xFF01Emergency stop
0x7300Encoder0xFF02 / 03 / 04Measurement / detection / startup failed
0x1000Other

Master loss

Master loss is detected by:

While the drive is in Operation Enabled, 0x6007 decides what happens: 0 nothing, 1 fault (default), 2 switch on disabled, 3 quick stop.

Configure a heartbeat consumer or an RPDO deadline. Under CANopen the generic can_timeout does not apply, and both of these are off by default. A master that simply goes silent then leaves the drive running on its last setpoint. For example, set 0x1016:1 to the master's node ID and 3 × its heartbeat period, or set 0x1400:5 to a few cycles of your RPDO rate.

Examples

A master (node 1) bringing up node 10 in velocity mode with the default PDOs:

ID     DLC  Data (hex)                Meaning
0x000  2    01 0A                     NMT start node 10 (not needed with canopen_autostart 1)
0x70A  1    05                        Heartbeat from node 10: Operational
0x60A  8    23 09 23 00 08 01 00 00   SDO write 0x2309:00 (input_opt) = 264, 4 bytes
0x58A  8    60 09 23 00 00 00 00 00   Write confirmed
0x60A  8    23 16 10 01 2C 01 01 00   SDO write 0x1016:01 = watch node 1, 300 ms
0x58A  8    60 16 10 01 00 00 00 00   Write confirmed
0x60A  8    23 10 10 01 73 61 76 65   SDO write 0x1010:01 = "save": store everything
0x58A  8    60 10 10 01 00 00 00 00   Write confirmed
0x20A  4    06 00 00 00               RPDO1: controlword 0x0006 (shutdown), vl target 0
0x20A  4    07 00 00 00               RPDO1: controlword 0x0007 (switch on)
0x20A  4    0F 00 E8 03               RPDO1: controlword 0x000F (enable operation), 1000 rpm
0x18A  6    37 02 E8 03 23 00         TPDO1: statusword 0x0237, 1000 rpm, MOSFET 35 °C
0x60A  8    40 41 60 00 00 00 00 00   SDO read 0x6041:00 (statusword)
0x58A  8    4B 41 60 00 37 02 00 00   Reply, 2 bytes: 0x0237 operation enabled, remote

With 0x1016:1 set, the master must send its own heartbeat (0x701) at least every 300 ms.

Reading the frames

0x60A        = 0x600 (SDO request) + node 10; the reply comes on 0x580 + node
23 09 23 00 08 01 00 00
23           expedited download of 4 bytes  (2B = 2 bytes, 2F = 1 byte)
09 23        index 0x2309, lowest byte first
00           subindex 0
08 01 00 00  value 264
60           reply: download done  (80 = abort, abort code in bytes 4..7)

4B 41 60 00 37 02 00 00
4B           upload reply with 2 bytes  (43 = 4 bytes, 4F = 1 byte)
41 60 00     index 0x6041, subindex 0
37 02        statusword 0x0237

0x20A  0F 00 E8 03    RPDO1: controlword 0x000F | vl target 0x03E8 = 1000 rpm
0x18A  37 02 E8 03 23 00
                      TPDO1: statusword 0x0237 | 1000 rpm | 0x0023 = 35 °C

Statusword 0x0237 is operation enabled (0x0037) plus bit 9, remote: CAN setpoints are allowed.

In Python

The canopen package (pip install canopen) handles the SDO protocol. It opens the adapter itself, so use it instead of the plain bus.

import canopen, struct, time

net = canopen.Network()
net.connect(interface="pcan", channel="PCAN_USBBUS1", bitrate=1000000)
node = net.add_node(10)                    # add_node(10, "exported.eds") also gives names

node.sdo.download(0x2309, 0, struct.pack("<I", 264))        # input_opt: UART + CAN
print(hex(struct.unpack("<H", node.sdo.upload(0x6041, 0))[0]))   # statusword

for cw in (0x06, 0x07, 0x0F):              # shutdown, switch on, enable operation
    net.send_message(0x20A, struct.pack("<Hh", cw, 0))
    time.sleep(0.05)
net.send_message(0x20A, struct.pack("<Hh", 0x0F, 1000))      # 1000 rpm
time.sleep(2)
net.send_message(0x20A, struct.pack("<Hh", 0x06, 0))         # back to ready to switch on
net.disconnect()

9. VESC

can_protocol = 9. A subset of the VESC CAN protocol, so VESC-compatible displays, dashboards and ECUs can command and monitor the controller.

At a glance

Selectcan_protocol = 9
IDs29-bit: packet << 8 | controller ID
Node IDThe VESC controller ID is can_node_id; the node also accepts the broadcast ID 0xFF
Byte orderBig-endian, as in VESC (the only big-endian protocol here)
SpeedMechanical rpm, not electrical rpm (ERPM) as on a real VESC: divide ERPM by the pole-pair count on the master side
SetpointsNeed input_opt bit 256; each one selects its own control mode
Command losscan_timeout (default 1000 ms) zeroes the CAN setpoints
TelemetrySTATUS, STATUS_4, STATUS_5 and STATUS_ERROR at can_status_hz (50 Hz)

Setting it up

  1. In the CAN view, set Protocol to VESC, the Baud Rate of your bus and the Node ID your display or ECU expects.
  2. Tick Enable CAN setpoints and choose a Timeout.
  3. If the master works in ERPM, convert to mechanical rpm, or scale it on the master.

Messages

PacketIDDirectionPayload
SET_DUTY (0)0x000nnto nodeint32, duty × 100000
SET_CURRENT (1)0x001nnto nodeint32, mA
SET_RPM (3)0x003nnto nodeint32, mechanical rpm
STATUS (9)0x009nnfrom node[0..3] int32 mechanical rpm
[4..5] int16 current × 10 (A, + motoring, - regen)
[6..7] int16 duty × 1000
STATUS_4 (16)0x010nnfrom node[0..1] MOSFET temperature × 10 °C
[2..3] motor temperature × 10 °C
[4..5] battery current × 10 A
[6..7] 0
STATUS_5 (27)0x01Bnnfrom nodeDLC 6: [0..3] 0 (no tachometer)
[4..5] bus voltage × 10 V
STATUS_ERROR (80, Dynamesys)0x050nnfrom node[0..3] u32 latched errors
[4..7] u32 every error since power-up, also cleared ones
Bit N-1 = error N (table)

Status frames are sent at can_status_hz (default 50 Hz). Other VESC packets (brake current, position, relative current, ping, buffer commands) are ignored. Loss of commands is handled by can_timeout.

On a bus with VESC devices, give every node a unique, pinned can_node_id. A node that picks its own ID only avoids other Dynamesys nodes, because VESCs send no presence announce.

Examples

Controller ID 10:

ID          DLC  Data (hex)                Meaning
0x0000010A  4    00 00 27 10               SET_CURRENT 10 A (10000 mA)
0x0000030A  4    00 00 05 DC               SET_RPM 1500 mechanical rpm
0x0000000A  4    00 00 61 A8               SET_DUTY 0.25 (25000)
0x0000090A  8    00 00 05 DC 00 64 00 FA   STATUS from node 10: 1500 rpm, 10.0 A, duty 0.250

Reading the frames

0x0000010A   = packet 0x01 (SET_CURRENT) << 8 | controller 0x0A
00 00 27 10  = 0x00002710 = 10000 mA = 10 A, highest byte first

STATUS  00 00 05 DC | 00 64 | 00 FA
        0x05DC = 1500 rpm | 0x0064 = 100 / 10 = 10.0 A | 0x00FA = 250 / 1000 = 0.250 duty

In Python

NODE = 10
SET_CURRENT, SET_RPM, STATUS = 1, 3, 9

# 10 A for 2 s, every 20 ms; note ">" (big-endian) in the format
task = bus.send_periodic(can.Message(arbitration_id=SET_CURRENT << 8 | NODE,
                                     data=struct.pack(">i", 10000), is_extended_id=True), 0.02)
time.sleep(2)
task.stop()
bus.send(can.Message(arbitration_id=SET_CURRENT << 8 | NODE, data=struct.pack(">i", 0),
                     is_extended_id=True))                              # back to 0 A

msg = bus.recv(1.0)
while msg is not None and msg.arbitration_id != (STATUS << 8 | NODE):
    msg = bus.recv(1.0)
if msg:
    rpm, amps, duty = struct.unpack(">ihh", msg.data)
    print(rpm, amps / 10, duty / 1000)

10. SAE J1939

can_protocol = 10. The controller behaves like a simple engine ECU: it takes speed or torque requests in TSC1 and reports EEC1, VEP1 and ET1.

At a glance

Selectcan_protocol = 10
IDs29-bit J1939: priority, PGN, (destination) and source address
AddressThe source address is can_node_id (1 to 127)
Byte orderLittle-endian; 0xFF means "not available"
SetpointsTSC1, 8 bytes, to our address or 0xFF; need input_opt bit 256
Command losscan_timeout (default 1000 ms) zeroes the CAN setpoints
TelemetryEEC1, VEP1 and ET1 at can_status_hz (50 Hz), priority 6
File≡ > CAN Exports > J1939 DBC File

Setting it up

  1. In the CAN view, set Protocol to J1939, the Baud Rate (J1939 buses usually run at 250 or 500 kbit/s) and the Node ID as the source address.
  2. Tick Enable CAN setpoints and choose a Timeout.
  3. On a network with other J1939 ECUs, set CAN_options to 0 (see Running next to any protocol).
  4. Send TSC1 periodically, faster than the timeout.

Messages

Received

PGNContentEffect
TSC1, 0 (to our address or 0xFF, any priority)
  • [0] bits 0-1 override mode;
  • [1..2] requested speed, 0.125 rpm/bit;
  • [3] requested torque, 1 %/bit, offset -125.
  • Mode 1: speed control (forward only).
  • Mode 2: torque control, % of par_i_max.
  • Mode 0: zero command.
  • Mode 3: ignored.
Request, 59904 (0xEA00)[0..2] requested PGNAnswers Address Claimed, EEC1, VEP1, ET1

Sent

Each frame is sent at can_status_hz with priority 6.

PGNIDContent
EEC1, 61444 (0xF004)0x18F004SA
  • [0] 0;
  • [1] driver demand torque and [2] actual torque, both Iq as % of par_i_max + 125;
  • [3..4] speed, 0.125 rpm/bit (mechanical);
  • [5] source address.
VEP1, 65271 (0xFEF7)0x18FEF7SA
  • [0] and [1] battery current, 1 A/bit + 125;
  • [2..3] and [6..7] bus voltage, 0.05 V/bit.
ET1, 65262 (0xFEEE)0x18FEEESA
  • [0] MOSFET temperature + 40 °C;
  • [2..3] motor temperature, 0.03125 °C/bit, offset -273;
  • [6] capacitor temperature + 40 °C.
Address Claimed, 609280x18EEFFSASent at start and on request; arbitrary address capable

The controller does not defend its address against other ECUs, and has no transport protocol or DM1 diagnostics. Use a unique address and CAN_options 0 on a shared J1939 network. Get a DBC from ≡ > CAN Exports > J1939 DBC File.

Examples

A service tool (address 0xFE) and the controller at address 0x0A. TSC1 must be 8 bytes; shorter frames are ignored.

ID          DLC  Data (hex)                Meaning
0x0C000AFE  8    01 E0 2E 7D FF FF FF FF   TSC1 to 0x0A: speed control, 1500 rpm
0x0C000AFE  8    02 00 00 9B FF FF FF FF   TSC1: torque control, 30 % of par_i_max
0x0C000AFE  8    00 00 00 7D FF FF FF FF   TSC1: override off, zero command
0x18EA0AFE  3    04 F0 00                  Request PGN 61444 (EEC1) from 0x0A
0x18F0040A  8    00 A5 A5 C0 5D 0A FF FF   EEC1 from 0x0A: torque 40 %, 3000 rpm

Reading the frames

0x0C000AFE
  bits 28-26  3      priority
  bits 25-24  0      reserved, data page
  bits 23-16  0x00   PDU format: TSC1 (below 240, so the next byte is a destination)
  bits 15-8   0x0A   destination address
  bits  7-0   0xFE   source address
0x18F0040A    priority 6, PGN 0xF004 (EEC1, a broadcast), source 0x0A

TSC1  01 | E0 2E | 7D | FF FF FF FF
      01     override mode 1: speed control
      E0 2E  0x2EE0 = 12000 x 0.125 rpm = 1500 rpm
      7D     125 - 125 = 0 % torque (not used in speed mode)
      FF     not available

EEC1  00 | A5 | A5 | C0 5D | 0A
      A5     0xA5 = 165 - 125 = 40 % of par_i_max (demand, then actual)
      C0 5D  0x5DC0 = 24000 x 0.125 rpm = 3000 rpm
      0A     controlling device: the node itself

In Python

SA, TOOL = 0x0A, 0xFE

def tsc1(mode, rpm=0, torque_pct=0):
    data = struct.pack("<BHB", mode, int(rpm / 0.125), torque_pct + 125) + b"\xff" * 4
    return can.Message(arbitration_id=3 << 26 | SA << 8 | TOOL, data=data, is_extended_id=True)

task = bus.send_periodic(tsc1(1, rpm=1500), 0.02)      # speed control, every 20 ms
time.sleep(3)
task.stop()
bus.send(tsc1(0))                                       # override off: zero command

11. DroneCAN

can_protocol = 4. DroneCAN (UAVCAN v0) ESC, for flight controllers such as ArduPilot and PX4.

At a glance

Selectcan_protocol = 4
IDs29-bit DroneCAN: priority, message type and source node
Node IDcan_node_id; no dynamic node ID allocation (runs as node 10 until an ID is set)
ESC numbercan_esc_index (0 to 19): which element of RawCommand and RPMCommand is ours
Byte orderLittle-endian, with fields bit-packed as the DSDL definitions specify
SetpointsAccepted from any node; need input_opt bit 256; RawCommand uses can_control_mode (0 torque by default)
Command losscan_timeout (default 1000 ms) zeroes the CAN setpoints
Telemetryesc.Status at can_status_hz (50 Hz), NodeStatus at 1 Hz

Setting it up

  1. In the CAN view, set Protocol to DroneCAN, the Baud Rate of the flight controller's CAN port (usually 1 Mbit/s) and a Node ID no other node uses.
  2. Set ESC Index to the ESC number the flight controller uses for this motor.
  3. Set CAN Mode: torque, speed or duty.
  4. Tick Enable CAN setpoints and choose a Timeout.
  5. On a bus with other DroneCAN nodes, set CAN_options to 0 (see Running next to any protocol).

Messages

MessageDirectionContent
esc.RawCommand (1030)to nodeElement can_esc_index, -8192..8191, gives -1..1 in the mode set by can_control_mode
esc.RPMCommand (1031)to nodeElement can_esc_index, mechanical rpm, speed mode
GetNodeInfo (service 1)request / responseName, firmware and hardware version
NodeStatus (341)from node, 1 HzUptime, health OK, mode operational
esc.Status (1034)from node, can_status_hz
  • Bus voltage, battery current;
  • MOSFET temperature in K;
  • mechanical rpm, ESC index.

Examples

A flight controller (node 127, priority 16) and the controller at node 10, can_esc_index 0:

ID          DLC  Data (hex)                Meaning
0x1004067F  3    00 40 C0                  RawCommand: ESC 0 at 4096 (+50 %)
0x1004067F  3    00 80 C1                  RawCommand: ESC 0 at -8192 (-100 %)
0x1004067F  8    00 40 01 00 04 00 10 C2   RawCommand: ESCs 0 to 3 all at 4096
0x1F01550A  8    64 00 00 00 00 00 00 C0   NodeStatus from node 10: uptime 100 s, healthy, operational

Reading the frames

0x1004067F
  bits 28-24  16       priority
  bits 23-8   0x0406   message type 1030 (esc.RawCommand)
  bit  7      0        a message, not a service
  bits 6-0    0x7F     source node 127

00 40 C0
  00 40   4096 as a 14-bit value: the low 8 bits in byte 0,
          the top 6 bits in bits 7..2 of byte 1 (0x10 << 2 = 0x40)
  C0      tail byte: start of transfer, end of transfer, transfer ID 0

64 00 00 00 | 00 | 00 00 | C0     NodeStatus
  uptime 0x00000064 = 100 s | health 0 (OK), mode 0 (operational) | vendor code 0 | tail

In Python

A single-frame RawCommand for ESC 0, packed by hand:

def raw_command(value, tid):                 # value -8192..8191, ESC 0 only
    v = value & 0x3FFF
    return can.Message(arbitration_id=16 << 24 | 1030 << 8 | 127,
                       data=bytes([v & 0xFF, (v >> 8) << 2, 0xC0 | tid & 0x1F]),
                       is_extended_id=True)

for tid in range(100):                       # +25 % for 2 s at 50 Hz
    bus.send(raw_command(2048, tid))
    time.sleep(0.02)
bus.send(raw_command(0, 100))

12. Custom

can_protocol = 5 selects a customer-specific protocol that is built into some firmware builds only. Its frames and byte order are described in the documentation supplied with that build. On a build without one, Custom switches CAN off. The presence announce, the tunnel and the status packets run next to a custom protocol as next to any other.

13. Workbench CAN exports

The Workbench writes description files for other CAN tools. Open ≡ > CAN Exports and pick a file type.

Menu itemFileDescribesUse with
CANopen EDS File.eds (CiA 306)The connected controller's full object dictionary: communication objects, PDOs, CiA 402 objects and every parameter at 0x2000 + id with its limitsCANopen masters and configuration tools
Dynamesys DBC, This Device.dbcDynamesys protocol commands and status packets of the selected controller, with its node ID, name and custom status slotsCAN analysers and loggers (BUSMASTER, SavvyCAN, PCAN-Explorer, CANalyzer, cantools)
Dynamesys DBC, Full Network.dbcThe same for every connected Dynamesys node, frames prefixed N<node>_As above, for a whole vehicle or machine
J1939 DBC File.dbcThe J1939 frames (EEC1, VEP1, ET1, TSC1) at the controller's source addressJ1939 tools and displays

14. Diagnostics

Text terminal commands

Run these on a controller's terminal (in the Workbench, or through can_attach):

Common problems

SymptomCheck
No devices found on the busPower, wiring, termination at both ends, the same bitrate on every device. A wrong bitrate looks like an empty bus.
Setpoints are ignored or answered with ERR 6input_opt bit 256; a running detection or update; an active error or E-STOP
Motor stops after one secondSetpoints are sent slower than can_timeout
Error 12 CAN bus collisionTwo devices share a node ID. See Node IDs.
A device moved to another node IDA clash was resolved (CAN_options 2 or 3). Pin IDs and use CAN_options 1 to prevent it.
Replies time out with two PCs connected, "another host took this CAN bus"Only one host per bus, and the last one to connect has it; disconnect the other Workbench or bridge
A lone controller on a PC adapter is not foundThe adapter must be active (not listen-only) so the controller's frames are acknowledged
Plots have gaps over CANFewer signals, a lower plot rate, or a higher bitrate. Some candleLight clones with old firmware drop frames; update their firmware.
Foreign devices misbehave next to Dynamesys controllersSet CAN_options 0 (see Running next to any protocol)

15. Reference tables

Error codes

In bit masks (STATE bytes 3..6, VESC STATUS_ERROR, CANopen EMCY bytes 3..6) error N is bit N-1.

NErrorNError
1-3Overcurrent phase U / V / W17-18ADC out of range, phase V / W
4Overvoltage19ADC out of range, bus voltage
5Undervoltage20Watchdog
6Hardware break input21Unbalanced currents
7-9MOSFET overtemperature U / V / W22Measurement failed
10Motor overtemperature23Detection failed
11Emergency stop24, 25Hall state 0 / 7
12CAN bus collision (node ID clash)26Encoder lost
13Temperature sensor open or shorted27Input out of range
14Memory fault28Startup failed
15Usage fault29App (for example Vehicle app in a mode other than current)
16ADC out of range, phase U30Capacitor overtemperature
31Control loop stall
32Position following error

Motor states

ValueStateValueState
0Initialising7Run
1Detecting8Measuring KV
2Align9Test
3Measuring10Error
4Open-loop start13Idle
5Open-loop transition15Motor detection
6Tracking (coasting, bridge off)16Firmware update

Active limits (HEALTH bytes 4..5)

BitLimitBitLimit
0x0001-0x0004MOSFET U / V / W temperature0x0200Speed ramp
0x0008Capacitor temperature0x0400Voltage limit
0x0010Motor temperature0x0800Iq maximum
0x0020Field weakening0x1000Battery regen limit
0x0040Battery power0x2000Id maximum
0x0080Battery current0x4000Overspeed
0x0100Speed limit0x8000Battery low

CAN parameters

NameIdDefaultMeaning
can_protocol0x04041Protocol, see Selecting a protocol
can_baudrate0x04050 (1 Mbit/s)Bitrate
can_node_id0x04060 (pick)Node ID
can_esc_index0x04070ESC number (DroneCAN)
can_timeout0x04081000 msSetpoint timeout (0 = off)
can_control_mode0x04090Mode for DroneCAN RawCommand
can_status_hz0x040A50 HzStatus rate (every protocol's telemetry)
can_status_slow_hz0x041B10 HzSlow status rate
can_status_mask0x041C0x1FFStatus frames on
CAN_options0x04153Dynamesys layers
can_tcount0x040ESignal: time left before the setpoint timeout, ms

Dynamesys Interfacing Guide for firmware 2.5.0. Parameter ids and limits for your exact firmware are in the Parameter Reference.