Siemens LOGO! 8 OBA8: Inhibiting Q Output at Counter Zero
When a Siemens LOGO! 8 OBA8 is used as a soft PLC to control a wireless handheld receiver through simulated Q-output "button presses," a subtle edge case appears at counter value zero: pressing the wired DOWN input drives the device to its alternate reset state (commonly 100 on legacy training pendants and low-cost industrial controllers). The counter still reads 0 in LOGO!, but the handheld has jumped to its alternate state and the two values are now permanently out of sync. The fix is a function-block-level gate placed ahead of the Q6 pulse generator. This article documents the root cause, the building blocks involved (B001 Up/Down Counter, B054 Analog Threshold Trigger, V flags, AND gate), and the proven latch-and-gate solution.
Problem Summary
The classic "Zombied" symptom surfaces on a custom LOGO! Web Editor (LWE) page that drives a wireless handheld receiver. Network inputs from the page increment or decrement an internal up/down counter (B001), and the count is read back to the page using a status variable. After power-up:
- Counter initializes to
0. - Handheld receiver display also reads
0. - Clicking the UP button on the web page increments the counter to
1, the handheld to1. State is consistent. - Clicking the DOWN button to return to zero works the first time. State is consistent.
- Clicking the DOWN button a second time, with the counter at
0, does not leave it at-1(the counter clamps at0), but the handheld display jumps to100. The receiver's firmware treats an edge on its DOWN input at the minimum as a "cycle past minimum" command, rolling the parameter over to the maximum. - From this point, the LOGO! counter reads
0and the handheld reads100. The two values cannot be re-aligned by the web interface, and only a manual button press on the handheld itself can recover.
The handheld's firmware cannot be modified. The required behavior is: Q6 (or whichever Q drives the simulated DOWN contact) must be inhibited while the counter equals 0. The fix must live entirely in the LOGO! program.
System Topology
The reference installation is a 12/24 RCE OBA8 with one DM8 230R expansion module and an Ethernet connection to the plant LAN. The custom web page is hosted by the OBA8's internal web server and edited with LOGO! Web Editor V8.x.
| Resource | Assignment | Notes |
|---|---|---|
| I1, I2, I3, I4 | Discrete inputs from the rest of the machine | 12/24 V on the OBA8 base |
| I5, I6, I7, I8 (DM8) | Discrete inputs from the rest of the machine | 230 V on the expansion module |
| Q1 | Relay contact wired across the handheld's UP push button | Closure for 200 ms simulates a press |
| Q2 | Relay contact wired across the handheld's ON/OFF push button | Closure for 500 ms toggles the handheld power state |
| Q3, Q4 (DM8) | Handheld stop / reset | Not affected by the zero-inhibit |
| Q6 (DM8) | Relay contact wired across the handheld's DOWN push button | The output that "zombie's" the device at count = 0 |
| NI1 | Network input — "UP" button on the LWE page | Mapped to V0.2 in the program |
| NI2 | Network input — "DOWN" button on the LWE page | Mapped to V0.3 in the program |
| NI3 | Network input — "ON/OFF" toggle on the LWE page | Mapped to V0.4 |
| NA1 | Network analog — counter value to display on LWE | Integer 0…100 |
Function block inventory in the working program before the fix:
- B001 — Up/Down Counter (Cnt = simulated UP pulses, Dir = V0.0 = direction flag, R = V0.1 = reset)
- B003…B020 — standard machine sequencing blocks (mutually exclusive running, fault latch, run-time hour counter, etc.)
- B039 — Wiping Relay (pulse generator that produces the 200 ms contact closure on Q1 and Q6)
- B041 — Off delay used for the 500 ms ON/OFF pulse on Q2
The handheld's DOWN pulse is generated by feeding V0.3 (the web "DOWN" command) into a wiping relay, and the wiping relay's output is wired directly to Q6. With no gating, Q6 fires whenever V0.3 goes high — regardless of the counter value. That is the bug.
Root Cause: Why the Handheld Resets to 100 on a Downward Pulse
The handheld receiver is built around a small microcontroller that interprets one of two behaviors when its DOWN input sees a falling edge:
- If the internal parameter is currently above its minimum, decrement by one.
- If the internal parameter is already at the minimum, wrap to the maximum (a common UI pattern in legacy remotes and training tools that originally had a mechanical thumb wheel).
The LOGO! cannot tell the difference between a human press and a wired-from-Q6 press. The 200 ms closure on Q6 is electrically identical to a fingertip on the membrane switch. The bug is therefore a firmware limitation of the handheld, not a LOGO! bug. The PLC must enforce the constraint that the simulated DOWN press is only delivered when the LOGO! counter is strictly above zero.
Two naive fixes that don't work in LOGO! 8:
-
Lower the counter's lower clamp and let it go negative. The up/down counter in LOGO! 8 can be configured to allow negative values, but the counter is the LOGO!'s view, not the handheld's. The handheld's
0is still the trigger, and the Q6 pulse will still be generated against a counter that the LOGO! thinks is at0. Worse, the web page will start showing-1, confusing the operator. -
Reset the counter to
1on every DOWN press. This breaks the count semantics. Two DOWN presses from3should land at1, not bounce back to1after a single press.
The correct approach is to gate the pulse that drives Q6, leaving the counter itself untouched.
LOGO! 8 OBA8 Building Blocks Used in the Solution
The function blocks referenced in the working program and discussed below are all native to LOGO! Soft Comfort V8.x. No expansion library is required.
| Block | Library Path in Soft Comfort | Purpose |
|---|---|---|
| Up/Down Counter | SF → Counter → Up/Down Counter | Tracks the logical position (B001). The reference number B001 is project-relative; the count value is exposed as a block parameter that can be fed into an analog function block. |
| Analog Threshold Trigger | SF → Analog → Analog Threshold Trigger | Compares a numeric input against configurable ON/OFF thresholds. Used to detect count > 0 with hysteresis. The block number B054 in this article is project-relative and indicates the 54th block placed in the program — yours will be different. |
| AND (Edge) | SF → Logic → AND | Booleans AND. Combines the V0.3 web command with the threshold trigger's output to gate the pulse generator. |
| Wiping Relay (Pulse Relay) | SF → Special → Wiping Relay | Single-shot pulse generator with configurable pulse width. Already present in the program for the UP pulse; an additional instance drives Q6. |
| V flags (V0.0…V0.7) | Co → Marker → Flag | Internal flags. V0.3 in this design carries the LWE-driven DOWN request. The threshold trigger output can also be latched through a dedicated V flag (V0.5) for monitoring on the LWE page. |
| Network Inputs (NI1…NI64) | Co → Network → Network Input | Receive boolean or analog values from remote LOGO! nodes or from the LWE web server (LWE writes the value on a button click). |
Analog Threshold Trigger Behavior
The threshold trigger is the heart of the inhibit. Its transfer characteristic is hysteresis, not a single comparator:
- Input Ax: numeric value (signed integer or scaled analog, depending on source).
-
ON threshold: when
Ax ≥ ON, the output goes high. -
OFF threshold: when
Ax ≤ OFF, the output goes low. - Gain: multiplier on Ax (default 1.00). Leave at 1.00 when feeding a counter value.
- When
OFF < Ax < ON, the output holds its previous state. This is the hysteresis band that prevents chattering around the threshold.
For a count that should be considered "non-zero" only when the integer is at least 1, configure:
- ON = 1 (output goes high when count reaches 1 or above)
- OFF = 0 (output goes low when count returns to 0)
For applications where the count needs to be at least 2 before the DOWN button is enabled (e.g. to leave one step of headroom), set ON = 2, OFF = 0.
Counter Behavior Notes
The Up/Down Counter block on LOGO! 8 has these terminals:
| Terminal | Function |
|---|---|
| Cnt | Count input — rising edge increments or decrements based on Dir |
| Dir | Direction — 0 = up, 1 = down (configurable: Invert Dir swaps the assignment) |
| R | Reset — high resets the counter to the start value |
| Start value | Initial value on first cycle, on reset, and on power-up |
| Threshold | Behavior |
| ON threshold | Count value at which the block's internal output goes high |
| OFF threshold | Count value at which the block's internal output goes low |
Solution Architecture: Threshold Switch + V-Flag Latch
The signal flow is:
- The LWE page's "DOWN" button sets NI2 = 1 → mapped to V0.3 = 1.
-
B001 (Up/Down Counter) holds the current count. Its count value is exposed on the parameter rail as
B001(the block's value parameter). - B054 (Analog Threshold Trigger) is fed with the value of B001. It is configured with ON = 1, OFF = 0. Its boolean output is high whenever the count is ≥ 1.
- An AND block (e.g. B055) takes V0.3 and B054's output. Its result is high only when both are high — i.e., the web page has issued a DOWN command and the counter is non-zero.
- The AND output feeds the Wiping Relay that drives Q6. The relay's pulse width (200 ms) produces the simulated button press.
- The B054 output is also latched into a V flag (e.g. V0.5) so the LWE page can render a disabled-state indicator on the DOWN button when the count is at zero. This is the "lock with V0.5" pattern — the boolean "DOWN permitted" is exposed as a network output (NA1.bit) for the web page to read.
Below is the function-block topology. The pulse generator for Q6 is shared with the existing wipe-relay pattern, but the input is now gated by the AND block.
Why a "latch" rather than a direct AND
The phrase "lock the result with V0.3" in some implementations means: write the AND result into a V flag (V0.5) on every scan, and use V0.5 as the gate. This adds a one-cycle delay that can be useful when the LWE page polls a network analog of the inhibit state to grey out the DOWN button. The V flag becomes a stable "DOWN permitted" indicator that the web page can read.
The same V flag can be used as a soft interlock for the on-board HMI: when V0.5 is low, the LWE JavaScript disables the DOWN button visually and refuses to issue another NI2 pulse until the counter increments above zero again.
Step-by-Step Implementation in LOGO! Soft Comfort V8.4
The following procedure assumes Soft Comfort V8.4 SP1 or later, the LOGO! 8 OBA8 hardware in the topology above, and that the existing program is already on the engineering PC. The exact block numbers will be different in your project; refer to the topology diagram for the relative position of each block.
Step 1 — Confirm the Counter Reference
Open the program and locate the Up/Down Counter that drives the handheld. In this example it is B001. Right-click the block, choose Properties → Parameter, and confirm the start value (typically 0) and the ON/OFF thresholds. The thresholds should already be set to whatever the existing program requires (e.g. ON = 1, OFF = 0 to indicate "at least one unit present").
Step 2 — Add the Analog Threshold Trigger
Drag an Analog Threshold Trigger from the SF folder onto an empty area of the FBD program editor. Drop it close to the counter for visual clarity. Click on the threshold trigger's input connector and select the up/down counter's count value (the parameter exposed as the block number, e.g. B001) from the connection picker.
Step 3 — Configure the Thresholds
Open the threshold trigger's block properties:
| Field | Value | Notes |
|---|---|---|
| Gain | 1.00 | Do not scale — the counter value is an integer 0…N. |
| Offset | 0 | Default. |
| ON threshold | 1 | Output goes high when count ≥ 1. |
| OFF threshold | 0 | Output goes low when count ≤ 0. |
Click Apply. The block's output connector is now a boolean that mirrors "count > 0".
Step 4 — Add the AND Gate
Drag an AND block from SF → Logic. Connect its first input to the threshold trigger's output. Connect its second input to V0.3 (the network input mapped to NI2).
Step 5 — Add the Wiping Relay (Pulse Generator) for Q6
If the existing Q6 pulse is already generated by a wiping relay, modify that relay's trigger input to the new AND output. If Q6 is wired directly, add a fresh wiping relay and configure:
| Field | Value |
|---|---|
| Trg (Trigger) | AND output |
| Par (Parameter) | Standard |
| Pulse width (T) | 200 ms |
| Retentivity | Off |
Connect the wiping relay's output to Q6. Save the project.
Step 6 — Latch the Inhibit State to a V Flag (Optional but Recommended)
Add a digital flag block (Co → Marker → Flag) and set its address to V0.5. Connect the threshold trigger's output to V0.5. V0.5 is now "DOWN permitted" — high when the count is ≥ 1.
Step 7 — Expose the Inhibit State to the Web Page
In the network output list (or the LWE project), add a network analog or a network boolean derived from V0.5. The LWE page reads this value and visually disables the DOWN button when V0.5 is low. The pattern in the LWE HTML is:
<button id="btnDown" onclick="logoSet('NI2',1)">DOWN</button>
<script>
setInterval(function(){
fetch('/logo.cgi?NA2')
.then(r=>r.text())
.then(v=>{ document.getElementById('btnDown').disabled = (v.trim()==='0'); });
}, 250);
</script>
Replace NA2 with the actual network output carrying the V0.5 value. Some firmware revisions use a different endpoint; consult the LOGO! Web Editor V8.x documentation for the syntax that matches your Soft Comfort version.
Step 8 — Save, Compile, and Download
Press F5 (or Tools → Simulation) to simulate in Soft Comfort. With the counter at 0, click the simulated V0.3 input — Q6 should not toggle. Increment the counter to 1, click V0.3 again — Q6 should pulse for 200 ms. Decrement back to 0, click V0.3 — Q6 should remain idle. Stop the simulation, then download the program to the OBA8 (Tools → Transfer → PC → LOGO!).
Step 9 — Cycle Power and Verify on Hardware
Power-cycle the OBA8 to clear volatile state. The counter initializes to its start value (0). The handheld display reads 0. Press the wired UP button (Q1) once — the handheld increments to 1. Press the web DOWN button once — the handheld decrements to 0. Press the web DOWN button again — nothing happens on the handheld, and the web button should grey out within one poll interval. The counter remains at 0. The bug is gone.
Alternative Implementations
Three other approaches solve the same problem. Each has trade-offs in program size, scan-time latency, and reliance on the counter's built-in features.
Alternative A — Use the Counter's Internal ON/OFF Output
If the counter's internal ON/OFF output is not already driving something else, the simplest fix is to AND that internal output with V0.3 and feed the AND to the pulse generator. Configure the counter with ON = 1, OFF = 0 in its block parameters. The block's output connector carries the boolean "count ≥ 1".
Pros: zero new blocks, smallest program. Cons: ties the counter's threshold to the gate; if the threshold must be moved to a different value (e.g. ON = 5 to drive an alarm at 5 units), the gate logic changes with it.
Alternative B — Pre-Offset the Counter to a Range of 1…101
Set the counter's start value to 1 instead of 0. Subtract 1 on the display side before showing on the LWE page. The counter itself never reaches 0; the zero state is only ever a logical zero in the display. The web page must do the offset (logo.cgi shows 0…100, internal is 1…101).
Pros: no gate required, no threshold trigger. Cons: every count value in the program must know about the offset, the on-board LOGO! TD display shows 1…101, and any operator who reads the TD panel is confused. Not recommended for installations where the LOGO! TD is the primary HMI.
Alternative C — Wiping Relay with Gate Input
Replace the AND + wiping-relay combination with a single Wiping Relay (with gate) block. Some SF blocks accept a gate input that suspends the trigger. Connect V0.3 to Trg and the threshold trigger output to the gate. The pulse will only fire when the gate is high.
Pros: one block instead of two. Cons: not all Wiping Relay variants in every firmware release expose a separate gate; verify in the actual SF list. The pulse width cannot be made conditional on the gate state — if V0.3 stays high for 1 second and the gate drops mid-pulse, behavior is implementation-defined.
Alternative D — Conditional Pulse via the AND-of-AND Pattern
For installations with a button on the LOGO! TD that also needs to drive DOWN, double-gate: AND the threshold output with the TD button, AND the threshold output with the web command, then OR the two AND results into the wiping relay trigger. This protects every entry point, not just the web one.
Verification and Commissioning
Pre-Commissioning Checklist
- Confirm the OBA8 firmware is in the supported 8.x range. Minimum recommended: FS:04 for 6ED1052-XXXXX-0BA8 hardware. Newer firmware (FS:05 or FS:06) is preferred for security fixes.
- Back up the existing program with Tools → Transfer → PC → LOGO! before downloading the new one.
- Verify the new blocks are visible in the simulation (Tools → Simulation) and that the threshold trigger output toggles correctly when the counter value crosses 1.
- Verify the LWE page loads in a browser pointed at
http://<LOGO!_IP>and that the DOWN button visually disables when the count is 0.
Functional Test Matrix
| Test # | Initial Counter | Action | Expected Counter | Expected Q6 State | Pass Criterion |
|---|---|---|---|---|---|
| 1 | 0 | Web DOWN | 0 | Inactive (no pulse) | Handheld remains at 0; web button greyed |
| 2 | 0 | Web UP | 1 | Inactive (no Q6) | Handheld increments to 1; web button enabled |
| 3 | 1 | Web DOWN | 0 | One 200 ms pulse | Handheld decrements to 0 |
| 4 | 0 (post #3) | Web DOWN (repeat) | 0 | Inactive | Handheld stays at 0 — regression |
| 5 | 50 | Web DOWN | 49 | One 200 ms pulse | Handheld decrements to 49 |
| 6 | 1 | Web DOWN twice fast | 0 then 0 | Two pulses then idle | Handheld at 0, second click inhibited |
| 7 | 0 | TD DOWN (if present) | 0 | Inactive | Same protection as web path |
| 8 | 0 | Power cycle | 0 | Inactive | Counter starts at 0, no spurious pulse on power-up |
Diagnostic Outputs to Add During Commissioning
For a one-shift burn-in, expose the following on the LWE page or in the LOGO! TD menu:
- V0.5 ("DOWN permitted") — should mirror "count ≥ 1".
- B001's count value as NA1.
- A count of Q6 pulses in the last hour, using a hours counter block, to detect any spurious pulse that might still slip through.
- Flag V1.0 = "glitch detected" — set if the counter ever reads 0 and Q6 fires within the same scan. Should never be 1 in steady state.
Edge Cases and Field-Proven Caveats
Counter at Maximum
The same problem exists in reverse. If the counter is at 100 (or the max of your scale) and the operator clicks UP, the Q1 pulse will fire and the handheld may either overflow to 0 or refuse the command (manufacturer-dependent). Mirror the same gate for the UP path: a second threshold trigger on the same B001 with ON = max, OFF = max - 1, ANDed with V0.2, feeding the Q1 pulse generator. The cost is one more AND and one more threshold trigger.
Network Input Bounce from the Web Page
LWE buttons driven by JavaScript can produce multiple NI2 edges on a single click if the polling loop and the click handler race. The wiping relay is edge-triggered, so a sustained V0.3 = 1 (from a stuck input or a tab that the browser keeps open) will not produce repeated pulses — it produces one pulse on the leading edge. This is the correct behavior. If the operator double-clicks rapidly, the wiping relay will fire twice (once per click), which is also the expected behavior. Verify by watching Q6 with a counter.
Counter Overflow and Underflow
LOGO! 8's Up/Down Counter clamps to its start value and its configured max. Confirm the start value (0) and the max (100) match the handheld's range. If the LOGO! counter is set to 16-bit full range (±32767) by default and the user rapidly fires UP, the count will sit at 32767 long before the handheld has reached its real maximum. Set the counter's max parameter explicitly in block properties.
Threshold Trigger Hysteresis with Integer Values
The OFF threshold must be strictly less than the ON threshold for the hysteresis to make sense. With ON = 1 and OFF = 0, the hysteresis is 1 count, which is the smallest possible and exactly correct for a 1-step inhibit. With ON = 0 and OFF = 0, the block becomes a non-hysteretic comparator that may chatter as the value hovers around 0 due to integer representation. Always use ON = 1, OFF = 0 for this use case.
Scan-Time Latency
The LOGO! 8 base unit scans the program in roughly 1–2 ms per block per cycle (typical 5–10 ms for a 60-block program). The full chain — threshold trigger + AND + wiping relay + output driver — adds about 4 ms of latency between V0.3 going high and Q6 energizing. This is well within the 200 ms pulse width and is not noticeable to the handheld. If your pulse width is shorter than 50 ms, increase it; the latency itself is not the issue, but the minimum debounce time of the handheld's membrane switch is.
Expansion Module Q Addressing
On a base OBA8 with one DM8 expansion, the Q numbering is 1…4 on the base, 5…8 on the first expansion. Q6 is therefore on the DM8, not the base. If the design moves Q6 to the base, the same block wiring applies — the LOGO! resolves Q numbering automatically. Do not hard-code DM8 positions in the program; the LOGO! auto-detects topology on power-up.
Web Editor (LWE) Polling Latency
The LWE page polls at 250 ms in the example. A fast operator can click DOWN twice within 250 ms; the first click increments V0.3 = 1, Q6 fires (assuming count is non-zero), V0.3 returns to 0 after the wiping relay's pulse width. The second click arrives while the LWE page still shows the button as enabled. This is acceptable; the gate still prevents the worst-case scenario of clicking at count = 0. For faster visual feedback, drop the polling interval to 100 ms.
Retentive Counter Behavior
If the counter is set to retentive (survives power cycle), the bug reappears on power-up if the last value was 0 and the operator clicks DOWN within seconds of power restoration. The fix still holds: the threshold trigger output is high only when count ≥ 1, regardless of whether the count was retentive. Confirm by checking the retentivity box on the up/down counter's block properties.
Frequently Asked Questions
What firmware version of the LOGO! 8 OBA8 supports the analog threshold trigger and the up/down counter block used in this solution?
Both blocks are native to the OBA8 platform and have been available since the first 0BA8 firmware (FS:01). Any OBA8 running FS:04 or later supports the full solution. Refer to the LOGO! 8 system manual for the firmware revision notes specific to your hardware variant.
Can I use the counter's built-in ON/OFF output instead of adding the analog threshold trigger block?
Yes, if the counter's internal ON/OFF output is not already driving something else. Configure the counter with ON = 1 and OFF = 0 in its block properties, then AND the block's output connector with V0.3 and feed the AND to the pulse generator. This saves one block. The trade-off is that the threshold is shared between the indicator logic and the gate logic; if you need them at different values, keep the analog threshold trigger as a separate block.
How do I expose the "DOWN permitted" boolean to the LOGO! Web Editor (LWE) so the button greys out at count zero?
Write the threshold trigger's output into a V flag (e.g. V0.5). Map that V flag to a network output (NA2 or similar) in the network output list. In the LWE HTML, poll that network output with a JavaScript interval (typically 100–250 ms) and set the button's disabled attribute based on the value. The LWE documentation is at Siemens Industry Online Support.
Why does the handheld jump to 100 on a DOWN press at minimum, and can that be fixed on the handheld itself?
The handheld's firmware treats a DOWN edge at the minimum parameter as a "wrap to maximum" command. This is a UI convention from legacy thumb-wheel remotes. The firmware is typically not user-modifiable, and the bug is invisible to a human operator (who would never press DOWN at minimum). The fix must be in the LOGO! program, gating the simulated DOWN pulse to the count-equals-zero condition.
Will this solution also work on the LOGO! 8 with a DM8 expansion that places Q6 on the expansion module?
Yes. The LOGO! resolves Q numbering automatically across the base and up to two DM8 expansions (or one AM2 / AM2 RTD analog expansion combined with DM8 digital modules). The block wiring is identical; the only consideration is the relay's make/break rating on the expansion module — the DM8 230R is rated 5 A resistive per output, and the handheld's momentary contact draws well under 100 mA, so the relay is comfortably within spec.
Can I skip the analog threshold trigger and just use a comparison block?
LOGO! Soft Comfort V8.x does not include a dedicated "greater than" comparison block in the SF list. The analog threshold trigger is the standard primitive for this comparison, with built-in hysteresis that prevents output chatter near the boundary. If you need a strict greater-than-zero test without hysteresis, you can use the mathematical instruction block with a custom formula, but this adds scan-time cost and is not recommended for a 1-bit gate.
What is the maximum count value the up/down counter can hold in LOGO! 8 OBA8?
The up/down counter's count range is configurable from −32768 to +32767 in block properties. For this use case, the upper limit is set to 100 to match the handheld's range. The lower limit is 0 (or whatever the start value is, since the counter clamps at the start value on underflow attempts). The displayed value on the LWE page is the raw counter value; apply a scaling factor of 1.0 for direct display.