Motion Master 6.0.0-alpha.86
Next-generation motion control software
Loading...
Searching...
No Matches
mm::node::cia402 Namespace Reference

Namespaces

namespace  objects
 

Classes

struct  FsaTransition
 The next step of a walk toward a target state. More...
 
struct  StandardOperationMode
 One row of the standard operation-mode table — a mode, the 0x6502 bit that advertises it, and the two names the profile gives it. More...
 

Enumerations

enum  Object : uint16_t {
  kErrorCode = 0x603F , kControlword = 0x6040 , kStatusword = 0x6041 , kQuickStopOptionCode = 0x605A ,
  kModeOfOperation = 0x6060 , kModeOfOperationDisplay = 0x6061 , kPositionDemandValue = 0x6062 , kPositionActualValue = 0x6064 ,
  kFollowingErrorWindow = 0x6065 , kFollowingErrorTimeout = 0x6066 , kPositionWindow = 0x6067 , kPositionWindowTime = 0x6068 ,
  kVelocityDemandValue = 0x606B , kVelocityActualValue = 0x606C , kVelocityWindow = 0x606D , kVelocityWindowTime = 0x606E ,
  kVelocityThreshold = 0x606F , kVelocityThresholdTime = 0x6070 , kTargetTorque = 0x6071 , kMaxTorque = 0x6072 ,
  kMaxCurrent = 0x6073 , kTorqueDemand = 0x6074 , kMotorRatedCurrent = 0x6075 , kMotorRatedTorque = 0x6076 ,
  kTorqueActualValue = 0x6077 , kDcLinkCircuitVoltage = 0x6079 , kTargetPosition = 0x607A , kPositionRangeLimit = 0x607B ,
  kHomeOffset = 0x607C , kSoftwarePositionLimit = 0x607D , kPolarity = 0x607E , kMaxMotorSpeed = 0x6080 ,
  kProfileVelocity = 0x6081 , kProfileAcceleration = 0x6083 , kProfileDeceleration = 0x6084 , kQuickStopDeceleration = 0x6085 ,
  kMotionProfileType = 0x6086 , kTorqueSlope = 0x6087 , kTorqueProfileType = 0x6088 , kGearRatio = 0x6091 ,
  kFeedConstant = 0x6092 , kHomingMethod = 0x6098 , kHomingSpeeds = 0x6099 , kHomingAcceleration = 0x609A ,
  kSiUnitVelocity = 0x60A9 , kVelocityOffset = 0x60B1 , kTorqueOffset = 0x60B2 , kTouchProbeFunction = 0x60B8 ,
  kTouchProbeStatus = 0x60B9 , kTouchProbe1PositiveEdge = 0x60BA , kTouchProbe1NegativeEdge = 0x60BB , kTouchProbeTimeStamp1PositiveValue = 0x60D1 ,
  kTouchProbeTimeStamp1NegativeValue = 0x60D2 , kPositioningOptionCode = 0x60F2 , kFollowingErrorActualValue = 0x60F4 , kControlEffort = 0x60FA ,
  kPositionDemandInternalValue = 0x60FC , kDigitalInputs = 0x60FD , kDigitalOutputs = 0x60FE , kTargetVelocity = 0x60FF ,
  kSupportedDriveModes = 0x6502
}
 Standard CiA402 object dictionary indices used by the drive profile, ordered by index. More...
 
enum class  OperationMode : int8_t {
  kNoMode = 0 , kProfilePosition = 1 , kVelocity = 2 , kProfileVelocity = 3 ,
  kProfileTorque = 4 , kHoming = 6 , kInterpolatedPosition = 7 , kCyclicSyncPosition = 8 ,
  kCyclicSyncVelocity = 9 , kCyclicSyncTorque = 10 , kCyclicSyncTorqueCommutationAngle = 11
}
 CiA402 operation modes (object 0x6060 / 0x6061 values). More...
 
enum class  State : uint8_t {
  kNotReadyToSwitchOn , kSwitchOnDisabled , kReadyToSwitchOn , kSwitchedOn ,
  kOperationEnabled , kQuickStopActive , kFaultReactionActive , kFault
}
 States of the CiA402 device control state machine (decoded from the statusword). More...
 
enum  Command : uint16_t {
  kCmdShutdown = 0x0006 , kCmdSwitchOn = 0x0007 , kCmdEnableOperation = 0x000F , kCmdDisableVoltage = 0x0000 ,
  kCmdQuickStop = 0x0002 , kCmdFaultReset = 0x0080
}
 Canonical controlword command-bit patterns (the value of the bits in kCommandMask). More...
 
