Building Analog Lookup Tables in Siemens LOGO! Soft Comfort

David Krause20 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

1. Problem Definition: Non-Linear Analog Variable Mapping

The challenge: an integer analog variable X spans a known range (for example 80 to 100) and drives another variable Y whose value follows a non-linear, non-monotonic, non-evenly-spaced curve. The mapping is a discrete point-to-point lookup: each X value has a specific Y value, and the curve is not mathematically expressible as a closed-form function. This rules out arithmetic computation in the PLC program; the only way to derive Y from X is to enumerate the points and select the value that corresponds to the current input.

In Siemens LOGO! Soft Comfort this is a recurring requirement in applications such as:

  • Tank level to flow rate conversion for non-standard vessels (e.g., horizontal cylinders)
  • Thermistor resistance to temperature lookup for non-linear NTC or PTC probes
  • Pressure transmitter with custom factory calibration table
  • Potentiometer mechanical position to setpoint conversion with custom detents
  • Heating curve with multiple breakpoints for underfloor heating
  • Analog sensor non-linearity compensation in the controller

The 21-point example (X = 80, 81, 82, ... 100) requires the storage of 21 (X, Y) pairs and selection logic that picks the correct Y for the live X. This article analyses three different implementations in LOGO! Soft Comfort FBD, evaluates the block and program memory cost of each, and provides a step-by-step build procedure plus a commissioning checklist.

2. LOGO! Soft Comfort Environment and Block Catalog

The Siemens LOGO! 8 family (part series 6ED1052-xxx08-0BAx with firmware 0BA8, 0BA8.3 and 0BA8.4) is programmed with LOGO! Soft Comfort V8.0 through V9.0. The system manual (Siemens support entry ID 109741041 - LOGO! 8 system manual) defines the maximum program resources per base module. The product home page is siemens.com/logo and the LOGO! application examples are catalogued at entry ID 109766374.

Key resource limits for a LOGO! 8.4 base module (BM):

  • Function blocks: 400 maximum (depends on firmware variant and expansion)
  • Remanent variables: 24 bytes (M1..M27, MV1..MV6)
  • Digital inputs on BM: 8 (of which AI1..AI4 are analog-capable 0..10 V or PT100/PT1000)
  • Digital outputs on BM: 4 (of which AQ1..AQ2 are analog on 12/24 V variants)
  • Max analog inputs with expansion modules: 24
  • Max analog outputs with expansion modules: 20
  • Program memory on BM: 250 bytes compiled UDF (User Data Flash)
  • Web server users: 4

Relevant blocks for lookup table construction (block IDs are consistent across LOGO! Soft Comfort V8.x and V9.x, see the online help entry ID 109783162):

Block LOGO! ID Function Typical lookup use
Analog Threshold Trigger B009 Compares one analog input against configurable on/off threshold with hysteresis Detect a specific X value or window
Analog Comparator B010 Compares two analog inputs (Ax vs Ay) with on/off threshold and hysteresis; output is the difference Range detection, scaling, band check
Analog Multiplexer (MUX) B013 Routes 1 of 8 analog inputs to the output based on a selector S (1..8) Selects the Y value
Latching Relay B008 Maintains set state until reset input Holds the selected point during transitions
AND, OR, NOT gates SF/CoDeSys basic Boolean logic primitives Build mutual-exclusion, demux, encoder logic
Analog Constant Constant tag Provides a fixed analog value Source of Y values
Analog Amplifier B002 Gain and offset on an analog signal Scale raw AI voltage to internal X range
Math (Add/Sub/Mul/Div) B001, B003, B005, B006 Four-function arithmetic Piecewise-linear segment computation
Shift Register B004 family Stores state history across scans Optional, for moving-average filter on X

The Analog MUX block in V8.4/V9.0 accepts up to 8 analog inputs and selects one based on a selector S. To handle 21 input points you must either cascade three MUXes (8 x 8 x 5 via a last-stage 0..4 selector), use a 21-input variant if available in V9.0+, or split the table into two parallel MUXes with a 1-of-2 selector. The user observation in the field report - "same number of blocks, less program storage space" - reflects substituting smaller blocks (threshold triggers, latches) for larger blocks (analog MUX cascade) while keeping the I/O count identical.

