LOGO! Short vs Long Pulse Detection Using On-Delay Timers

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

Overview

The Siemens LOGO! is a compact logic module widely used for small automation tasks. A recurring requirement in panel design is differentiating a short button press (e.g., toggle on/off) from a medium or long press (e.g., select a menu or run a mode) on a single digital input. This article documents a robust implementation using the on-delay (Ta) special function block, signal-edge evaluation, and a release-latch mechanism so that only the matching output energises after the operator releases the pushbutton.

Use case: a single panel pushbutton on input I1. If released within 1 s, output Q1 toggles. If held between 1 s and 2 s, Q1 latches. If held for 2 s or longer, Q2 latches instead — and Q1 must not energise during or after the long press.

Prerequisites

Hardware

  • Siemens LOGO! 8 base module (6ED1052-xxx08-0BA1 / -0BA2 family) or LOGO! 8.3 / 8.4 (e.g., 6ED1052-1MD08-0BA1, -1FB08-0BA1).
  • 24 V DC powered base with at least one free digital input (I1..I8) and at least one free digital output (Q1..Q4).
  • One normally-open panel pushbutton, 24 V DC rated, with wires terminated to the LOGO! input terminal.
  • LOGO!Power 24 V supply (6EP1331-1SH03) or equivalent regulated 24 V / 2 A source.

Software

  • LOGO!SoftComfort V8.0 or later (V8.3 / V8.4 recommended to match module firmware). Available from the Siemens LOGO! 8 system manual and download portal.
  • LOGO! base module firmware 1.82.x or later (LOGO! 8.4 ships with FS-04 firmware as of 2023).
  • Ethernet or USB programming cable.

Documentation

  • LOGO! 8 System Manual (entry ID 109751459) — support.industry.siemens.com.
  • LOGO!SoftComfort Online Help — bundled in the software under Help > Contents.

Functional Specification

Define the timing thresholds explicitly before any code is written. A common three-class scheme:

Press duration Tp Detected class Output Q1 Output Q2
Tp < 1.0 s Short (toggle) Toggle on release 0
1.0 s ≤ Tp < 2.0 s Medium (latch) 1 (latched on release) 0
Tp ≥ 2.0 s Long (latch) 0 (must stay off) 1 (latched on release)

Three engineering constraints fall out of this specification:

  1. Outputs must not change state while the button is held (prevents a Q1 pulse from appearing on a long press).
  2. Decision logic must be triggered on the falling edge of I1 (button release).
  3. The two on-delays must not both feed the output simultaneously — the higher tier must inhibit the lower tier.

Step-by-Step Implementation in FBD

LOGO!SoftComfort defaults to Function Block Diagram (FBD). The implementation below extends the simple on-delay approach with explicit edge evaluation and gating, addressing the constraint that Q1 must not fire on a long press.

Step 1 — On-delay for the short threshold

  • Insert Special Function On-delay from the toolbar (folder: SF > Timers > On-delay).
  • Parameter Ta = 01.00 s.
  • Trigger (Trg) input wired to I1.
  • Output (Q) is B001.Q, which rises to 1 only after I1 has been continuously high for ≥ 1 s.

Step 2 — On-delay for the long threshold

  • Insert a second On-delay block, B002.
  • Ta = 02.00 s.
  • Trg wired to I1.
  • Output B002.Q rises to 1 only after I1 has been continuously high for ≥ 2 s.

Step 3 — Build a release-edge strobe

LOGO! does not expose a dedicated falling-edge block. Build it as follows:

  1. Place an Inverter (NOT) on I1 — output is /I1.
  2. Wire /I1 into the trigger of a Pulse output (B003) with Pa = 1 cycle. A one-scan pulse is produced on the rising edge of /I1, i.e. the moment the button is released.
  3. The output of B003 is the release strobe that enables the output AND gates.
This is the LOGO! equivalent of the IEC 61131-3 F_TRIG (falling-edge trigger) function block. The release strobe must be the gating signal on every output path, not the raw I1 input.

Step 4 — Wire the Q1 path

Q1 must set on release only if B001 has fired and B002 has not. Use a three-input AND gate (B004):

AND-1 input Source Logic
A B003.Q Release detected
B B001.Q 1 s threshold reached
C NOT(B002.Q) 2 s threshold not reached

AND-1.Q is the set coil for Q1.

Step 5 — Wire the Q2 path

Q2 must set on release only if B002 has fired. Use a two-input AND (B005):

  • Input A: B003.Q (release strobe)
  • Input B: B002.Q (≥ 2 s)

AND-2.Q is the set coil for Q2.

Step 6 — Latch the outputs

Wire each output through a self-holding contact so that once set, the output remains set. Reset of Q1 is driven by a separate short-press branch (use a current-impulse-relay / toggle function on the short sub-band). Reset of Q2 can be tied to a dedicated input or to a long-press of ≥ 4 s.

Complete FBD Wiring Reference

