LOGO! 0BA8 Tank Level PI Control: 0-10V Sensor Wiring and Tuning

David Krause14 min read
PID ControlSiemensTutorial / 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

Overview

This reference designs a closed-loop tank level control using a Siemens LOGO! 0BA8 (LOGO! 8 generation) and an analog infrared distance/level sensor with a 0-10 V output. The control law is implemented with the integrated PI controller function block in LOGO! Soft Comfort V8.x, driving a pump or valve through a discrete or analog output. The block exposes a manual/automatic switch on a digital input, allowing the operator to override the loop during commissioning, cleaning, or sensor maintenance.

Important: The LOGO! PI block does not include an auto-tuning function. The engineer must determine the controller gain (KC) and integral action time (TI) manually using step-test or open-loop characterization. Derivative action is not available, hence PI rather than PID.

System Architecture and Components

The minimum bill of materials for a working bench-top or pilot loop is:

Item Function Notes
LOGO! 12/24 RCE (6ED1052-1MD08-0BA1) or 230 RCE (6ED1052-1FB08-0BA1) Logic relay and PI controller 0BA8 hardware; RCE includes Ethernet, web server, micro SD
LOGO! AM2 (6ED1055-1MA00-0BA2) Additional 0-10 V or 0/4-20 mA inputs Two analog inputs; only required if base AI is occupied
LOGO! AM2 AQ (6ED1055-1MM00-0BA2) 0-10 V analog output (optional) Used to drive a variable-speed pump or proportional valve
Infrared distance/level sensor, 0-10 V output Process variable (PV) measurement Confirm sensing range covers the full tank height with margin
24 VDC power supply (LOGO! or external) Sensor and module power Sensor current draw must be within PSU rating
Pump or solenoid valve Final control element Discrete (relay output) or analog (AQ module)
LOGO! Soft Comfort V8.x Programming environment Free download from Siemens support

Verify the sensor is an analog type, not a switching type, and that the output range is 0-10 VDC (or jumpered to 0-10 V if 0/4-20 mA/0-10 V selectable). A 4-20 mA sensor on a 0-10 V input will produce zero voltage at 4 mA and is not directly compatible without a 250 Ω shunt resistor and recalibration of the live-zero.

Prerequisites

  1. LOGO! 0BA8 base module powered and functional; firmware status readable in LOGO! > Diagnostics on the device or in LOGO! Soft Comfort online mode.
  2. LOGO! Soft Comfort V8.0 or later installed on a Windows PC; project file set to "LOGO! 0BA8" as the target device.
  3. Ethernet or USB cable to download the program to the controller.
  4. Sensor datasheet on hand for: output type (0-10 V), response time, sensing range, dead band, and warm-up time.
  5. Known tank geometry: cross-sectional area A (m²) and maximum permissible level (for setpoint selection).
  6. Multimeter for verifying 0-10 V at the LOGO! terminal under actual tank conditions.
  7. Means of filling and draining the tank for step-testing (e.g., manual fill valve, drain valve).

Wiring and Signal Conditioning

On the LOGO! 0BA8 base module, terminals I7 (AI1) and I8 (AI2) double as 0-10 V analog inputs. Reference the analog ground at terminal M or M1 on the same base unit. The sensor's 0-10 V output connects between AI1 and M. Shielded cable is recommended for the analog run; ground the shield at the LOGO! end only.

Standard base-unit analog input characteristics (refer to the LOGO! 8 system manual for exact ratings):

Parameter Value
Input range 0 to 10 VDC
Input impedance ≥ 100 kΩ
Resolution (engineering units) 10 bits, 0 to 1000
Maximum overvoltage Refer to manual; reverse polarity protection is limited
If using an AM2 (4-20 mA) input instead, set the DIP switch on the AM2 to "I" (current) and wire the sensor in a current loop. The 0-10 V base inputs cannot accept 4-20 mA directly.

For the final control element, two wiring options exist:

  • Discrete (bang-bang-ish but with PI output scaled to PWM): Use a relay output (Q1-Q4 on the base). The PI block output 0-1000% is converted to a pulse-width modulation on the digital output via an Analog Threshold Trigger or PWM block. Suitable for a fill solenoid.
  • Continuous (recommended): Install an AM2 AQ module. The PI block's analog output drives the 0-10 V output directly into a variable-speed pump drive or proportional valve.

