Making HMI Setpoints Retentive in Siemens LOGO! 8 via VM Mapping

David Krause13 min read
HMI / SCADASiemensTroubleshooting
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 Statement: HMI Setpoint Values Disappear After Power Cycle

A Siemens LOGO! 8 logic module (e.g., 6ED1052-1MD08-0BA1 / 6ED1052-1CC08-0BA0 / 6ED1052-1FB08-0BA0 series with firmware 8.x) is exchanging integer setpoints with a SIMATIC KTP400 Basic HMI (or KTP400 Comfort) over Ethernet. Two analog setpoints are written from the HMI to NAI1 and NAI2 (Network Analog Inputs 1 and 2) of the LOGO!. After a power cycle, the operator enters the same values again because the LOGO! returns to the default value of the NAI — the value the HMI wrote into the controller is not retained.

The desired behavior is the same as a PLC retaining tag values: when the HMI restarts, the input field must be pre-populated with the last value the operator entered — and that value must survive both an HMI restart and a LOGO! power cycle.

Symptom summary: HMI value flashes briefly, then drops to 0 (or to the HMI project's default value) immediately after entering. The value never returns after power cycling the LOGO!.

2. Root Cause: NAI Is an Input, Not Retentive VM

The NAI (Network Analog Input) blocks (block numbers 5–8 in the LOGO! programming tree, depending on slot) are input blocks. Every LOGO! cycle, the firmware overwrites the runtime value of NAI with whatever the last Ethernet write from the S7/modbus peer (here, the KTP400) provided. The NAI value is therefore not retained across a power cycle, even if the underlying VM address that backs it appears in the LOGO!'s "VM mapping" list.

LOGO!'s retentive memory is the onboard flash-backed Variable Memory (VM). The retention rule inside the LOGO!Soft Comfort engineering tool is: only values that are bound to a writable block parameter (such as the V1 of a math instruction, the threshold of an analog threshold trigger, or the on/off threshold of a counter/timer) are committed to flash at the end of a clean cycle. A passive NAI input is never committed, even when it sits in a VM-mapped slot, because the runtime model treats it as a slave input.

Block family Direction Retentive across power cycle? Reason
NAI (Network Analog Input) Input from network No Overwritten by HMI/peer every cycle; never written to flash
NAQ (Network Analog Output) Output to network No Read-only snapshot, not a parameter
Math instruction V1 / V2 / V3 / V4 Parameter input Yes Parameter VM is committed to flash if "Retentive" is enabled
Analog Threshold Trigger threshold Parameter input Yes Parameter is a writable block input
Counter / Timer setpoint Parameter input Yes Parameter is a writable block input

3. The Correct Architecture: A Math Instruction as the Retention Vehicle

To make an HMI-supplied setpoint persist, the value must be moved out of the NAI and into a writable block parameter that is part of the retentive VM. The proven approach in LOGO!Soft Comfort V8.x is to insert a math instruction (e.g., B048 — "Math" / "Arithmetic" — the Analog Arithmetic block), expose its V1 parameter, and map that V1 parameter to a VM address in the VM mapping table. The HMI is then re-pointed at that VM address instead of the NAI.

Functional chain after fix:

  KTP400 input field
        │
        ▼  (Ethernet S7/modbus write)
  VM address VW100  ◄── VM mapping of B048 parameter V1
        ▲
        │  (LOGO! writes V1 → flash at end of cycle)
  B048 (Math Instruction)
        │
        ▼  (B048 output Ax feeds downstream logic,
            e.g., the threshold of an Analog Threshold Trigger)

Because the HMI is now writing directly to VW100, and VW100 is bound to parameter V1 of a math instruction, the firmware commits that value to flash on every clean cycle stop. On power-up, the flash contents are restored into VW100, the HMI reads the restored value back into the input field, and the operator sees the previous setpoint.

4. Prerequisites

  • LOGO! 8 base module, firmware 1.08.xx or newer (LOGO!Soft Comfort V8.3 or V8.4 recommended for the latest VM mapping editor). Confirm via the LOGO! display: LOGO! → Diagnostics → Software Version or in LOGO!Soft Comfort: Tools → Transfer → PC → LOGO! (FW info).
  • LOGO!Soft Comfort V8.3 or later installed on the engineering PC. The VM mapping editor was extended in V8.2 and matured in V8.3 to allow per-block-parameter VM assignment. See the LOGO!Soft Comfort V8.3 system manual on the Siemens Industry Online Support portal.
  • SIMATIC KTP400 Basic mono/TN/TP configured in WinCC flexible 2008 SP5 or SIMATIC WinCC TIA Portal (Basic / Comfort), depending on the KTP generation. The TIA Portal configuration is the recommended path for firmware 8.3 projects.
  • Ethernet connectivity between the HMI and the LOGO! on the same subnet. The LOGO! must have a static IP (default 192.168.0.3 in many factory-shipped units) and the KTP400 IP must match the subnet.
  • The S7 connection or Modbus TCP connection between the HMI and the LOGO! must already be running and the HMI must be able to read/write at least one VM address to confirm field communication before adding retentive logic.

5. Step-by-Step Implementation

  1. Open the program in LOGO!Soft Comfort and identify the two NAI blocks that currently receive the setpoint from the KTP400. Note their block numbers (e.g., B005, B006) and the current VM mapping addresses (commonly VW0 and VW2).
  2. Delete the NAI block from the dataflow feeding the downstream consumer. Do not delete the HMI tag — keep the HMI's setpoint I/O field, but change its PLC address from the NAI's VM address to a free VM address such as VW100 and VW102.
  3. Insert a Math instruction (Analog Arithmetic / "Math" block). In LOGO!Soft Comfort's block tree, drag Special Functions → Math onto the diagram. Assign a block number below the highest existing block — e.g., B048 and B049 — to control execution order (see Section 6).
  4. Expose parameter V1 on the math instruction: double-click the block, in the block properties tick the box "Parameter V1 is to be displayed in the message text / VM". The V1 value range is typically -32768 to +32767 (16-bit signed) for integer setpoints.
  5. Map V1 to a VM address: go to Tools → VM Mapping (or right-click the block → Block Properties → VM Mapping). Assign VW100 to B048/V1 and VW102 to B049/V1. The mapping dialog should now show two rows with the VM addresses appearing in the right-hand column.
  6. Connect the math instruction output to the consumer: e.g., run a wire from B048's Ax output to the input of the downstream Analog Threshold Trigger (B043 in the example) and to any PI controller, comparator, or numeric display.
  7. Make V1 retentive: in the block properties dialog of the math instruction, set Retentivity = On. LOGO!Soft Comfort writes the parameter to the on-board flash whenever the LOGO! transitions to STOP cleanly and restores it on the next RUN.
  8. On the HMI side, open the configuration for the setpoint I/O field. Change the tag's PLC address from the NAI VM address to VW100 (int) or the equivalent symbolic name. The tag's acquisition mode should be "Cyclic continuous" with a reasonable update rate (250–500 ms is sufficient for a setpoint).
  9. Compile and download the LOGO! program. Power cycle the LOGO! to verify the HMI field is re-populated with the value you previously entered.

6. Block Numbering and Cycle Order Considerations

LOGO! processes blocks in ascending block number order each cycle. If the math instruction that hosts V1 is numbered after the downstream consumer, then on the first cycle after power-up the consumer will see the stale value (the one that was in V1 from the previous run) for one cycle — and then the HMI's write in the same cycle will overwrite V1 with the operator's current value. In practice, this is harmless because the HMI value converges in one cycle.

However, if the HMI write order is not deterministic, the consumer may briefly see a mismatched value for one cycle after power-up. The robust pattern is:

Recommended block numbering (low → high):

  B040  Math instruction #1 (V1 ← VM, e.g., VW100)
  B041  Math instruction #2 (V1 ← VM, e.g., VW102)
  B042  Wire-through / passthrough (gain = 1, offset = 0) if scaling is needed
  B043  Analog Threshold Trigger (consumes B040 output)
  B044  PI controller or downstream consumer

Place the retentive parameter before the consumer so that the value is read at the start of the cycle, then the HMI's later write in the same cycle is committed to flash at the next STOP transition.

Cycle timing: A LOGO! 8 with 200 function blocks typically completes a cycle in 5–20 ms. A 4-block chain like the one above adds well under 1 ms to the cycle. The HMI's 250–500 ms polling cycle is therefore the dominant latency, not the LOGO! cycle.

7. Verification Procedure

  1. Online watch in LOGO!Soft Comfort: connect to the LOGO! via Ethernet, open the VM table (Tools → Online → VM Table or View → VM Table), confirm that VW100 reflects the HMI's last written value.
  2. Online watch of B048/V1: in the program diagram, right-click the math block and select Watch On/Off. The V1 field should display the same value as VW100.
  3. Power-cycle test 1 (LOGO! only): enter a value of 75 on the HMI, wait 2 seconds for the write to settle, then remove the 24 V supply from the LOGO!. Re-apply power. The HMI field should display 75 within 1–2 polling cycles.
  4. Power-cycle test 2 (HMI and LOGO! together): enter a value of 120, power-cycle both devices, restore. The HMI field should display 120.
  5. Edge test: enter 0, power-cycle. The HMI field should display 0 (not the factory default 100, unless that is your engineering default). This confirms the retention path is functioning and the value did not snap back to the project default.
  6. Forced override: in the LOGO! display, manually edit VM address VW100 via LOGO! → VM → Edit and confirm the HMI tracks the manual edit. If it does not, the VM mapping of B048/V1 is missing.

8. Common Pitfalls and Their Symptoms

Pitfall Symptom Fix
HMI still pointing at the NAI's VM address Value visible for one cycle, then 0 Re-point HMI tag to the new VM address (e.g., VW100) backed by V1 of the math block
VM mapping not assigned to V1 Value flashes, LOGO! displays "Transfer failed" on VM write from HMI Re-open VM Mapping, assign the new address to the math block's V1 parameter
Retentivity flag not set on the math block Value retained for current RUN, lost on power cycle Enable Retentivity on the math instruction block properties
Math instruction configured for non-passthrough operation (gain ≠ 1, offset ≠ 0) HMI shows scaled value, downstream consumer sees a different scaled value Use gain=1, offset=0 unless you intentionally want scaling; otherwise let the consumer scale
Block numbered after the consumer that uses the value First cycle after power-up shows wrong value for ~1 cycle Re-number: assign lower block numbers to the retentive parameter blocks
VM address overlaps with a different block's parameter Two blocks fight over the same VM word, value jitters Use unique, non-overlapping VM addresses (LOGO!Soft Comfort warns on overlap in the VM Mapping dialog)
LOGO!Soft Comfort version older than V8.2 VM mapping table does not show the math block's V1 Upgrade to LOGO!Soft Comfort V8.3 or later; older versions have a more limited VM mapping editor

9. Why the M8 Flag Is Not Required

The original post mentioned an M8 (or any edge-flag) "write-back" technique. With the math-instruction approach, the M8 flag is not needed, because:

  • The HMI is now the authoritative writer to VM address VW100.
  • The LOGO! firmware automatically commits the V1 parameter of the math instruction to flash at the end of every clean STOP transition.
  • On power-up, the firmware restores the flash contents into V1, which is the same word that the HMI reads back into its input field.

If a project requires a one-shot write-back (e.g., to initialise a derived value), M8 (a one-cycle pulse at startup) can still be used to copy the restored value into a secondary parameter, but it is not what performs the retention itself. The retention is intrinsic to the parameter VM commit/restore cycle.

10. Scaling, Range Clamping, and PI Controller Considerations

If the math instruction is configured for passthrough (gain = 1, offset = 0, operator = +), it behaves like a copy. But the same block can also perform scaling, which is sometimes required when the HMI is configured in engineering units (e.g., 0.0–100.0 °C) and the LOGO! PI controller expects a raw 0–1000 range:

Example: scale HMI value 0..100 (°C) to LOGO! internal 0..1000

  Gain  = 10
  Offset = 0
  Operator = +
  V1 = HMI value (0..100, °C)
  Ax = V1 * Gain + Offset   (0..1000, internal)

Range clamp the HMI field with a min/max on the tag to keep V1 within the math block's accepted range. The math block's V1 range is -32768 to +32767 (int). For higher-resolution values (e.g., 0.1 °C resolution across 0.0–200.0 °C, which fits in 12 bits), no scaling is required.

PI controller setpoint: If the math instruction is feeding a PI controller's SP parameter, also enable Retentivity on the PI controller's SP. The same retention rule applies — only writable block parameters are committed to flash.

11. Field Commissioning Checklist

  • LOGO! firmware version confirmed (8.x).
  • LOGO!Soft Comfort project version matches the firmware (8.3 project → LOGO! 8.3 firmware).
  • VM mapping table shows B048/V1 → VW100 and B049/V1 → VW102.
  • Retentivity flag is set on both math blocks.
  • HMI tag for setpoint 1 points at VW100, setpoint 2 at VW102 (or symbolic equivalents).
  • HMI tag acquisition mode = cyclic continuous, update rate 250–500 ms.
  • Block numbering: retentive parameter blocks numbered below the consumer.
  • Power-cycle tests 1 and 2 both pass.
  • Edge tests (0, max value, negative value) all pass.
  • Documentation: VM map printed and stored in the project's \docs folder for future maintenance.

12. Alternate Approaches and Trade-offs

Approach Pros Cons
Math instruction V1 mapped to VM (recommended) Single block, clean retention, no edge logic, easy to scale Consumes 1–2 blocks per setpoint
Analog Threshold Trigger threshold parameter mapped to VM Native consumer of the setpoint; no extra block Couples retention to the threshold value; harder to read the "live" setpoint
Counter setpoint or Timer setpoint Common block, familiar to most LOGO! users Only integer counts/durations; not appropriate for analog setpoints
Network Analog Output (NAQ) holding the latest value and copying on startup with M8 No extra block Verbose, fragile, and easier to mis-wire
External retentive storage on the HMI side (recipe / tag persistent) Independent of PLC firmware behaviour Survives HMI reboot only; if the HMI is replaced or the project is reloaded, the value is lost

For most LOGO! 8 projects, the math instruction approach is the cleanest and is what is used in the official Siemens application examples. The HMI-side recipe layer is a useful complement if a backup of last-known-good values is required for a service engineer to restore after a project reload.

Why does my HMI value appear for one second and then drop to zero?

The HMI is still writing to the NAI's VM address, not to the parameter V1 of a math block. NAI is an input and is overwritten every cycle by the firmware, so the value you see is the most recent HMI write followed by a snap-back. Re-point the HMI tag to the VM address assigned to the math block's V1.

Do I need the M8 startup flag to write the value back into VM?

No. Once the math block's V1 is mapped to a VM address and Retentivity is enabled, the LOGO! firmware commits V1 to flash on every clean STOP and restores it on the next RUN. No edge flag is required. M8 can still be used to copy the restored value into a secondary block if a project requires it.

Which LOGO!Soft Comfort version supports per-block-parameter VM mapping?

LOGO!Soft Comfort V8.2 introduced the extended VM mapping editor that exposes the V1/V2/V3/V4 parameters of math instructions and other special function blocks. V8.3 and later are recommended for stability and for compatibility with the latest LOGO! 8 firmware (8.3.x).

Can I use a single math block for two setpoints, or do I need two blocks?

Use one math block per setpoint. Each math block has a single V1 input; you cannot route two HMI values into the same block's V1. A typical project uses two math blocks (e.g., B048 and B049) for two setpoints, each with its own VM mapping row.

What is the V1 value range of the math instruction?

Parameter V1 of the math instruction is a 16-bit signed integer, range -32768 to +32767. For floating-point or larger-range setpoints, scale the HMI value (e.g., 0.0–100.0 °C as 0–1000 int) before writing, then apply a gain of 0.1 in the math block to recover the engineering range.

Back to blog