Use SetBitWhileKeyPressed for momentary commands, SetBit and ResetBit for latched commands, and always send the command to a PLC interface data block rather than writing directly to an output. Drive lamps from device feedback, not from the command bit, and gate manual commands with the current mode so an operator cannot fight the automatic sequence.
- Commands go from the panel into an HMI interface DB; the PLC decides what to do with them.
- A lamp that follows the command bit lies to the operator; drive it from feedback or a status word.
- Mode selection must be a single source of truth in the PLC, echoed back to the panel, not stored only on the HMI.
The HMI to PLC Command Interface
A panel should never write directly to a physical output. If a button writes to Q0.0, the machine loses every interlock the PLC program provides, and a communication fault can leave an output in an unknown state.
Instead, build a small interface data block in the PLC and let the panel write only into that structure. A typical layout uses three groups:
- Commands from HMI: Start, Stop, Reset, ModeRequest, JogForward, JogReverse.
- Status to HMI: Running, Stopped, Faulted, ModeActive, StepNumber.
- Values: setpoints, counters and timers exchanged as REAL or DINT.
Give the block a UDT so the same structure can be reused for every device on the machine. If you are new to structured tags, review Siemens PLC addressing and data types first.
Because the PLC evaluates commands rather than acting on them blindly, an operator pressing Start while a permissive is missing produces a message instead of an unexpected movement. The interlock logic in PLC interlocks and permissives stays in control.
Configuring Buttons and Command Events
Add a button from the toolbox, then open its Events properties. TIA Portal offers several system functions and each behaves differently.
| System function | Behaviour | Use for |
|---|---|---|
| SetBitWhileKeyPressed | Bit is true only while the button is held | Jog, inch, hold-to-run functions |
| SetBit | Sets the bit to true and leaves it | Start command reset by the PLC |
| ResetBit | Sets the bit to false | Clearing a latched request |
| InvertBit | Toggles the bit each press | Lamp test, screen options, never machine start |
| SetValue | Writes a fixed number to a tag | Mode request, speed preset selection |
For a Start command, the cleanest pattern is SetBit on the HMI and a one-shot in the PLC that acts on the rising edge and then clears the bit. The command cannot stick on if communication drops mid-press, and the panel does not need to know anything about the machine sequence.
Making buttons readable
- Label with a verb the operator recognises: Start Conveyor, not CMD_01.
- Keep the same button in the same screen position across all screens by placing it on the template.
- Size touch targets for gloved hands; small buttons cause mispresses on a factory floor.
- Use colour consistently across the whole project, and never rely on colour alone to signal state.
Status Lamps and Animation from Feedback
A status lamp answers one question: what is the machine actually doing? If the lamp is animated from the command bit, it turns green the moment the operator presses Start, even when the motor never ran. Drive it from the contactor feedback or from a status bit the PLC sets only when running is confirmed.
In TIA Portal, add a circle or a symbolic object and use Animations → Display → Appearance with the status tag. Define one range per state so the object cannot fall between definitions.
| State | Source tag | Typical appearance |
|---|---|---|
| Stopped and ready | Status.Ready | Grey or dark outline |
| Running | Status.Running from feedback | Green fill |
| Faulted | Status.Faulted from the fault word | Red fill with flashing enabled |
| Not available | Status.Ready false and no fault | Dimmed with the object made non-operable |
Use the Visibility and Enable animations as well. Hiding a button an operator must not press is safer than letting them press it and generating an alarm. For screen-level layout rules, see HMI screen design best practices.
Practise on a real Siemens panel
Softwell HMI sessions run on KTP Comfort panels with a live PLC, online or in the Pune classroom.
Auto and Manual Mode Selection
Mode is a machine state, so it belongs in the PLC. The panel sends a mode request; the PLC decides whether the change is allowed and writes back the mode that is actually active. A conveyor running an automatic cycle should not drop into manual halfway through a transfer.
A workable pattern looks like this:
- The operator presses Auto or Manual; the button uses SetValue to write 1 or 2 into ModeRequest.
- The PLC checks that the machine is idle and no cycle is active, then sets ModeActive to the requested value.
- The panel displays ModeActive, not ModeRequest, so the operator sees the truth.
- Manual jog buttons are enabled only when ModeActive equals manual, using the Enable animation.
- The automatic start command is accepted by the PLC only when ModeActive equals auto.
Add a text field or text list that spells the mode out in words. A single indicator that reads Auto, Manual or Changeover Blocked removes most of the phone calls maintenance receives about a machine that will not start.
Finally, protect manual controls with a user authorisation so that only trained staff can jog a machine. The details are covered in HMI user administration and runtime settings.
Hands-On Lab: Build a Start/Stop Screen with Mode Selection
Hands-on- TIA Portal with WinCC Comfort and a KTP panel or panel simulation
- An S7-1200 or S7-1500 CPU, real or in PLCSIM, with an HMI interface DB
- Use internal bits or lamps only; do not command a real motor for this exercise
- Estimated time: 35 minutes
Create the interface DB
Add a data block with Commands, Status and Values structures and connect the panel to the PLC in Devices and Networks.
Add Start and Stop buttons
Use SetBit on Start and Stop, and clear both bits in the PLC after a one-shot evaluation.
Add a jog button
Configure a second button with SetBitWhileKeyPressed for a jog command.
Animate the status lamp
Add a circle animated from Status.Running, which the PLC sets only from feedback.
Add mode selection
Add Auto and Manual buttons using SetValue on ModeRequest, display ModeActive as text, and enable the jog button only in manual.
Every command reaches the PLC through the interface DB, lamps follow feedback rather than commands, mode is decided by the PLC, and manual controls are disabled in automatic mode.
Frequently asked questions
Should an HMI button write directly to a PLC output?
No. Write to a command bit in an interface data block and let the PLC program apply interlocks and mode conditions before it drives any output.
What is the difference between SetBit and SetBitWhileKeyPressed?
SetBit sets the bit and leaves it set until something resets it. SetBitWhileKeyPressed holds the bit true only while the operator keeps the button pressed, which suits jog and hold-to-run functions.
Why does my lamp turn on even though the motor did not start?
The animation is almost certainly linked to the command bit. Link it to the running feedback or to a status bit the PLC sets after confirming the contactor auxiliary contact.
Where should the auto and manual mode be stored?
In the PLC. The panel sends a request and displays the active mode returned by the controller, so a communication loss or a panel restart cannot leave the machine in an unclear state.
