Skip to content

Virtual PLC (Structured Text)

Commercial

Included in the public demo Compare editions

The virtual PLC runs a Structured Text (ST) program directly in the browser. Write the program in the PLC editor, then click Deploy and Run. Once per simulation tick, it reads the twin’s PLC signals, runs your logic and writes the outputs. You need no separate build or installation. The browser compiles the program when you deploy it.

Use it to test control logic against the twin before the real controller exists, to try out a sequence quickly, or to teach PLC programming on a running machine. For simple sequences without code, use logic steps instead.

The PLC editor in the Laser Welding Assembly Station: an ST program for the curling check of station 4 is running, the watch list below the code shows the cycle counter and the probe signals, and the probe block in the 3D view is lowered

  1. Switch to the Planner workspace and click the PLC Editor button in the tool bar on the left.
  2. If the model already has PLC programs, the editor opens the first one. Otherwise the model gets a node PLC with a PLC Program component and a short template program.
  3. Edit the program. Syntax errors are marked while you type.
  4. Click Deploy to compile and load the program. Compile errors and unknown signals appear as markers in the code.
  5. Click Run. The status changes to running and the watch list shows live values.

The editor stays open when you change workspaces, and the PLC keeps running while you watch the plant. Only the Viewer workspace hides the editor.

The PLC scans once per simulation tick (60 times per second). Each scan reads all inputs at once, runs the program from top to bottom, then writes all outputs together through one identified writer per program occurrence. Repeated placements of one program remain separate writers. This works like the process image of a real PLC. Outputs act on the drives in the same tick.

One PLC scan per tick, or one scan per event Top: in continuous simulation the virtual PLC scans once per simulation tick, 60 times per second. The twin's PLC inputs are read all at once, the program runs from top to bottom, all outputs are written together, and the outputs act on the drives in the same tick. Bottom: in discrete-event simulation there is no fixed scan rate. A program scans on start, when a signal it reads changes, when one of its timers reaches a deadline, and again at the same simulated time after its own change. Continuous simulation: one scan per tick, 60 per second Twin signals PLC inputs 1 Read all inputs at once 2 Run top to bottom 3 Write all outputs together Drives act in the same tick With several programs, all scan in the same tick, one after another in the order of their Order field. Discrete-event simulation: a scan when something happens time start a signal it reads changes a timer reaches its deadline after its own change: again at the same simulated time No fixed scan rate between events. Use TON, TOF or TP for elapsed time, not a count of scans.
The same program scans on every tick in continuous simulation and on events in DES.
PageWhat you find there
PLC editorDeploy, Run, Stop, Step and Reset, the watch list, export and import, saving
Signals and variablesConnect program variables to signals with VAR_EXTERNAL, the station 4 example, global variable lists and AT
Programs and the scan cycleSeveral programs in one model, cold and warm start, RV_FirstScan, scan errors
Language referenceWhat the compiler accepts, what it does not, and the standard function blocks
Data typesStrings, enums and numeric rules
Simulation or PLC modeWho writes the model outputs, and how a program steps aside for a real PLC
ST FunctionsBuilt-in functions for calculations, limits and type conversion
Function Blocks & LibrariesYour own functions and function blocks, shared through PLC Library
PLCopen MotionMC function blocks for axes and Cartesian paths
Running ST in DESWriting programs that run on events in discrete-event simulation

Generating a CODESYS 4 project from the PLC programs of the twin is coming.