Create a project, add the CPU that matches your hardware, declare every physical signal in the PLC tag table, copy the inputs into DB_IO in an input mapping FC, write the start/stop seal-in rung on DB members, drive the output from an output mapping FC, then test with a watch table and the HMI before touching real equipment.
- Stop buttons are wired NC and read with a normally open contact.
- Physical addresses live in the tag table and the mapping FCs only.
- Test with PLCSIM and a watch table before the first download to real hardware.
What a PLC Actually Does
A PLC reads its inputs, executes the program and writes its outputs – over and over, every few milliseconds. Everything in this series builds on that loop, explained in detail in the PLC scan cycle. In TIA Portal you organise the program in blocks: OB1 calls FCs and FBs, data lives in DBs – see OB, FB, FC and DB.
Lab Flow: From Push Button to Running Motor
Every lesson in the Softwell PLC lab manual series follows the same six stages and the same address rule, so the code you write here plugs straight into the HMI lessons.
Stage 1Field Wiring and PLC Tag Table
Create a project, add the CPU that matches your hardware (for example an S7-1200 CPU 1214C), and declare every physical signal with a meaningful name and comment. A good name survives handover: S2_Stop, not I6_1.
| PLC tag | Address | Type | Device / comment |
|---|---|---|---|
S1_Start | %I6.0 | Bool | Start push button, NO |
S2_Stop | %I6.1 | Bool | Stop push button, NC, 1 = not pressed |
F1_Overload | %I6.2 | Bool | Overload relay auxiliary, NC, 1 = healthy |
K1_M1 | %Q3.0 | Bool | Motor contactor coil |
Stage 2Input Mapping into DB_IO
Create a global data block DB_IO and an FC FC_InputMapping called first in OB1. From now on the logic never uses %I; this is the same rule used throughout the HMI lab manual series.
// FC_InputMapping "DB_IO".Start_PB := "S1_Start"; "DB_IO".Stop_OK := "S2_Stop"; // NC: 1 = healthy "DB_IO".Overload_OK := "F1_Overload"; // NC: 1 = healthy
Stage 3Logic: the Start/Stop Seal-In Rung
// SCL equivalent
"DB_M1".Run_Cmd := ("DB_IO".Start_PB OR "DB_M1".Run_Cmd) AND "DB_IO".Stop_OK AND "DB_IO".Overload_OK;
// FC_OutputMapping
"K1_M1" := "DB_M1".Run_Cmd;The next step on a real machine is adding permissives and interlocks around this rung – see PLC interlocks and permissives.
Stage 4Link PLC Tags to the HMI
Add a panel in the same project, drag DB_M1 into the HMI tag table, and add two command bits HMI_Start and HMI_Stop that are ORed into the rung in the PLC. The panel never writes to %Q. The full pattern is in HMI buttons, lamps and auto/manual mode.
| HMI tag | PLC member | Used by |
|---|---|---|
DB_M1_Run_Cmd | "DB_M1".Run_Cmd | Run lamp |
DB_M1_HMI_Start / _HMI_Stop | "DB_M1".HMI_Start / HMI_Stop | HMI buttons |
Stage 5Link the Graphics: Lamp and Buttons
| # | Object | Properties | Tag / event |
|---|---|---|---|
| ① | Circle lamp M1 | Appearance: 0 white STOP, 1 dark RUN | DB_M1_Run_Cmd (better: contactor feedback) |
| ② | Button START | Press: SetBit, PLC clears it | DB_M1_HMI_Start |
| ③ | Button STOP | Press: SetBit, PLC clears it | DB_M1_HMI_Stop |
Compile with Software (rebuild all), download to PLCSIM, open a watch table with the DB_IO members and test before connecting any real equipment.
Stage 6Perform and Test: Start/Stop Circuit Online
Hold START, release it, then press STOP. Break the stop wire, and compare the correct NC wiring with the wrong NO wiring. The rung below is the online view of the network above, with power flow in green.
Troubleshooting
| Symptom | Likely cause | First check |
|---|---|---|
| Motor runs only while START is held | Seal-in contact missing | Parallel Run_Cmd branch |
| Motor never starts | Stop or overload contact programmed NC on an NC-wired input | Contact type vs wiring |
| Stop button does nothing | Stop wired NO and the wire is broken | Rewire NC |
| Output ignores the rung | Written a second time later | Cross reference of K1_M1 |
Hands-On Lab: Your First Start/Stop Circuit
Hands-on- TIA Portal and an S7-1200 or PLCSIM
- Two push buttons and a lamp on the trainer kit, or simulated inputs
- Estimated time: 60 minutes
Wire and declare the tags
Wire S1 start (NO), S2 stop (NC), F1 overload (NC) and contactor K1, and declare them in the PLC tag table.
Map inputs into DB_IO
Create DB_IO and copy the three inputs in FC_InputMapping.
Write the seal-in rung
In FC_MotorM1 write the start/stop rung on DB_IO members and DB_M1.Run_Cmd; drive K1 in FC_OutputMapping.
Link HMI tags
Drag DB_M1 into the HMI tag table and add command bits for HMI start and stop.
Build the lamp and buttons
Add a run lamp from feedback and HMI start/stop buttons that write command bits.
Download and test
Compile, download to PLCSIM, test start, stop, overload and a broken stop wire.
The motor starts, latches, stops on STOP, overload or a broken wire, and no block except the mapping FCs touches a physical address.
Frequently asked questions
Which PLC should a beginner start with?
The Siemens S7-1200 with TIA Portal is the most common entry point in India, and the same software and concepts carry directly to the S7-1500 used on larger plants.
Why is the stop button wired normally closed?
So a broken wire or a loose terminal produces the same result as pressing stop. If it were wired normally open, a broken wire would leave the machine running with a stop button that does nothing.
What is a seal-in contact?
A contact from the output itself, in parallel with the start button, that keeps the output energised after the operator releases the button.
Do I need real hardware to learn PLC programming?
No. PLCSIM simulates the CPU well enough to learn logic, timers, counters and sequences. Hardware matters when you reach wiring, analog signals and commissioning.
Why map inputs into a DB instead of using %I directly in the logic?
So every physical address appears in one place only. If a wire moves to another terminal, you change one line in FC_InputMapping and the logic, the HMI and the alarms stay untouched.
Why is the stop contact programmed as normally open?
Because the NC stop button gives 1 when it is not pressed. A normally open contact passes power while the signal is 1, so the rung conducts until someone presses stop or a wire breaks.