Overview
When you commission a 4-20 mA level sensor on a Siemens LOGO! 8 base module, the controller has already done half the work for you: every analog input channel is normalised by the A/D converter to a raw integer between 0 and 1000. The remaining engineering task is to turn that raw count into millimetres of liquid level, and to wire up the four alarm thresholds the application requires: High-High (HH), High (H), Low (L) and Low-Low (LL).
This reference walks through the scaling math, the parameter block and the threshold triggers needed for a 0-2 m tank with a 4-20 mA submersible level probe. The same procedure applies to pressure, flow, temperature and analytical transmitters, and to any 0-10 V sensor wired through a precision shunt.
The procedure relies on three function blocks in LOGO! Soft Comfort:
- Analog Amplifier (B042) — performs the raw-count to engineering-units conversion with Gain and Offset.
- Analog Threshold Trigger (B028) — produces the boolean on/off level alarms.
- Message Text (B024) — displays the live value and the active alarm on the LOGO! onboard screen or on a LOGO! TDE.
Prerequisites
- LOGO! 8 base module (6ED1052-1xx08-0BAx) with firmware 0BA8 or later, or any current LOGO! 8.3 / 8.4 generation hardware. The four onboard analog inputs AI1-AI4 are 0-10 V inputs that can be read as 4-20 mA with a 500 Ω precision shunt.
- LOGO! AM2 analog input module (6ED1055-1MA00-0BAx) if you want direct 0/4-20 mA input without an external shunt. The AM2 RTD module (6ED1055-1MD00-0BAx) is for PT100/PT1000 only.
- LOGO! Soft Comfort V8.4 (or current release) installed on the engineering PC. The Analog Amplifier, Analog Threshold Trigger and Analog Comparator blocks are under the "Analog" instruction group.
- A 4-20 mA loop-powered or 2-wire/3-wire/4-wire level transmitter with a published calibration range. This example uses 0-2 m (0-2000 mm).
- A precision multimeter or process calibrator (Fluke 787, 789 or 754) to inject mA and verify scaling during commissioning.
- A 24 VDC power supply sized for the loop: V_supply minus the transmitter minimum drop must exceed 20 mA × R_loop_total.
4-20 mA Current Loop Fundamentals
The 4-20 mA current loop is the workhorse of process instrumentation. According to Fluke's reference material on 4-20 mA current loops, the loop "typically includes a power supply, a sensor or transmitter, a receiver or controller, and wiring that connects them all in series." The same pair of wires carries both the supply voltage to the transmitter and the analogue current signal back to the controller.
Three engineering rules govern loop design:
- Maximum loop resistance. R_loop_max = (V_supply − V_transmitter_min) / 0.020 A. With a 24 VDC supply and a transmitter that needs 12 V minimum at 20 mA, the maximum loop resistance is (24 − 12) / 0.020 = 600 Ω.
- Live-zero detection. The 4 mA bottom of the range allows the controller to distinguish between a true zero (4 mA) and a broken wire (0 mA). Any reading below 4 mA must be treated as a fault, not as a real value.
- Cable sizing. Cable resistance adds directly to the loop budget. For runs longer than 100 m, use shielded twisted pair, ground the shield at the panel end only, and verify the resistance budget with a wire-resistance table.
For a deeper treatment of loop design, refer to National Instruments' 4-20 mA current loop fundamentals and the AutomationDirect 4-20 mA transmitter troubleshooting guide.
LOGO! 8 Analog Input Architecture
The onboard analogue inputs AI1-AI4 of a LOGO! 8 base module are 0-10 V voltage inputs with an input impedance of 72 kΩ or higher. To read a 4-20 mA signal on these channels, install a 500 Ω precision resistor (0.1% tolerance, 25 ppm/°C or better) across the input terminals. The 4-20 mA becomes 2-10 V, which is well inside the 0-10 V range. In this case the amplifier block must be configured for sensor type "0-10 V" rather than "4-20 mA," because the LOGO! is measuring voltage.
If you fit an AM2 analogue input module (6ED1055-1MA00-0BAx), the inputs are true 0-20 mA / 4-20 mA inputs and the sensor type can be selected directly in the amplifier block. The AM2 module supports two channels and draws from the LOGO! backplane; its terminals accept 0/4-20 mA signals directly without an external shunt.
Whichever path you take, the LOGO! A/D converter normalises the input to 0-1000 raw counts. For a 0-10 V input, 0 V = 0 counts and 10 V = 1000 counts. For a 0-20 mA input, 0 mA = 0 counts and 20 mA = 1000 counts. For a 4-20 mA input on a module configured for 0-20 mA, 4 mA = 200 counts and 20 mA = 1000 counts. That raw count is what the Analog Amplifier block sees on its AI pin.
| Hardware path | Input signal | Raw count at low end | Raw count at high end | Sensor type in amplifier |
|---|---|---|---|---|
| Onboard AI with 500 Ω shunt | 4-20 mA → 2-10 V | 200 | 1000 | 0-10 V |
| AM2 module, direct 4-20 mA | 4-20 mA | 200 | 1000 | 4-20 mA |
| 0-10 V level sensor | 0-10 V | 0 | 1000 | 0-10 V |
| 0-20 mA sensor on AM2 | 0-20 mA | 0 | 1000 | 0-20 mA |
Engineering the Scaling Math
The transmitter for this application has the following published calibration:
- Output: 4-20 mA
- Calibrated range: 0-2 m, or 0-2000 mm of liquid level
The raw count from the A/D converter is 200 at 4 mA and 1000 at 20 mA. We need to map:
- 200 raw counts → 0 mm
- 1000 raw counts → 2000 mm
The linear transform y = m × x + b gives:
- Slope m = (2000 − 0) / (1000 − 200) = 2000 / 800 = 2.5
- Intercept b = 0 − 2.5 × 200 = -500
So:
y (mm) = 2.5 × raw_counts − 500
The Gain parameter in the amplifier is the slope (2.50) and the Offset parameter is the intercept (-500).
Worked Example: 0-10 V Level Sensor with 0-2 m Range
For a 0-10 V sensor with the same 0-2 m range, the raw counts run from 0 to 1000 across the full range and the transform is simply:
y (mm) = 2.0 × raw_counts + 0
This is the Gain = 2.00, Offset = 0 case, with no live zero.
Worked Example: Broken-Wire Fault Detection
If the wire breaks or the transmitter fails, the loop current drops to 0 mA, the raw count is 0, and the amplifier output becomes 0 × 2.5 − 500 = -500. Reading the amplifier output (AQ1) as a negative value in your program is a reliable fault indicator; it cannot occur during normal tank operation because the live-zero protects the lower limit. Drive the negative-AQ condition into a "Sensor Fault" flag and disable the HH/H/L/LL alarm logic in that state.
Signal Path Diagram
Step-by-Step: Configuring the Analog Amplifier
- In LOGO! Soft Comfort, open or create the program. Drag the Analog Amplifier block (B042) onto the schematic.
- Connect the block's AI input to the appropriate analog input flag: AI1 for onboard channel 1, or AI1 of the AM2 module in slot 1 if you used the AM2.
- Open the block properties. Under "Sensor:" select 4-20 mA if using the AM2 module, or 0-10 V if you used a 500 Ω shunt on an onboard channel.
- Set
Measuring range minimum = -500. This sets the lower limit of the displayed engineering range and gives the amplifier headroom to compute the linear transform near the live zero. - Set
Measuring range maximum = 2000. - Set
Gain = 2.50. - Set
Offset = -500. - Set the number of decimal places to 2 if you want the display to read in metres (0.00 to 2.00). Set to 0 for whole millimetres. With two decimal places the amplifier internally scales to 0-200 centi-metres (i.e. 2.00 m), and the AQ flag carries that scaled integer.
- Compile the program with Ctrl+B and download to the LOGO! (Tools → PC ↔ LOGO! Transfer).
The amplifier output flag, e.g. AQ1, now carries the live level in engineering units. Feed this flag into the threshold triggers in the next step.
Step-by-Step: Configuring Threshold Switches for Level Alarms
The application needs four level alarms: HH, H, L and LL. The Analog Threshold Trigger (B028) provides simple on/off alarming with a settable hysteresis. For window alarming (e.g. alarm when the level is between two values), use the Analog Comparator (B013) instead.
Typical alarm setpoints for a 0-2 m chemical-feed tank:
| Alarm | Setpoint (mm) | Hysteresis (mm) | Use case |
|---|---|---|---|
| LL | 100 | 50 | Critical low — protect pump from cavitation |
| L | 300 | 50 | Low — request refill |
| H | 1500 | 50 | High — close inlet, slow inflow |
| HH | 1800 | 50 | High-high — emergency shutoff, spill prevention |
- Drop an Analog Threshold Trigger (B028) on the schematic and connect its AI to the Analog Amplifier output (AQ1).
- Open the block properties. Set
On threshold = 1800for the HH alarm. SetOff threshold = 1750to provide 50 mm of hysteresis and prevent chattering at the setpoint. - Set the amplifier gain and offset to
1.00and0on the trigger block if you are feeding the amplifier's already-scaled output (in mm) directly into the trigger. Alternatively, leave the trigger's gain/offset at default and feed the raw 0-1000 count; the trigger evaluates against the raw range. The mm-based approach is easier to maintain. - The block's Q output is the boolean alarm flag. Wire it to a relay output, indicator lamp, or to a Message Text block for the LOGO! display.
- Repeat for H, L and LL with the setpoints in the table above. For the LL alarm, set the On threshold above the Off threshold (e.g. On = 150, Off = 200) so the alarm asserts when the level drops below 150 mm and clears when it rises above 200 mm. The trigger naturally inverts when configured this way.
Combining Multiple Alarms into a Single Indicator
If you want a single "any alarm" flag for the message text, OR the four Q outputs with a basic OR block (B001) and feed the result into the Message Text trigger. The Message Text block (B024) can show the active alarm number on the onboard LOGO! display or on a LOGO! TDE.
Adding Hysteresis vs. Latching
The Analog Threshold Trigger does not latch; it follows the input through its hysteresis band. To latch an alarm (HH or LL), route the Q output through an SR (Set-Reset) flip-flop block (B003), set the level alarm as the Set input, and use an operator-acknowledge pushbutton (wired to a digital input) as the Reset input. The Q of the SR flip-flop drives the message text and the alarm relay.
Wiring, Filtering and Commissioning
Wiring a 2-Wire Loop-Powered Transmitter
| LOGO! terminal | Connection |
|---|---|
| 24 VDC supply + | Loop power supply + |
| 24 VDC supply − | Transmitter − |
| Transmitter + | AI input + (or top of 500 Ω shunt for onboard channels) |
| AI input − | Bottom of shunt, then back to supply − |
For the AM2 module, connect the transmitter + to the I (input) terminal and the transmitter − to the M (ground) terminal; the AM2 has its own internal shunt and accepts 0/4-20 mA directly.
Shielding and Grounding
Use shielded twisted pair (e.g. Belden 8760, Alpha 2466C) for any run longer than a few metres. Ground the shield at the panel end only, on a clean protective-earth bar, to avoid ground loops. Do not ground the shield at the transmitter end unless the transmitter documentation explicitly requires it.
Analog Filtering (Smoothing) in LOGO!
Level probes in turbulent tanks can produce 5-10 mm of jitter at 100 ms sample time. The LOGO! analog input has a hardware filter on the module, and you can add an "Average value" filter (F006) downstream of the amplifier to smooth the signal. A moving average of 8-16 samples is a good starting point; verify that the response time is still acceptable for your control loop. The 0-1000 raw count is sampled at approximately 10 Hz on the LOGO! 8, so a 16-sample average is about 1.6 seconds of lag.
Verification
- Connect a process calibrator in place of the transmitter (or in series with the loop using the test points).
- Inject 4.000 mA. The amplifier output (AQ1) should read 0 ±1 mm. If it reads 5 mm, the offset is slightly off; adjust the Offset parameter by approximately -5 / 2.5 = -2 raw units of equivalent (i.e. -5 mm of offset correction).
- Inject 12.000 mA (mid-scale, equivalent to 1.000 m of level). The amplifier output should read 1000 ±1 mm.
- Inject 20.000 mA. The amplifier output should read 2000 ±1 mm.
- Inject 0.000 mA (simulated broken wire). The amplifier output should read -500, and the Sensor Fault flag should assert. All four level alarms should clear because the reading is out of range low.
- Reconnect the actual transmitter and verify the level reading against a hand tape or sight glass. Allow a 1-2% tolerance for sensor linearity, temperature drift and mounting height.
- Walk the level through each alarm setpoint (slowly fill or drain) and confirm that each Q output asserts at the On threshold and de-asserts at the Off threshold.
Troubleshooting Matrix
| Symptom | Likely cause | Action |
|---|---|---|
| Reading is stuck at 0 or -500 | Broken wire, blown fuse, transmitter unpowered, reverse polarity | Check loop voltage at the transmitter terminals with a multimeter; verify polarity |
| Reading is stuck at 2000 (full scale) | Loop shorted, transmitter in default high-scale output, sensor in air at full range | Disconnect the transmitter, inject a known mA from the calibrator, re-verify scaling |
| Reading is noisy (±5-10 mm jitter) | Long cable run, no shield, ground loop, turbulent tank, electrical noise from VFD | Use shielded twisted pair, ground shield at panel end only; add F006 average filter; separate signal cable from VFD power cables by at least 200 mm |
| Reading is off by 5-10 mm at mid-scale | Shunt resistor tolerance, A/D offset error, sensor mounting height | Recalibrate with a precision calibrator; adjust the Offset parameter to compensate |
| HH alarm asserts below 1800 mm | Gain set too low, Offset too negative, wrong sensor type in amplifier | Recompute Gain and Offset; verify the raw count at 12 mA matches 600 raw counts |
| All alarms stuck active | Wires reversed on AI channel, wrong sensor type selected, sensor in fault state | Verify the sensor type matches the hardware; check the AQ1 value in online mode |
| Reading goes negative in normal operation | Transmitter live zero shifted (e.g. 3.8 mA instead of 4.0 mA), or wrong sensor type selected | Verify 4 mA → 200 raw count behaviour at the AI terminal with a calibrator; re-zero the transmitter if it has a trim pot |
| Display shows values, alarms never fire | Threshold trigger not connected to AQ1, wrong trigger block, Gain/Offset on the trigger itself is scaling incorrectly | Open the program online, watch the trigger's Q bit; verify the AI pin of the trigger is wired to AQ1 |
| Message text never appears on the LOGO! display | Message Text block not enabled, Acknowledge setting blocking it, or no alarm flag driving the enable | Verify the Message Text enable input is wired to the OR of all four alarm Q bits; check the Acknowledge setting |
How do I compute Gain and Offset for any 4-20 mA sensor on a LOGO!?
Use the two-point linear transform from the sensor's published calibration: Gain = (Eng_Max − Eng_Min) / 800, Offset = Eng_Min − Gain × 200. For a 0-100 °C temperature transmitter, Gain = 100 / 800 = 0.125 and Offset = −25. For a 0-10 bar pressure transmitter, Gain = 10 / 800 = 0.0125 and Offset = −2.5. The constant 800 is the live-zero span (1000 − 200 raw counts) and 200 is the 4 mA raw count.
Can I read 4-20 mA directly on the LOGO! onboard AI1-AI4 inputs without an AM2 module?
Yes. Install a 500 Ω precision resistor (0.1% tolerance, 25 ppm/°C or better) across the input terminals. The 4-20 mA becomes 2-10 V, which the LOGO! measures as 0-10 V. Set the amplifier sensor type to "0-10 V" and use Gain 2.5, Offset -500 with the same calibration; the math is identical because 4 mA still maps to 200 raw counts and 20 mA to 1000 raw counts.
Why does the source example use Offset = -500 instead of 0?
Because the LOGO! A/D converter normalises 0-20 mA (or 0-10 V) to 0-1000 raw counts, not 4-20 mA. The 4 mA live zero therefore appears as 200 raw counts. To map 200 counts to 0 mm and 1000 counts to 2000 mm, the linear transform must have a slope of 2.5 and an intercept of -500. The -500 is the dead zone below 4 mA, which is reserved for fault detection; the amplifier's "Measuring range minimum" parameter is also set to -500 so the math has enough headroom to correctly compute values just above 0 mm.
How do I latch the LL alarm so it stays on until the operator acknowledges it?
Route the LL threshold trigger's Q output through an SR (Set-Reset) flip-flop block (B003). Wire the LL alarm to the S (Set) input, and wire a normally-open operator-acknowledge pushbutton on a digital input to the R (Reset) input. The Q output of the SR flip-flop then drives the message text and the alarm relay, and remains asserted until the operator presses the acknowledge button.
How do I display the live tank level on the LOGO! built-in screen?
Drop a Message Text block (B024) on the schematic, set it to "Message text on LOGO! display," and in the text body insert the AQ1 amplifier output with two decimal places to show 1.234 m, for example. Wire the Message Text enable to a digital input or to the OR of the alarm bits if you want it to appear automatically on alarm. Press ESC on the LOGO! to scroll through active messages, or wire the enable to a digital input for automatic display.
How fast does the LOGO! sample the analog input, and can I increase the rate?
The LOGO! 8 analog inputs are sampled at approximately 10 Hz (100 ms per channel, multiplexed across the four onboard channels). The AM2 module also samples at 10 Hz. If you need faster sampling, you must move to a SIMATIC S7-1200 or ET 200SP, both of which support 1 ms or faster analog conversion. For most tank-level applications, 10 Hz is more than adequate, and the moving-average filter in the LOGO! smooths turbulent readings without further delay.
What happens to the alarms if the transmitter fails or the wire breaks?
The loop current drops to 0 mA, the raw count becomes 0, and the amplifier output becomes -500. The HH, H, L and LL alarms will all clear because the reading is below their On thresholds. The recommended safety pattern is to add a "Sensor Fault" flag driven by AQ1 < 0, latch that flag with an SR flip-flop, and gate the alarm outputs through the negation of the fault flag so that a broken wire produces a known safe state (typically: disable pump, assert a system-fault indicator, raise the LL alarm artificially).