Learn SIEMENS-S7-SIMULATION with Real Code Examples
Updated Nov 27, 2025
Code Sample Descriptions
1
S7 Sim – Simple Start/Stop Motor Logic
NETWORK 1
TITLE = Start/Stop Motor
A I0.0
S M0.0
A I0.1
R M0.0
= Q0.0
Basic motor latch logic using simulated I/O inside TIA Portal.
2
S7 Sim – Timer ON Delay (TON)
NETWORK 1
TITLE = TON Example
A I0.0
TON T1, PT := T#5s
= Q0.0
Simulates a TON block to delay output activation.
3
S7 Sim – Blinking Light Using Free Running Clock
NETWORK 1
TITLE = Blink
A M0.5 // 1Hz clock bit
= Q0.1
Uses S7 system clock memory bytes to create a blink effect.
4
S7 Sim – Conveyor Belt Interlock Logic
NETWORK 1
TITLE = Conveyor Interlock
A I0.0 // Start
A NOT I0.1 // Emergency Stop
A I0.2 // Object sensor
= Q0.0
Simulated conveyor motor protected by emergency stop and sensor.
5
S7 Sim – Counter Up (CTU)
NETWORK 1
TITLE = CTU Example
A I0.3
CTU C1, PV := 10
= Q0.2
Simulates a CTU to count pieces on a virtual production line.
6
S7 Sim – Tank Level Control (Analog Simulation)
NETWORK 1
TITLE = Tank Control
L PIW256
L 500
>I
= Q0.3
Controls pump based on analog tank level in PLC simulator.
7
S7 Sim – Alarm Trigger Logic
NETWORK 1
TITLE = Alarm
L PIW258
L 300
>I
= M10.0
Creates an alarm bit when a condition exceeds threshold.
8
S7 Sim – PID Basic Structure
NETWORK 1
TITLE = PID Control
CALL FB41, DB41
PV := PIW260,
SP := PIW262,
LMN := QW300
Simulated PID block controlling motor speed or temperature.
9
S7 Sim – Traffic Light Controller
NETWORK 1
TITLE = Traffic
A M0.0
TON T1, PT := T#5s
TON T2, PT := T#2s
NETWORK 2
= Q0.0 // Red
NETWORK 3
= Q0.1 // Yellow
NETWORK 4
= Q0.2 // Green
Simulates 3-light traffic cycle using timers.
10
S7 Sim – Automatic Gate Control
NETWORK 1
TITLE = Gate Logic
A I0.0 // Open Button
A NOT I0.2 // Fully open LS
= Q0.4 // Open Motor
NETWORK 2
A I0.1 // Close Button
A NOT I0.3 // Fully closed LS
= Q0.5 // Close Motor
Simulates an opening/closing gate using limit switches and motor outputs.