Skip to content

Simulation or PLC Mode

Commercial

Included in the public demo Compare editions

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.

Who writes the model outputs Three writers feed the model outputs: logic steps, ST PLC programs and the real PLC through CONNECT. Only logic roots with Active set to Disconnected stop in PLC mode; their outputs return to start values. ST PLC programs scan in both modes. A check of RV_SimulationMode must stop output writes in PLC mode; running programs using that variable receive a one-time output reset when PLC mode starts. An ST program without the check competes with the real PLC. The real PLC takes over on its first model output write, and the saved mode returns when the connection ends. Who writes the model outputs Logic steps per logic root Active setting Active = Disconnected → stops in PLC mode owned outputs → start values Always / Connected / Disconnected / Never Editor-created containers: Always ST PLC programs scan in both modes checks RV_SimulationMode → stops writing in PLC mode; one-time reset on entry IF NOT RV_SimulationMode ... no check → competing writer Stop before you connect a real PLC Real PLC through CONNECT PLC mode = taken over first model output write Model outputs (drives, cylinders, lamps…)
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.