PLC Programming · Lab Manual

PID Controller in Siemens PLC: PID_Compact Lab Manual from Sensor to Tuned Loop

A PID loop is only as good as its sample time, its scaling and its limits. This lab manual builds an oven temperature loop through all six stages – sensor wiring, scaling, PID_Compact in a cyclic interrupt OB, HMI tags and a faceplate – and lets you tune it, switch to manual and break it with jitter in the browser.

2,500+ engineers trained 4.9/5 Google rating 21+ years, Chinchwad, Pune Next batch: contact for dates
Quick answer

Scale the process value in the input mapping, call PID_Compact from a cyclic interrupt OB such as OB30 so the sample time is constant, set output and process value limits before tuning, run pretuning then fine tuning, and give the HMI setpoint, process value, output, mode and manual value.

  • PID belongs in a cyclic interrupt OB, not OB1.
  • Set limits before tuning.
  • Manual and automatic must switch bumplessly.

Where PID_Compact Fits in a Control Loop

The loop is sensor → scaled process value → PID → output → actuator → process. PID_Compact compares setpoint and process value and calculates the output from proportional, integral and derivative parts. It contains its own commissioning tools: pretuning finds the first parameters from a step response, fine tuning refines them around the setpoint.

Lab Flow: From Temperature Sensor to a Tuned Loop

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.

Lab manual flow: field input to tested HMI screenSix stages: field device and PLC tag, input mapping to DB_IO, PLC logic, HMI tags, graphics linking, and perform and test.1Field + tags%IW106 %QW86sensor, SCR2Input mappingNORM_X / SCALE_X→ DB_IO °C3LogicOB30 PID_Compactlimits, mode4HMI tagsDB_Oven2_*SP, PV, Out5GraphicsPID faceplatetrend, manual6Perform + testSimulatortune, jitterAddress rule for every lesson: %I only in FC_InputMapping, %Q only in FC_OutputMapping, symbolic DB members everywhere else – including the HMI.
Figure 1 – Six-stage lab flow for this lesson.

Stage 1Field Signals and PLC Tags

PLC tagAddressTypeDevice / comment
TT70_Raw%IW106IntOven thermocouple transmitter 4–20 mA = 0 – 300 °C
SCR70_Ref%QW86IntThyristor power controller 0 – 10 V = 0 – 100 %

Stage 2Input Mapping and Scaling

// FC_InputMapping
"DB_IO".TT70_degC := SCALE_X(MIN := 0.0, MAX := 300.0, VALUE := NORM_X(MIN := 0, VALUE := "TT70_Raw", MAX := 27648));

Scaling options and plausibility checks: PLC analog input scaling.

Stage 3Logic: PID_Compact in a Cyclic Interrupt OB

// OB30 "Cyclic interrupt", cycle 100 ms
"PID_Oven"(Setpoint := "DB_Oven2".SP,
           Input    := "DB_IO".TT70_degC,          // already scaled → use Input, not Input_PER
           ManualEnable := "DB_Oven2".Manual,
           ManualValue  := "DB_Oven2".ManualValue,
           Output   => "DB_Oven2".Out_pct);

// FC_OutputMapping
"SCR70_Ref" := REAL_TO_INT("DB_Oven2".Out_pct * 276.48);   // 0–100 % → 0–27648
Setting (PID_Compact configuration)ValueWhy
Controller typeTemperature, °CUnits on the commissioning screen
Process value limits0 – 300 °CError if the sensor leaves the range
Output limits0 – 100 %Actuator range
Sample timefrom OB30 (100 ms)Constant time base for I and D

The constant time base is explained in the scan cycle lesson.

Stage 4Link PLC Tags to the HMI

HMI tagPLC memberUsed by
DB_Oven2_SP"DB_Oven2".SPSetpoint input, limits
DB_IO_TT70_degC"DB_IO".TT70_degCPV field and trend
DB_Oven2_Out_pct"DB_Oven2".Out_pctOutput field and trend
DB_Oven2_Manual / _ManualValue"DB_Oven2".Manual / ManualValueMode button, manual input

Stage 5Link the Graphics

#ObjectPropertiesTag / event
①Trend viewPV, SP (dashed) and output on two axesLogged or real-time curves
②I/O field setpointLimits; authorisation OperatorDB_Oven2_SP
③Button MANUAL/AUTOInvertBit; authorisation MaintenanceDB_Oven2_Manual
④I/O field manual valueVisible only in manualDB_Oven2_ManualValue