enum class  FsaAction : uint8_t { kArrived , kCommand , kWait , kUnreachable }
 What a master should do next, having observed one state and wanting another. More...
 

Functions

constexpr std::optional< OperationModetoOperationMode (int value)
 Maps a raw mode value (as written to 0x6060 / read from 0x6061) to a known operation mode. Rejects values outside the standard set so an API boundary can 400 an unknown mode.
 
constexpr State decodeState (uint16_t statusword)
 Decodes the CiA402 state machine state from a statusword (0x6041) value.
 
constexpr bool isFaulted (uint16_t statusword)
 Whether the statusword's fault bit (bit 3) is set, gated to the faulted states.
 
constexpr std::string_view toString (State state)
 Human-readable name of a state (for logging / JSON). Never returns nullptr.
 
constexpr std::string_view toString (OperationMode mode)
 Human-readable name of an operation mode (for logging / JSON). Never nullptr.
 
constexpr bool quickStopHolds (int16_t optionCode)
 Whether a quick stop configured with optionCode leaves the drive in Quick Stop Active, or passes through it into Switch On Disabled.
 
constexpr std::optional< StateparseState (std::string_view token)
 Parses a state name as toString spells it. std::nullopt for anything else.
 
constexpr bool isCommandableState (State state)
 Whether a master can ask a drive to reach state.
 
constexpr FsaTransition nextFsaTransition (State from, State target, bool allowQuickStopOverride)
 One step of the walk from from toward target — the CiA402 state machine as a next-hop table.
 

Variables

constexpr uint16_t kCommandMask = 0x008F
 Controlword (0x6040) command-bit mask — the state-machine bits a transition touches.
 
constexpr StandardOperationMode kStandardOperationModes []
 Every standard operation mode, with its 0x6502 bit — ETG.6010 §6.8.1, Figure 15.
 
constexpr int kFirstManufacturerDriveModeBit = 16
 The first bit of 0x6502 that the profile leaves to the vendor (ETG.6010 Figure 15).
 

Enumeration Type Documentation

◆ Command

enum mm::node::cia402::Command : uint16_t

Canonical controlword command-bit patterns (the value of the bits in kCommandMask).

Enumerator
kCmdShutdown 

→ ReadyToSwitchOn (enable voltage + no quick stop).

kCmdSwitchOn 

→ SwitchedOn (also "disable operation" from OperationEnabled).

kCmdEnableOperation 

→ OperationEnabled.

kCmdDisableVoltage 

→ SwitchOnDisabled.

kCmdQuickStop 

→ QuickStopActive.

kCmdFaultReset 

Rising edge of bit 7 clears a fault.

◆ FsaAction

enum class mm::node::cia402::FsaAction : uint8_t
strong

What a master should do next, having observed one state and wanting another.

Enumerator
kArrived 

Already there; nothing to issue.

kCommand 

Issue FsaTransition::command and look again.

kWait 

The drive is mid-transition on its own; issue nothing and look again.

kUnreachable 

No path exists — only when the target is not a isCommandableState, or when a quick stop must be overridden and the caller did not permit it.

◆ Object

enum mm::node::cia402::Object : uint16_t

Standard CiA402 object dictionary indices used by the drive profile, ordered by index.

Simple VAR objects are addressed at subindex 0; the two-element ARRAY objects (0x607B, 0x607D, 0x6091, 0x6092, 0x6099, 0x60FE) at sub-entries 1..2.

Enumerator
kErrorCode 

UNSIGNED16, ro, TxPDO — code of the last drive fault.

kControlword 

UNSIGNED16, rw, RxPDO — commands the state machine.

kStatusword 

UNSIGNED16, ro, TxPDO — reports the state machine.

kQuickStopOptionCode 

INTEGER16, rw — reaction to a quick stop.

kModeOfOperation 

INTEGER8, rw, RxPDO — requested operation mode.

kModeOfOperationDisplay 

INTEGER8, ro, TxPDO — active operation mode.

kPositionDemandValue 

INTEGER32, ro, TxPDO — trajectory generator demand.

kPositionActualValue 

INTEGER32, ro, TxPDO — actual position.

kFollowingErrorWindow 

UNSIGNED32, rw, RxPDO — max tolerated following error.

kFollowingErrorTimeout 

UNSIGNED16, rw, RxPDO — ms outside window before fault.

kPositionWindow 

UNSIGNED32, rw, RxPDO — target-reached position window.

kPositionWindowTime 

UNSIGNED16, rw, RxPDO — ms in window for target reached.

kVelocityDemandValue 

INTEGER32, ro, TxPDO — ramp generator demand.

