Comparing Analog Values in LOGO! 8: Threshold & Comparator Blocks

David Krause15 min read
HMI ProgrammingSiemensTutorial / 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

Comparing Analog Values in LOGO! 8: Threshold, Differential Trigger, and Analog Comparator Blocks

The Siemens LOGO! 8 (6ED1052 series) and LOGO! 8.3 (6ED1052-xx08-0BA1) combine discrete and analog I/O on a single Basic Module (BM) and offer dedicated function blocks for evaluating analog values against a constant, against another analog signal, or against a window. This reference explains the three native analog comparison blocks - Analog Threshold Trigger (B006), Analog Differential Trigger (B007), and Analog Comparator (B008) - and shows how to wire them in LOGO! Soft Comfort V8.3 / V8.4 for a practical low-water-level pump cutoff application. The configuration flow follows the official Siemens Support document "With LOGO! how can you compare 2 analog values with each other?" (Siemens Support entry ID 24786764), extended with parameter ranges, scaling, MUX switching, and verification procedures.

1. Overview: Why a Dedicated Compare Block?

LOGO! Soft Comfort supplies three blocks that compare an analog value (input AI or function block output AQ) against a threshold and emit a digital 0/1 result. None of them require a separate constant block - the threshold, gain, and offset are entered directly in the block's properties. This eliminates the common beginner mistake of trying to write a greater-than instruction against a free-standing constant tag, which is not a feature of the FBD editor in the way ladder logic programmers may expect.

Table 1 - LOGO! 8 analog comparison blocks at a glance
Block Block # Inputs Output Typical Use
Analog Threshold Trigger B006 Ax (analog) 1 bit (Q) Trip a digital action when a single analog value crosses a level
Analog Differential Trigger B007 Ax, Ay (two analogs) 1 bit (Q) Trip when the difference |Ax - Ay| exceeds a threshold (offset)
Analog Comparator B008 Ax, Ay, ON/OFF thresholds 1 bit (Q) Hysteresis window - turn on at one level, turn off at another
Analog Multiplexer B013 Ax, Ay, Az, S (selector) AQ (analog) Route one of three analog sources to a single output (or two sources via selector bit)

All four blocks live in the Instruction Tree under Special Functions > Analog. They run on a 50 ms cycle in the LOGO! 8 BM and at the configured analog-input scan rate when used with expansion modules.

2. Prerequisites

