Repository navigation
Custom profiles
The bundled profiles are a start. Your own device is a YAML file: either a full description or — usually easier — a bundled profile with your changes on top.
profile: names the base, everything else overrides it. identity and model are
merged key by key; every other key replaces the base value.
# tank-sensor.yaml
# A level sensor on a generic I/O module: analog input 1 swings like a
# filling and emptying tank, input 2 is a noisy constant.
profile: generic-io
name: tank-sensor
description: Tank level sensor on a generic I/O module (analog input 1 = level)
identity:
vendor_id: 0x00001234
device_name: TANK-LEVEL-1
model:
loopback: false
signals:
ai1:
- {type: sine, offset: 16000, amplitude: 8000, period: 20}
ai2:
seed: 1
sources:
- {type: constant, value: 12000}
- {type: noise, sigma: 50}
objects:
- {index: 0x2000, name: Tank capacity litres, type: UNSIGNED16, access: rw, default: 5000, high: 20000}
limits:
- "level is a sine, not a hydraulic model"canopen-sim map tank-sensor.yaml --id 7 # check what you built
canopen-sim export-eds tank-sensor.yaml --id 7 -o tank.eds
canopen-sim serve --profile tank-sensor.yaml --id 7 --interface socketcan --channel vcan0In a bench, a node entry can point at the file (profile: tank-sensor.yaml, resolved
relative to the bench file) and override keys of its own, such as heartbeat_ms.
| key | what it is |
|---|---|
profile |
base profile: a bundled name or a YAML path |
name, description
|
shown by list, map and state
|
identity |
device_type, vendor_id, product_code, revision, serial, device_name (objects 0x1000, 0x1018, 0x1008) |
heartbeat_ms |
producer heartbeat time (0x1017); 0 switches it off |
model |
the behaviour: type: drive, io or encoder with its parameters (below) |
tpdos, rpdos
|
default PDOs: number (0 = PDO 1), mapping ("0x6041:0/16" = index:sub/bits), transmission_type, event_timer_ms, inhibit_100us, enabled
|
objects |
extra manufacturer objects in 0x2000–0x5FFF: index, sub, name, type, access (ro, wo, rw, const), default, low, high, pdo (mappable) |
sources, limits
|
what the profile follows and what it does not do; shown by map
|
Data types are the CANopen names: BOOLEAN, INTEGER8 … INTEGER64, UNSIGNED8 …
UNSIGNED64, REAL32, REAL64, VISIBLE_STRING, OCTET_STRING (default as hex).
Unknown keys are an error, not ignored, so a typo does not go unnoticed.
| model | parameters (default) |
|---|---|
drive |
max_velocity (3000), acceleration (1000), deceleration (1000), following_error_window (1000), temperature_limit (80.0) |
io |
digital_inputs (8), digital_outputs (8), analog_inputs (2), analog_outputs (2), loopback (true), signals
|
encoder |
resolution (4096 steps per revolution), multiturn (true), speed_rpm (0.0) |
An I/O input without loopback can follow a signal. Keys are the channels, di1 …
and ai1 … (1-based); each takes a list of sources that are added up:
| source | parameters |
|---|---|
constant |
value |
ramp |
start, stop, period (seconds; jumps back to start) |
sine |
offset, amplitude, period (seconds) |
noise |
sigma (Gaussian) |
Give seed next to sources (as for ai2 above) and the noise is the same in every
run — useful when a test compares values. An injected fault (wire_break,
short_circuit, over_range) wins over the signal until it is cleared.
Write into sources which manual or document the object set comes from, and into
limits what the simulation does not do. canopen-sim map shows both, so whoever uses
your profile knows how far to trust it. Do not copy text or tables from CiA documents
into a profile you publish; they are not freely licensed.
canopen-sim · MIT licensed · CANopen® and CiA® are registered trademarks of CAN in Automation (CiA) e.V.; canopen-sim is not certified by or affiliated with CiA.