Skip to main content
Version: 1.0.12

ecdev::CiA402DriveProfile

CiA 402 (CANopen-over-EtherCAT) servo-drive profile. More...

#include <cia402_drive_profile.hpp>

Inherits from ecdev::IDeviceProfile, ecdev::IMotionProfile, IDeviceLifecycle

Public Classes

Name
structConfig

Public Types

Name
using DriveOpModeOpMode
Cyclic operation mode this profile drives.

Public Functions

Name
virtual voidwriteOutputs(ProcessImage & image, std::uint64_t cycle_count) override
virtual std::int32_ttargetPosition() const override
virtual std::uint16_tstatusword() const override
virtual voidsetTargetVelocity(std::int32_t counts_per_sec) override
CSV target velocity in counts/s.
virtual voidsetTargetTorque(std::int32_t per_mille_rated) override
CST target torque in per-mille of rated torque.
virtual voidsetTargetPosition(std::int32_t counts) override
Command CSP target position in encoder counts; implicitly leaves "hold actual" mode.
virtual voidsetOperatingMode(DriveOpMode mode) override
Choose the operating mode.
virtual voidsetAutoFaultRecover(bool enable) override
Set the CiA402 auto fault-reset/recover behaviour.
boolrequiresMotionShutdown() const override
boolrequiresAlShutdown() const override
virtual voidrequestFaultReset() override
One-shot fault-reset edge (acted on only while the drive reports Fault).
virtual voidrequestEnable() override
Request the drive walk to Operation Enabled (cancels a prior disable request).
virtual voidrequestDisable() override
Request the drive walk back to a de-energised resting state.
boolreadyForShutdown() const override
boolreadyForAlShutdown() const override
virtual voidreadInputs(const ProcessImage & image, bool wkc_valid, bool operational) override
virtual const char *profileName() const override
Stable identifier for diagnostics (e.g.
virtual voidprimeOutputs(ProcessImage & image) override
voidprepareShutdown() override
virtual std::stringprepareSafeOp(ISlaveServices & svc, ProcessImage & image) override
virtual std::int32_tmodeDisplay() const override
Drive's modes-of-operation display (CiA402 0x6061; 8=CSP, 9=CSV, 10=CST).
std::uint16_tlastStatusWordForDiagnostics() const override
virtual boolisOperationEnabled() const override
virtual boolisFault() const override
boolhasLeftOperationEnabled() const override
boolcyclicStopRequested() const override
std::stringcyclicStopReason() const override
virtual std::stringconfigurePreOp(ISlaveServices & svc, ProcessImage & image) override
virtual voidcaptureExitDiagnostics(ISlaveServices & svc) override
End-of-run, after the RT thread has joined; safe to do SDO reads via svc.
virtual IMotionProfile *asMotion() override
virtual std::int32_tactualVelocity() const override
virtual std::int32_tactualTorque() const override
Drive's reported actual torque (CiA402 0x6077, per-mille of rated).
virtual std::int32_tactualPosition() const override
CiA402DriveProfile(Config cfg)

Additional inherited members

Public Functions inherited from ecdev::IDeviceProfile

Name
~IDeviceProfile() override =default
virtual voidresolveTopology(const ProcessImage & image)
Resolve the static channel/PDO topology from the ENI-derived process image.
virtual IIoProfile *asIo()
virtual IEncoderProfile *asEncoder()

Public Functions inherited from ecdev::IMotionProfile

Name
virtual~IMotionProfile() =default

Detailed Description

class ecdev::CiA402DriveProfile;

CiA 402 (CANopen-over-EtherCAT) servo-drive profile.

Plugs onto a [GenericEniDevice] and provides the drive-class behaviour that used to live in CiA402Device:

  • PreOP validation + operating-mode setup: it confirms the cyclic objects it drives (controlword/statusword/target+actual position) are present in the ENI PDO mapping and fails otherwise. It makes NO configuration assumptions ("ENI is law") with ONE deliberate exception: the operating mode 0x6060, which is application/axis intent rather than bus wiring, so the profile writes it (from Config::op_mode) and reads it back to confirm at PreOP. SM sync-mode (0x1C32/0x1C33), the 0x60C2 interpolation time, and any vendor tuning still arrive as ENI CoE InitCmds replayed by [GenericEniDevice]; DC SYNC0 is activated by the master from the ENI ; the generic 0x1C1x/0x16xx PDO assignment is done by [GenericEniDevice].
  • DS402 controlword state machine ([CiA402Fsm]) on the RT cyclic path.
  • A lock-free snapshot so application threads (through the Axis facade / IMotionProfile) read position/statusword and command targets without touching PDO bytes.

It implements [IMotionProfile](/lxmaster/api/classes/IMotionProfile), which is the only thing the Axis facade depends on, so the controlword/statusword stay hidden inside this profile.

Extending it: this class is intentionally NOT final. To add vendor/extra PDO variables (objects the ENI maps beyond the standard CiA402 set), subclass it, override the relevant lifecycle method (typically readInputs, and optionally resolveTopology/configurePreOp), and CHAIN to the base (CiA402DriveProfile::readInputs(...)) before doing your own work. Resolve your extra objects with ProcessImage::resolve(index, sub) and publish them to application threads through your own lock-free state (atomics). Axis keeps working unchanged because the subclass inherits this profile's asMotion(). This mirrors the [GenericIoProfile](/lxmaster/api/classes/GenericIoProfile) -> [CiA401IoProfile](/lxmaster/api/classes/CiA401IoProfile) precedent. The application reaches the subclass via ecfacade::DeviceFacade::deviceProfile().

Public Types Documentation

using OpMode

using ecdev::CiA402DriveProfile::OpMode = DriveOpMode;

Cyclic operation mode this profile drives.

CSP commands target position (0x607A); CSV commands target velocity (0x60FF); CST commands target torque (0x6071, INT16). The ENI/ESI must map the matching object and set the drive's modes-of-operation (0x6060) accordingly – the profile only validates the mapping. The per-mode cyclic facts live in the OpModeTraits table in cia402_drive_profile.cpp.

Public Functions Documentation

function writeOutputs

virtual void writeOutputs(
ProcessImage & image,
std::uint64_t cycle_count
) override

Reimplements: ecdev::IDeviceProfile::writeOutputs

function targetPosition

inline virtual std::int32_t targetPosition() const override

Reimplements: ecdev::IMotionProfile::targetPosition

function statusword

inline virtual std::uint16_t statusword() const override

Reimplements: ecdev::IMotionProfile::statusword

function setTargetVelocity

inline virtual void setTargetVelocity(
std::int32_t counts_per_sec
) override

CSV target velocity in counts/s.

Reimplements: ecdev::IMotionProfile::setTargetVelocity

Has its own command slot (0x60FF) so a CSP position target and a CSV velocity target can coexist for bumpless live mode switching; only the object matching the active op-mode is honoured by the drive.

function setTargetTorque

inline virtual void setTargetTorque(
std::int32_t per_mille_rated
) override

CST target torque in per-mille of rated torque.

Reimplements: ecdev::IMotionProfile::setTargetTorque

Has its own command slot (0x6071) so it can coexist with position/velocity targets for bumpless live mode switching; only the object matching the active op-mode is honoured by the drive.

function setTargetPosition

inline virtual void setTargetPosition(
std::int32_t counts
) override

Command CSP target position in encoder counts; implicitly leaves "hold actual" mode.

Reimplements: ecdev::IMotionProfile::setTargetPosition

function setOperatingMode

inline virtual void setOperatingMode(
DriveOpMode mode
) override

Choose the operating mode.

Reimplements: ecdev::IMotionProfile::setOperatingMode

Pre-start this seeds the initial mode; while running it also switches live – when the ENI maps 0x6060 into the RxPDO the profile writes out_.desired_mode every cycle, so CSP/CSV/CST switch while OPERATIONAL. The atomic store is RT-safe; cfg_.op_mode (used only by the legacy no-0x6060 path, which is fixed at PRE_OP) is not read cyclically in PDO mode.

function setAutoFaultRecover

inline virtual void setAutoFaultRecover(
bool enable
) override

Set the CiA402 auto fault-reset/recover behaviour.

Reimplements: ecdev::IMotionProfile::setAutoFaultRecover

Call between prepare() and start(); not RT-safe.

function requiresMotionShutdown

inline bool requiresMotionShutdown() const override

function requiresAlShutdown

inline bool requiresAlShutdown() const override

function requestFaultReset

inline virtual void requestFaultReset() override

One-shot fault-reset edge (acted on only while the drive reports Fault).

Reimplements: ecdev::IMotionProfile::requestFaultReset

function requestEnable

inline virtual void requestEnable() override

Request the drive walk to Operation Enabled (cancels a prior disable request).

Reimplements: ecdev::IMotionProfile::requestEnable

function requestDisable

inline virtual void requestDisable() override

Request the drive walk back to a de-energised resting state.

Reimplements: ecdev::IMotionProfile::requestDisable

function readyForShutdown

inline bool readyForShutdown() const override

function readyForAlShutdown

bool readyForAlShutdown() const override

function readInputs

virtual void readInputs(
const ProcessImage & image,
bool wkc_valid,
bool operational
) override

Reimplements: ecdev::IDeviceProfile::readInputs

function profileName

inline virtual const char * profileName() const override

Stable identifier for diagnostics (e.g.

Reimplements: ecdev::IDeviceProfile::profileName

"CiA402-drive").

function primeOutputs

virtual void primeOutputs(
ProcessImage & image
) override

Reimplements: ecdev::IDeviceProfile::primeOutputs

function prepareShutdown

inline void prepareShutdown() override

function prepareSafeOp

virtual std::string prepareSafeOp(
ISlaveServices & svc,
ProcessImage & image
) override

Reimplements: ecdev::IDeviceProfile::prepareSafeOp

function modeDisplay

inline virtual std::int32_t modeDisplay() const override

Drive's modes-of-operation display (CiA402 0x6061; 8=CSP, 9=CSV, 10=CST).

Reimplements: ecdev::IMotionProfile::modeDisplay

0 if unmapped.

function lastStatusWordForDiagnostics

inline std::uint16_t lastStatusWordForDiagnostics() const override

function isOperationEnabled

inline virtual bool isOperationEnabled() const override

Reimplements: ecdev::IMotionProfile::isOperationEnabled

function isFault

inline virtual bool isFault() const override

Reimplements: ecdev::IMotionProfile::isFault

function hasLeftOperationEnabled

bool hasLeftOperationEnabled() const override

function cyclicStopRequested

inline bool cyclicStopRequested() const override

function cyclicStopReason

std::string cyclicStopReason() const override

function configurePreOp

virtual std::string configurePreOp(
ISlaveServices & svc,
ProcessImage & image
) override

Reimplements: ecdev::IDeviceProfile::configurePreOp

function captureExitDiagnostics

virtual void captureExitDiagnostics(
ISlaveServices & svc
) override

End-of-run, after the RT thread has joined; safe to do SDO reads via svc.

Reimplements: ecdev::IDeviceProfile::captureExitDiagnostics

function asMotion

inline virtual IMotionProfile * asMotion() override

Reimplements: ecdev::IDeviceProfile::asMotion

function actualVelocity

inline virtual std::int32_t actualVelocity() const override

Reimplements: ecdev::IMotionProfile::actualVelocity

function actualTorque

inline virtual std::int32_t actualTorque() const override

Drive's reported actual torque (CiA402 0x6077, per-mille of rated).

Reimplements: ecdev::IMotionProfile::actualTorque

0 if the profile does not map it. Diagnostic only.

function actualPosition

inline virtual std::int32_t actualPosition() const override

Reimplements: ecdev::IMotionProfile::actualPosition

function CiA402DriveProfile

explicit CiA402DriveProfile(
Config cfg
)

Updated on 2026-07-04 at 20:22:54 +0000