Configuring S7-1200 KTP400 HMI I/O Field for Motor Control

David Krause9 min read
SiemensTIA PortalTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

1. System Overview and Problem Statement

A common entry-level automation task combines a Siemens SIMATIC S7-1200 CPU 1212C AC/DC/RLY with a SINAMIC KTP400 Basic Panel to monitor an analog temperature sensor and start a motor when the measured value exceeds an operator-defined setpoint. The challenge for engineers who are new to TIA Portal is twofold: link a screen input element on the HMI to a real PLC tag, and use that tag inside a compare instruction that drives a digital output.

This reference walks through the full workflow: defining the PLC tag that holds the operator-entered setpoint, creating the HMI variable that mirrors it, placing an I/O field on the KTP400 screen, and writing the comparison logic that energises the motor contactor. All steps are written for TIA Portal V16 or newer and have been validated against the S7-1200 system manual and KTP400 Basic operating instructions available on the Siemens Industry Online Support portal.

Field note: A "Basic" HMI panel does not support VBScript or arrays, but it does support symbolic tags, I/O fields, and standard compare logic. Avoid using absolute addresses on the panel side; always link through an HMI tag that points to a PLC tag.

2. Prerequisites

Before opening TIA Portal, verify that the following hardware, software, and signal-wiring prerequisites are met.

Item Specification Typical Order Number
CPU S7-1200 1212C AC/DC/RLY, FW 4.4 or later 6ES7212-1BE40-0XB0
HMI KTP400 Basic, 4" TFT, PN interface, mono or color 6AV2123-2DB03-0AX0 (color)
Sensor 0-10 V analog output temperature probe, 0-100 °C PT100 + transmitter
Engineering tool TIA Portal V16 / V17 with STEP 7 Basic and WinCC Basic 6ES7822-0AA07-0YA7 (V17)
Ethernet cable Cat5e or better, crossover not required —
Motor contactor 24 V DC coil, ≤ 2 A (within 1212C relay rating) —

Confirm the firmware of the CPU by selecting Online → Accessible devices in TIA Portal. The 1212C AC/DC/RLY shipped from 2017 onward carries firmware 4.2 minimum; update to 4.4 if a feature such as OPC UA server or secure communication is required.

3. Hardware Topology and Signal Flow

Temperature Sensor 0-10 V / 4-20 mA AI2 channel PT100 + TX S7-1200 1212C AC/DC/RLY Tags: AI_Temp, SP_Temp Compare: AI > SP DQ0 → Motor KTP400 Basic PN 192.168.0.10 I/O Field → SP_Temp Display ← AI_Temp Motor Contactor 24 V DC coil Q0.0 via relay

PROFINET is the only supported path between the S7-1200 and the KTP400 Basic. The 1212C CPU has a single PROFINET port (X1) and the KTP400 Basic has a single PROFINET port (X1). Both must be on the same subnet, and the HMI must point to the PLC's IP address as its connection target.

4. Configuring the PLC Tags in TIA Portal

Open the project tree and select PLC_1 → PLC tags → Add new tag. Create the following symbols. The compare block needs the raw analog value, a scaled engineering value, and the operator setpoint.

Name Data type Address Retain Purpose
AI_Temp_Raw Int %IW64 No Raw value of AI2 (channel 0)
AI_Temp_C Real — No Scaled value in degrees Celsius
SP_Temp_C Real — Yes Operator setpoint from the HMI I/O field
Motor_On Bool %Q0.0 No Output to motor contactor
Motor_Ack Bool %M10.0 No Auxiliary flag used in OB1

Set SP_Temp_C retain so the operator-entered value survives a power cycle. Use a Real because most temperature sensors are scaled to a floating-point value.

5. Implementing the Compare Logic in the PLC

Add a new FC called TempControl and call it from the main OB1. The block performs three jobs: scale the raw analog word to engineering units, compare to the setpoint, and drive the digital output with a small hysteresis to prevent contactor chattering.

// FC "TempControl" (ST source view)
// Inputs:  AI_Temp_Raw  (Int)  - IW64
//          SP_Temp_C    (Real) - HMI setpoint
// Outputs: Motor_On     (Bool) - Q0.0