Source Block Destination Purpose
I1 direct B001.Trg / B002.Trg Start the 1 s and 2 s timers
I1 NOT B003.Trg Detect release edge
B001.Q AND-1 input B ≥ 1 s condition
B002.Q AND-2 input B ≥ 2 s condition
B002.Q NOT AND-1 input C Inhibit Q1 on long press
B003.Q AND-1 / AND-2 input A Release gating
AND-1.Q Q1 set coil Short / medium action
AND-2.Q Q2 set coil Long press action

Why a Plain On-Delay Is Not Enough

If Q1 is driven directly from B001.Q while I1 is held, Q1 will rise at 1 s and remain high for the entire 2 s press — exactly the behaviour the application forbids ("Q1 may not be energised if the button is pressed for 2 seconds"). Three techniques correct this:

  1. Release-edge gating — outputs change only on the release of I1, never during the press.
  2. Latch-and-block — once a long press is detected, a flag (M1) blocks the short-press path.
  3. Sequential priority — if the higher-tier timer has fired, it inhibits the lower-tier output through an inverter.

The implementation above combines techniques 1 and 3, which is the most common and least resource-intensive.

Edge Detection in LOGO!SoftComfort

LOGO!'s FBD library contains an Edge-triggered retentive function block (Special Functions > Edge). The standard pattern for a release detector is:

I1 ---[NOT]---> B003.Trg   (Pulse output, Pa = 1 cycle)
B003.Q  ------>  release_strobe

Each scan of the LOGO! evaluates all blocks. The pulse generator output is high for exactly one scan cycle after a rising edge on its trigger, giving a clean one-shot strobe on button release.

LOGO! Cycle Time and Timing Accuracy

LOGO! scans the program deterministically. For a LOGO! 8 base module the cycle time is typically 0.3–1.5 ms depending on program size. Practical implications:

  • Minimum resolvable press duration ≈ 1 scan + Ta accuracy.
  • For Ta = 1.00 s the effective response window is 0.999 s to 1.001 s.
  • For Ta = 2.00 s the window is 1.999 s to 2.001 s.
  • The gap between thresholds (1.001 s–1.999 s) is the "medium press" band, approximately 1.0 s wide.

LOGO!'s on-delay accuracy is ±0.1 % of the set time per the system manual — well within typical pushbutton debounce windows. For sub-100 ms thresholds, add a hardware RC filter (10 kΩ + 100 nF gives ≈ 1 ms time constant) or use the LOGO! input filter setting in the hardware configuration.

Debounce and Input Filtering

A mechanical pushbutton typically bounces for 5–20 ms. The 1 s and 2 s on-delay timers reject this naturally because Ta is several orders of magnitude larger than the bounce duration. If the application used sub-100 ms thresholds, install:

  • Hardware RC filter: 10 kΩ in series, 100 nF to GND, time constant ≈ 1 ms.
  • Software debounce: Special Function Off-delay with Ta = 20 ms on I1, then feed the off-delay output to the timer triggers.

Variant — Toggle vs Latch on the Same Button

To make a short press toggle Q1 and a medium press latch Q1, split the short band into its own timer:

Press length Active timer Action
< 0.4 s None Toggle Q1 via impulse relay
0.4–1.0 s B005 (0.4 s) only No change (dead band)
1.0–2.0 s B001 (1 s) only Latch Q1 on release
≥ 2.0 s B002 (2 s) Latch Q2 on release, Q1 inhibited

Use Special Function Current impulse relay (B006) to implement the toggle. Its trigger is the < 0.4 s sub-band output, and its reset input is wired to itself for auto-toggling or to a separate reset input for explicit off.

Variant — Three or More Press Classes

For more than two thresholds, cascade on-delay timers. The general rule for the output AND gate of tier n:

  • Input A: release strobe (B003.Q)
  • Input B: tier-n timer output
  • Input C: NOT of tier-(n+1) timer output

For N tiers, each gate uses 3 inputs and one output of an AND block. With 200 function blocks available on a LOGO! 8, the pattern extends to 5–6 tiers comfortably while leaving headroom for additional logic.

Commissioning Procedure

  1. Wire the pushbutton to I1 and a 24 V source. In LOGO!SoftComfort online mode, confirm that the I1 status indicator turns red when the button is pressed.
  2. Download the program to the LOGO! base module via Ethernet.
  3. Switch to Online Test mode (Tools > Simulation or the online test toggle).
  4. Press the button for 0.5 s, release. Verify Q1 toggles and Q2 stays 0.
  5. Press for 1.5 s, release. Verify Q1 sets latched and Q2 stays 0.
  6. Press for 3.0 s, release. Verify Q2 sets latched and Q1 stays 0 throughout.
  7. Press again for 0.5 s. Verify Q1 toggles back.
  8. Power-cycle the LOGO!. Verify the latched output state matches the retentive flag setting (M-flag or output retentivity).

Verification Matrix