Before configuring any of the compare blocks, verify the following:

  1. Hardware: a LOGO! 8 or LOGO! 8.3 BM with at least one analog input (AI1 is the default, AI3 and AI4 are available on the 12/24 RCEo and 24 RCE variants; analog input mode 0-10 V or 0-20 mA is selected in the BM's properties). For PT100 / PT1000 / Ni1000 temperature, add a LOGO! AM2 RTD module (6ED1055-1MD00-0BA2).
  2. Firmware: BM firmware FS 04 or higher (FS 05 on the 6ED1052-xx08-0BA1 device). The 24786764 Siemens note is valid for LOGO! 8 (FS 01+) and applies unchanged on LOGO! 8.3.
  3. Software: LOGO! Soft Comfort V8.0 or later (V8.3 / V8.4 recommended for the 6ED1052-xx08-0BA1 BM).
  4. Sensor scaling: know the engineering unit (cm, bar, °C) and the raw mV / μA / Ω from the transducer. Analog input resolution is 10 bits (0-1023) on the 0-10 V range, giving ~9.77 mV per LSB.
  5. Wire shield: shielded twisted pair for runs longer than 5 m, with shield grounded at the BM end only.
The analog inputs of the LOGO! 8 BM share the same ground with the digital 24 V supply. If the sensor is powered from a separate PSU, you must tie the sensor 0 V / GND to the LOGO! M terminal to keep the input inside the common-mode range.

3. Analog Input Wiring and Scaling

LOGO! Soft Comfort displays AI values in their raw count (0-1023 for 0-10 V, 0-1023 for 0-20 mA when AM2 module is used). Two approaches are common when the application needs engineering units:

  • Block-driven: feed the raw value into an Analog Amplifier (B005) and apply Gain / Offset to obtain the engineering range (e.g., 0-500 mV → 0.0-5.0 m of water level with gain 100, offset 0).
  • Direct threshold: enter the threshold in the same units as the raw input. For a 0-10 V level probe with 1 V = 50 cm of water, the low-level cutoff at 20 cm corresponds to 2.0 V = 205 counts.

For the water level example used later, the raw threshold of 205 is the most maintainable because it is independent of gain changes elsewhere in the program.

4. Block 1 - Analog Threshold Trigger (B006)

The Analog Threshold Trigger compares one analog input against a user-entered threshold and outputs a logic 1 when the input rises above (or falls below) that threshold, with optional hysteresis.

Block properties dialog fields:

Table 2 - B006 parameter mapping
Field Meaning Typical range
On threshold Value at which Q turns ON (rising) -20000 to +20000
Off threshold Value at which Q turns OFF (falling) -20000 to +20000
Sensor Selection: 0-10 V / 0-20 mA / PT100 / none Drop-down
Sensor range min/max Engineering range 0-1000 (default)
Output Q flag retained after power cycle? Yes / No

Configuration example: pump cutoff when raw AI1 < 205 counts:

  • On threshold = 205
  • Off threshold = 230 (hysteresis = 25 counts ≈ 25 mV ≈ 12 cm)
  • Sensor = 0-10 V, range 0-1000

The block output Q is wired directly to a digital output (Q1) controlling the pump contactor coil, or to a function block (AND, OR, latching relay). The hysteresis prevents rapid chattering when the level probe fluctuates around the trip point.

5. Block 2 - Analog Differential Trigger (B007)

The Analog Differential Trigger evaluates the difference between two analog signals. It outputs 1 when the magnitude of the difference (Ax - Ay, computed as |Ax - Ay|) exceeds a configurable offset. This is the right block when the engineering question is "is value A more than X higher than value B?"

Typical application: redundant level probes where the controller only acts if both probes disagree by more than, say, 5 cm. The block can be implemented with two threshold triggers plus an AND, but B007 does it with a single instance and a single threshold parameter.

Table 3 - B007 parameter mapping
Field Meaning
Ax First analog input / analog tag
Ay Second analog input / analog tag
Threshold Difference magnitude that trips Q
Sensor & range Same as B006
B007 does not distinguish "A higher than B" from "B higher than A". Use the Analog Comparator (B008) when directional information is required.

6. Block 3 - Analog Comparator (B008)

The Analog Comparator is the most expressive of the three. It compares Ax and Ay directly, with separate ON and OFF thresholds applied to (Ax - Ay). It is the canonical block for windowed decisions and for "is A greater than B?" questions that have to drive a digital output.

Table 4 - B008 parameter mapping
Field Meaning
Ax First analog
Ay Reference / second analog
On threshold (Ax - Ay) at which Q turns ON
Off threshold (Ax - Ay) at which Q turns OFF
Sensor & range Same as B006/B007

Example - stop the pump if tank level falls below setpoint:

  • Ax = AI1 (live level)
  • Ay = fixed analog constant of 205 (entered as the B008 Ax reference against an analog amplifier holding the constant, or by routing a free "analog constant" parameter through the block's gain/offset)
  • On = 0, Off = -25 (Ax below Ay → Q drops to 0, releasing the pump contactor)

Per the Siemens 24786764 entry, when only one analog value is involved, the second input can be tied to a fixed analog tag set to the trip level, or the B006 block is simpler. Use B008 only when the second source is also live (e.g., comparing AI1 against AI2 of a second sensor, as in the 24786764 two-sensor example).

7. Application: Water Level Pump Stop on Low Level

The motivating problem is straightforward: a tank has a 0-10 V submersible level probe; the pump must run when level is high, stop when level drops below the low setpoint, and remain off until level recovers to a separate high setpoint (hysteresis prevents short cycling).

Two approaches work in LOGO! Soft Comfort.

Approach A - Single Analog Threshold Trigger (simplest)

AI1 ---> [B006 Analog Threshold Trigger]
   On threshold = 410 (≈ 4.0 V, 200 cm, low-level reset / pump start)
   Off threshold = 205 (≈ 2.0 V, 100 cm, low-level cutoff / pump stop)
   Q   ---> [B001 RS Latch "Pump_Run"]
   S input = (Q of B006)
   R input = (NOT Q of B006, or a separate B006 with swapped thresholds)
RS Q  ---> Q1 (pump contactor)

This works because the hysteresis built into B006 with a 0-20 mA or 0-10 V sensor produces non-overlapping trip points. A single B006 with the inverted-polarity trick (On = 410, Off = 205) is enough; no constant block is needed.

Approach B - Analog Comparator against a live reference

AI1 (level)         ---> Ax of B008
Analog constant tag "LowSet"  ---> Ay of B008 (entered as 205 raw counts via an Analog Amplifier gain=1, sensor=0-10V range 0-1000)
B008 Q  ---> Pump run logic (AND with manual auto, etc.)

Approach B is preferable when the setpoint has to be adjusted from the LOGO! display or from the LOGO! Web server (only on -0BA0 and -0BA1 BM with Ethernet) - the analog constant becomes a parameter the user can edit from the LOGO! TDE text display.

8. Using Analog MUX (B013) to Switch Between Two Sensor Sources

When the controller must decide between two sensor sources (for example, a primary probe and a redundant probe) and apply the same threshold to whichever is active, an Analog Multiplexer sits between the probes and the threshold block.

AI1 (probe A)  ---> Ax of B013
AI2 (probe B)  ---> Ay of B013
Selector flag M10  ---> S of B013
B013 AQ  ---> Ax of B006 (Analog Threshold Trigger)
B006 Q  ---> pump logic

The selector flag S = 0 routes Ax to the output; S = 1 routes Ay. The threshold block therefore evaluates whichever probe is active without re-wiring the program. The B013 block can be cascaded - a second instance can switch the AQ to a fallback reference level if both probes fail, yielding a three-state health signal.

LOGO! Soft Comfort allows up to 4 MUX instances in a single program on the 6ED1052-xx08-0BA1 BM (FS 05). Exceeding the instance count triggers the program-compile error "Maximum number of blocks exceeded".

9. Step-by-Step Configuration in LOGO! Soft Comfort

  1. Open or create the project. From the toolbar, choose File > New, select BM 6ED1052-1CC01-0BA8 (or matching 0BA1), and set the analog-input mode to 0-10 V in the BM properties (Start screen > BM > AI1..AI4 mode = 0-10 V).
  2. Insert the comparison block. Drag Analog Threshold Trigger from the tree into the FBD workspace. Double-click the block to open its property dialog.
  3. Wire the analog input. Drag from AI1 in the connector list to the Ax pin of the block. The connection is verified by the green tick in online mode.
  4. Enter the threshold. In the block properties, set On threshold and Off threshold in the engineering unit of the sensor range. Click Apply.
  5. Wire the output. Connect the block's Q to either a digital output (Q1) or to the S input of an RS latch, depending on whether the digital action should be momentary or latched.
  6. Download. With the BM connected via Ethernet, choose PC > LOGO! and click Download. Online monitoring turns every active block border red.
  7. Save backup. Choose File > Save As to archive the .lsc project file. LOGO! Soft Comfort V8.4 saves as .lsc; older versions used .lgo.

10. Verification and Testing

Verification combines offline simulation, online monitoring, and field forcing.

  1. Offline simulation: Tools > Simulation. Move the AI1 slider below the Off threshold - the Q output indicator on the block must turn from green to grey. Move it above the On threshold - Q must turn green. If the indicator flickers near the threshold, hysteresis is too small; widen the On/Off gap to at least 20 counts.
  2. Online monitor: Tools > Online Test. Verify the actual raw count by hovering the mouse over the AI1 connector; the tooltip shows the live value. Confirm the displayed count matches a hand-held DMM reading at the AI1 terminal within ±1 count (10 mV on 0-10 V).
  3. Field forcing: disconnect the level probe and inject a calibrator voltage at the AI1+ / M terminals. Step the calibrator from 0 to 10 V in 1 V steps. Log the B006 Q state at each step. The transition must occur within ±10 mV of the configured threshold.
  4. Power-cycle retention: if the Q output of the threshold block is configured to retain state, power down the BM for 30 s and power up. Q must return to its last state, not default to 0.
Never inject voltage outside the 0-10 V / 0-20 mA common-mode range. The BM's analog input protection is a 30 V TVS; sustained over-voltage destroys the input.

11. Troubleshooting Matrix

Table 5 - Common analog compare problems and remediation
Symptom Likely Cause Remediation
Q never changes from 0 Threshold is in engineering units, raw input is in counts (or vice versa) Match threshold units to sensor range. With 0-10 V / 0-1000 range, use the raw 0-1000 count, not the mV value.
Q flickers at the trip point Hysteresis too narrow or absent Set On threshold ≠ Off threshold with at least 2% of full-scale gap.
Block compiles but Q reads 0 in online mode Wrong sensor type selected (PT100 selected on a 0-10 V input) Open the block properties, set Sensor = "None, 0-10 V" (or 0/4-20 mA as wired).
AI1 always reads 0 Mode jumper in mA position but sensor is voltage, or vice versa Check the BM's front-panel mode jumper: UP = 0-10 V, DOWN = 0/4-20 mA. The setting must match the sensor wiring.
Block not visible in FBD toolbar Project created with an older BM profile Open Tools > BM Selection and choose a 6ED1052-xx08-0BA1 BM profile.
Q output stuck after power cycle Retention flag not set Open the block, enable Output retained.
Comparison is inverted (Q high when level low) Sensor wiring polarity reversed (AI1+ and AI1- swapped on a 3-wire probe) Swap the AI1+ and AI1- wires, or invert by setting On threshold > Off threshold instead of On < Off.
MUX always outputs Ax Selector flag never set Drive the MUX S pin from a digital flag, not a free input; verify the flag toggles in online mode.
Program won't download ("block count exceeded") More than 4 B013 instances or more than 8 B006/B007/B008 instances Reduce block count, share threshold logic across a single block, or upgrade to a -0BA1 BM with a larger block budget.

12. Field-Proven Tips

  • Wire the analog ground at the BM end, not at the sensor end. Long cable runs with two ground points create ground loops that bias the AI input by tens of mV.
  • Filter noise with an Analog Filter block (B004) ahead of the threshold block when the level probe is on the same tray as a VFD output cable. A 200 ms time constant removes 50/60 Hz pickup without slowing the low-level trip unacceptably.
  • Document the threshold in the FBD comment field of the block. Right-click the block → Block Comment - this text exports with the project PDF and is the only way another engineer can read the trip level without opening the property dialog.
  • Use the LOGO! TDE (text display, 6ED1055-4MH00-0BA0) to expose the threshold as a settable parameter. Map the threshold to a VM (variable memory) tag and bind the VM to the threshold field - the operator can then adjust the level setpoint from the panel without a programming PC.
  • Test the failure case: with the sensor disconnected, the AI reads 0 (or 4 mA on 4-20 mA mode, where 4 mA = 205 counts). If the threshold is set above that, the pump will simply stop - which may be the wrong safe state. For fail-safe design on a 4-20 mA loop, set the threshold above the 4 mA zero so a wire break forces the safe (off) state.

13. Frequently Asked Questions

Which block should I use to compare a single analog input with a constant in LOGO! Soft Comfort?

Use the Analog Threshold Trigger (B006). It has built-in On and Off thresholds, so no separate constant block is required. The Analog Comparator (B008) is needed only when the second value is also a live analog signal, as documented in Siemens Support entry 24786764.

What is the difference between the Analog Differential Trigger (B007) and the Analog Comparator (B008)?

B007 outputs a digital signal based on the magnitude of |Ax - Ay| exceeding a threshold, with no directional information. B008 outputs based on the signed difference (Ax - Ay) and supports separate ON and OFF thresholds for hysteresis, making it the right block for "is A greater than B?" decisions.

Why does my threshold block never trip even though the analog input looks correct?

Most often the threshold is entered in engineering units (mV, cm) while the input is displayed in raw counts (0-1023 for 0-10 V). Match the units: for a 0-10 V sensor with a 0-1000 sensor range in the block, enter 205 (counts) to trip at 2.05 V, not 2.05. The Siemens 24786764 entry shows the same precaution for two-sensor comparisons.

How many threshold / comparator blocks can a single LOGO! 8 program contain?

On a 6ED1052-xx08-0BA1 BM with FS 05 firmware, the practical limit is 8 instances of B006 / B007 / B008 combined, and 4 instances of the B013 Analog Multiplexer. Exceeding these counts raises a program-compile error and requires consolidating the logic or using the variable-memory (VM) area to share a single threshold across multiple decisions.

Can I change the threshold from the LOGO! TDE without a programming PC?

Yes. Map the On/Off threshold fields to a VM tag (range VM 0-VM 127 on LOGO! 8), then expose that VM on a TDE message line. Operators adjust the VM from the panel and the change is picked up on the next 50 ms analog cycle. The threshold retention is non-volatile across power cycles.

How do I switch between two level probes feeding the same threshold block?

Place an Analog Multiplexer (B013) between the two probes and the threshold block. The S (selector) input is a digital flag; S = 0 routes the first probe to AQ, S = 1 routes the second. The threshold block downstream sees a single source and needs no other change.

Back to blog