Sensor Scaling and Calibration

The example in the source uses an inverse mapping: 0 V corresponds to 2 m filling height (sensor closest to liquid) and 10 V corresponds to 0 m filling height (sensor farthest). This is typical for top-mounted infrared distance sensors that measure the gap above the liquid surface.

Define the engineering range:

  • PV_min = 0.00 m (empty tank, sensor output = 10 V)
  • PV_max = 2.00 m (full tank, sensor output = 0 V)

The transfer function in engineering units (meters) from the LOGO! raw value R (0-1000 representing 0-10 V) is:

Level (m) = PV_max - (R / 1000) * (PV_max - PV_min)
Level (m) = 2.00 - (R / 1000) * 2.00

Implement this in the FBD using an Mathematical Instruction (subtraction) or an Amplifier block configured with the following gain/offset:

Parameter Value Meaning
Sensor type 0 - 10 V Live range of the physical sensor
Lower sensor limit 0.00 m Process value at 10 V (sensor far)
Upper sensor limit 2.00 m Process value at 0 V (sensor near)
Gain -1.00 Inverts so 10 V → 0 m, 0 V → 2 m
Offset 2.00 Shifts to engineering zero

Calibration steps before running the loop:

  1. Empty the tank. Read the LOGO! raw value at AI1 and confirm it is near 1000 (close to 10 V). Adjust the sensor's "far distance" or "zero" trim if your sensor provides it.
  2. Fill the tank to the maximum mark. Confirm the raw value is near 0 (close to 0 V). Adjust the sensor's "near distance" or "span" trim.
  3. Document the actual raw values at empty and full for the operator's reference (e.g., 998 empty, 4 full). The ideal 0/1000 endpoints are rarely achieved in practice.

PI Controller Configuration in LOGO! Soft Comfort

Open the Instruction catalog and drag the PI Controller block onto the FBD canvas. Connect:

  • PV input → the scaled level signal from the Amplifier block.
  • SP input → a constant block (or analog flag) holding the setpoint, e.g., 1.50 m for a 75% target fill.
  • Auto/Man input → digital input I1, configured as a switch (closed = automatic).
  • Manual value input (ManVal) → a constant holding the manual output, e.g., 30.0%.
  • Output (AQ) → either the AM2 AQ 0-10 V channel or the input of a PWM generator driving a digital output.

Block parameter settings (refer to LOGO! Soft Comfort V8 help for the exact field names):

Parameter Typical value Description
SP (Setpoint) 1.50 m Desired level in engineering units
KC (Gain) Start at 0.5 Proportional gain (dimensionless)
TI (Integral time) Start at 60 s Reset action in seconds; 0 disables integral
Dir (Direction) Positive (or Negative) Sign of control action; choose so PV rising → output decreases for fill control
Min output 0 Lower output clamp (0% or 4 mA)
Max output 100 Upper output clamp (100% or 20 mA)
Manual mode behavior Bumpless transfer LOGO! tracks PV error in auto; freezes integral in manual
Direction of action: If the pump fills the tank, increasing level should reduce pump speed. Use the controller direction setting that yields negative output for positive error (PV above SP). For a drain pump, invert the direction.

Manual/Automatic Switching Logic

The Auto/Man input is a boolean. When I1 is OFF, the controller output is held at the value provided on the ManVal input. When I1 is ON, the PI algorithm runs. LOGO! implements bumpless transfer by initializing the integral term with the current manual output value at the moment of switch-over, preventing an output step. To ensure this works, hold ManVal close to the steady-state output you expect in auto.

Recommended wiring of I1:

  • Use a maintained selector switch, not a momentary pushbutton, unless latching logic is added in the FBD.
  • Wire a panel indicator lamp in parallel with I1 to show the loop is in automatic.
  • Add a software debounce of 50-100 ms in the FBD using an On-Delay block if the switch is mechanical and located in a vibrating panel.

Tuning KC and TI Without Auto-Tune

Because the LOGO! PI block has no auto-tune, use one of the three classic manual methods.

Method 1: Open-Loop Step Test

  1. Place the loop in manual. Drive the output to a known value, e.g., 40%.
  2. Wait for the level to settle to a steady reading (this may take minutes for tall tanks).
  3. Step the output from 40% to 50% (a 10% step). Record the level versus time.
  4. From the recorded curve, read:
  • Kp_process = ΔLevel / ΔOutput (in m per %)
  • τ (tau) = apparent dead time (s) before the level changes after the step
  • T (T_63) = time to reach 63% of the total ΔLevel