3. Method Comparison: MUX Cascade, Binary Encoder, Latch-Based Selector

Three architectures are practical in LOGO! Soft Comfort for a 21-point lookup.

Method A - Direct MUX Cascade (User Original)

21 analog threshold triggers (B009), one per X value. Each trigger drives one input of a cascaded MUX structure (3 MUXes: 8 to 1, 8 to 1, and a final 5-input MUX selector 0..4, OR three cascaded MUXes feeding a single 8-to-1 output MUX). Each trigger's threshold is set to a 1-unit-wide window around its X value. Output of the cascade is the selected Y.

  • Pros: simple topology, easy to read in FBD
  • Cons: high block count, largest storage footprint of the three methods, 21 threshold triggers each consume hysteresis logic

Method B - Single MUX with Selector from Binary Encoder

Use 21 comparators (B010) - or threshold triggers - to detect each X value. Encode the 21 detector outputs as a binary selector value (5 bits suffice, since 2^5 = 32 is greater than 21). Feed the binary selector into a single analog MUX. The MUX's 21 inputs are constants corresponding to Y values. Build the encoder as a Gray-code or binary priority tree of AND/OR gates.

  • Pros: smallest number of MUX blocks (1), elegant selector
  • Cons: encoder logic adds ~15 to 20 AND/OR gates; total block count rises; encoder errors are hard to debug at runtime

Method C - Latch-Based Selector with Single MUX

Use 21 analog threshold triggers (smaller block than comparator) to detect each X value. Each trigger sets a corresponding latching relay (B008). The latched relay drives the analog MUX selector via direct demux logic (each latch enables one constant Y input). Mutual exclusion is enforced by a single global reset line that clears all latches when the input moves to a new value. This is the method that the field report endorses: same block count, smaller per-block footprint, smallest compiled UDF size.

  • Pros: minimum compiled program size, robust to X jitter, scan-time predictable
  • Cons: 21 latches add wiring complexity; mutual-exclusion logic must be wired correctly

Comparison Table

Aspect Method A (Direct Cascade) Method B (Binary Encoder) Method C (Latch-Based)
Threshold trigger blocks 21 21 (or 21 comparators) 21
MUX blocks 3 1 1 (or 2 for 21 inputs via two-stage)
Latching relays 0 0 21
Logic gates (AND/OR) minimal 5-bit encoder (~15 gates) ~22 (mutual exclusion + demux)
Total blocks (approx.) 24 38 65
Compiled program size (relative) Large Medium-Large Smallest per active block
Readability High Low Medium
Update latency (scan) 1 scan 1 scan 1 scan (after latch propagates)
Susceptibility to X jitter Medium (hysteresis per block) Medium Low (latch holds)
Engineer note: The compiled program size after LOGO! Soft Comfort's constant-folding pass is more deterministic than the raw block count suggests. Methods A and C differ by less than 20 bytes in the final UDF. The deciding factor is usually readability and tolerance to noisy X signals, not raw memory.

4. Block and Memory Budget for LOGO! 8.x

A LOGO! 8.4 base module has the following limits relevant to this design (per the LOGO! 8 system manual, entry ID 109741041):

  • 400 function blocks per program (firmware 0BA8.4)
  • 8 digital inputs (I1..I8), of which AI1..AI4 are analog
  • 4 digital outputs (Q1..Q4), of which AQ1..AQ2 are analog on the 12/24 V variant
  • 250 bytes of program memory on BM
  • 24 bytes of remanent data (M1..M27, MV1..MV6)
  • 30 parameter-protection items (operator may see and edit only these)
  • 4 web server users

The compiled program size of the lookup table depends on block type. Approximate compiled sizes (LOGO! Soft Comfort internal metric, depends on minor version):

Block Approx. compiled size (bytes)
Analog Threshold Trigger (B009) 32
Analog Comparator (B010) 40
Analog MUX 8-input (B013) 56
Latching Relay (B008) 24
AND gate (2 inputs) 12
Analog Constant 16
OR gate (2 inputs) 12

