118 if (value < INT8_MIN || value > INT8_MAX) {
121 switch (
static_cast<OperationMode>(
static_cast<int8_t
>(value))) {
133 return static_cast<OperationMode>(
static_cast<int8_t
>(value));
174 if ((statusword & 0x4F) == 0x40) {
177 if ((statusword & 0x6F) == 0x21) {
180 if ((statusword & 0x6F) == 0x23) {
183 if ((statusword & 0x6F) == 0x27) {
186 if ((statusword & 0x6F) == 0x07) {
189 if ((statusword & 0x4F) == 0x0F) {
192 if ((statusword & 0x4F) == 0x08) {
208 return "NotReadyToSwitchOn";
210 return "SwitchOnDisabled";
212 return "ReadyToSwitchOn";
216 return "OperationEnabled";
218 return "QuickStopActive";
220 return "FaultReactionActive";
233 return "ProfilePosition";
237 return "ProfileVelocity";
239 return "ProfileTorque";
243 return "InterpolatedPosition";
245 return "CyclicSyncPosition";
247 return "CyclicSyncVelocity";
249 return "CyclicSyncTorque";
251 return "CyclicSyncTorqueCommutationAngle";
286 "Cyclic synchronous torque mode with commutation angle"},
307constexpr bool quickStopHolds(int16_t optionCode) {
return optionCode >= 5 && optionCode <= 8; }
313constexpr std::optional<State>
parseState(std::string_view token) {
394 if (from == target) {
439 return allowQuickStopOverride
constexpr std::optional< OperationMode > toOperationMode(int value)
Maps a raw mode value (as written to 0x6060 / read from 0x6061) to a known operation mode....
Definition cia402.h:115
constexpr bool quickStopHolds(int16_t optionCode)
Whether a quick stop configured with optionCode leaves the drive in Quick Stop Active,...
Definition cia402.h:307
OperationMode
CiA402 operation modes (object 0x6060 / 0x6061 values).
Definition cia402.h:98
@ kNoMode
No mode assigned. Always legal; has no 0x6502 bit.
@ kInterpolatedPosition
IP — interpolated position.
@ kCyclicSyncVelocity
CSV — cyclic velocity.
@ kCyclicSyncTorque
CST — cyclic torque.
@ kCyclicSyncPosition
CSP — cyclic position (the common SOMANET mode).
@ kHoming
HM — reference/homing run.
@ kVelocity
VL — the frequency-converter velocity mode.
@ kCyclicSyncTorqueCommutationAngle
CSTCA — cyclic torque with commutation angle.
@ kProfileTorque
PT — profiled torque.
@ kProfilePosition
PP — trapezoidal point-to-point positioning.
@ kProfileVelocity
PV — profiled velocity.
Command
Canonical controlword command-bit patterns (the value of the bits in kCommandMask).
Definition cia402.h:158
@ kCmdShutdown
→ ReadyToSwitchOn (enable voltage + no quick stop).
Definition cia402.h:159
@ kCmdDisableVoltage
→ SwitchOnDisabled.
Definition cia402.h:162
@ kCmdFaultReset
Rising edge of bit 7 clears a fault.
Definition cia402.h:164
@ kCmdQuickStop
→ QuickStopActive.
Definition cia402.h:163
@ kCmdSwitchOn
→ SwitchedOn (also "disable operation" from OperationEnabled).
Definition cia402.h:160
@ kCmdEnableOperation
→ OperationEnabled.
Definition cia402.h:161
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.
Definition cia402.h:390
State
States of the CiA402 device control state machine (decoded from the statusword).
Definition cia402.h:139
@ kNotReadyToSwitchOn
Drive initialising; no clear state yet.
@ kQuickStopActive
Quick stop in progress.
@ kSwitchedOn
Switch-on command accepted; power stage on, no motion.
@ kReadyToSwitchOn
Shutdown command accepted.
@ kFaultReactionActive
A fault is being reacted to (e.g. controlled stop).
@ kOperationEnabled
Fully enabled; setpoints are followed.
@ kFault
Faulted and stopped; needs a fault reset.
@ kSwitchOnDisabled
Powered, holding; the resting state after init.
constexpr int kFirstManufacturerDriveModeBit
The first bit of 0x6502 that the profile leaves to the vendor (ETG.6010 Figure 15).
Definition cia402.h:310
constexpr std::string_view toString(State state)
Human-readable name of a state (for logging / JSON). Never returns nullptr.
Definition cia402.h:205
constexpr uint16_t kCommandMask
Controlword (0x6040) command-bit mask — the state-machine bits a transition touches.
Definition cia402.h:155
constexpr StandardOperationMode kStandardOperationModes[]
Every standard operation mode, with its 0x6502 bit — ETG.6010 §6.8.1, Figure 15.
Definition cia402.h:274
constexpr State decodeState(uint16_t statusword)
Decodes the CiA402 state machine state from a statusword (0x6041) value.
Definition cia402.h:171
constexpr std::optional< State > parseState(std::string_view token)
Parses a state name as toString spells it. std::nullopt for anything else.
Definition cia402.h:313
constexpr bool isFaulted(uint16_t statusword)
Whether the statusword's fault bit (bit 3) is set, gated to the faulted states.
Definition cia402.h:199
Object
Standard CiA402 object dictionary indices used by the drive profile, ordered by index.
Definition cia402.h:23
@ kFollowingErrorActualValue
INTEGER32, ro, TxPDO — live following error.
Definition cia402.h:81
@ kFollowingErrorTimeout
UNSIGNED16, rw, RxPDO — ms outside window before fault.
Definition cia402.h:33
@ kSupportedDriveModes
UNSIGNED32, ro — capability bit field of supported modes.
Definition cia402.h:88
@ kProfileDeceleration
UNSIGNED32, rw, RxPDO — profile deceleration.
Definition cia402.h:58
@ kPositionRangeLimit
2×INTEGER32, rw — position wrap range (min/max).
Definition cia402.h:51
@ kTouchProbe1PositiveEdge
INTEGER32, ro, TxPDO — position at probe 1 rising edge.
Definition cia402.h:73
@ kDigitalOutputs
2×UNSIGNED32, rw — physical outputs + enable mask.
Definition cia402.h:86
@ kQuickStopOptionCode
INTEGER16, rw — reaction to a quick stop.
Definition cia402.h:27
@ kPositionActualValue
INTEGER32, ro, TxPDO — actual position.
Definition cia402.h:31
@ kPositionDemandValue
INTEGER32, ro, TxPDO — trajectory generator demand.
Definition cia402.h:30
@ kHomingSpeeds
2×UNSIGNED32, rw — switch/zero search speeds.
Definition cia402.h:66
@ kStatusword
UNSIGNED16, ro, TxPDO — reports the state machine.
Definition cia402.h:26
@ kFeedConstant
2×UNSIGNED32, rw — feed per shaft revolutions.
Definition cia402.h:64
@ kTargetVelocity
INTEGER32, rw, RxPDO — CSV/PV setpoint.
Definition cia402.h:87
@ kVelocityThreshold
UNSIGNED16, rw, RxPDO — standstill velocity threshold.
Definition cia402.h:40
@ kGearRatio
2×UNSIGNED32, rw — motor/shaft revolutions.
Definition cia402.h:63
@ kMaxCurrent
UNSIGNED16, rw, RxPDO — current limit (per-mille).
Definition cia402.h:44
@ kHomeOffset
INTEGER32, rw, RxPDO — home offset from machine zero.
Definition cia402.h:52
@ kSiUnitVelocity
UNSIGNED32, rw — SI unit code of velocity objects.
Definition cia402.h:68
@ kFollowingErrorWindow
UNSIGNED32, rw, RxPDO — max tolerated following error.
Definition cia402.h:32
@ kHomingMethod
INTEGER8, rw, RxPDO — homing method number.
Definition cia402.h:65
@ kErrorCode
UNSIGNED16, ro, TxPDO — code of the last drive fault.
Definition cia402.h:24
@ kTouchProbeFunction
UNSIGNED16, rw, RxPDO — touch probe arm/config bits.
Definition cia402.h:71
@ kTorqueActualValue
INTEGER16, ro, TxPDO — actual torque.
Definition cia402.h:48
@ kTorqueProfileType
INTEGER16, rw, RxPDO — torque trajectory shape.
Definition cia402.h:62
@ kVelocityWindowTime
UNSIGNED16, rw, RxPDO — ms in window for target reached.
Definition cia402.h:39
@ kControlword
UNSIGNED16, rw, RxPDO — commands the state machine.
Definition cia402.h:25
@ kMotorRatedTorque
UNSIGNED32, rw — motor rated torque (mNm).
Definition cia402.h:47
@ kProfileAcceleration
UNSIGNED32, rw, RxPDO — profile acceleration.
Definition cia402.h:57
@ kVelocityActualValue
INTEGER32, ro, TxPDO — actual velocity.
Definition cia402.h:37
@ kTorqueOffset
INTEGER16, rw, RxPDO — torque feed-forward.
Definition cia402.h:70
@ kPositionDemandInternalValue
Definition cia402.h:83
@ kTargetTorque
INTEGER16, rw, RxPDO — CST/PT setpoint (per-mille).
Definition cia402.h:42
@ kPositionWindow
UNSIGNED32, rw, RxPDO — target-reached position window.
Definition cia402.h:34
@ kDigitalInputs
UNSIGNED32, ro, TxPDO — digital input bit field.
Definition cia402.h:85
@ kDcLinkCircuitVoltage
UNSIGNED32, ro, TxPDO — DC bus voltage (mV).
Definition cia402.h:49
@ kControlEffort
INTEGER32, ro, TxPDO — position loop output.
Definition cia402.h:82
@ kMotorRatedCurrent
UNSIGNED32, rw — motor rated current (mA).
Definition cia402.h:46
@ kQuickStopDeceleration
UNSIGNED32, rw, RxPDO — deceleration on quick stop.
Definition cia402.h:59
@ kPolarity
UNSIGNED8, rw, RxPDO — position/velocity polarity bits.
Definition cia402.h:54
@ kTouchProbeTimeStamp1NegativeValue
Definition cia402.h:78
@ kHomingAcceleration
UNSIGNED32, rw, RxPDO — homing acceleration.
Definition cia402.h:67
@ kTorqueDemand
INTEGER16, ro, TxPDO — control loop torque demand.
Definition cia402.h:45
@ kMaxMotorSpeed
UNSIGNED32, rw, RxPDO — motor speed limit.
Definition cia402.h:55
@ kMotionProfileType
INTEGER16, rw, RxPDO — trajectory shape.
Definition cia402.h:60
@ kTorqueSlope
UNSIGNED32, rw, RxPDO — PT torque ramp rate.
Definition cia402.h:61
@ kModeOfOperationDisplay
INTEGER8, ro, TxPDO — active operation mode.
Definition cia402.h:29
@ kVelocityOffset
INTEGER32, rw, RxPDO — CSP/CSV velocity feed-forward.
Definition cia402.h:69
@ kTouchProbe1NegativeEdge
Definition cia402.h:74
@ kTargetPosition
INTEGER32, rw, RxPDO — CSP/PP setpoint.
Definition cia402.h:50
@ kTouchProbeStatus
UNSIGNED16, ro, TxPDO — touch probe latch status.
Definition cia402.h:72
@ kVelocityWindow
UNSIGNED16, rw, RxPDO — target-reached velocity window.
Definition cia402.h:38
@ kMaxTorque
UNSIGNED16, rw, RxPDO — torque limit (per-mille).
Definition cia402.h:43
@ kProfileVelocity
UNSIGNED32, rw, RxPDO — PP cruise velocity.
Definition cia402.h:56
@ kVelocityThresholdTime
UNSIGNED16, rw, RxPDO — ms below threshold = standstill.
Definition cia402.h:41
@ kModeOfOperation
INTEGER8, rw, RxPDO — requested operation mode.
Definition cia402.h:28
@ kPositioningOptionCode
UNSIGNED16, rw, PDO — PP positioning options.
Definition cia402.h:80
@ kTouchProbeTimeStamp1PositiveValue
Definition cia402.h:76
@ kPositionWindowTime
UNSIGNED16, rw, RxPDO — ms in window for target reached.
Definition cia402.h:35
@ kVelocityDemandValue
INTEGER32, ro, TxPDO — ramp generator demand.
Definition cia402.h:36
@ kSoftwarePositionLimit
2×INTEGER32, rw — software end stops (min/max).
Definition cia402.h:53
constexpr bool isCommandableState(State state)
Whether a master can ask a drive to reach state.
Definition cia402.h:329
FsaAction
What a master should do next, having observed one state and wanting another.
Definition cia402.h:346
@ kCommand
Issue FsaTransition::command and look again.
@ kArrived
Already there; nothing to issue.
The next step of a walk toward a target state.
Definition cia402.h:356
FsaAction action
Definition cia402.h:357
uint16_t command
Meaningful only for FsaAction::kCommand.
Definition cia402.h:358
One row of the standard operation-mode table — a mode, the 0x6502 bit that advertises it,...
Definition cia402.h:258
std::string_view label
The profile's own wording, for a user-facing list.
Definition cia402.h:264
OperationMode mode
Definition cia402.h:259
std::string_view abbreviation
The profile's short form: "csp", "hm", …. Empty for kNoMode.
Definition cia402.h:263
int bit
Definition cia402.h:262