Overview
This reference covers automatic HMI screen changeover on a Siemens SIMATIC KTP400 Basic panel driven entirely by PLC tag values from a SIMATIC S7-1200 CPU programmed in TIA Portal. The typical use case is an operator-guidance sequence: screen 1 displays "Place product in tool", sensor I0.0 detects the part, screen 2 displays "Press start button", and the cycle continues without any HMI button press.
Two engineering-grade implementations are documented end-to-end:
-
HMI tag event method - uses the WinCC Basic system function
ActivateScreenByNumber(orActivateScreen) wired to the value-change event of an HMI tag that mirrors a PLC data block integer. - Job mailbox method - uses the standardized Siemens area pointer 70 ("Job mailbox") to issue job number 51 (ActivateScreenByNumber) from the PLC program.
The first approach is preferred on KTP400 Basic because it requires no VBS script (Basic panels do not run VBS) and minimal PLC ladder logic. The job mailbox approach is the documented Siemens alternative when the project is being ported between Comfort/Professional panels and Basic panels, or when a single screen number has to be set from multiple PLC sources.
Throughout this document, the example PLC hardware is a CPU 1214C DC/DC/DC (firmware V4.4 or later) and the example HMI is a 6AV2 123-2DB03-0AX0 KTP400 Basic mono PN or 6AV2 123-2MA03-0AX0 KTP400 Basic color PN, programmed with WinCC Basic inside TIA Portal V16. Behavior on TIA Portal V13 SP1 and later is identical for the screen-change functions.
Terminology note: an "HMI input tag" in Siemens TIA Portal is any tag whose value is read from the PLC into the HMI (contrast with the HTML <input> form element documented at MDN Web Docs: <input>, which is unrelated). The screen-change mechanism described below uses an input tag whose value the HMI consumes to decide which screen to display.
Prerequisites
- TIA Portal V16 or later (V13 SP1 minimum) with STEP 7 Basic and WinCC Basic installed.
- SIMATIC S7-1200 CPU, firmware V4.1 or later (CPU 1211C / 1212C / 1214C / 1215C / 1217C).
- SIMATIC KTP400 Basic (4-inch mono or color PN variant), PROFINET interface.
- Configured PROFINET connection between the CPU and the HMI in the TIA project (Devices & Networks editor) with the HMI in the same subnet and the S7-1200 set as the IO controller.
- HMI screens named and numbered in the project; for the example: Screen_1 = "Place product", Screen_2 = "Press start", Screen_3 = "Cycle running".
- PLC data block
DB_HMIcontaining a globalScreenNotag of data typeInt(orUInt) with start value1. Sensor wired toI0.0. - For the job mailbox method: HMI connection area pointer "Job mailbox" enabled in the HMI connection properties.
ActivateScreen and ActivateScreenByNumber, but it does not support VBS scripts, dynamic screen arrangements, or user-defined functions that return a value. Any screen-change logic must therefore reside either in the PLC (recommended) or in the HMI tag event configuration (also acceptable for tag-driven changes).Architecture: PLC-Driven Screen Sequencing
For the requested sequence, the engineering target is a state machine that the PLC owns and that the HMI only visualizes. The PLC increments or assigns a screen number based on the process inputs and outputs, and the HMI panel simply renders the screen that matches the current value.
The most robust pattern uses a single integer tag shared by both controllers and one HMI tag event that fires whenever the integer changes. This avoids polling delays and ensures deterministic screen transitions even when the PLC updates the tag multiple times in quick succession.
The basic data flow is:
- The PLC updates
DB_HMI.ScreenNowhenever a transition condition becomes true (e.g.,I0.0rising edge). - The HMI tag
Tag_ScreenNumberis connected toDB_HMI.ScreenNothrough the standard HMI tag configuration (acquisition mode: "Cyclic continuous", acquisition cycle: 1 s by default; tighten to 100 ms if the operator-guidance sequence is time-critical). - The HMI tag event "Value change" fires and calls
ActivateScreenByNumberwith the new tag value as the screen number parameter.
Screen numbers are assigned by the engineer in TIA Portal under screen properties (right-click screen → Properties → General → Screen number). They are not necessarily the order in the project tree. Recording the intended screen number on each screen is recommended for maintainability.
PLC Tag Design and Screen Number Tracking
To prevent the screen from being re-activated on every HMI tag refresh (or on every PLC scan if the HMI is polling the tag very fast), the PLC must guarantee that the screen number tag only changes when the screen should change. Three practical implementations are described below.
| Variant | PLC data type | Range | Use case |
|---|---|---|---|
| Sequential counter | Int | 1..N | Linear operator-guidance sequence with a fixed maximum number of screens |
| Explicit assignment | UInt | 0..65535 | Non-linear navigation where each PLC state maps directly to a screen number |
| Indexed list | Array[1..20] of Int | 1..N | Recipe-driven screen selection where the recipe number selects a screen number from a list |
The most common implementation is the explicit-assignment variant. The PLC moves a constant into the screen-number tag from the step-transition code:
// FB_Sequence - STEP 10: Place product
IF "I0.0" THEN // Sensor detects part present
"DB_HMI".ScreenNo := 2; // Activate screen 2 ("Press start")
State := 20;
END_IF;
// STEP 20: Operator presses start
IF "I0.1" AND NOT "M_StartMem" THEN // Edge detection on start button
"DB_HMI".ScreenNo := 3; // Activate screen 3 ("Cycle running")
State := 30;
END_IF;
"M_StartMem" := "I0.1";
When using this approach, the HMI tag event fires only on a value change (1→2, 2→3), not on repeated identical writes. If the PLC must write the same value multiple times (e.g., to re-show screen 3 after a fault), include a one-step "bounce" through an intermediate value or use the job mailbox method described below.
Tag_ScreenNumber to the event "On exceeding" with threshold 0 and your PLC pre-initializes DB_HMI.ScreenNo to 1 at startup, the panel may perform no screen change because the HMI tag value is already 1 when the runtime starts. Use the "Value change" event instead, or use a startup tag value of 0 and force the panel to start on screen 1 via the HMI start-screen property.Step-by-Step: Configure ActivateScreenByNumber via HMI Tag Event
-
Create the PLC data block. In the S7-1200 program, add a new global data block (e.g.,
DB_HMI). Add a tagScreenNoof typeIntwith the start value1. Compile and download the PLC program. -
Add the HMI tag. In the TIA project tree, expand the KTP400 Basic and open "HMI tags". Add a new tag:
-
Name:
Tag_ScreenNumber - Connection: the configured S7-1200 connection
-
PLC tag:
DB_HMI.ScreenNo(link via the PLC tag dialog) - Data type: Int (must match the PLC tag)
- Acquisition mode: Cyclic continuous
- Acquisition cycle: 1 s (default); reduce to 200 ms for fast sequences
-
Name:
-
Open the tag event editor. Right-click
Tag_ScreenNumberin the HMI tags list and choose "Properties". Switch to the "Events" tab. -
Add the value-change event. Click "Add" in the Events table. For the event, choose "Value change" from the drop-down. For the function list, expand "Screen" → "Activate" and select
ActivateScreenByNumber. -
Bind the parameter. The system function
ActivateScreenByNumbertakes a single input parameter (screen number). Click the input field and bind it toTag_ScreenNumberitself. This ensures the function receives the current value of the tag every time it changes. - Set the start screen. In the HMI project tree, right-click the KTP400 Basic → "Properties" → "Screens" → "Start screen". Select "Screen_1" (or whichever screen corresponds to screen number 1).
- Compile and download. Compile the HMI project fully (right-click the panel → "Compile" → "Software (all)"). Download to the panel via PROFINET or Ethernet. Confirm the project is set to "RT" (Runtime) mode on the panel.
-
Test with the PLC tag table. In the PLC project online view, open the data block
DB_HMIand use the "Monitor/modify" function to write2toScreenNo. The HMI should switch to screen 2 within one acquisition cycle. Write3to switch to screen 3.
Alternative: Job Mailbox (Area Pointer 70) Method
The job mailbox is the documented Siemens interface for triggering HMI functions from the PLC without any configuration on the tag-event side. It is particularly useful when:
- Multiple PLC programs need to trigger the same screen change.
- The screen number to be activated is computed dynamically (e.g., from a recipe) and would be cumbersome to bind to a single HMI tag.
- The project must work identically across WinCC Basic, Comfort, and Professional panels.
The job mailbox is one of the standard PROFINET/S7 area pointers. For S7-1200 + KTP400 Basic, it is configured as follows.
-
Configure the area pointer. In the HMI project, right-click the connection to the S7-1200 and choose "Properties" → "Area pointers". Enable the "Job mailbox" pointer. The default DB number is the user-defined
DB_HMI; the default start address is0. The pointer occupies 4 bytes. - Accept the DB on the PLC side. The pointer write target must exist in the PLC. Accept the default DB number suggested by TIA Portal (or change it to your project DB) and compile the PLC.
-
Job mailbox byte layout. The job mailbox is a 4-byte buffer:
Byte Name Meaning Example for ActivateScreenByNumber(2) Byte 0 Job number Function code 51 (= ActivateScreenByNumber) Byte 1 Parameter 1 (low) First parameter (screen number for job 51) 2 Byte 2 Parameter 1 (high) / Parameter 2 (low) Word/byte depending on job 0 Byte 3 Parameter 2 (high) / Parameter 3 Reserved 0 -
Trigger the job from the PLC. Use the standard pattern of writing job 51 to the pointer and then resetting it to 0:
// Trigger screen change to ScreenNo via job mailbox "DB_HMI".JobMB[0] := 51; // Job number 51 "DB_HMI".JobMB[1] := UINT_TO_BYTE("DB_HMI".ScreenNo); // Screen number "DB_HMI".JobMB[2] := 0; "DB_HMI".JobMB[3] := 0; - Reload and test. Compile both projects, download to PLC and HMI, and verify with the PLC monitor.
Verification and Commissioning
The following acceptance test confirms the configuration before handing the system over to production:
- Power up the PLC and the HMI. Confirm that the HMI starts on the configured start screen (screen 1).
- Force
I0.0ON using the PLC monitor. Within one acquisition cycle, the HMI should switch to screen 2. - Force
I0.1ON briefly (edge). The HMI should switch to screen 3. - Force
DB_HMI.ScreenNodirectly to 2, then to 1, then to 2 again. Confirm the HMI follows the values in order and does not skip. - Disconnect the PROFINET cable for 5 seconds. Confirm that when the connection re-establishes, the HMI re-synchronizes the screen number from the current PLC value (no manual reload required).
- Check the HMI diagnostics buffer for any communication errors and the PLC diagnostics buffer for any PROFINET IO faults.
- Cycle power on the panel only (PLC remains running). Confirm the panel re-acquires the current screen number from
DB_HMI.ScreenNoon startup instead of reverting to the start screen.
Troubleshooting
| Symptom | Likely cause | Remediation |
|---|---|---|
| HMI never changes screen | HMI tag event not configured, or function name misspelled | Re-open the HMI tag events tab; verify the function is ActivateScreenByNumber, not ChangeScreen (which does not exist in WinCC Basic) |
| HMI changes screen once then locks on screen 2 | PLC keeps writing the same value to ScreenNo; the "Value change" event fires only on edges |
Add a one-step bounce (write intermediate value 0 then 2) or switch to the job mailbox method |
| Screen flickers between two screens | PLC logic has no edge detection on the sensor input; ScreenNo oscillates 1↔2 |
Add rising-edge detection in the PLC; assign screen numbers only on a positive edge of the state-transition condition |
| HMI shows alarm "Tag connection lost" after PLC restart | HMI tag acquisition cycle too slow for the PLC restart | Reduce the acquisition cycle to 200 ms; verify the PROFINET device name on the HMI matches the project |
| "Screen number does not exist" message | PLC wrote a value outside the configured screen number range | Add a PLC-side range check (IF ScreenNo < 1 OR ScreenNo > MAX THEN ScreenNo := 1; END_IF;) |
| Job mailbox triggers but screen does not change | Job mailbox DB not compiled on PLC, or pointer start address wrong | Compile the PLC fully; verify the pointer in the HMI connection properties points to the same DB and offset used by the PLC code |
| HMI reports "Function not available" | Project on panel is older than project in TIA; or panel firmware does not support the function | Re-perform a full HMI compile and download; verify the KTP400 firmware version is 14.0.0 or later |
| Screen changes 2 seconds after PLC tag update | HMI tag acquisition cycle is too long | Drop acquisition cycle to 100–250 ms in the tag properties and the area pointer properties |
KTP400 Basic Hardware and Firmware Constraints
| Item | Value | Source |
|---|---|---|
| Article number (color PN) | 6AV2 123-2MA03-0AX0 | Siemens catalog (SIMATIC HMI) |
| Article number (mono PN) | 6AV2 123-2DB03-0AX0 | Siemens catalog (SIMATIC HMI) |
| Display size | 4.3 in | Product datasheet |
| Colors | 65536 (color variant) | Product datasheet |
| Maximum number of screens | 100 | WinCC Basic engineering limits |
| Maximum number of tags | 250 | WinCC Basic engineering limits |
| Number of area pointers (job mailbox) | 1 (mailbox + up to 9 others, configuration dependent) | WinCC Basic online help |
| VBS script support | No | WinCC Basic documentation |
| Minimum TIA Portal version | V13 SP1 | Siemens compatibility tool |
| Required PLC firmware | S7-1200 CPU FW ≥ V4.1 | Siemens compatibility tool |
Frequently Asked Questions
Can I trigger a screen change with a Boolean tag instead of an Integer?
Directly, no. The ActivateScreenByNumber function expects an integer screen number, and a Boolean tag cannot encode that. Use the PLC to convert the Boolean into an integer (e.g., set ScreenNo := 2 on the rising edge of I0.0), then drive the HMI from the integer as described above.
Why does my KTP400 Basic panel not execute the screen change even though the PLC tag is correct?
The most common cause is that the HMI tag was added but the event was not bound. Right-click the HMI tag, open "Properties" → "Events", and confirm that "Value change" is set to ActivateScreenByNumber with the parameter bound to the tag itself. Also confirm the screen number written by the PLC exists as a screen in the HMI project (otherwise the panel reports "Screen number does not exist").
Does the KTP400 Basic support VBS scripts to implement more complex screen logic?
No. The WinCC Basic runtime on KTP400 Basic does not include a VBS engine. Any conditional logic must be implemented in the PLC. The job mailbox method (area pointer 70) is the most flexible alternative when the screen-change decision depends on data that is not available in a single tag.
How fast does the screen change after the PLC writes a new value?
The HMI tag acquisition cycle (default 1 s) is the dominant latency. Tightening the cycle to 100 ms reduces worst-case latency to about 100 ms plus the HMI runtime's screen-loading time (typically < 50 ms). For tighter response, use the job mailbox with the same reduced cycle.
Can I use the same approach on a Comfort or Unified panel?
Yes. The HMI tag event configuration works identically on Comfort, Unified, and Basic panels. Comfort panels additionally support VBS and user-defined functions, but the PLC-driven approach is recommended for clarity and maintainability across panel classes.