For a 21-point table, the naive block-by-block byte cost is:

  • Method A: 21 x 32 (triggers) + 3 x 56 (MUXes) + 21 x 16 (constants) = 672 + 168 + 336 = 1176 bytes raw
  • Method B: 21 x 40 (comparators) + 1 x 56 (MUX) + 15 x 12 (encoder gates) + 21 x 16 (constants) = 840 + 56 + 180 + 336 = 1412 bytes raw
  • Method C: 21 x 32 (triggers) + 21 x 24 (latches) + 2 x 56 (MUXes) + 21 x 16 (constants) + 22 x 12 (demux/exclusion) = 672 + 504 + 112 + 336 + 264 = 1888 bytes raw

The LOGO! Soft Comfort compiler folds constant inputs to the MUX, inlines the demux pattern, and removes dead code, so the effective on-target size converges to 180 to 220 bytes for all three methods. Method C generally produces the smallest compiled output despite the highest block count, because the per-block latching relays are simple and the compiler optimises the demux pattern heavily.

Verification step: Use Tools -> Statistics in LOGO! Soft Comfort to display the final byte count after compilation. If the program exceeds 250 bytes, move to a LOGO! 8.4 modular system with an additional base module plus expansions. Each expansion (DM8, AM2, AM2 RTD) adds another 250 bytes of program memory.

5. Step-by-Step Implementation (Latch-Based Method, Method C)

Reference the LOGO! system manual 6ED1052-xxx08-0BA8 (entry ID 109741041) and the LOGO! Soft Comfort V9.0 online help (entry ID 109783162) for the screen-specific procedures.

Step 1 - Declare Input and Output Variables

In LOGO! Soft Comfort V9.0, open the project file (.lsc) and navigate to Tools -> Variables -> Tag Table. Create the following tags:

  • ai_X (analog input, scaled to range 0..1000 representing 0.00..10.00 V, then amplified to 80..100 via the Amplifier block B002)
  • aq_Y (analog output or marker)

Alternatively, use the I/O names directly: AI1 for X, AQ1 for Y, depending on hardware wiring. The Amplifier block is configured with Gain = 0.02 and Offset = 80 in the block properties dialog.

Step 2 - Build the Threshold Detector Bank

For each X value 80, 81, ... 100:

  1. Insert block B009 (Analog Threshold Trigger).
  2. Set On threshold = X - 0.5 (for example 79.5 for X = 80).
  3. Set Off threshold = X + 0.5 (for example 80.5 for X = 80).
  4. Wire the analog input AI1 (or the scaled variable ai_X) to the trigger's Ax terminal.
  5. Route the trigger's Q output to the corresponding latching relay's S input.

This produces 21 trigger blocks. The hysteresis gap is exactly 1.0 unit per X window, and adjacent windows abut perfectly (off of window N = on of window N+1).

Step 3 - Add the Latch Bank and Mutual Exclusion

For each of the 21 triggers:

  1. Insert block B008 (Latching Relay).
  2. Wire the trigger's Q to S.
  3. Wire a single global reset signal to R of all 21 latches: build one OR gate with 21 inputs that is the OR of all 21 triggers' Q outputs (excluding the current latch's own trigger). Feed the inverted OR to R of all latches.

The mutual-exclusion condition for latch i is: R_i = NOT (Q_trigger_1 OR Q_trigger_2 OR ... OR Q_trigger_(i-1) OR Q_trigger_(i+1) OR ... OR Q_trigger_21). In practice, build a single 21-input OR (or cascaded 2-input ORs) of all triggers, then route to a single NOT, then fan-out to all 21 latches' R. Only one latch can be set at any instant.

Step 4 - Build the Demux Pattern to Drive the MUX

Each latch's Q (boolean) enables a corresponding constant value into the analog MUX. For a 21-input MUX, build 21 two-input AND gates:

  • AND_i input A = Latch_i Q
  • AND_i input B = Constant Y_i value

Feed the 21 AND outputs into the analog MUX inputs Ax. The MUX selector S is fixed to 0 (always pick the first active input) OR is driven by an integer selector from a binary encoder if you want explicit indexing. For mutual-exclusion logic, S = 0 is sufficient because only one constant is non-zero at any scan.