kVelocityActualValue 

INTEGER32, ro, TxPDO — actual velocity.

kVelocityWindow 

UNSIGNED16, rw, RxPDO — target-reached velocity window.

kVelocityWindowTime 

UNSIGNED16, rw, RxPDO — ms in window for target reached.

kVelocityThreshold 

UNSIGNED16, rw, RxPDO — standstill velocity threshold.

kVelocityThresholdTime 

UNSIGNED16, rw, RxPDO — ms below threshold = standstill.

kTargetTorque 

INTEGER16, rw, RxPDO — CST/PT setpoint (per-mille).

kMaxTorque 

UNSIGNED16, rw, RxPDO — torque limit (per-mille).

kMaxCurrent 

UNSIGNED16, rw, RxPDO — current limit (per-mille).

kTorqueDemand 

INTEGER16, ro, TxPDO — control loop torque demand.

kMotorRatedCurrent 

UNSIGNED32, rw — motor rated current (mA).

kMotorRatedTorque 

UNSIGNED32, rw — motor rated torque (mNm).

kTorqueActualValue 

INTEGER16, ro, TxPDO — actual torque.

kDcLinkCircuitVoltage 

UNSIGNED32, ro, TxPDO — DC bus voltage (mV).

kTargetPosition 

INTEGER32, rw, RxPDO — CSP/PP setpoint.

kPositionRangeLimit 

2×INTEGER32, rw — position wrap range (min/max).

kHomeOffset 

INTEGER32, rw, RxPDO — home offset from machine zero.

kSoftwarePositionLimit 

2×INTEGER32, rw — software end stops (min/max).

kPolarity 

UNSIGNED8, rw, RxPDO — position/velocity polarity bits.

kMaxMotorSpeed 

UNSIGNED32, rw, RxPDO — motor speed limit.

kProfileVelocity 

UNSIGNED32, rw, RxPDO — PP cruise velocity.

kProfileAcceleration 

UNSIGNED32, rw, RxPDO — profile acceleration.

kProfileDeceleration 

UNSIGNED32, rw, RxPDO — profile deceleration.

kQuickStopDeceleration 

UNSIGNED32, rw, RxPDO — deceleration on quick stop.

kMotionProfileType 

INTEGER16, rw, RxPDO — trajectory shape.

kTorqueSlope 

UNSIGNED32, rw, RxPDO — PT torque ramp rate.

kTorqueProfileType 

INTEGER16, rw, RxPDO — torque trajectory shape.

kGearRatio 

2×UNSIGNED32, rw — motor/shaft revolutions.

kFeedConstant 

2×UNSIGNED32, rw — feed per shaft revolutions.

kHomingMethod 

INTEGER8, rw, RxPDO — homing method number.

kHomingSpeeds 

2×UNSIGNED32, rw — switch/zero search speeds.

kHomingAcceleration 

UNSIGNED32, rw, RxPDO — homing acceleration.

kSiUnitVelocity 

UNSIGNED32, rw — SI unit code of velocity objects.

kVelocityOffset 

INTEGER32, rw, RxPDO — CSP/CSV velocity feed-forward.

kTorqueOffset 

INTEGER16, rw, RxPDO — torque feed-forward.

kTouchProbeFunction 

UNSIGNED16, rw, RxPDO — touch probe arm/config bits.

kTouchProbeStatus 

UNSIGNED16, ro, TxPDO — touch probe latch status.

kTouchProbe1PositiveEdge 

INTEGER32, ro, TxPDO — position at probe 1 rising edge.

kTouchProbe1NegativeEdge 

INTEGER32, ro, TxPDO — position at probe 1 falling edge.

kTouchProbeTimeStamp1PositiveValue 

UNSIGNED32, ro, TxPDO — time stamp at probe 1 rising edge.

kTouchProbeTimeStamp1NegativeValue 

UNSIGNED32, ro, TxPDO — time stamp at probe 1 falling edge.

kPositioningOptionCode 

UNSIGNED16, rw, PDO — PP positioning options.

kFollowingErrorActualValue 

INTEGER32, ro, TxPDO — live following error.

kControlEffort 

INTEGER32, ro, TxPDO — position loop output.

kPositionDemandInternalValue 

INTEGER32, ro, TxPDO — demand in internal increments.

kDigitalInputs 

UNSIGNED32, ro, TxPDO — digital input bit field.

kDigitalOutputs 

2×UNSIGNED32, rw — physical outputs + enable mask.

kTargetVelocity 

INTEGER32, rw, RxPDO — CSV/PV setpoint.

kSupportedDriveModes 