Trend configuration: HMI trends and data logs; setpoint entry: HMI I/O fields.

Stage 6Perform and Test: Oven Temperature Loop

A PID controls an oven heater. Change setpoint and gains, apply the pretuning result, switch to manual and back (bumpless), and move the PID from the cyclic interrupt OB into OB1 to see why the sample time must be constant. Time runs 10× faster.

Oven and PLC
HMI · PID faceplate
PID_OvenOB30 · 100 ms
SP °CKpTi sTd s
PVOutManual %

Troubleshooting

SymptomLikely causeFirst check
Loop oscillatesGain too high or Ti too shortRetune; check actuator
Output stuck at limitLimits wrong or wind-upOutput limits, PV range
Erratic behaviourPID called in OB1Move to OB30
Pretuning errorProcess not stable or actuator not movingWait for steady state; test the actuator

Hands-On Lab: Build and Tune a Temperature Loop with PID_Compact

Hands-on
Before you start
  • TIA Portal with an S7-1200/1500 or PLCSIM with a simulated process
  • Estimated time: 90 minutes
1

Wire and declare the loop signals

Declare TT70_Raw and the SCR heater reference SCR70_Ref.

Sensor and actuator tags are declared.
2

Scale into DB_IO

Scale TT70 to °C in FC_InputMapping.

TT70_degC reads in °C.
3

Call PID_Compact in OB30

Create OB30 (100 ms), call PID_Oven with Setpoint, Input and Output; set limits.

PID runs in OB30 with limits set.
4

Link HMI tags

Publish setpoint, PV, output, mode and manual value.

HMI shows SP, PV, output and mode.
5

Build the PID faceplate

Trend with PV, SP and output, input fields and a MANUAL/AUTO button.

Trend shows all three curves; manual value appears only in manual.
6

Tune and test

Pretune, fine tune, step the setpoint and test manual/auto switching.

After tuning the setpoint step settles without large overshoot; manual/auto switches bumplessly.
Checkpoint—how to know you did it right

The loop runs at a constant sample time, within its limits, tuned by pretuning and fine tuning, and the operator can see and take control of it from the panel.

Frequently asked questions

Can PID_Compact be called in OB1?

It is technically possible but not recommended. The controller needs a constant sampling time, and OB1 cycle time varies with load, which distorts the integral and derivative calculation.

What is the difference between PID_Compact and PID_3Step?

PID_Compact drives a continuous actuator such as a control valve, drive reference or PWM heater output. PID_3Step drives a motorised valve using open and close pulses with optional position feedback.

Do I need derivative action?

Many industrial loops run as PI only. Derivative reacts to the rate of change and amplifies measurement noise, so it is used only on slow processes with a clean signal.

Why does pretuning fail with an error?

Pretuning needs a stable process before it starts and a measurable response to its test step. A noisy signal, an actuator that is not moving, or a process still settling usually causes the failure.

Should the process value be scaled before PID_Compact?

Use Input with a value already scaled in the input mapping, or Input_PER with the raw value and the scaling configured in the PID. Doing both scales twice.

How does the operator switch PID to manual?

Through the PID mode and a manual value from the HMI, written into the instance DB or an interface DB. PID_Compact switches bumplessly when configured correctly.

Reviewed by Bhawesh Kumar SinghIndustrial Automation Trainer and Industry 4.0 Consultant · Softwell Automation · 21+ years industry experience

Get the full syllabus + free demo class

Share your details—a Softwell training advisor will contact you with batch dates, fees and hardware-practice options.

No spam. Used only to share course details for this enquiry.

Learn with practical industrial examples

Join live online, Pune classroom or corporate in-plant automation training.

Request Course Details
Verified learning pathway

Discuss PID Controller in Siemens PLC

Explore practical curriculum, software, hardware and batch options for this technology.

Content reviewed: 16 October 2026

Siemens PLC & TIA Portal Learning Path

Continue with the related Siemens PLC tutorials in this practical learning series.

  1. SCL vs Ladder Logic
  2. Upload PLC Program
  3. TIA Selection Tool
  4. Analog Input Scaling
  5. PLC Counters
  6. PLC Timers
  7. Addressing & Data Types
  8. Hardware & PLC Tags
  9. OB, FB, FC & DB
☎ Call WhatsApp ✉ Email Enquire Now