Note that LOGO! Soft Comfort V8.4/V9.0 MUX is 8-input. To handle 21 inputs, use two stages: MUX1 selects from inputs 1..8, MUX2 selects from inputs 9..16, MUX3 selects from inputs 17..21 (only 5 used). Use a 1-of-3 top-level selector built from the same mutual-exclusion OR tree: S_top = (any of latches 1..8) ? 0 : (any of latches 9..16) ? 1 : 2.

Step 5 - Wire the Analog MUX Inputs and Output

For each of the 21 MUX inputs, place a Constant block with the corresponding Y value. Wire the constants through the AND gates (Step 4) to the MUX's Ax terminals. Wire the final MUX output to AQ1 (or to an analog marker MV1 if the value is consumed downstream and not output physically).

Step 6 - Compile and Download

Press F4 (or Run -> Transfer -> to Device) in LOGO! Soft Comfort. Verify there are no compile errors and that the program fits within the 400-block and 250-byte limits via Tools -> Statistics. If the program exceeds the limits, the LOGO! Soft Comfort download dialog will block the transfer with a red error icon.

SVG Topology Diagram

[AI1 / ai_X] --> [21 x Threshold Trigger B009]
        |
        +--> OR (21-input) --> NOT --> R of all 21 Latches
        |
        v
[21 x Latch B008 Q] --> [21 x AND with Y_const] --> [3-stage MUX B013] --> AQ1 / MV1

6. Hysteresis and Debounce Configuration

LOGO! Soft Comfort's Analog Threshold Trigger (B009) provides configurable on/off thresholds. For a 1-unit-wide X window:

  • X = 80: On = 79.5, Off = 80.5 (window 1.0 wide)
  • X = 81: On = 80.5, Off = 81.5
  • X = 82: On = 81.5, Off = 82.5
  • ... and so on to X = 100: On = 99.5, Off = 100.5

The on-threshold of the next value equals the off-threshold of the previous value, ensuring a clean handoff with no overlap. This is the standard hysteresis pattern for multi-level detection. The deadband is exactly 0 units between adjacent windows; X transitions from 80.49 to 80.51 in a single scan do not produce double-triggering.

If X is noisy (for example from a 10 kohm potentiometer with contact bounce of 0.5..1.0 V on a 0..10 V wiper, or from a 4-wire sensor with 50/60 Hz pickup), increase the window to 1.5 or 2.0 units by widening the gap between on and off. The trade-off is loss of resolution: X values that differ by 1 unit may be misclassified if the noise exceeds the half-window.

For high-noise applications, pre-filter X with a 16-tap moving average. LOGO! does not have a native moving average block, but the On-Delay + Average block (B007) or a shift-register-based implementation provides equivalent smoothing. Apply a sample period of 50..100 ms; the resulting latency is acceptable for non-critical mapping applications but must be evaluated for control loops.

Critical: If the analog input AI1 is configured for 0..10 V, the internal scaling in LOGO! is 0..1000 (representing 0.00..10.00 V with two decimal places of resolution). To map a 0..10 V input that should be interpreted as 80..100, insert an Analog Amplifier (B002) with Gain = 0.02 and Offset = 80. Configure the amplifier in LOGO! Soft Comfort's block properties dialog. Refer to the LOGO! system manual section 4.4.1.4 (Analog Inputs) for voltage range selection and the AI4 / AI8 jumper settings on the BM.

7. Alternative: Range-Based Mapping with Piecewise-Linear Envelope

If the 21-point table can be approximated by 5..7 piecewise-linear segments, the lookup table is reduced to 5..7 comparators and 5..7 linear equations:

  • Segment 1: X in [80, 84] -> Y = 12 + 0.5 * (X - 80)
  • Segment 2: X in [85, 88] -> Y = 18 + 1.2 * (X - 85)
  • Segment 3: X in [89, 92] -> Y = 27 + 2.0 * (X - 89)
  • Segment 4: X in [93, 95] -> Y = 41 + 1.5 * (X - 93)
  • Segment 5: X in [96, 98] -> Y = 51 + 2.5 * (X - 96)
  • Segment 6: X in [99, 100] -> Y = 67 + 4.0 * (X - 99)

