Motion Control Library EC-Motion

General Description

The EC-Master Class A example application EcMasterDemoMotion includes a simple Motion Control Library, called EC-Motion, for drives based on the profile CiA402®. This library supports the single-axis movement commands that are specified within the PLCopen standard “Function blocks for motion control” without the need for costly additional hardware. EC-Motion provides a Programmable Logic Controller (PLC) style interface. It is designed to be easy integrating in a PLC or any other C++ application for controlling servo drives.

In every cycle the integrated trajectory generator calculates the new commanded position for the drives. The generator supports jerk-limited movements as well as blending between velocities. The servo drives can be operated in the Cyclic Synchronous Position (CSP) mode or in Cyclic Synchronous Velocity (CSV) mode.

Software Architecture

The library offers administrative function blocks, like MC_Power to set an axis into the state “Operation enabled”, and motion function blocks to move the axis to a specific position, like MC_MoveAbsolute.

If the axis is still busy with performing a movement, the motion block is queued and automatically executed after the ongoing movement is finished. By using the different blending modes (low, previous, next, high) comprehensive movements are possible.

The core component of the library is the trajectory generator which divides a movement into different sections (accelerate, decelerate, constant velocity) before a movement starts. For all accelerate and decelerate sections the jerk can be limited.

For a smooth axis movement, the generator has to calculate in every cycle the next velocity until the final position is reached. The axis layer is converting the velocity depending on the axis mode either into a target position (CSP mode), or a target velocity (CSV mode).

Configuration and Diagnosis

The EtherCAT configuration and diagnosis tool EC-Engineer helps the user easily to define the parameters and settings for all axis which shall be operated by the EcMasterDemoMotion application. Based on this configuration all CiA402 compatible drives can be operated without changing the application´s source code. In EC-Engineer´s diagnosis mode all axis inputs and outputs can be monitored. On the “motion control panel” the “Drive State” and “PLCopen State” is shown and the axis can be powered-on and moved.


  • Available on Linux, Xenomai, FreeRTOS, QNX, VxWorks, RTX64, etc.
  • Available for CPU architecture x86, x64, ARM, ARM64
  • Continuous movements based on buffering and blending
  • Changing parameters during movement (continuous update)
  • Administrative Function Blocks:
    • MC_Power: Controls the power stage (On or off)
    • MC_SetPosition: Shifts the coordinate system
    • MC_ReadParameter, MC_ReadBoolParameter: Returns the value of a parameter
    • MC_WriteParameter, MC_WriteBoolParameter: Modifies the value of a parameter
    • MC_ReadActualPosition: Returns the actual position
    • MC_ReadActualVelocity: Returns the actual velocity
    • MC_ReadMotionState: Returns the actual velocity
    • MC_ReadAxisInfo: Reads information concerning an axis
    • MC_ReadAxisError: Presents general axis errors not relating to the Function Blocks
    • MC_Reset: Makes the transition from the state ‘ErrorStop’ to ‘Standstill’ by resetting errors
    • MC_CalcMoveProfile, MC_CalcMoveTimeAtPos: Calculate trajectory without moving
  • Motion Function Blocks with jerk limitation
    • MC_Stop: Commands a controlled motion stop and transfers the axis to the state ‘Stopping’
    • MC_Halt: Commands a controlled motion stop and transfers the axis to the state ‘Standstill’
    • MC_MoveAbsolute: Commands a controlled motion to a specified absolute position
    • MC_MoveRelative: Commands a controlled motion of a specified distance relative to the set position
    • MC_MoveVelocity: Commands a never ending controlled motion at a specified velocity

Advantages and Benefits

  • Included in EC-Master Class A license
  • EcMasterDemoMotion and EC-Motion Library are provided with complete source code
  • Supporting all EtherCAT drives based on ETG.6010 (Implementation Directive for CiA 402 Drive Profile) and CiA402 Profile (CANopen device profile for drives and motion control)
  • Function Blocks (API) according to PLCopen Standard V2.0
  • Efficient implementation resulting in a low CPU load