Master/Slave State Machine

Scope

The native master/slave state machine is the preferred way to coordinate synchronized virtual/physical systems.

Use it when:

  • one axis group should act as the master set
  • another axis group should follow as the slave set
  • only one side should accept commands at a time
  • you want a native ecmc object instead of PLC-side state-machine logic

Typical examples are slit and mirror systems with virtual master axes and physical slave axes.

Startup Script

Use the wrapper script:

${SCRIPTEXEC} ${ecmccfg_DIR}addMasterSlaveSM.cmd \
  "NAME=Slit_SM, MST_GRP_NAME=virtualAxes, SLV_GRP_NAME=realAxes"

Arguments:

  • NAME: object name shown in PVs and overviews
  • MST_GRP_NAME: master-group name, normally the virtual axes
  • SLV_GRP_NAME: slave-group name, normally the physical axes
  • MST_DISABLE (optional): auto-disable master axes when not busy
  • SLV_DISABLE (optional): auto-disable slave axes when not busy

If you want full control from each axis YAML instead, leave MST_DISABLE and SLV_DISABLE at 0 and configure axis.autoEnable per axis.

Runtime PVs

For state machine 0, the main PVs are:

  • $(IOC):SM00-EnaCmd
  • $(IOC):SM00-StateCmd
  • $(IOC):SM00-Stat
  • $(IOC):SM00-MstsAutoDsbleCmd
  • $(IOC):SM00-SlvsAutoDsbleCmd
  • $(IOC):SM00-DbgPrntEna
  • $(IOC):SM00-MstGrpNam
  • $(IOC):SM00-SlvGrpNam

StateCmd supports these states:

  • IDLE
  • SLAVE
  • MASTER
  • RESET

The exact transition behavior depends on the object state and the involved axes, but in normal use the state machine decides which group should currently drive the synchronized system.

Object List And Overview Support

Master/slave objects are also exposed through the standard linked-list summary PVs:

  • $(IOC):MCU-Cfg-SM-FrstObjId
  • $(IOC):MCU-Cfg-SM<n>-NxtObjId
  • $(IOC):MCU-Cfg-SM<n>-PrvObjId

These are primarily used by overview panels and object-browser tooling.

  1. Define the synchronized axes in two axis groups, typically one virtual and one physical group.
  2. Create one master/slave state machine with addMasterSlaveSM.cmd.
  3. Send commands only through the active side of the system.
  4. If a slave axis enters limit, interlock, or error, resolve that axis problem first and then reset/recover the state machine.

For most new systems, this is preferable to keeping equivalent switching logic in PLC code.