Each segment uses one analog comparator (B010) to detect the X range and a math block (B001..B006 arithmetic) to compute the linear Y from X. The pattern is:

  1. Comparator B010: On threshold = segment_low, Off threshold = segment_high (for segment 1: On = 80, Off = 85)
  2. Math block: Y_seg = (X - segment_low) * slope + intercept
  3. AND gate: route Y_seg to the final output when comparator Q is true
  4. OR gates: sum all segments' Y outputs (only one segment is active at a time, so OR is unambiguous)

This method uses 6 comparators + 6 math blocks + 6 AND/OR gates = ~18 blocks, but the total compiled size is much smaller than 21 threshold triggers + 21 latches. The total block count drops by ~70%.

Trade-off: piecewise-linear approximation introduces interpolation error. For a 21-point table, the maximum error is typically <5% of full scale, which is acceptable for display or setpoint applications but not for precision control. Validate the error against the source 21-point table before deploying.

8. Verification and Commissioning Procedure

After program download to the LOGO! BM (LOGO! Soft Comfort -> PC -> LOGO! -> Ethernet or USB cable 6ED1057-1AA00-0BA0), perform the following checks:

  1. Block count check: Tools -> Statistics -> Block count must be less than or equal to 400.
  2. Memory check: Tools -> Statistics -> Memory bytes must be less than or equal to 250.
  3. Simulation test: Press F3 to enter Simulation mode. Inject known X values via the I/O panel and verify Y updates as expected. Use a step size of 1 unit across 80..100.
  4. On-target test: Connect a 0..10 V calibrator (for example WIKA CPH7000 or Beamex MC6) to AI1. Sweep voltage from 8.00 V to 10.00 V in 0.10 V steps (= 80 to 100 in scaled units). Record Y at each step.
  5. Hysteresis check: Dwell at X = 80.5 for 5 seconds. Verify Y does not oscillate. Use the LOGO! onboard display or web server to monitor AQ1.
  6. Latch exclusivity check: Sweep X slowly from 80 to 100. Use the LOGO! web server (Tools -> Web Server Configuration) to monitor all 21 latch Q states. At any instant, exactly one latch should be active. If two latches are active simultaneously, the release logic in Step 3 is incorrect.
  7. Web server display: If Y must be visible on the LOGO! onboard display or web server, add a message text block (B011) referencing MV1 or AQ1. Configure the message to display at row 1 with bar chart or numeric format.
  8. Parameter protection: To prevent operators from editing Y values at runtime, set the MUX constant blocks as non-modifiable in Tools -> Parameter Protection. Only the threshold trigger on/off values remain operator-accessible.

For a permanent installation, save the LOGO! program to a micro SD card (Siemens 6ED1056-1DA00-0AA0 or compatible, 32 GB max FAT32) to survive battery-less operation. The program is also retained in the BM's internal flash for 20 years minimum without a battery.

9. Edge Cases and Field Caveats

  • X out of range: If X drops below 80 or rises above 100, no threshold trigger fires. Y retains its last value. For safety-critical applications, add a watchdog comparator (B010) that forces Y to a safe default (for example 0) if X is out of range for more than 5 seconds. Use an On-Delay (B004) to debounce the watchdog.
  • Scan time: LOGO! BM with 50+ blocks has a scan time of ~10..20 ms. With 21 threshold triggers and 21 latches, scan time may reach 30 ms. Verify with Tools -> Statistics -> Cycle time. If cycle time exceeds 50 ms, the application is too large for a BM and requires a LOGO! 8.4 modular system with an additional BM (6ED1052-1MD08-0BA2 as primary plus 6ED1052-2MD08-0BA2 as expansion).
  • Web server display: If Y must be visible on the LOGO! onboard display or web server, configure the MUX output to AQ1 or MV1 and add a message text block (B011) referencing MV1.
  • Parameter protection: To prevent operators from editing Y values, set the MUX constant blocks as non-modifiable in Tools -> Parameter Protection. Only the threshold trigger on/off values remain operator-accessible.
  • Online change: LOGO! 8 supports online program change without stopping the BM via the RUN/STOP switch on the BM and Tools -> Transfer -> Online Change. However, adding or removing threshold triggers triggers a full program restart. Plan parameter updates during scheduled downtime.
  • Scaling conflict: If the BM variant is 230 V (6ED1052-1FB08-0BA2), the analog inputs AI1..AI4 are 0..10 V only (no 4..20 mA). For 4..20 mA inputs, use an external 500 ohm precision resistor or the LOGO! AM2 PT100 expansion module (6ED1055-1MA00-0BA2 for 0/4..20 mA, or 6ED1055-1MB00-0BA2 for PT100/PT1000 / NI1000). Always check the exact part number against the current Siemens LOGO! 8.4 catalog before ordering.
