GUIDES

AI for CODESYS SoftMotion and motion control

Motion projects combine device configuration, library details and code that only shows its faults when an axis moves. Rung Coder lets the AI set up the axes and kinematics, write the motion code and record the result on the controller. This guide covers what it configures and how motion is verified.

← All guides · Updated

What the AI sets up

  • SoftMotion axes, virtual or physical, and their parameters.
  • CiA402 (DSP402) axes on EtherCAT servo drives, with the EtherCAT master network card, PDO mapping for position, velocity or torque mode, and SDO access.
  • Axis groups with 24 kinematic models from the SoftMotion transformation library: gantries (2 and 3 axes, H and T gantries), SCARA, polar, tripod and bipod, palletizer, 5-axis kinematics and 6-axis articulated robots, plus wrist, C-axis and tool kinematics.
  • CNC objects: CNC settings and CNC programs with DIN 66025 G-code.
  • Electronic cams, written as code: fixed point tables with MC_CAM_REF, or cams built at runtime with the CamBuilder library.

Writing the motion code

The AI writes the PLCopen motion function blocks in Structured Text, such as power, homing, absolute and relative moves, cam and gear coupling and group moves, and wires them into a state machine. It also sets up what a fresh SoftMotion project needs before the code compiles, such as the axes and the tasks of an axis group.

Verifying the motion

Sampling runs on the controller itself and is read back afterwards, so it is not limited by the much slower online reading of single variables.

  1. Build the project until there are 0 errors and 0 warnings.
  2. Once you grant full control, download to the controller or simulator and start the application.
  3. Record positions, velocities and states with 1 ms high-speed sampling on the controller, an in-PLC oscilloscope with trigger, or a trace.
  4. The AI reads the recording and compares it with the expected profile, then adjusts and repeats.

An example prompt

Create a virtual axis Axis_X and a function block FB_Positioner that powers the axis,
homes it, then moves between 0 and 200 mm at 100 mm/s with MC_MoveAbsolute.
Compile until clean, download to the simulator, run five cycles
and show me the position and velocity recorded with 1 ms sampling.

Safety

Motion moves real mechanics. Every online action needs full control, which in Authorized mode the AI only gets after you confirm it, and a real controller must be allowed explicitly. Verify new motion code on a simulator or a virtual axis first, keep the hardware safety chain independent of the PLC program, and do not leave commissioning to the AI alone.

Drive-specific settings vary by vendor. The AI is guided to look up your drive in the built-in reference library of device files, manuals and example projects before configuring it, but check the drive parameters against the manufacturer's manual.

Try it on your own CODESYS project

Rung Coder is free for 2 months from your first sign-in, with no payment method needed. Windows 10/11 and CODESYS V3.5 SP18 or newer.