Machinery TwinDocs

HIL with TwinCAT

Full hardware-in-the-loop, a TwinCAT motion program commissioned against the twin.

The complete HIL workflow on Beckhoff: real PLC + NC code, virtual machine. Requirements: TwinCAT 3 XAE (free) with a local runtime, and the Machinery Twin Windows PLC Connector Pro plan and up.

1. The PLC side

A minimal motion setup in TwinCAT: two NC axes (virtual, no drives needed, the simulation encoder closes the loop), a master axis cycling 0–360°, a slave coupled by an NC cam table (MC_CamIn), i.e. the controller-side twin of a cam profile. Activate, run, verify axes move in the TwinCAT scope.

2. The twin side

Build (or reuse from the flying shear tutorial) a machine driven by one master variable and cam slaves. The twin's cams should express the intended motion design.

3. Connect

Connections → new Beckhoff connection: the runtime PC's IP and AMS Net ID, port 851. Add the ADS route if the runtime is on another PC (local runtime needs none). Test, enable.

4. Map the axes

Twin variableADS symbol
Line_MasterGVL.MasterAxis.NcToPlc.ActPos
Shear_Carriage (Online config)GVL.SlaveAxis.NcToPlc.ActPos

Note the design decision: in Simulation the carriage follows the twin's cam; in Online it follows the NC's actual position. The twin's own cam remains as the reference for what should happen.

5. Commission

Switch to Online. Now compare intent vs implementation:

  • Phase error between the NC cam table and the design → the carriage cuts off-pitch on screen.
  • Wrong sync-zone velocity → visible drag during the cut window.
  • Sequence/interlock bugs in the PLC → the twin's state-machine-driven product flow (fed by PLC flags) exposes them.

Fix in TwinCAT, activate, watch again, the edit-download-observe loop takes seconds, no machine time, no crash risk.

6. Keep it

Save and export the project next to the TwinCAT solution. At FAT, the same file becomes the live dashboard, and the reference you demo against.

On this page