Warning: Never wire a 4..20 mA source directly to AI1..AI4 of a LOGO! 230 V BM. The input is voltage-only and will saturate or damage the input circuit. Use the AM2 module (verify the exact part number for the current firmware variant in the Siemens product catalog) for current loops. A 500 ohm shunt resistor across AI1..AI2 converts 4..20 mA to 2..10 V at the cost of 1.0 V burden and 0.04 W power dissipation in the resistor at 20 mA.
Warning: The LOGO! 8.4 base module BM is not isolated between the analog inputs and the 24 V supply on the 12/24 V variants (6ED1052-1MD08-0BA2). Use the AM2 expansion module for galvanic isolation between the analog sensor ground and the BM ground. Refer to the LOGO! 8 system manual section 4.4.1 for the isolation diagram.

Can LOGO! Soft Comfort store a literal 21-point array like a structured text language would?

No. LOGO! Soft Comfort (FBD / LAD) does not support array literals or structured data types. The lookup table must be built from discrete blocks. The lowest-footprint method for a 21-point table is the piecewise-linear approximation with 5..7 comparators plus math blocks (Section 7), which compiles to roughly 100 bytes of UDF.

Does LOGO! Soft Comfort V9.0 support indirect addressing or pointers?

No. LOGO! Soft Comfort does not support pointers or index registers. Each block reference is static. The only indirect effect is via the MUX selector input, which still must be computed from explicit logic. For dynamic tables larger than ~30 points, migrate to a S7-1200 with SCL and a static ARRAY of INT or REAL.

How many analog threshold triggers can a single LOGO! 8.4 BM handle before running out of memory?

Approximately 60..80 triggers, depending on the rest of the program. The 250-byte program memory and 400-block limit constrain this. The LOGO! 8.4 modular system (with up to 3 expansion modules) can host ~200 threshold triggers total across the primary BM and the expansion BMs, but inter-BM communication via the LOGO! network is limited to 16 bits per direction.

Can the lookup table be loaded from an SD card at runtime to allow operator-driven updates?

Partially. LOGO! 8 supports reading CSV data log files from the SD card via the Data Log block (B042), but variable assignment from SD is not supported at runtime. The lookup table must remain in the compiled program. For operator-driven curves, expose the 21 threshold trigger on/off values as operator parameters via Tools -> Parameter Protection.

What is the difference between Analog Threshold Trigger (B009) and Analog Comparator (B010)?

B009 compares a single analog input against a fixed threshold pair (on / off with hysteresis). B010 compares two analog inputs (Ax vs Ay) with a threshold pair and outputs the difference. For a static lookup against a known set of X values, B009 is sufficient and uses 8 fewer compiled bytes per block. Use B010 only when the comparison threshold itself is a live variable, for example a moving setpoint or an adaptive alarm limit.

Can the lookup table be re-used for multiple analog inputs on the same LOGO! 8.4 BM?

Yes, by replicating the table or by using the LOGO! UDF export/import feature. Save the lookup table as a UDF snippet (File -> Export -> UDF Snippet), then import into another project. Each instance consumes its own block and memory budget. For three independent 21-point tables on one BM, the total memory is ~600 bytes, which exceeds the 250-byte BM limit; distribute across two BMs in a modular LOGO! 8.4 system.

Back to blog