UNSIGNED32, ro — capability bit field of supported modes.

◆ OperationMode

enum class mm::node::cia402::OperationMode : int8_t
strong

CiA402 operation modes (object 0x6060 / 0x6061 values).

Every mode the profile defines, whether or not this codebase can drive one: the set is what a device's 0x6502 capability field is read against, so a mode missing here would be a supported mode nothing could name. Mode 5 is absent because the profile reserves it — there is no mode 5. Vendors define their own modes in the negative half, which is a manufacturer vocabulary and therefore lives with the vendor (somanet::OperationMode), not here.

Enumerator
kNoMode 

No mode assigned. Always legal; has no 0x6502 bit.

kProfilePosition 

PP — trapezoidal point-to-point positioning.

kVelocity 

VL — the frequency-converter velocity mode.

kProfileVelocity 

PV — profiled velocity.

kProfileTorque 

PT — profiled torque.

kHoming 

HM — reference/homing run.

kInterpolatedPosition 

IP — interpolated position.

kCyclicSyncPosition 

CSP — cyclic position (the common SOMANET mode).

kCyclicSyncVelocity 

CSV — cyclic velocity.

kCyclicSyncTorque 

CST — cyclic torque.

kCyclicSyncTorqueCommutationAngle 

CSTCA — cyclic torque with commutation angle.

◆ State

enum class mm::node::cia402::State : uint8_t
strong

States of the CiA402 device control state machine (decoded from the statusword).

Enumerator
kNotReadyToSwitchOn 

Drive initialising; no clear state yet.

kSwitchOnDisabled 

Powered, holding; the resting state after init.

kReadyToSwitchOn 

Shutdown command accepted.

kSwitchedOn 

Switch-on command accepted; power stage on, no motion.

kOperationEnabled 

Fully enabled; setpoints are followed.

kQuickStopActive 

Quick stop in progress.

kFaultReactionActive 

A fault is being reacted to (e.g. controlled stop).

kFault 

Faulted and stopped; needs a fault reset.

Function Documentation

◆ decodeState()

constexpr State mm::node::cia402::decodeState ( uint16_t  statusword)
constexpr

Decodes the CiA402 state machine state from a statusword (0x6041) value.

Pure function of the statusword's defined bits; uses the ETG.6010 mask/match table. An unrecognised pattern maps to State::kNotReadyToSwitchOn (the "no clear state" bucket).

◆ isCommandableState()

constexpr bool mm::node::cia402::isCommandableState ( State  state)
constexpr

Whether a master can ask a drive to reach state.

Three of the eight cannot be asked for, and each for its own reason: kNotReadyToSwitchOn and kFaultReactionActive are passed through automatically by the drive and have no command that enters them, and kFault is entered by something going wrong rather than by being requested.

◆ isFaulted()

constexpr bool mm::node::cia402::isFaulted ( uint16_t  statusword)
constexpr

Whether the statusword's fault bit (bit 3) is set, gated to the faulted states.

◆ nextFsaTransition()

constexpr FsaTransition mm::node::cia402::nextFsaTransition ( State  from,
State  target,
bool  allowQuickStopOverride 
)
constexpr

One step of the walk from from toward target — the CiA402 state machine as a next-hop table.

A table rather than a search, because the graph is eight states and fits on a page, and because the interesting part is not the pathfinding but the handful of states that behave unlike the rest. Iterating it is what produces a multi-hop walk: each call answers only "what now", so a caller re-reads the drive between steps and never assumes a command took effect.

The graph is ETG.6010 §5.1 Figure 2, checked against the SOMANET firmware's own get_next_state. Four rows are worth knowing:

  • kFault — every target begins with a fault reset, which reaches kSwitchOnDisabled (transition 15) and only if the cause is gone; the firmware refuses while the error is still reported, so a caller must not read a reset as progress.
  • kFaultReactionActive and kNotReadyToSwitchOn — no command enters or leaves them; the drive moves on by itself (transitions 14 and 1), so the answer is to wait.
  • kQuickStopActive — leaving downward is kCmdDisableVoltage (transition 12), and leaving upward to kOperationEnabled is transition 16, which IEC 61800-7-201 calls not recommended and this firmware implements as "forced". It is offered only when allowQuickStopOverride, so that overriding a deliberate stop is a decision a caller makes rather than a side effect of asking to be enabled.
  • **kReadyToSwitchOnkSwitchedOn** uses kCmdSwitchOn rather than the combined kCmdEnableOperation that ETG.6010 permits: the firmware answers both by moving one state, so the plain command reaches the same place while leaving the intermediate state observable.
