cd ..

> PLC & Motion Control Simulation

// IEC 61131-3 Structured Text & Multi-Axis Synchronization

Schneider Modicon M262 Docs

Demonstrating high-precision motion control using PLCopen standard function blocks on industrial PLC architectures. Execute point-to-point motion, electronic gearing, or non-linear electronic cam profiles to visualize real-time synchronized axis traces.

Select Motion Scenario

Functional Description:MC_MoveAbsolute moves an axis to an absolute target position. It generates a trapezoidal or S-curve velocity profile, accelerating to the maximum velocity and decelerating to zero speed at the target.
// PLCopen Output Flags
ACTIVE
BUSY
DONE
State Log:Initializing...
Multi-Axis Mechanical Shaft SimulatorAxis X1 (P2P)
Linear Axis Slide Travel Path
X1
0 mmTarget: 150 mm150 mm
Trace
Master Pos Master Vel
Note: The function blocks demonstrated here represent a core selection of the PLCopen Motion Control standard. Full system capabilities include advanced features like multi-cam switching, phase offsets, and multi-axis coordinated path interpolation (CNC/Robotics).

IEC Structured Text Workspace

IEC 61131-3 ST Syntax
PRG_MotionControl.stStructured Text
// IEC 61131-3 Structured Text - Single Axis Point-to-Point
PROGRAM PRG_MoveAbsolute
VAR
    fbPowerMaster    : MC_Power;
    fbMoveAbsolute   : MC_MoveAbsolute;
    fbHaltMaster     : MC_Halt;
    
    bEnable          : BOOL := TRUE;
    bTriggerMove     : BOOL;
    bTriggerHalt     : BOOL;
    
    lrTargetPosition : LREAL := 150.0;
    lrMaxVelocity    : LREAL := 50.0;
    lrAcceleration   : LREAL := 50.0;
    lrDeceleration   : LREAL := 50.0;
    
    bDone            : BOOL;
    bBusy            : BOOL;
    bActive          : BOOL;
    bError           : BOOL;
    uErrorID         : UDINT;
END_VAR

// 1. Enable Drive Power Stage
fbPowerMaster(
    Axis := AxisMaster,
    Enable := bEnable,
    EnablePositive := bEnable,
    EnableNegative := bEnable
);

// 2. Instantiate and Trigger Motion
fbMoveAbsolute(
    Axis := AxisMaster,
    Execute := bTriggerMove,
    Position := lrTargetPosition,
    Velocity := lrMaxVelocity,
    Acceleration := lrAcceleration,
    Deceleration := lrDeceleration,
    Jerk := 5000.0, // S-curve profile
    BufferMode := mcAborting,
    Done => bDone,
    Busy => bBusy,
    Active => bActive,
    Error => bError,
    ErrorID => uErrorID
);

// 3. Optional Halt Command
fbHaltMaster(
    Axis := AxisMaster,
    Execute := bTriggerHalt,
    Deceleration := lrDeceleration,
    Done => bTriggerHalt
);
END_PROGRAM

PLCopen Motion Core Reference Guide