A program can read the model’s control mode through the read-only system variable RV_SimulationMode:
VAR_EXTERNAL
RV_SimulationMode : BOOL; (* TRUE = Simulation, FALSE = a real PLC owns the outputs *)
END_VAR
ST programs keep scanning in both modes. To stop writing when a real controller takes over, you check RV_SimulationMode in the program and write nothing while it is FALSE. When the model switches to PLC, running programs that use this variable get a one-time reset of their outputs to their start values. The welding station’s programs all work like this.
A program without this check keeps writing in PLC mode and works against the real controller. Stop it before you connect one.
For logic steps, you set Active on each logic root: Always, Connected, Disconnected or Never. Only roots set to Disconnected stop in PLC mode. Editor-created containers run Always. When a root stops, the outputs it owns return to their start values.
You control which writers reach the model outputs through the logic root's Active setting and the ST program's RV_SimulationMode check. The saved mode returns when the real PLC connection ends.
The virtual PLC runs independently of a model’s logic steps. If both write the same outputs, they conflict. You must resolve this in the model yourself.