ECMC runs inside an EPICS IOC process. EPICS records expose commands and
readbacks to clients; the ECMC realtime thread executes motion and logic at
the configured EC_RATE. ecmccfg supplies the scripts, templates and YAML
loading that build this configuration during startup.
Solid connections show the runtime layers; commands travel toward the hardware and state/feedback returns toward the clients. Dashed arrows show startup configuration. The diagram groups responsibilities rather than showing the execution order of every function.
The motor record and normal EPICS record processing run outside the ECMC
realtime cycle. Requests pass into the engine, and state is published back to
EPICS. PV update rates can therefore differ from EC_RATE. Encoder filters,
trajectory generation, monitoring and the configured cyclic logic execute in
the engine; the position-control loop can run in ECMC or in the drive,
depending on drive mode.
With SIM=1, memory I/O replaces the physical EtherCAT path. A separate model
or injected values supply feedback; the motor dynamics are not generated by
the backend itself. With MASTER_ID=-1, no EtherCAT master is claimed, which
is useful for virtual axes and logic without bus hardware.
require ecmccfg loads ECMC and prepares the asyn port, selected I/O backend
and cycle rate.addSlave.cmd declares hardware and process-data mappings and loads slave
PVs. applyComponent.cmd applies motor, encoder or other device settings.loadYamlAxis.cmd and the PLC loaders validate and render YAML into
configuration commands and record loading. These create the runtime objects
and link them to I/O entries.finalize.cmd / setAppMode.cmd validate the configuration and start ECMC
runtime. iocInit initializes EPICS records and completes IOC startup.
Their relative order follows
START_EPICS_FIRST; scalar SDORT objects
automatically select EPICS first so autosave can restore before activation.
Motion readiness is
controlled by the startup gate.startup.cmd takes the following arguments:
Arguments
[optional]
ECMC_VER = 11.1.1 (default in startup.cmd; override for your installation)
EthercatMC_VER = 3.0.2 (obsolete)
INIT = initAll
MASTER_ID = 0 <-- put negative number to disable master, aka non ec-mode
SIM = 0/1, default 0. Use typed memory I/O instead of physical EtherCAT
SCRIPTEXEC = iocshLoad
NAMING = mXsXXX (default), ClassicNaming, ESSnaming
EC_RATE = 1000
MODE = FULL / DAQ / NO_MR
FULL: Init ecmc with support for both motion and DAQ (DEFAULT)
DAQ: Init ecmc with support for only daq (not motion)
NO_MR: Init ecmc with support for motion (without motor record) and DAQ
PVA = YES / NO
TMP_DIR = directory for temporary files
ENG_MODE = 1/0. If ENG_MODE is set then PVs used for commissioning will be available
EC_TOOL_PATH = Path to ethercat tool defaults to ethercat tool in ECmasterECMC_DIR,
otherwise "/opt/etherlab/bin/ethercat"
MAX_PARAM_COUNT = Maximum asyn param count, defaults to 1675
ECMC_ASYN_PORT_MAX_PARAMS = Explicit capacity override; takes precedence over MAX_PARAM_COUNT
ECMC_ASYN_TRACE_MASK = asyn trace mask for the main ecmc asyn port, defaults to 0x1
ECMC_STARTUP_GATE = 1/0, default 0. Set explicitly to 1 to hold motion until complete
native-axis and loaded motor-record startup.
START_EPICS_FIRST = 1/0, default 0. Start EPICS records before ECMC runtime
and EtherCAT when set to 1. Scalar SDORT objects also
select this order automatically, even when this is 0.
[set by module]
ECMC_CONFIG_ROOT = root directory of ${MODULE}
ECMC_CONFIG_DB = database directory of ${MODULE}
EthercatMC_DB = database directory of EthercatMC
ECMC_EC_MASTER_ID = EtherCAT master id in use (for use in later scripts)
ECMC_EC_SAMPLE_RATE = EtherCAT bus sampling rate [Hz] (1000 default)
ECMC_EC_SAMPLE_RATE_MS = EtherCAT bus sampling rate [ms] (1 default)
ECMC_MODE = ecmc mode. FULL/DAQ, Defaults to FULL
ECMC_PVA = use pva, default NO
ECMC_SUPPORT_MOTION = Variable to be used to block use of motion (""/empty=support motion or "#-"=disable motion)
ECMC_TMP_DIR = directory for temporary files, defaults to "/tmp/${IOC}/EcMaster_${ECMC_EC_MASTER_ID}}/"
ECMC_EC_TOOL_PATH = path to ethercat tool
ECMC_SAMPLE_RATE_MS = current record update rate in milliseconds
ECMC_SAMPLE_RATE_MS_ORIGINAL = ECMC_SAMPLE_RATE_MS (used for restore to default if ECMC_SAMPLE_RATE_MS is changed)
Normally these arguments are set when the module is required:
require ecmccfg "ENG_MODE=1,MASTER_ID=2"
Use require ecmccfg "MASTER_ID=0,SIM=1,EC_RATE=1000" to select the memory
backend before slave configuration. SIM=0 is the default; MASTER_ID=-1
retains masterless behavior. Feedback comes from separate models or PV writes.
See Simulation backend (SIM=1)
for generated SIM PVs, Python models, GUI controls and limitations.
The main ecmc asyn port trace mask is set in initAll.cmd:
asynSetTraceMask(${ECMC_ASYN_PORT}, -1, ${ECMC_ASYN_TRACE_MASK=0x1})
The asynSetTraceMask(...) command above can also be copied and executed
directly in iocsh to change the trace mask for a running IOC.
The default value is 0x1. To revert to the old, more verbose asyn trace
information, set ECMC_ASYN_TRACE_MASK when loading ecmccfg:
require ecmccfg "ECMC_ASYN_TRACE_MASK=0x41"
Without scalar SDORT objects, the default, START_EPICS_FIRST=0, preserves the
traditional startup order: ECMC enters runtime and starts EtherCAT before
iocInit completes. Configuring scalar SDORT objects automatically selects
EPICS first, as described below.
| Scalar SDORT objects configured | START_EPICS_FIRST | Effective order |
|---|---|---|
| No | 0 (default) | ECMC/EtherCAT first |
| No | 1 | EPICS first |
| Yes | 0 or 1 | EPICS first, automatically |
Set START_EPICS_FIRST=1 when EPICS records must be initialized before ECMC
runtime and EtherCAT start:
require ecmccfg "START_EPICS_FIRST=1"
In this mode, startup.cmd allows iocInit to reach the IOC-running state and
then schedules ECMC startup asynchronously. The worker waits for
ECMC_EC_STABILIZATION_TIME seconds (default 2) before executing
Cfg.SetAppMode(1).
This ordering can be useful with EPICS autosave. It gives autosave restore and record/device-support initialization an opportunity to apply restored PV values before the realtime thread and EtherCAT bus start. For example:
require ecmccfg "START_EPICS_FIRST=1,ECMC_EC_STABILIZATION_TIME=5"
The delay is a time window, not a completion handshake with autosave. Select a
delay long enough for the IOC’s restore workload and verify the startup log and
restored values. For ECMC builds with the complete motor-record startup gate,
set ECMC_STARTUP_GATE=1 to hold cyclic motion producers until the motor
handshake completes; do not rely on the fixed delay alone. Older builds need
an explicit restore-complete mechanism for this guarantee.
PLCs can use epics_get_started(), ec_get_started(), and
system_get_started() to inspect startup readiness. See
PLC functions.
Loading a scalar SDO through addEcSdoRT.cmd (BYTE_SIZE omitted or 0)
automatically defers ECMC runtime and master activation until after EPICS
initialization. This applies even when no saved value exists or
WRITE_ON_VAL=0. There is no separate startup mode or additional flag to select.
Static EcAddSdo* settings alone and byte-array SDORT objects do not trigger
this automatic ordering.
The sequence is:
StartupData_ waveforms in autosave pass 1.
The driver collects valid saved requests through its initialization hook.ECMC_STARTUP_GATE controls motion readiness; it does not select which starts
first. Pending startup SDOs enforce the verification/readiness hold even with
ECMC_STARTUP_GATE=0. With no pending SDOs, setting it to 1 still enables the
general axis/motor-record startup gate described below.
See scalar SDO startup restore
for the request file, manual Val/WrtCmd interface and WRITE_ON_VAL option.
Set ECMC_STARTUP_GATE=1 before setAppMode.cmd/finalize.cmd runs. With
matching ECMC startup-restore support, the gate waits for IOC readiness, bus
stabilization, native axis initialization, and startup of each loaded motor
record, including any requested position load and its RT acknowledgement.
Axes with no loaded motor record have no motor-record handshake to wait for.
Ordinary PLC/plugin cyclic execution and other motion producers stay held,
drives stay disabled, and early execute/enable commands are rejected. STOP,
disable, coordinate loading and status polling remain available. The dedicated
safety plugin and bus I/O continue; configuration/enter-RT initialization hooks
still prepare runtime, with their supported motion requests held as well.
Gate 0 selects legacy startup when there are no pending startup SDOs; pending
SDO verification still enforces the startup hold.
See motor position and soft-limit autosave for the restore configuration and the narrow startup COMM-alarm workaround.
When EtherCAT startup fails with messages like Max wait time 30 second(s),
increase the maximum EtherCAT startup wait using the EC_TIMEOUT startup
parameter. The value is in seconds and defaults to 45 seconds in ecmccfg:
require ecmccfg "EC_TIMEOUT=100"
startup.cmd applies this parameter with
Cfg.SetEcStartupTimeout(${EC_TIMEOUT=45}). The underlying ecmc default is
30 seconds when no timeout is explicitly configured.
You can also override the timeout after loading ecmccfg, before ecmc enters
runtime:
ecmcConfigOrDie "Cfg.SetEcStartupTimeout(100)"
Place the command after require ecmccfg or startup.cmd has loaded ecmc,
but before setAppMode.cmd or finalize.cmd starts runtime. In the normal
startup flow, this means before iocInit, because finalize.cmd is typically
registered to run at init.
This is different from ECMC_EC_STARTUP_DELAY. That macro is used by
setAppMode.cmd for Cfg.EcSetDelayECOkAtStartup(...) and controls a startup
delay/minimum wait, not the maximum OP-state timeout.
MASTER_ID=-1Setting MASTER_ID=-1 starts ecmc without claiming an EtherCAT master.
This is the supported master-less or non-EtherCAT mode.
Typical use cases:
Example:
require ecmccfg "MASTER_ID=-1,ENG_MODE=1"
In this mode, EtherCAT-dependent hardware setup scripts such as addSlave.cmd
are normally not used, but other parts of ecmc still work, for example:
loadPLCFile.cmd or loadYamlPlc.cmdaddDataStorage.cmdecmc needs to be started with root privileges (or with a user in the realtime group), otherwise ecmc might segfault.
FULL, DAQ, NO_MR, and ENG_MODE.