Test Expected Pass criterion
Press 0.3 s Q1 toggles Q1 changes state on release; Q2 = 0
Press 1.5 s Q1 latches Q1 = 1 on release; Q2 = 0
Press 2.5 s Q2 latches Q2 = 1 on release; Q1 = 0
Press 5.0 s Q2 latches Q2 = 1; Q1 = 0 (no transient Q1 pulse)
Release mid-press at 0.8 s No change Q1 and Q2 unchanged from prior state
Power cycle after Q2 latched Q2 remains Q2 = 1 after cold start (if retentive flag enabled)
Press 1.0 s exactly Borderline Acceptable: Q1 latches; the ±1 scan uncertainty window is unavoidable

Troubleshooting Matrix

Symptom Likely cause Remedy
Q1 fires on long press Release-edge gating missing Insert NOT(I1) pulse generator into AND-1 input A
Q1 never fires AND-1 input A wired to I1 directly Replace with B003.Q (release strobe)
Q1 and Q2 both fire on long press AND-1 missing the NOT(B002.Q) inhibit Add inverter on B002.Q to AND-1 input C
Timers never count up Mechanical chatter on I1 Add 20 ms off-delay on I1, or hardware RC filter
Q1 toggles instead of latching at 1.5 s Ta on B001 set to 0.5 s Verify B001 Ta = 1.00 s in the block properties dialog
Long press detected as short Ta on B002 = 1.5 s instead of 2.0 s Re-check; LOGO!SoftComfort shows Ta with two decimals (e.g., 02.00)
Outputs latch on power-up unexpectedly Retentive M-flag was 1 at last power-down Clear via LOGO! menu > Setup > Reset, or wire a startup one-shot to clear
Online monitoring shows B001.Q = 1 during press Working as designed Q1 only sets on release; the B001.Q state during the press is the timing measurement, not the output
Release strobe too short to be visible in online monitor Normal; B003 is 1 scan cycle wide Use Trend view or scope function in LOGO!SoftComfort to capture

Performance and Memory Notes

  • LOGO! 8 stores the program in on-board flash; a program with 8 special functions uses < 4 % of available program memory.
  • Each on-delay occupies one of the 200 available function-block slots. Plan to leave at least 30 slots free for future expansion.
  • For LOGO! 8.3 (6ED1052-1MD08-0BA1) and later, the on-delay time base is 0.01 s (10 ms).
  • Retentive behaviour for output Q1 / Q2 is configured in the block properties under Retentivity. On-delay blocks themselves are not retentive (their output is a function of the input and elapsed time only).

Safety Considerations

This is a non-safety logic function. If Q1 or Q2 drive machinery (e.g., a motor contactor), the LOGO! must not be the sole protective device. For safety-rated logic, use a LOGO! 8 with the integrated safety option or a separate safety relay per ISO 13849-1 and IEC 62061. Long-press detection is not a substitute for a hardwired Emergency Stop circuit.

Frequently Asked Questions

How do I detect a short versus long press on a single Siemens LOGO! input?

Use two on-delay (Ta) blocks with different thresholds. Wire the button to both timers. Gate each output through an AND that is enabled only on the falling edge of I1 (release strobe) and inhibited by the longer timer having fired. This prevents the short-press output from triggering during a long press.

Why does my Q1 output fire even when the button is held for 2 seconds?

The release-edge detector is missing or wired incorrectly. Replace the direct I1 input on the output AND gate with the output of a one-cycle pulse generator triggered by the inverted I1 signal. This ensures the AND gate only opens on the falling edge of the button press, not while it is held.

What timing accuracy can the LOGO! on-delay achieve?

The on-delay block has an accuracy of ±0.1 % of the set time, plus one scan cycle of jitter. For a 1.00 s Ta the effective response window is 0.999 s to 1.001 s. The cycle time on a LOGO! 8 base module is typically under 1.5 ms, so for human-scale presses the accuracy is dominated by the ±0.1 % spec, not the cycle time.

Can I use this method for more than two press classes (short, medium, long)?

Yes. Cascade additional on-delay blocks with longer Ta values. Each output is gated by an AND that requires the matching timer fired, the release edge, and all higher-tier timers NOT fired. The same pattern extends to 4, 5, or more classes within the 200 function-block limit of a LOGO! 8.

How do I make Q1 toggle on short press but latch on medium press using a single button?

Split the short band into its own on-delay (e.g., 0.4 s) and route its output to a current-impulse-relay for toggle behaviour. The medium band (1–2 s) drives a separate latch coil on Q1. With three on-delays (0.4 s, 1 s, 2 s) and one impulse relay, both behaviours are produced from a single pushbutton without conflict.

Is the LOGO! on-delay block retentive across power cycles?

No. The on-delay's internal elapsed-time counter resets on power-down. Use a separate retentive flag (M-flag) or a retentive output if the last classified press must survive a power cycle. Output Q1 or Q2 can be made retentive independently in their block properties under Retentivity.

Back to blog