Skip to main content
Version: 1.1.1

ecfacade::Axis

High-level motion handle a PLC/application programmer uses, analogous to a TwinCAT "NC axis". More...

#include <axis.hpp>

Inherits from DeviceFacade

Public Functions​

Name
std::uint16_tstatusword() const
Raw DS402 statusword (CiA402 0x6041).
voidsetDriveMode(ecdev::DriveOpMode mode)
Select the cyclic operating mode (CSP / CSV / CST) this axis runs; the CiA402 profile writes 0x6060 to match.
voidresetFault()
Clear a latched drive fault (one-shot).
voidmoveTo(std::int32_t counts)
Command an absolute target position (CSP).
voidmoveAtVelocity(std::int32_t counts_per_sec)
Command a target velocity (CSV).
ecdev::IMotionProfile *motionProfile() const
Escape hatch for advanced callers that need the underlying motion contract.
std::int32_tmodeDisplay() const
Drive-reported modes-of-operation display (0x6061; 8=CSP, 9=CSV, 10=CST); 0 if unmapped.
boolisFaulted() const
True when the drive reports a latched fault (DS402 Fault state, statusword bit 3).
boolisEnabled() const
True when the DS402 state machine has reached Operation Enabled.
voidenable()
Request the drive to power up and hold position.
voiddisable()
Request the drive to power down to a de-energised resting state.
std::int32_tcommandedPosition() const
Last target position sent to the drive (encoder counts).
voidapplyTorque(std::int32_t per_mille_rated)
Command a target torque (CST).
std::int32_tactualVelocity() const
Actual velocity reported by the drive (encoder counts/s, CiA402 0x606C).
std::int32_tactualTorque() const
Drive-reported actual torque (0x6077, per-mille of rated); 0 if the profile doesn't map it.
std::int32_tactualPosition() const
Actual position reported by the drive (encoder counts, CiA402 0x6064).
Axis(ecdev::IMotionProfile * motion, std::string name, ecdev::IEthercatDevice * device)

Detailed Description​

class ecfacade::Axis;

High-level motion handle a PLC/application programmer uses, analogous to a TwinCAT "NC axis".

An [Axis](/lxmaster/api/classes/Axis) is a thin, safe wrapper over an [ecdev::IMotionProfile](/lxmaster/api/classes/IMotionProfile). The application never sees CiA402 controlwords, PDO offsets, the ENI, or the backend: it commands positions and reads back status in engineering-relevant terms. The same [Axis](/lxmaster/api/classes/Axis) works for any drive family whose profile implements IMotionProfile, so swapping a CiA402 servo for a different drive class does not change application code.

All methods are safe to call from the application thread while the RT cycle runs (the backing profile uses lock-free state). Exception: [setDriveMode()](/lxmaster/api/classes/Axis#function-setdrivemode) and the inherited configure() must only be called between EcNetwork::prepare() and EcNetwork::start().

Public Functions Documentation​

function statusword​

std::uint16_t statusword() const

Raw DS402 statusword (CiA402 0x6041).

Useful for advanced diagnostics or for drives that expose manufacturer-specific bits beyond what [isEnabled()](/lxmaster/api/classes/Axis#function-isenabled) / [isFaulted()](/lxmaster/api/classes/Axis#function-isfaulted) cover. RT-safe.

function setDriveMode​

void setDriveMode(
ecdev::DriveOpMode mode
)

Select the cyclic operating mode (CSP / CSV / CST) this axis runs; the CiA402 profile writes 0x6060 to match.

Parameters:

  • mode The desired operating mode (DriveOpMode::Csp, Csv, or Cst).

Call before start() to choose the initial mode, or while running to switch live – a live switch takes effect only when the ENI maps 0x6060 into the RxPDO (eni_gen does this for CiA402 drives). RT-safe.

function resetFault​

void resetFault()

Clear a latched drive fault (one-shot).

function moveTo​

void moveTo(
std::int32_t counts
)

Command an absolute target position (CSP).

Parameters:

  • counts Target position in encoder counts (CiA402 0x607A).

Implicitly exits "hold actual" mode.

function moveAtVelocity​

void moveAtVelocity(
std::int32_t counts_per_sec
)

Command a target velocity (CSV).

Parameters:

  • counts_per_sec Target velocity in encoder counts per second (CiA402 0x60FF).

Only has effect while the drive runs in CSV mode.

function motionProfile​

ecdev::IMotionProfile * motionProfile() const

Escape hatch for advanced callers that need the underlying motion contract.

Return: The IMotionProfile backing this axis. Never null while the axis is valid.

function modeDisplay​

std::int32_t modeDisplay() const

Drive-reported modes-of-operation display (0x6061; 8=CSP, 9=CSV, 10=CST); 0 if unmapped.

function isFaulted​

bool isFaulted() const

True when the drive reports a latched fault (DS402 Fault state, statusword bit 3).

Call [resetFault()](/lxmaster/api/classes/Axis#function-resetfault) to clear. RT-safe.

function isEnabled​

bool isEnabled() const

True when the DS402 state machine has reached Operation Enabled.

RT-safe.

function enable​

void enable()

Request the drive to power up and hold position.

function disable​

void disable()

Request the drive to power down to a de-energised resting state.

function commandedPosition​

std::int32_t commandedPosition() const

Last target position sent to the drive (encoder counts).

Matches the most recent [moveTo()](/lxmaster/api/classes/Axis#function-moveto) argument, or the actual position at enable time when in "hold actual" mode. RT-safe.

function applyTorque​

void applyTorque(
std::int32_t per_mille_rated
)

Command a target torque (CST).

Parameters:

  • per_mille_rated Target torque in per-mille of rated torque (CiA402 0x6071).

Only has effect while the drive runs in CST mode.

function actualVelocity​

std::int32_t actualVelocity() const

Actual velocity reported by the drive (encoder counts/s, CiA402 0x606C).

0 if the drive does not map this object. RT-safe.

function actualTorque​

std::int32_t actualTorque() const

Drive-reported actual torque (0x6077, per-mille of rated); 0 if the profile doesn't map it.

function actualPosition​

std::int32_t actualPosition() const

Actual position reported by the drive (encoder counts, CiA402 0x6064).

RT-safe.

function Axis​

Axis(
ecdev::IMotionProfile * motion,
std::string name,
ecdev::IEthercatDevice * device
)

Updated on 2026-07-13 at 20:44:41 +0000