#AI_Temp_C  := NORM_X(MIN := 0,     VALUE := #AI_Temp_Raw,
                     MAX := 27648.0) * 100.0;   // 0-10 V = 0-100 °C

IF #AI_Temp_C >= #SP_Temp_C THEN
    #Motor_On := TRUE;
END_IF;

IF #AI_Temp_C <= (#SP_Temp_C - 1.0) THEN
    #Motor_On := FALSE;                         // 1 °C hysteresis
END_IF;

If the sensor is 4-20 mA into a 500 Ω shunt, replace the NORM_X range with MIN=0, MAX=27648 and scale to (NORM * 100) - 0 only after offset correction. The 1212C onboard AI is 0-10 V voltage only on channels 0 and 1; for 4-20 mA use an external resistor or a signal conditioner module such as the SM 1231 (6ES7231-4HD32-0XB0).

6. Configuring the KTP400 HMI Connection

Drag a HMI device → SIMATIC Basic Panel → 4" → KTP400 Basic color PN into the project. Open Devices & Networks, draw a PROFINET line between PLC_1.PNIE_1 and HMI_1.PNIE_1, then select the line to create an HMI connection automatically. Verify the IP addresses:

Device IP address Subnet mask PROFINET name
CPU 1212C 192.168.0.1 255.255.255.0 plc-1212c
KTP400 192.168.0.10 255.255.255.0 ktp400-pn

Open HMI_1 → Connections and confirm the partner is PLC_1 with the role IO device. The access point must remain S7ONLINE so that the panel is discoverable from TIA Portal during download.

7. Creating the HMI Variable that Mirrors the PLC Tag

Switch the project tree to HMI_1 → HMI tags and add the following tags. The acquisition mode must be Cyclic continuous at 1 s so that the operator's entry is written back to the PLC immediately.

Name Connection PLC tag Data type Length Acquisition Cycle
HMI_SP_Temp HMI_Connection_1 SP_Temp_C Real 4 Cyclic continuous 1 s
HMI_AI_Temp HMI_Connection_1 AI_Temp_C Real 4 Cyclic continuous 1 s
HMI_Motor_On HMI_Connection_1 Motor_On Bool 1 Cyclic continuous 1 s
Common mistake: choosing Cyclic on use for the setpoint tag. The I/O field will not write back to the PLC until the field is touched or the screen changes. Use Cyclic continuous for any tag bound to an I/O field used in input mode.

8. Building the HMI Screen with the I/O Field

Open HMI_1 → Screens → Add new screen. On the toolbox, drag the I/O field element onto the canvas and configure the properties exactly as shown below. The I/O field is the only HMI control that lets the operator write a numeric value into a PLC tag.

Property Value
Tag HMI_SP_Temp (linked to PLC tag SP_Temp_C)
Mode Input/output
Format pattern 999.9
Representation Decimal
Lower limit 0.0
Upper limit 100.0
Hidden input No (KTP400 has no number pad, so popup numeric keyboard is used)

Add a second I/O field bound to HMI_AI_Temp in Output mode to display the live temperature. Add a circle or text field that changes color based on HMI_Motor_On by configuring an Appearance → Animation on the element. Save the screen as Overview and set it as the start screen under HMI_1 → Runtime settings → Start screen.

9. Downloading to the PLC and HMI

  1. Select PLC_1 → Compile → Hardware (rebuild all) and resolve any errors in the diagnostics pane.
  2. Right-click PLC_1 → Download to device → Hardware and software. Accept the default and confirm with the displayed MAC address.
  3. Right-click HMI_1 → Download to device → Software (all). Choose the visible HMI_1 node on subnet 192.168.0.0/24.
  4. At the panel, accept the runtime transfer prompt. If a transfer password has been set, enter it.
Tip: the first download on a brand-new 1212C may fail with the diagnostic Online: There is no online connection to a CPU of the specified type. Close all TIA Portal instances, restart the engineering PC, and re-attempt. Switch firewall profiles to Domain only during commissioning.

10. Verification and Field Commissioning

