LOGO! Engine Direction Detection with Non-Overlapping Pulse Inputs
Detecting the rotation direction of a shaft from two 90°-shifted sensors on a Siemens LOGO! 24CE (or any LOGO! 8 / LOGO! 8.FS4 variant) is a recurring field problem. This technical reference covers the physical sensor geometry, the LOGO! fast-input hardware limits, the cycle-time pitfalls of program-based evaluation, and three robust implementation strategies — edge-latch RS, time-delta discrimination, and the built-in up/down high-speed counter — with complete FBD examples, parameter tables, and a commissioning checklist.
1. Problem Definition
Two inductive proximity switches (or Hall-effect sensors) are mounted 90° apart on a rotating shaft. Each sensor produces a short pulse once per revolution. The relationship between the two pulse streams encodes the rotation direction:
- Clockwise (CW): Sensor A on input I5 produces its rising edge before sensor B on input I6.
- Counter-clockwise (CCW): Sensor B on input I6 produces its rising edge before sensor A on input I5.
The required Boolean output is a single bit:
| Engine Direction | Leading Edge | Output Q1 |
|---|---|---|
| Clockwise (CW) | I5 fires first | 0 |
| Counter-clockwise (CCW) | I6 fires first | 1 |
The engine speed range is 1 Hz to 40 Hz. At 40 Hz, the time between two consecutive edges of the same sensor is 25 ms. With a 90° mechanical offset, consecutive edges from different sensors are 6.25 ms apart at top speed and 250 ms apart at minimum speed.
2. Sensor Geometry and Signal Waveforms
The two sensors are physically offset by 90° (one quarter of a revolution). Because inductive proximity switches produce a short pulse only when a target passes the active face, the resulting waveforms are non-overlapping: sensor A is OFF long before sensor B fires, and vice versa. The signal diagram for a 4-pulse sequence during clockwise rotation is:
Fig. 1 — Non-overlapping quadrature-style pulse trains for CW rotation. I5 always leads I6 by T/4.
For CCW rotation, the two trains swap roles: I6 always leads I5. The information needed to determine direction is therefore the identity of the sensor that produced the most recent rising edge.
3. Siemens LOGO! Fast-Input Hardware Specifications
The LOGO! 24CE (LOGO! 8 / 8.FS4 base module, 24 V DC powered, 8 digital inputs) dedicates inputs I3, I4, I5, I6 to high-speed functions. The remaining inputs (I1, I2, I7, I8) are general-purpose 24 V DC inputs limited to the standard debounce filter.
| Parameter | I1, I2, I7, I8 | I3, I4, I5, I6 (fast) |
|---|---|---|
| Max count frequency | — (not supported) | 5 kHz |
| Min pulse width | typ. 1.5 ms | 100 µs |
| Program-side evaluation | Cycle-dependent | Direct on FB input: cycle-independent |
| Recommended function blocks | Digital logic, timers | Up/Down Counter, Threshold Trigger – Frequency, High-Speed Counter |
| Edge detection in program | Possible but jittery > 50 Hz | Reliable up to 5 kHz on the FB input |
Source: LOGO! 8 System Manual (109751401), Chapter 4.2 "Digital inputs" and Appendix A "LOGO! 8 24CE technical data." The same limits apply to the LOGO! 8.FS4 (6ED1052-xxx08-0BA1) hardware revision.
4. The Cycle-Dependent Evaluation Problem
Standard FBD logic is evaluated once per LOGO! scan cycle. A typical cycle time for a small LOGO! 8 program is 0.6 – 8 ms, depending on block count, display update activity, and any open Ethernet/Modbus connections. The relevant cycle time is the worst-case, not the average.
If two non-overlapping sensor pulses arrive within the same scan window, the program only sees the post-cycle state and cannot tell which edge occurred first. The 5 kHz fast-input limit is therefore only valid when the signal is wired directly to the count input of an up/down counter or a frequency threshold trigger — not to a generic AND/OR tree that the scheduler evaluates each cycle.
For the 1 – 40 Hz engine, the worst-case inter-edge time is 6.25 ms (at 40 Hz, between the leading edge of one sensor and the leading edge of the other 90° later). A LOGO! cycle of 0.6 – 2 ms will catch a single edge per cycle with margin, so direct program logic is feasible. For anything above ~80 Hz, a hardware-latch or counter-based method is mandatory.
5. Solution 1 — Edge-Latch with Set/Reset Coils (Cycle-Based, 1–80 Hz)
The simplest reliable method is a software RS flip-flop. One sensor's rising edge sets the direction bit; the other sensor's rising edge resets it. Because the flip-flop holds the value between edges, the output is stable and can be read by the rest of the program at any scan.
FBD structure (LOGO! Soft Comfort 8.x):
Block B01 — Positive edge of I5 → Set coil M1
Block B02 — Positive edge of I6 → Reset coil M1
Block B03 — M1 (N.C.) → Q1 (direction = 0 means CW)
Truth table (steady-state rotation):
I5 fires first → M1=1 → Q1=0 (CW)
I6 fires first → M1=0 → Q1=1 (CCW)
Program parameters in LOGO! Soft Comfort:
| Block | Function | Input | Output / Parameter | Notes |
|---|---|---|---|---|
| B01 | Edge-triggered relay (positive) | I5 | Set on M1 | Detects rising edge of I5 |
| B02 | Edge-triggered relay (positive) | I6 | Reset on M1 | Detects rising edge of I6 |
| B03 | NOT (NC contact) | M1 | Q1 | Q1 = 0 when I5 fired last (CW) |
This solution fails in three cases:
- Both edges occur within one scan cycle (only relevant above ~80 Hz for LOGO! 8).
- Power-up before the first edge: M1 powers up at 0 (CW assumed). Add a "direction unknown" flag if the application cannot tolerate this.
- Reversal mid-rotation: if the engine stops, the second edge "resets" the latch even though the engine is no longer rotating. The output then reflects the direction of the last rotation, not the current state.
6. Solution 2 — Time-Delta Discrimination (Most Robust at Low Speed)
For the 1 – 40 Hz engine, a time window approach is the most reliable against scan jitter. After the first sensor fires, start a timer; if the second sensor fires within a window shorter than the expected half-period, the leading sensor identifies the direction.
FBD structure:
B01 — I5 → [Positive edge] → Start timer T1 (on-delay, Ta = 100 ms), Set M1 = "I5 candidate"
B02 — I6 → [Positive edge] → Reset timer T1
B03 — T1 Q output (timed out) → Reset M1 (no I6 within window → no direction known)
B04 — I6 → [Positive edge] → If M1 = 1, latch Q1 = 0 (CW confirmed); M1 = 0
B05 — I6 → [Positive edge] → Reset M1
B06 — I6 → [Positive edge] → Start timer T2, Set M2 = "I6 candidate"
B07 — I5 → [Positive edge] → Reset timer T2
B08 — I5 → [Positive edge] → If M2 = 1, latch Q1 = 1 (CCW confirmed); M2 = 0
Timer Ta must be < T/2 at top speed. At 40 Hz, T/2 = 12.5 ms; pick Ta = 8 – 10 ms.
For variable-speed operation, derive Ta from a frequency measurement (B09 below).
B09 — I5 → Frequency threshold trigger (T_f) → output "HighSpeed" disables Ta < 8 ms
B10 — I5 → Frequency threshold trigger (T_f2) → output "LowSpeed" extends Ta to 100 ms
The advantage of this method is that it survives a missed edge (e.g. due to contact bounce on the proximity switch) — if the second sensor fails to fire within the window, the candidate is dropped and the output is not falsely latched. The disadvantage is the timer tuning per speed band.
7. Solution 3 — Up/Down High-Speed Counter (Hardware-Cycle-Independent)
The cleanest, most cycle-independent solution is to use the LOGO! built-in High-Speed Counter function block configured for up/down counting. The hardware captures the count and direction on each input edge, so the program only reads a settled CV (current value) once per cycle.
Function block configuration (LOGO! Soft Comfort > Special Functions > Counter > Up/Down Counter):
| FB Parameter | Value | Description |
|---|---|---|
| Function block type | Up/Down Counter | Counts up on Cnt, direction on Dir |
| Cnt input | I3 | Hardwired to fast input; up to 5 kHz |
| Dir input | I4 | 0 = up = CW, 1 = down = CCW |
| Rst input | I1 (or unused) | Optional reset |
| On threshold | 0 | Lower bound, inclusive |
| Off threshold | 0 | Same as On if you only want the direction bit |
| Start value | 0 | CV powers up at 0 |
| Output (high active) | Q2 = (CV > 0) | Indicates non-zero count (optional indicator) |
Wiring to the sensors:
Sensor A (I5) ──> I3 (Cnt, the count input)
Sensor B (I6) ──> I4 (Dir, the direction input)
The hardware samples the state of I4 at the instant of an I3 edge.
If I4 = 0 at the I3 rising edge, the counter increments (CW).
If I4 = 1 at the I3 rising edge, the counter decrements (CCW).
Read CV each scan; the sign of CV is the net direction. The instantaneous
direction bit is the current state of I4 sampled at the last I3 edge.
How this matches the user's rule ("I5 before I6 = CW, I6 before I5 = CCW"):
- CW rotation: I5 fires first → I3 edge happens while I4 (=I6) is still 0 → counter goes up.
- CCW rotation: I6 fires first → I4 = 1 before I3 fires → counter goes down.
This is the recommended approach for production installations because it is immune to LOGO! scan-time jitter and provides a free running count that can be tied to threshold triggers (e.g. "stop motor at CV = 0," or "warn at CV > 9999").
Documentation: LOGO! 8 System Manual §4.5.3 "Up/Down Counter," and the LOGO! 8 Function Blocks reference (109766930).
8. Complete FBD Program (LOGO! Soft Comfort 8.x, 8.FS4 compatible)
The following program combines the up/down counter (Solution 3) with a separate direction-bit RS flip-flop (Solution 1) for backward compatibility with installations where the operator panel must read the direction without computing the sign of CV.
// ─── Inputs ─────────────────────────────────────────
I1 = Manual reset pushbutton (N.O., momentary)
I2 = Engine running contactor aux (optional interlock)
I3 = Sensor A pulse (fast input, 5 kHz capable)
I4 = Sensor B pulse / direction (fast input, 5 kHz capable)
I5 = (spare) — alt wiring of A on fast input
I6 = (spare) — alt wiring of B on fast input
// ─── Function blocks ─────────────────────────────────
B01 Up/Down Counter Cnt=I3, Dir=I4, Rst=I1
Start = 0, On = 0, Off = 0
→ Qa = (CV > 0) // "engine ran net CW" indicator
→ CV → analog-out chain (optional display)
B02 Positive-edge trigger In=I3 → sets M1 (latch: I3 was last edge)
B03 Positive-edge trigger In=I4 → resets M1
B04 NC contact M1 → Q1 // Q1 = 0 means I3 was last = CW
B05 RS flip-flop S=(I3 rising) R=(I4 rising) → M2
B06 NOT M2 → Q1 // Inverted output: 0 = CW, 1 = CCW
B07 Threshold trigger (frequency) In=I3, Threshold_On=2 Hz, Threshold_Off=1 Hz
→ output "EngineRunning" used as interlock for counter reset
B08 AND (EngineRunning, NOT I1) → Reset input to B01 // auto-clear when stopped
// ─── Outputs ───────────────────────────────────────
Q1 = Direction bit (0 = CW, 1 = CCW)
Q2 = "Engine running" lamp (from B07)
Q3 = (optional) Up-count display driver
Q4 = (optional) Down-count display driver
The dual-path (B02-B04 vs B05-B06) is intentional: B05-B06 holds the direction bit with sub-cycle resolution because the RS flip-flop executes on every edge at the FB input, not once per program cycle. B02-B04 provides a slower, scan-synchronous mirror for the HMI.
9. Wiring Diagram (Inline SVG)
Fig. 2 — Wiring of two 3-wire PNP proximity sensors to LOGO! 24CE fast inputs. Brown = +24 V, Blue = 0 V, Black = signal.
10. Parameter Summary
| Item | Value | Source / Reason |
|---|---|---|
| Sensors | 2× PNP NO, 10–30 V DC, > 5 kHz switching | Match LOGO! fast-input range |
| Sensor spacing | 90° mechanical on the shaft | Quadrature-style offset |
| Pulse rate (worst case) | 40 Hz on each sensor | Given by application |
| Inter-pulse time (worst case) | 6.25 ms at 40 Hz | T/4 = 25 ms / 4 |
| LOGO! cycle time (typical) | 0.6 – 8 ms | Program-size dependent |
| Cycle margin (worst case) | 6.25 ms / 8 ms ≈ 0.78 | Cycle-based logic may fail — use counter method |
| Fast-input limit | 5 kHz | LOGO! 8 datasheet |
| Min pulse width | 100 µs | LOGO! 8 datasheet |
| Counter method direction input | I4 (Dir) | Direct on FB, cycle-independent |
| Direction output convention | Q1 = 0 = CW; Q1 = 1 = CCW | Application requirement |
11. Verification and Commissioning Procedure
- Power the LOGO! base module and connect the LOGO! Soft Comfort programming cable (Ethernet on 8.FS4, USB cable 6ED1057-XXX00-0BA0 on older 8.0/8.1).
- Download the program and switch the LOGO! to RUN. Confirm the I3, I4 LED indicators toggle as the shaft is turned by hand.
- Open LOGO! Soft Comfort in online mode and watch the B01 counter CV. Manually rotate the shaft clockwise — CV should increase. Reverse — CV should decrease.
- Verify the Q1 direction bit with a multimeter or by writing it to the LOGO! display via the message-text function block.
- Spin the engine (or motor) to 40 Hz and verify Q1 is stable (no flicker). Flicker at top speed indicates a missed-edge condition; re-tune the counter FB or check sensor alignment.
- Power-cycle the LOGO! to confirm the retained state of M1 / M2 (retentive on-delay or retentive RS flip-flop if the application requires direction memory across power loss).
- Run for 30 minutes at the rated speed and log the counter value to a CSV via LOGO! Soft Comfort > Tools > Data Log (LOGO! 8.FS4 only).
12. Common Pitfalls and Field Notes
| Symptom | Root Cause | Fix |
|---|---|---|
| Q1 flickers at 30 – 40 Hz | Cycle-based RS flip-flop, scan time > 3 × inter-pulse | Switch to up/down counter (Solution 3) |
| Q1 always reads 0 | Sensor B (I6/I4) is wired NPN, not pulled high | Use PNP sensor or add pull-up resistor (1 kΩ to +24 V) |
| Q1 does not change on direction reversal | Both edges land in the same scan | Move sensor wiring to I3/I4 fast inputs and use counter FB |
| Direction is "unknown" for the first 25 ms | No edge has occurred yet | Acceptable; or add a default direction in a startup FB |
| Counter overflow / underflow | CV reaches ±2,147,483,647 | Add an external counter modulo FB or use the on/off threshold to wrap |
| Missed pulses due to vibration | Sensor target is loose on the shaft | Replace the target; verify with oscilloscope on I3, I4 |
| LOGO! web server slows scan time | Ethernet activity on 8.FS4 base module | Disable web server in the project settings if not needed |
| Scan time displayed in LOGO! menu > 8 ms | Program too large, or display update is active | Reduce FB count; switch direction logic to the counter method |
| Q1 toggles on every power-up | No retentive flag | Use a retentive RS flip-flop (Rem = on) and initialize in startup FB |
13. When NOT to Use LOGO!
For any of the following, consider an S7-1200 with a high-speed counter (HSC) submodule, or a SIMATIC ET 200SP counting module:
- Pulse rate > 5 kHz on either sensor.
- Engine reverses in < 1 ms (the LOGO! counter FB cannot catch a direction change faster than the resolution of its internal edge detector).
- Functional safety requirement (LOGO! does not have SIL-rated high-speed inputs; use a F-CPU).
- Distributed I/O over PROFINET with cycle-synchronous counting (use SIMATIC drive-based or ET 200SP TM Count).
Reference for migration: LOGO! 8 System Manual (109751401) §1.3 "Notes on the manual," and the S7-1200 system manual at S7-1200 Programmable Controller (109751706).
14. Frequently Asked Questions
Can the LOGO! 24CE measure 40 Hz engine pulses reliably with plain FBD logic?
Yes, provided the LOGO! cycle time is below ~2 ms. The fast-input limit of 5 kHz applies only when the signal is wired directly to the count input of an up/down counter or a frequency threshold trigger FB. For scan-synchronous logic, keep the inter-pulse time at least 5× the measured cycle time (LOGO! menu → Diagnostics → Cycle time).
My two sensors never overlap. Do I still need a quadrature counter?
No. With non-overlapping signals the direction is determined by "which sensor fired first," not by the state of the other sensor at the transition. An RS flip-flop or an up/down counter with a single direction input (Solution 3) is sufficient. A true quadrature (×4) decoder is only needed when you also want 4× angular resolution.
Why does the LOGO! 24CE documentation say 5 kHz but my program misses pulses at 200 Hz?
Because 5 kHz is the hardware limit of the input pin, not a guarantee of program-side recognition. The input circuit can capture a 100 µs pulse, but the FBD scheduler only looks at the input state once per scan. If your cycle is 6 ms, the scheduler reads the input 166 times per second and will miss anything that does not coincide with a read. Always use the counter FB for high-speed work.
Can I use I5 and I6 instead of I3 and I4 for the up/down counter?
On LOGO! 8 base modules, the up/down counter FB accepts any of the four fast inputs (I3 – I6) as the Cnt pin. The Dir pin is assigned to a different fast input by the FB. Wiring both sensors to I5/I6 works, but the convention in Siemens documentation is I3 = Cnt, I4 = Dir; keep the convention unless you have a conflict with another fast function.
What happens at power-up before the first pulse?
Both M1 and M2 are 0, so the direction bit reads "CW" by default. The up/down counter FB powers up at its Start value (typically 0). If the application must distinguish "stopped" from "running clockwise," add a frequency threshold trigger (e.g. threshold 2 Hz) on I3 and gate the Q1 output with the "engine running" flag.
Is there a way to get the direction as an analog signal for an indicator lamp?
Yes. Add the LOGO! "Analog output" FB to your project and route the up/down counter CV to a 0 – 10 V analog output (LOGO! 8 AM2 AQ module). Positive CV drives the voltage above 5 V (CW), negative drives it below 5 V (CCW). This lets you feed an analog indicator or a remote VFD display.
Does the LOGO! 24CEo (transistor output) version change the wiring?
No, the input circuit is identical. The 24CEo (6ED1052-1MD08-0BA1) replaces the relay outputs with 24 V DC / 0.3 A transistor outputs. Use 24CEo only if the load requires high cycle counts or if the direction output must switch faster than the 10 Hz mechanical limit of the 24CE relay contacts.