Parameters
fromThe state just read from the drive.
targetWhere the caller wants it. See isCommandableState.
allowQuickStopOverrideWhether transition 16 may be used.

◆ parseState()

constexpr std::optional< State > mm::node::cia402::parseState ( std::string_view  token)
constexpr

Parses a state name as toString spells it. std::nullopt for anything else.

◆ quickStopHolds()

constexpr bool mm::node::cia402::quickStopHolds ( int16_t  optionCode)
constexpr

Whether a quick stop configured with optionCode leaves the drive in Quick Stop Active, or passes through it into Switch On Disabled.

The distinction is why targeting Quick Stop Active is not simply "issue quick stop and wait". The profile's codes 0-4 all end the quick stop in Switch On Disabled — 0 disables the drive outright and 1-4 ramp down first — so on a drive configured that way Quick Stop Active is a state it passes through, sometimes for microseconds. Codes 5-8 ramp down the same ways but stay there. Only that 5-8 band holds, which is what this answers.

A vendor may define values above 8, and one that does need not hold. SOMANET implements a sparse subset — 0, 2, 6 and 9 — of which 9 is its own: "transit into active short circuit and then into switch on disabled", so it passes through like 0 and 2 while shorting the motor phases on the way. It is outside the holding band and therefore already answered correctly, but the reason is that the band is closed, not that unknown values default to passing through.

Values this function cannot place are treated as passing through for a separate reason: a caller told the drive landed somewhere else recovers, where one waiting for a state that never comes only times out.

◆ toOperationMode()

constexpr std::optional< OperationMode > mm::node::cia402::toOperationMode ( int  value)
constexpr

Maps a raw mode value (as written to 0x6060 / read from 0x6061) to a known operation mode. Rejects values outside the standard set so an API boundary can 400 an unknown mode.

Returns
The mode, or std::nullopt if value is not a recognised operation mode.

◆ toString() [1/2]

constexpr std::string_view mm::node::cia402::toString ( OperationMode  mode)
constexpr

Human-readable name of an operation mode (for logging / JSON). Never nullptr.

◆ toString() [2/2]

constexpr std::string_view mm::node::cia402::toString ( State  state)
constexpr

Human-readable name of a state (for logging / JSON). Never returns nullptr.

Variable Documentation

◆ kCommandMask

constexpr uint16_t mm::node::cia402::kCommandMask = 0x008F
constexpr

Controlword (0x6040) command-bit mask — the state-machine bits a transition touches.

Bits 0 (switch on), 1 (enable voltage), 2 (quick stop), 3 (enable operation), 7 (fault reset). All other bits — mode-specific 4..6, halt 8, and manufacturer 9.. — are preserved across a transition by a read-modify-write masked with this value.

◆ kFirstManufacturerDriveModeBit

constexpr int mm::node::cia402::kFirstManufacturerDriveModeBit = 16
inlineconstexpr

The first bit of 0x6502 that the profile leaves to the vendor (ETG.6010 Figure 15).

◆ kStandardOperationModes

constexpr StandardOperationMode mm::node::cia402::kStandardOperationModes[]
inlineconstexpr
Initial value:
= {
{OperationMode::kNoMode, -1, "", "No mode selected"},
{OperationMode::kProfilePosition, 0, "pp", "Profile position mode"},
{OperationMode::kVelocity, 1, "vl", "Velocity mode (frequency converter)"},
{OperationMode::kProfileVelocity, 2, "pv", "Profile velocity mode"},
{OperationMode::kProfileTorque, 3, "tq", "Profile torque mode"},
{OperationMode::kHoming, 5, "hm", "Homing mode"},
{OperationMode::kInterpolatedPosition, 6, "ip", "Interpolated position mode"},
{OperationMode::kCyclicSyncPosition, 7, "csp", "Cyclic synchronous position mode"},
{OperationMode::kCyclicSyncVelocity, 8, "csv", "Cyclic synchronous velocity mode"},
{OperationMode::kCyclicSyncTorque, 9, "cst", "Cyclic synchronous torque mode"},
{OperationMode::kCyclicSyncTorqueCommutationAngle, 10, "cstca",
"Cyclic synchronous torque mode with commutation angle"},
}

Every standard operation mode, with its 0x6502 bit — ETG.6010 §6.8.1, Figure 15.

The bit is listed rather than computed, though bit = value - 1 holds for all ten of them. The arithmetic is a coincidence of how the profile happened to allocate the field, not a rule it states, and a future mode that broke it would break silently. Reserved positions (bit 4, and 11-15) are simply absent, as is the manufacturer half (bits 16-31), which no standard table can name.