Apply Ziegler-Nichols open-loop tuning for a PI controller:

Controller KC TI (s)
P τ / (Kp_process * T) —
PI 0.9 * τ / (Kp_process * T) 3.33 * τ
PID (n/a on LOGO!) 1.2 * τ / (Kp_process * T) 2 * τ

Ziegler-Nichols tends to be aggressive. Divide KC by 1.5-2.0 and increase TI by 1.5-2.0 for a smoother response, especially if the tank surface is agitated or the sensor is noisy.

Method 2: Closed-Loop Ultimate Gain (Relay Method)

  1. Place the loop in automatic with KC = 0.01, TI = 0 (purely proportional, very weak).
  2. Add a relay-like discrete block in the FBD: when PV > SP + ε, set output to 0%; when PV < SP - ε, set output to 100%. The relay amplitude ε = 1% of span is typical.
  3. Observe the sustained level oscillation. Measure Pu, the period of the oscillation.
  4. Compute Ku by gradually increasing KC and reducing the relay logic until a pure proportional loop oscillates. In practice, the LOGO! relay method is sufficient to estimate Pu; estimate Ku from the step-test Kp_process.

PI settings: KC = 0.45 * Ku, TI = Pu / 1.2.

Method 3: Trial and Error with Safety Clamps

  1. Set KC = 0.2, TI = 120 s. Run the loop with an empty tank and a low setpoint.
  2. Increase KC in 0.1 increments until you see a single overshoot of 3-5% on level.
  3. Reduce TI in 30 s increments until the controller eliminates offset within 2-3 cycles.
  4. Back off KC by 20% to leave margin for setpoint changes.

Complete Program Structure (FBD Outline)

A typical LSC V8 program for the loop consists of the following blocks in execution order:

  1. AI1 (0-10 V raw) → Amplifier (scaling 0-10 V → 0-2.00 m, inverted gain -1, offset +2) → tag PV_m.
  2. Constant block → 1.50 m → tag SP_m.
  3. PI Controller block: PV = PV_m, SP = SP_m, Auto/Man = I1, ManVal = constant 30.0, KC = 0.5, TI = 60 s, Dir = Negative, Min = 0, Max = 100. Output → tag CV_pct.
  4. Threshold trigger (optional): if CV_pct > 5% and Auto/Man = ON, set Q1 (pump starter) to ON.
  5. PWM block (alternative to threshold): period 5 s, input = CV_pct, output → Q1.
  6. AM2 AQ output (continuous): value = CV_pct * 10 (convert 0-100% to 0-10 V via the AQ block gain).
  7. HMI text block on the LOGO! onboard display: show PV_m, SP_m, CV_pct.

Save the program to the LOGO! via Ethernet or USB and switch to RUN mode. Use the LOGO!'s built-in web server (RCE variants) for browser-based monitoring without a panel.

Verification and Commissioning

  1. Signal check: With the sensor in air at the maximum distance, multimeter reads 9.5-10.0 V at AI1-M. With the sensor at minimum distance, multimeter reads 0-0.5 V.
  2. Scaling check: In online mode, observe PV_m. At empty tank PV_m = 0.00 ± 0.02 m. At full tank PV_m = 2.00 ± 0.02 m.
  3. Manual output check: Place Auto/Man switch in Manual, set ManVal = 50%. Pump runs at 50% speed (or relay cycles 50% duty if PWM).
  4. Setpoint step test: In auto, change SP from 1.00 m to 1.50 m. Record PV vs time. Expect monotonic rise, no overshoot greater than 5% of setpoint change, settle within 3-5 tau.
  5. Disturbance rejection test: Open a manual drain valve to simulate load disturbance. PV should dip but recover to SP within 1-2 tau.
  6. Bumpless transfer test: Toggle Auto/Man rapidly at setpoint. Output should not jump by more than 2%.

Troubleshooting Matrix