Confirm the loop by injecting a known signal at AI2 with a 0-10 V calibrator and reading the displayed value on the panel. The following checks should all pass before handing the system over to operations.

Step Action Expected result
1 Apply 0.00 V at AI2 AI_Temp_C reads 0.0 on HMI
2 Apply 10.00 V at AI2 AI_Temp_C reads 100.0 on HMI
3 Enter setpoint 30.0 via I/O field SP_Temp_C in PLC watch table reads 30.0
4 Raise input above 30 °C Motor_On = TRUE, Q0.0 LED on CPU is on, contactor pulls in
5 Drop input below 29 °C (hysteresis) Motor_On = FALSE, Q0.0 LED off, contactor drops out
6 Cycle power to the PLC SP_Temp_C retains the last value

11. Troubleshooting Matrix

Symptom Likely cause Corrective action
I/O field shows dashes after a write Format pattern overflow or out-of-range entry Set limits 0.0 - 100.0, change pattern to 999.9
Setpoint does not reach the PLC HMI tag set to Cyclic on use Change to Cyclic continuous, 1 s
PLC diagnostics IO device failure PROFINET name of KTP400 not assigned Use Online → Assign PROFINET device name with the value ktp400-pn
AI_Temp_C jumps to 32767 at 10 V Overflow on 16-bit Int cast Use NORM_X / SCALE_X with REAL math, not integer scaling
Output chatters around threshold No hysteresis in compare block Implement 1 °C deadband as shown in section 5
Operator setpoint lost on power cycle Retain attribute not set on SP_Temp_C Open PLC tags table, tick Retain
HMI transfer password forgotten Security setting enabled Connect a USB keyboard, hold SHIFT+ESC during power-up to reset transfer authorisation

12. Extending the Application

Once the single setpoint is working, the same pattern can be reused for proportional control. Replace the on/off compare with a PID_Compact instance (available in STEP 7 Basic V16) and bind the setpoint to SP_Temp_C. Add a second screen with a trend view to log AI_Temp_C at 500 ms intervals; the KTP400 supports up to 32,000 log entries. For remote supervision, expose AI_Temp_C and Motor_On through the integrated OPC UA server of the 1212C FW 4.4 and connect any SCADA client on the same subnet.

How do I link a TIA Portal HMI I/O field to a PLC tag in an S7-1200?

Create a PLC tag in the PLC tags table (for example, SP_Temp_C of type Real), then in the HMI tags table add a new tag of the same data type, set the connection to the HMI_Connection_1, and pick SP_Temp_C as the PLC tag. Bind this HMI tag to the I/O field in the screen properties and set the mode to Input/output so the operator can write a new value.

Why does the setpoint entered on the KTP400 never reach the S7-1200?

In most cases the HMI tag is set to Cyclic on use instead of Cyclic continuous. Change the acquisition mode to Cyclic continuous with a 1-second cycle, redownload the HMI project, and confirm the value in the PLC's watch table.

What IP addresses and PROFINET names should the S7-1200 and KTP400 use?

A common pattern is 192.168.0.1 / mask 255.255.255.0 for the 1212C with PROFINET name plc-1212c, and 192.168.0.10 / mask 255.255.255.0 for the KTP400 with PROFINET name ktp400-pn. Assign the PROFINET device name from TIA Portal under Online → Assign PROFINET device name before the first HMI download.

Can the 1212C onboard analog input read a 4-20 mA temperature transmitter?

The onboard AI of the 1212C is a 0-10 V voltage input. To read 4-20 mA directly you need a 500 ohm resistor across the input, or add an SM 1231 AI module (for example 6ES7231-4HD32-0XB0) which accepts ±10 V, 0-10 V, and 4-20 mA. Then scale the raw value with NORM_X and SCALE_X inside an FC.

Why does the motor relay chatter on and off when the temperature hovers near the setpoint?

The compare instruction is too sensitive. Add at least 1 °C of hysteresis in the PLC code, for example turn the output ON when AI ≥ SP and OFF only when AI ≤ SP − 1.0. This is standard practice for thermostat-style control on the 1212C.

Back to blog