Problem Overview
A common integration issue arises when a Siemens LOGO! controller is paired with a SIMATIC KTP700 HMI panel to implement a Down counter with an operator-settable start value. Two coupled symptoms appear together:
- The start value entered on the HMI I/O field is accepted momentarily but reverts to zero on the first reset, causing the counter to latch immediately with Q1 = 1.
- A higher-order counter (hours) reaches zero, but a lower-order counter (minutes) continues to decrement, generating spurious interval-elapsed events even though the parent counter has stopped.
Both faults trace back to the same root causes: misalignment between the LOGO! Parameter VM Mapping table and the HMI tag addresses, the use of 16-bit Word data types where 32-bit DWord is required, and the absence of a conditional gating block to clamp dependent counters when their parent counter has elapsed. This reference documents the field-proven diagnosis and the corrected implementation using a LOGO! analog multiplexer (MUX) block, with the Big Endian addressing rules that govern VM memory in the LOGO! family.
The reference application is a lubrication-interval tracker for a bank of mills (T5-1 through T5-4). The technician enters an operating-hours threshold on the HMI; the LOGO! counts down from the threshold and raises a "lubrication due" alarm. The same pattern applies to any application where two counters must be cascaded for display, including runtime limiters, service reminders, and batch counters.
System Architecture and Counter Block Parameters
The reference design uses the following components:
- A Siemens LOGO! base module executing the user program in FBD or LAD view inside LOGO! Soft Comfort.
- A SIMATIC KTP700 Basic panel connected via Ethernet for operator input and visualization.
- TIA Portal V16 as the engineering framework that hosts both the LOGO! project and the HMI configuration.
- A pair of Down counter blocks, B005 (hours) and B009 (minutes), wired so that B005.Q feeds B009.Reset in an attempt to cascade the counters.
Down Counter Block Parameters
The LOGO! Down counter exposes the following parameters on the block face in LOGO! Soft Comfort:
| Parameter | Direction | Type | Purpose |
|---|---|---|---|
| R (Reset) | Input | Bool | Positive edge reloads Start Value into CV and forces Q = 0 |
| Cnt (Count) | Input | Bool | Edge-triggered decrement on the configured edge direction |
| Dir | Input | Bool | Selects count direction (Down in this application) |
| Start Value | Parameter | DWord (Int32) | Preset loaded on power-up and on Reset |
| CV (Current Value) | Output | DWord (Int32) | Live counter value, decremented on each count edge |
| Q | Output | Bool | Asserts when CV <= 0; deasserts on Reset |
Both Start Value and CV are 32-bit signed integers internally. Any external client (HMI, OPC UA server, S7 peer) that needs to read or write these values must do so as a 32-bit data type. Mapping them as 16-bit Word silently truncates to the low half and produces values that read as 0 in many configurations.
Why a Q-to-Reset Cascade Fails
A naive cascade ties the Q output of the hours counter to the Reset input of the minutes counter. The intent is to clamp the minutes counter to 0 when the hours counter has elapsed. The implementation fails for two reasons:
- Q is a level output, not an edge. When B005 reaches 0, B005.Q stays at 1. A Reset input requires a positive edge to reload its Start Value. Once the first edge has fired on the way down to 0, no further edge occurs, so B009 cannot be re-reset on subsequent scans.
- Pulse-width mismatch. Even when Q is wired to a pulse generator (for example a one-shot), the resulting pulse is one scan cycle wide. A 60-minute countdown is many orders of magnitude longer, and any single missed edge will not stop the minutes counter from continuing to decrement.
The correct architecture is to display a clamped value while leaving the underlying counter register free to cycle. This is the role of the analog MUX block.
Problem 1: Start Value Loss — Diagnosis and Resolution
Symptoms
- The HMI I/O field is configured to write the start value to the LOGO! counter.
- The first scan accepts the value, but pressing the HMI Reset button or cycling power causes the start value to revert to 0.
- The counter latches immediately with Q1 = 1 because CV never moves away from 0.
Root Cause
Two independent configuration errors produce this symptom, and the field case contained both:
- Data-type mismatch on the HMI side. The I/O field was bound to an HMI tag of type Word (16-bit). The counter's Start Value is a 32-bit parameter. A Word write to the mapped VM address updates only one half of the DWord location, and the LOGO! reads back a value that does not equal the operator's entry. The original symptom ("DWord was good, I had a wrong address") is the same class of fault viewed from the address side.
- Address mismatch in the Parameter VM Mapping table. The HMI tag pointed to one VM address, but the LOGO! counter block's "Start Value" parameter was mapped to a different address (or not mapped at all). Writes from the HMI updated unused VM memory that no block reads, while the counter's actual Start Value register held the compile-time default of 0.
Resolution Steps
- Open the LOGO! project in LOGO! Soft Comfort.
- Select the counter block (B005) and open its block properties.
- Note the parameter slot for "Start Value". In the Parameter VM Mapping table, ensure an entry maps this parameter to a free DWord address such as
VD0. - In the KTP700 HMI configuration, create a tag:
- Name:
HMI_HoursStart - Data type:
DWord(UInt32, range 0–4294967295) - Address: the same DWord as the Parameter VM Mapping entry.
- Name:
- Bind the HMI I/O field to this tag with mode = Input/Output and limits 0 to 9999.
- Compile the LOGO! project and the HMI project; download both to the target devices.
- Enter a non-zero start value on the HMI; verify with the LOGO! online monitor that the mapped VM location now contains the entered value.
- Press Reset on the HMI; verify that the start value persists and the counter restarts decrementing from it.
A common verification shortcut is to use LOGO! Soft Comfort's online view and inspect the value of the Start Value parameter on the counter block face. If the value matches the HMI entry across a reset, the mapping is correct. If the value is 0 after every reset, the mapping is still broken on at least one of the two failure modes (data type or address).
Problem 2: Counter Cascading and MUX Gating
Symptoms
- With B005 (hours) preset to 0 at start-up, B005.Q is asserted immediately.
- B009 (minutes) ignores this and continues to count down from its own start value (4 minutes in the test setup, intended to be 60 minutes in production).
- The HMI shows minutes decrementing while the operator expects both to be at 0.
Root Cause
The Down counter block has no built-in dependency on another block. Its Reset input is edge-triggered, and its Q output is a level. There is no parameter on the counter block to inhibit counting based on an external condition. Once B009 is running, it continues to decrement until its own CV reaches 0, regardless of B005's state.
The earlier attempt to wire B005.Q to B009.Reset worked only for the first edge and then failed because no further edges were generated as B005 remained at 0. To stop the minutes counter, the program must change what is shown, not what the counter is doing internally.
Resolution: Analog Multiplexer Gating
The robust solution inserts an analog multiplexer block between the live current value of B009 and the VM address that the HMI reads for the minute display. The MUX has the following behavior:
| Sel (B005.Q) | MUX Output |
|---|---|
| 0 (hours still counting) | B009.CV (live value) |
| 1 (hours elapsed) | 0 (clamped) |
Wiring the MUX output to a separate VM address (for example VD8) gives the HMI a clamped view of the minutes while leaving B009's internal register free to cycle. On the next lubrication interval, when the operator clears the elapsed flag, B009 resumes normal countdown from its stored start value.
Implementation Details
The analog MUX block in LOGO! Soft Comfort exposes:
-
Sel— boolean selection input (selects V1 when 0, V2 when 1 in the default mapping; verify with the local block help for the specific LOGO! firmware version). -
V1,V2,V3,V4— analog value inputs. -
AQ— analog output.
For a two-input clamp, only V1 and V2 are used. Connect:
-
Sel←B005.Q -
V1←B009.CV(the live current value of the minutes counter) -
V2← constant0(use a Constant block configured as 0) -
AQ→ Parameter VM Mapping toVD8
AQ back into B009.StartValue or B009.Cnt. The MUX output is for display only; it must not interfere with the counter's internal state. Feeding the MUX back into the counter creates a feedback loop that the LOGO! scan cannot resolve predictably.Big Endian Addressing in LOGO! VM Memory
The LOGO! family stores 32-bit values in Big Endian byte order. For a DWord at VM address 16, the layout is:
Address: 16 17 18 19
+------+------+------+------+
VD16: | MSB | | | LSB | DWord
+------+------+------+------+
| VW16 | VW18 | Words
+------+------+------+------+
| VB16 | VB17 | VB18 | VB19 | Bytes
+------+------+------+------+
Consequences for the field case:
- Writing a 16-bit Word to
VW16updates only the high half ofVD16. - Writing a 16-bit Word to
VW18updates only the low half ofVD16. - A 32-bit DWord write to
VD16updates all four bytes correctly. - Bit tags
V16.0throughV19.7alias to the same physical memory asVD16.
In the reference program, the technician wrote the minutes value to VW18 expecting it to populate VD16. The Big Endian layout meant VW18 became the low half of VD16, but the HMI was reading the full VD16 and displaying a value that was 65536× the intended one when the high half was non-zero. Switching the HMI tag to VD16 (DWord) and binding the I/O field to a DWord tag resolved the read side. Writing the minutes value to VD16 directly (DWord) resolved the write side.
Bit/DWord Overlap Hazard
A second, more insidious problem appeared in the same program. The technician used VD0 for a DWord counter value and also defined bit tags V0.0 through V0.7 for status flags. Because VD0 and V0.0 share the same physical byte, every time the counter decremented, the status bits were overwritten. The reverse also happened: setting a status flag corrupted the counter.
The discipline that prevents this is to allocate VM regions by access width:
| Region | Width | Use For |
|---|---|---|
| VB0–VB31 | Byte / Bool | Discrete status flags, alarms, handshakes |
| VW32–VW63 | Word | 16-bit analog values, scaled engineering values |
| VD64–VD127 | DWord | 32-bit counter values, time stamps, accumulated totals |
Never cross the boundaries. A bit tag inside a DWord region is a latent fault waiting for the worst possible moment.
Building a Clean VM Address Map
Before writing any block logic, draft the VM address map on paper or in a comment header in the LOGO! program. The reference application's map looks like this:
| VM Address | Symbol | Type | Producer | Consumer | Notes |
|---|---|---|---|---|---|
| V0.0 | AlarmHoursElapsed_T51 | Bool | B005.Q | HMI alarm view | Hours counter elapsed for T5-1 |
| V0.1 | ResetActive_T51 | Bool | HMI reset button | B005.R, B009.R | One-shot reset |
| VD2 | HoursStart_T51 | DWord | HMI I/O field | B005.StartValue | Operator entry, range 0–9999 |
| VD6 | HoursCV_T51 | DWord | B005.CV | HMI display | Read-only |
| VD10 | MinutesStart_T51 | DWord | HMI I/O field | B009.StartValue | Operator entry, range 0–59 |
| VD14 | MinutesCV_T51 | DWord | B009.CV | HMI display (raw) | Read-only |
| VD18 | MinutesDisplay_T51 | DWord | Analog MUX output | HMI display (clamped) | Clamped to 0 when hours elapsed |
The map documents producer and consumer for every address. When a fault appears, the map tells the technician exactly which block is the source of a given value and which block is reading it, eliminating guesswork. It also makes the Parameter VM Mapping table a single source of truth that the HMI programmer can reference without reading the FBD logic.
Step-by-Step Counter/Display Loop Implementation
Prerequisites
- Siemens LOGO! base module with Ethernet port
- LOGO! Soft Comfort project saved as TIA V16 compatible
- TIA Portal V16 with the LOGO! add-in installed
- SIMATIC KTP700 Basic PN panel with TIA V16 HSP
- Ethernet switch or direct cable between LOGO! and KTP700
- IP addresses on the same subnet (for example LOGO! 192.168.0.10, KTP700 192.168.0.20)
Procedure
-
Allocate VM space. Reserve
V0.0–V0.7for handshakes,VD2–VD18for the T5-1 counter triplet, and leave the next 32-byte block free for the next mill. -
Configure B005 (hours):
- Start Value mapped to
VD2 - Reset =
V0.1(HMI reset button) - Cnt = chosen edge source (for example 1-hour timer pulse)
- Start Value mapped to
-
Configure B009 (minutes):
- Start Value mapped to
VD10 - Reset =
V0.1(shared with hours) - Cnt = 1-minute timer pulse
- Start Value mapped to
-
Insert Analog MUX block:
- Sel =
B005.Q - V1 =
B009.CV(the live current value) - V2 = constant 0
- Output AQ → mapped to
VD18
- Sel =
- Build the Parameter VM Mapping table with the entries from the VM map.
- Compile and download the LOGO! project.
-
In TIA Portal, configure the KTP700:
- Add the LOGO! as an S7 communication peer
- Create HMI tags matching the VM map with the correct data types (DWord for VD addresses, Bool for V bit addresses)
- Place I/O fields on a screen for the operator to enter the start values
- Place output fields to display the current values
- Compile and download the HMI project.
- Verify with the online monitor on both sides.
Verification Checklist
- Power-cycle the LOGO!; start values for both counters persist in their mapped VM locations.
- Press Reset on the HMI; both counters reload from VM and restart decrementing.
- Set hours start to 0 at the HMI; minutes display reads 0 immediately.
- Set hours start to 5; minutes start to 4; confirm minutes display counts down from 4 to 0, then latches at 0, then re-arms only when hours is non-zero again.
- Set hours start to 5, minutes start to 60; verify that after 5 hours the minutes display clamps to 0 (the internal B009.CV continues cycling in the background, which is the expected behavior of the MUX gate).
- No DWord and Bool tag share an address.
- No HMI tag uses Word (16-bit) where the LOGO! side uses DWord (32-bit).
HMI Tag Configuration for the KTP700
The KTP700 Basic panel talks to a LOGO! over Ethernet using the S7 communication protocol. Each HMI tag is a symbolic reference into the LOGO! VM area. The data type declared on the HMI side must match the data type of the LOGO! parameter, and the address must be the same VM address used in the Parameter VM Mapping table.
For the T5-1 counter triplet, the tag list is:
| HMI Tag Name | Address | Data Type | Length | Use |
|---|---|---|---|---|
| HMI_T51_Hours_Start | VD2 | DWord | 4 bytes | I/O field, input |
| HMI_T51_Hours_CV | VD6 | DWord | 4 bytes | Output field |
| HMI_T51_Minutes_Start | VD10 | DWord | 4 bytes | I/O field, input |
| HMI_T51_Minutes_CV | VD14 | DWord | 4 bytes | Output field (raw counter, may be non-zero when display is 0) |
| HMI_T51_Minutes_Display | VD18 | DWord | 4 bytes | Output field (clamped view) |
| HMI_T51_Reset | V0.1 | Bool | 1 bit | Button, momentary |
| HMI_T51_Alarm_HoursElapsed | V0.0 | Bool | 1 bit | Alarm view indicator |
The split between raw CV (VD14) and display (VD18) is intentional and serves two purposes:
- The operator sees a clean 0 when the hours counter has elapsed, even if the minutes counter is still cycling internally.
- The maintenance technician can connect with LOGO! Soft Comfort online and see the true state of B009.CV for diagnostics.
On the HMI screen, place an I/O field for each start value (Input/Output mode, limits 0–9999) and a read-only output field for each displayed value. Use a separate "Reset" button wired to the HMI_T51_Reset Bool. Style the alarm bit as a red banner that appears when HMI_T51_Alarm_HoursElapsed is true.
For the LOGO! side, refer to the Siemens Industry Online Support portal for the LOGO! system manual, the LOGO! Soft Comfort online help, and the Parameter VM Mapping section.
Extended Application: Multi-Mill Lubrication Tracking
The reference design scales from one mill to four (T5-1 through T5-4) by replicating the B005/B009/MUX triplet with offset VM blocks:
| Mill | Hours Block | Minutes Block | MUX Block | VM Region | Alarm Bit |
|---|---|---|---|---|---|
| T5-1 | B005 | B009 | MUX1 | V0.0–V0.7 / VD2–VD18 | V0.0 |
| T5-2 | B105 | B109 | MUX2 | V1.0–V1.7 / VD34–VD50 | V1.0 |
| T5-3 | B205 | B209 | MUX3 | V2.0–V2.7 / VD66–VD82 | V2.0 |
| T5-4 | B305 | B309 | MUX4 | V3.0–V3.7 / VD98–VD114 | V3.0 |
A summary HMI screen can be built with an image selector that toggles between per-mill detail screens. A top-level alarm view aggregates the four alarm bits into a single "Lubrication Due" banner; the operator clicks the banner to navigate to the affected mill's screen.
Cross-Platform Counter Concept
Engineers who have used other vendor HMIs with preset-value counters will recognize the pattern of "set preset, count down, assert Q at 0" as a standard building block. For example, the Proface HMI Up/Down Counter Preset Configuration FAQ documents a similar architecture where the preset value is held in a register, the current value is decremented on a count input, and the Q output is asserted when the current value reaches 0. The key difference is that on a Proface HMI, the preset is held in the HMI's own register; on a LOGO! + KTP700 combination, the preset is held in the LOGO!'s VM and is written from the HMI. The LOGO! version requires explicit Parameter VM Mapping and the DWord discipline described above; the Proface version has the binding implicit in the HMI tag configuration.
For an even larger deployment (for example 20 mills), the LOGO! approach becomes cumbersome because the Parameter VM Mapping table grows linearly. At that scale, migrate to an S7-1200 or S7-1500 with a structured DB and a single FB that encapsulates the counter/MUX triplet for any number of instances.
Troubleshooting Matrix
| Symptom | Likely Cause | First Check | Resolution |
|---|---|---|---|
| Start value reverts to 0 after Reset | HMI tag data type = Word (16-bit) | HMI tag list → Data type column | Change to DWord (UInt32 or Int32) |
| Start value reverts to 0 immediately on first scan | VM Mapping address does not match HMI tag address | LOGO! Parameter VM Mapping table vs HMI tag address | Reconcile addresses; verify with LOGO! online monitor |
| Counter shows a value 65536× too large | HMI reads VW16, write went to VW18 (Big Endian half) | HMI tag address column | Use full VD address with DWord data type |
| Minute counter keeps running when hour = 0 | MUX not inserted, or Sel wired wrong | Online view of MUX Sel and AQ | Add MUX, wire B005.Q to Sel, route AQ to a dedicated HMI display address |
| Counter value garbled (for example 256 instead of 1) | Bit tags overlap DWord in VM | List of V-bit addresses vs VD usage | Move bit tags out of any DWord address range |
| Reset button does nothing | Reset input mapped to a bit inside a DWord in use | Parameter VM Mapping table | Move Reset to an isolated Bool address outside all DWord regions |
| Counter never starts | Start value of 0 was loaded at power-up | LOGO! online monitor → Start Value | Set start value to non-zero via HMI I/O field |
| Counter decrements twice per pulse | Both edges of Cnt input are counted | Counter block properties → Edge | Switch to falling edge or rising edge only |
| HMI shows "####" overflow | Counter value exceeds I/O field display width | I/O field properties → Number of characters | Increase character count or use a different display format |
| Download of new program resets counter to 0 | LOGO! counter is not retentive, or retentive behavior was not enabled | Counter block properties → Remanence | Enable remanence on the counter; verify behavior across power-cycle |
Best Practices and Field-Proven Caveats
- Always use DWord for the Start Value and current value of any LOGO! counter when exposing them to an HMI. A 16-bit Word type on the HMI side is the single most common cause of "counter reverts to 0" symptoms.
- Document the VM map in a header comment block in the LOGO! program and in a separate text file shared with the HMI programmer. The Parameter VM Mapping table is the contract between the two worlds; an undocumented contract is a fault waiting to happen.
- Treat the analog MUX as a display gate, not a state machine. The underlying counter keeps cycling; the MUX only changes what the HMI sees. Do not try to use the MUX to feed back into the counter's Cnt or Reset inputs.
-
Verify endianness on every integration. A counter value written as
VW18and read asVD16will appear to work in one direction and fail in the other. Always use the same address width on both sides. - Use a diagnostic screen during commissioning that shows the raw CV, the MUX output, the start value, and the alarm bit for every mill. After commissioning, the diagnostic screen can be hidden but should remain in the project for field service.
- Enable retentive behavior on counters that must survive power cycles. In LOGO! Soft Comfort, right-click the counter block, select "Block Properties," and check the "Retentive" option. This stores the current value in non-volatile memory. Note that retentive counters are reset by a program download, so plan maintenance windows accordingly.
- Plan for scale. A four-mill lubrication tracker is comfortable on a LOGO!. A forty-mill tracker should be migrated to an S7-1200/1500 with a structured DB and an FB that encapsulates the counter/MUX triplet.
- Cross-reference the Parameter VM Mapping entry with the HMI tag address on every change. A change in one place that is not reflected in the other is the most common source of post-commissioning faults.
Safety Caveat for Lubrication Alarms
Frequently Asked Questions
Why does the LOGO! down counter lose its start value after a reset?
Either the HMI tag is declared as Word (16-bit) instead of DWord (32-bit), or the HMI tag address does not match the Start Value parameter in the LOGO! Parameter VM Mapping table. The counter block falls back to the compile-time default of 0 when the mapped value is never updated. Verify both the data type on the HMI side and the address correspondence in LOGO! Soft Comfort online view.
How do I stop a minute counter from continuing to count when the hour counter is at zero?
Insert an analog multiplexer block with B005.Q on the Sel input, the live B009 current value on V1, and a constant 0 on V2. Route the MUX output to a separate VM address used only for HMI display. The actual B009 register keeps cycling, but the operator sees 0 while the hour counter is latched. Do not wire the MUX output back into B009.
What is the difference between VW16, VW18, and VD16 in LOGO! VM memory?
VD16 is a 32-bit DWord covering bytes VB16 through VB19. VW16 is the high 16 bits and VW18 is the low 16 bits. LOGO! uses Big Endian, so writing to VW16 only updates the most significant half of VD16. To read or write a full 32-bit value, always use VD16 as the HMI tag address with a DWord data type.
Can I share VM bytes between bit tags and DWord tags?
No. Any DWord at VD0 overlaps the bits V0.0 through V3.7 and the Words VW0 and VW2. Mixing bit and DWord access to the same address corrupts both views. Allocate separate, non-overlapping VM regions: a Bool region, a Word region, and a DWord region. Document the allocation in a header comment block.
Does the analog MUX solution scale to four mills in the lubrication example?
Yes. Replicate the B005/B009/MUX triplet for each mill and offset the VM address block by 32 bytes per mill. Use a shared alarm word to flag any mill that has reached its lubrication interval. Beyond four mills, consider migrating to an S7-1200/1500 with a structured DB and a reusable FB.
Do I need to enable retentive behavior on the LOGO! counter?
Yes, if the counter must survive a power cycle. Open the counter block properties in LOGO! Soft Comfort, check the "Retentive" option, and verify with a power-cycle test. Note that retentive counters are reset by a program download, so plan maintenance windows accordingly.