Symptom Likely cause Action
PV reads 0.00 m regardless of actual level Sensor wiring reversed, AI set to wrong range, or sensor has 4-20 mA output on a 0-10 V input Verify 0-10 V at terminal with multimeter; check sensor DIP switch or jumper for voltage output
PV reads 2.00 m regardless of level Sensor saturated at far distance, or wiring open Check sensor supply voltage; check cable for breaks; confirm sensor in range
PV jitters by ± 0.05 m at steady state Sensor noise, no filtering, pump vibration coupling into sensor Add an Average value block with N=8 over AI1; mechanically isolate sensor from pump
Output saturates at 100% and never reaches setpoint Direction of action reversed Toggle Dir parameter in PI block; verify by watching output when PV > SP
Output oscillates continuously with growing amplitude KC too high for the loop dynamics Reduce KC by 50%; increase TI by 50%
PV settles at wrong value, offset persists TI set to 0 disables integral action Set TI to a finite value (30-300 s typical)
Large step in output when switching from Manual to Auto ManVal far from actual auto output Pre-load ManVal with current output before switch-over; rely on bumpless transfer
PI block shown grayed out / unavailable in catalog Wrong target device selected in LSC (e.g., older 0BA6 or 0BA7) In LSC: File > Properties > Target Device → set to LOGO! 0BA8
AM2 AQ module output is always 0 V Module not declared in hardware configuration In LSC: Tools > Hardware Catalog → add AM2 AQ at correct slot
Pump chatters (relay clicking rapidly) PWM period too short for the solenoid Increase PWM period to 10-30 s; consider continuous AQ output for proportional valves

Field-Proven Caveats

  • Infrared sensors are sensitive to foam, steam, dust, and condensation on the lens. Specify an IP67 sensor and clean the lens on a maintenance interval. Foamy liquids defeat most optical level sensors; consider guided-wave radar instead.
  • The 0BA8 analog inputs have no galvanic isolation from the supply. A grounded sensor near a VFD-driven pump can inject common-mode noise. Use a shielded cable, ground the shield at one end only, and consider a signal isolator if the noise persists.
  • The LOGO! PI block computes in engineering units scaled to the input range. If you change the scaling block (Amplifier) parameters, the PI block's KC interpretation also changes because KC is applied to the already-scaled signal. Recompute KC if you rescale.
  • Power-up behavior: on cold start, the PI integral term initializes to zero. If the tank is far from setpoint, expect a soft-start transient. Pre-charge the tank manually to near setpoint before switching to Auto for clean commissioning.
  • For batch tanks that fill and empty cyclically, consider adding a second PI controller with different KC/TI for filling versus draining, selected by a digital mode input. Single-loop tuning rarely works well for both directions when pump head curves are asymmetric.
  • LOGO! Soft Comfort's simulation mode runs the PI block. Use it extensively to verify scaling and direction of action before connecting to a live tank.

Related Documentation

Which analog input terminals on the LOGO! 0BA8 accept 0-10 V?

Terminals I7 (AI1) and I8 (AI2) on the base 0BA8 unit accept 0-10 VDC with 10-bit resolution. The reference is the M or M1 terminal on the same base. For additional channels use the AM2 expansion module (DIP-switched to voltage mode).

Does the LOGO! PI controller block support auto-tuning?

No. The PI controller block in LOGO! Soft Comfort exposes KC, TI, direction, and output clamps only. You must tune KC and TI by open-loop step test, relay-feedback test, or manual trial-and-error.

How do I scale a 0-10 V signal where 0 V means full and 10 V means empty?

Use the Amplifier (Analog) block with sensor type 0-10 V, set the lower engineering limit to 0.00 m (empty), the upper limit to your full level (e.g., 2.00 m), and apply a gain of -1 with an offset equal to the upper limit. This inverts and shifts the signal into the correct 0 to full-level range.

Can I drive a 4-20 mA valve from the LOGO! 0BA8?

Yes, by adding the LOGO! AM2 AQ module (catalog 6ED1055-1MM00-0BA2), which provides two 0-10 V outputs. Convert the LOGO! 0-10 V to 4-20 mA with an external V/I converter, or use a 4-20 mA valve with a 0-10 V input via a signal conditioner.

What is the difference between LOGO! 0BA8 and 0BA7 for this application?

Both generations support the PI controller block and 0-10 V analog inputs, but 0BA8 adds an integrated Ethernet port, a built-in web server for monitoring, micro SD card support, and a more responsive display. 0BA7 is acceptable for a non-networked bench loop; 0BA8 is the recommended choice for new installations.

Back to blog