Siemens LOGO! Rate Indicator: Pulse-to-Units/min Algorithm

David Krause17 min read
HMI ProgrammingSiemensTechnical Reference
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

Problem Definition: PLC-Based Rate Indicator

A rate indicator continuously converts a pulse train from a discrete sensor (photoeye, proximity switch, magnetic pickup, encoder) into a process rate expressed in engineering units per unit time — typically units/min, bottles/min, or m/min. The display update interval, statistical smoothing, alarm comparison, and downstream control paths together determine the algorithm architecture.

The application target uses a single PNP photoeye producing one pulse per unit passing the inspection point. The nominal process rate is 60 units/min, the operator panel must refresh at least every 5 seconds, and a digital comparator must enable a VFD-driven downstream conveyor when the measured rate exceeds 30 units/min. The system must boot to a useful value quickly (no one-minute startup blank) and must decay to zero on process stop within an operator-acceptable time.

Design tension: A short measurement window gives fast response but coarse resolution. A long window gives fine resolution but slow response and slow decay on input loss. The algorithm must match the process dynamics. A 5-second window on a 60 units/min line yields a worst-case display granularity of 12 units/min per pulse, which is acceptable for an above/below-30 comparison but inadequate for tight closed-loop speed control.

Documented specifications before implementation:

  • Pulse source: PNP photoeye, 24 VDC, 1 pulse per unit
  • Count rate: 0–120 pulses/min (100% margin above the 60 units/min nominal rate)
  • Display resolution: ≥ 1 unit/min
  • Display refresh interval: ≤ 5 seconds
  • Control output: Q1 digital for VFD enable; optional AQ1 analog for VFD speed reference
  • Operator interface: integrated LOGO! BM display, LOGO! TDE, or web server
  • Power: 24 VDC, isolated I/O where the photoeye and LOGO! share supplies

Hardware vs. Software Rate Indicator Trade-offs

A dedicated rate indicator such as the Red Lion CUB5 is purpose-built for frequency-to-engineering-units conversion. It implements a fixed windowed algorithm internally with hardware counter resolution up to 30 kHz and a 5-digit LED display. Choosing between a CUB5-class device and a PLC-implemented rate indicator depends on panel space, I/O count, communication requirements, and existing controller architecture.

Parameter Red Lion CUB5 (panel meter) PLC-implemented (Siemens LOGO!)
Display 5-digit red LED, 13 mm digit height LOGO! BM 6-line LCD or LOGO! TDE
Max count frequency 30 kHz (model dependent) 5 kHz on high-speed inputs (I3–I6 on LOGO! 8)
Min measurement window 10 ms typical (model dependent) Limited by PLC cycle time (~10 ms)
Output options Relay, NPN/PNP, analog 4–20 mA, RS-485 Digital Q, analog AQ, network tags
Communication Optional RS-485 Modbus RTU Built-in Ethernet (LOGO! 8), Modbus TCP, S7 communication
Power supply 9–30 VDC or 85–250 VAC versions 24 VDC or 100–240 VAC versions
Configuration Front-panel keys or Crimson software LOGO! Soft Comfort FBD/LAD
Integration with control Standalone; outputs are hard-wired Native: rate tag directly available to PID, timers, HMI

When the rate value must drive additional logic (PID control, batch totals, recipe scaling, alarm chains, networking, HMI trending), a PLC implementation removes the boundary between indication and control. When the rate is purely an operator readout and the panel has spare space, a CUB5-class device is faster to deploy and easier to replace.

Rate Calculation Mathematics

The fundamental relationship between pulse count, measurement window duration, and displayed rate is:

Equation 1 — Instantaneous rate from a counting window:

R_displayed = N_window × (T_reference / T_window)

Where:

  • N_window = number of pulses accumulated during the window
  • T_window = actual window duration (seconds)
  • T_reference = 60 seconds (for units/min) or 3600 seconds (for units/hour)
  • R_displayed = displayed rate (units per reference time)

For a 5-second window and a 60 units/min process: R_displayed = N × (60/5) = N × 12. The minimum non-zero display is 12 units/min (one pulse in 5 seconds). This is acceptable when the decision threshold is well above the LSB, but unacceptable if the setpoint is 25 units/min — the operator would see 0 or 36 with nothing in between.

Equation 2 — Resolution-limited minimum window time:

T_window_min = T_reference / R_required_resolution

For 1 unit/min resolution at the units/minute reference: T_window_min = 60 / 1 = 60 seconds. This is the inherent conflict between update speed and resolution on a low-frequency process.

Equation 3 — Exponential smoothing of the displayed value:

S[t] = α × R[t] + (1 − α) × S[t−1]

Where α is the smoothing factor (0–1, dimensionless) and S[t] is the smoothed value at update step t. With α = 0.3, the displayed value reaches 95% of a step change in approximately ln(0.05)/ln(0.7) ≈ 9 update cycles (45 seconds at 5-second updates). Use the moving average form instead when startup time matters.

Equation 4 — Simple moving average (M samples):

SMA[t] = (1/M) × Σ R[t−i] for i = 0 to M−1

The SMA reaches a non-zero value as soon as one non-zero sample enters the window, and reaches zero as soon as all M samples are zero. M = 8 with a 5-second window provides a 40-second averaging horizon with full response to a sustained process change.

Windowed Measurement Algorithm

A windowed counter resets the pulse accumulator at fixed intervals and reads the count as the basis for the rate calculation. There are three windowing strategies:

Strategy Update mechanism Response to input loss Response to startup Best use
Reset window (rolling) Counter zeroed each window Decays in one window Reads zero until first window completes High-frequency signals
Moving window (circular) Oldest sample removed, newest added Decays in M windows Reads partial value as samples fill Low-frequency signals (this application)
Continuous accumulator with decay Subtract fraction each cycle Asymptotic decay, controlled by α Asymptotic rise, controlled by α Smoothed display, noisy inputs

For the 60 units/min application with a 5-second update requirement, the moving-window algorithm eliminates both the 60-second startup blank and the slow decay on process stop that a fixed-window algorithm exhibits.

Windowed counter state machine

The windowed counter can be represented as a discrete state machine:

[IDLE] -- pulse on I1 --> [COUNT_WINDOW_ACTIVE]
[COUNT_WINDOW_ACTIVE] -- timer expires (5s) --> [LATCH_AND_RESET]
[LATCH_AND_RESET] -- latch count to R --> [COUNT_WINDOW_ACTIVE]
[LATCH_AND_RESET] -- process stop flag --> [IDLE]

The latch step is critical: it captures the count for the calculation before the counter resets, preventing display flicker caused by an out-of-order read.

Moving Average Filter Design

The moving-average filter smooths the stepped output of the windowed counter and is what the operator actually sees on the panel. Selection of M depends on the trade-off between display smoothness and step response:

M (samples) Window time (s) Display step (units/min) Step response time (s) Use case
1 5 12 5 No filtering, fast response
2 10 6 10 Display only, simple process
4 20 3 20 Operator trend, comfortable readout
8 40 1.5 40 Tight setpoint, slow process
12 60 1 60 High resolution, slow response

The 1-sample step is calculated as 60 / (M × 5) in units/min per increment. For a 30 units/min decision threshold, M = 2 yields 6 units/min per step, which is comfortably above the threshold granularity.

Anti-aliasing for short windows: When M < 4, each individual sample is visible to the operator and the display "ticks" between whole increments. M = 4 with 5-second updates produces a comfortable 20-second averaging window with 3 units/min LSB.

LOGO! Block Architecture

The complete rate indicator implementation in Siemens LOGO! uses the following FBD blocks. The reference platform is the LOGO! 8.3 (6ED1052-1x08-0BA0 series) programmed in LOGO! Soft Comfort V8.x.

Block Type Function
B001 Up/Down Counter Counts I1 pulses within current window
B002 Pulse Generator (asynchronous) Generates 1-second master clock
B003 Pulse Generator (asymmetric) Derives 5-second window trigger
B004 Shift Register (8 stages) Circular buffer of last 8 window samples
B005–B007 Math Instruction Sum of buffer, divide by M, multiply by 12
B008 Analog Threshold Trigger Q1 = 1 when rate > 30 units/min
B009 Message Text Display rate on LOGO! BM or TDE
B010 Math Instruction Scaling for AQ1 (0–10 V analog out)
B011 On-Delay Timer (watchdog) Resets buffer on loss-of-signal

Pulse counting and window timing

I1 [Photoeye] --> B001 (Up/Down Counter)
                   Cnt:    I1 rising edge
                   Dir:    +1 (constant)
                   Rst:    M1 (window reset pulse)
                   CV:     pulse count in current window

B002 (Pulse Generator, 1 Hz) --> B003 (Pulse Generator, Th=5s / Tl=very long)
                                  Out: M1 (latch + reset trigger)

Each rising edge of M1 latches the counter value into the shift register (B004) and resets B001, marking the start of the next 5-second window. The asymmetric pulse generator prevents multiple latch events within a single window.

Moving-average buffer and calculation

M1 --> B004 (Shift Register, 8 stages)
        Trigger: M1
        Input:  B001.CV
        Output: S1..S8 (8 most recent sample values)

S1..S8 --> B005 (Math Sum) --> B006 (Math /8) --> B007 (Math ×12)
                                                              |
                                                              +--> B008 (Threshold >30) --> Q1
                                                              +--> B009 (Message Text)
                                                              +--> B010 (Scale ×100/120) --> AQ1

The shift register forms a circular buffer of the last 8 sample values. Each sample is the pulse count captured in the prior 5-second window. The sum divided by 8 is the average sample count over the last 40 seconds; multiplied by 12 converts units/second × 60 to units/min.

Watchdog for loss-of-signal

I1 (rising edge) --> B011 (On-Delay, reset on I1 rising edge, Th=10s)
                    Out: NOT --> B004 Reset

If no pulse arrives for 10 seconds (twice the maximum inter-pulse interval at the 60 units/min nominal rate), the buffer is forced to zero. This prevents the display from holding a stale value when the process genuinely stops or the photoeye is blocked.

Cycle time: The full FBD shown runs in 6–12 ms typical on a LOGO! 8.3 BM, well below the 100 ms cycle budget of most low-speed process lines. If the program includes additional high-speed blocks (PID, math instructions with multiple operands), benchmark the actual cycle time with LOGO! Soft Comfort's online monitor before commissioning.

Threshold Comparison Logic

Direct comparison of the rate value to a constant is implemented with the Analog Threshold Trigger block. The block provides configurable On and Off thresholds for hysteresis:

Parameter Value Effect
On threshold 30 units/min Q1 energizes when smoothed rate rises above 30
Off threshold 28 units/min Q1 de-energizes when smoothed rate falls below 28
Hysteresis band 2 units/min Prevents relay chattering on the boundary
Sensor gain 1.0 Pure scaling (no sensor linearization)
Sensor offset 0 No zero correction

For multiple setpoints (e.g., rate > 30 enables conveyor 1, rate > 50 enables conveyor 2), cascade two threshold blocks with different On/Off values. Both blocks can use the same rate tag as input.

Alternative: digital threshold via math

If the Analog Threshold Trigger block is not available (older LOGO! versions), implement the comparison as a Math instruction followed by a NAND gate:

B007 (Rate × 1) --> B012 (Math: x − 30)
                   Out: signed value (negative = below threshold)
B012 sign bit --> B013 (NOT) --> Q1

This implementation is functionally equivalent but does not support hysteresis without additional logic.

Cycle Time and Memory Constraints

LOGO! 8.3 limits program complexity by total block count, memory footprint, and resulting cycle time. The rate-indicator program as drawn consumes:

Resource Used Available (LOGO! 8.3 BM) Margin
Function blocks 13 400 97% available
Digital I/O used 2 (I1, Q1) 8/8 on BM 6 free
Analog outputs 1 (AQ1) 0 (add AM2 AQ for 2 AQ) Requires expansion
Variable memory (bytes) ~16 850 98% available
Program memory (bytes) ~2,400 8,500 72% available
Typical cycle time 8 ms n/a Comfortable

If the program is embedded in a larger control system with high-speed counting on the same BM (e.g., encoder-based positioning), high-speed inputs may saturate the BM's 5 kHz channel and force distribution of the rate count to a separate BM. Use the LOGO! Soft Comfort online monitor to verify input event capture rate during commissioning.

HMI Display Integration

Three display paths are available on LOGO! 8:

Integrated BM display

The basic module's 6-line LCD supports the Message Text block (B009). Configure the message with embedded parameter text:

B009 (Message Text):
  Line 1: "Rate Indicator"
  Line 2: "Rate: %d units/min"
  Line 3: "VFD: %s"
  Line 4: "Set: 30  Hys: 2"
  Line 5: "Window: 5s  Avg: 8"

Configure the cursor keys for bar graph, setpoint entry, or message scrolling per the LOGO! 8 system manual, section on Message Text configuration.

LOGO! TDE (text display)

The LOGO! TDE (6ED1055-4MH00-0BA0) provides a 6-line backlit display with the same Message Text functionality but allows external mounting up to 2.5 m from the BM. Use the TDE when the BM is in a cabinet and the display must be on the operator door.

Web server (LOGO! 8 only)

LOGO! 8 BM variants with Ethernet (6ED1052-1x08-0BA1) include an integrated web server. The rate tag can be exposed as a process variable for browser-based monitoring on the plant network. From a remote PC, navigate to http://<LOGO_IP> and log in; the rate value appears on the dashboard. No programming is required beyond enabling the web server in the project properties.

SCADA integration via Modbus TCP

For higher-level SCADA, the LOGO! BM acts as a Modbus TCP server. The rate tag is exposed at a holding register address assigned by the project. A CUB5-class rate indicator cannot deliver this integration without an additional gateway.

Edge Cases and Field-Proven Caveats

Slow startup blank

A fixed-window algorithm that resets the counter to zero every 5 seconds will display zero until the first window completes. On a startup where the process has just begun, the operator sees "0 units/min" for up to 5 seconds — acceptable here, but unacceptable for higher-frequency processes. The moving-average algorithm fills the buffer with subsequent samples; the first non-zero display appears within one window after the first pulse arrives.

Slow decay on input loss

If the photoeye is blocked (e.g., by a fallen box, an operator's hand, or a cable draped across the lens), the count goes to zero immediately, but the displayed value persists until the buffer rolls over. With M = 8 and a 5-second window, full decay takes 40 seconds. The operator perceives this as "the line is still running" until the buffer empties.

Two mitigations:

  • Watchdog timer: Reset the buffer if no pulse has been received in 2 × window time. This forces the display to zero promptly when the process is genuinely stopped.
  • Loss-of-signal flag: Use a separate timer that asserts when the inter-pulse interval exceeds a threshold (e.g., 2 seconds at 60 units/min nominal = 1 pulse per second, so 2 seconds of silence is anomalous).

Photoeye wiring and noise

PNP (sourcing) photoeyes must connect to a sourcing input configured in the LOGO! project. Use shielded twisted-pair cable for the photoeye run, ground the shield at the cabinet end only, and route the cable at least 150 mm from VFD power cables to avoid capacitive coupling. On long runs (> 30 m), add a 10 kΩ pull-down resistor at the LOGO! input to prevent floating-input oscillation.

Photoeye dark-on vs light-on

A dark-on photoeye conducts when the beam is broken (most common for counting). Confirm the wiring diagram; a light-on photoeye requires an inversion (NOT gate) before the counter. The Red Lion CUB5 supports both modes; the LOGO! program requires an explicit inverter.

Single-pulse granularity

At 60 units/min, a single pulse arrives every 1 second. The 5-second window catches an average of 5 pulses, so the display steps in 12-unit/min increments. An operator used to analog gauges will see a steppy display. Add a rate-averaging step (M = 8) to smooth the display.

VFD setpoint stability

If Q1 is used as a digital enable for the VFD, the 2-unit/min hysteresis band on the threshold trigger prevents enable/disable chattering at the boundary. If AQ1 is used as an analog speed reference, do not feed the unsmoothed rate directly to AQ1 — apply the moving-average filter first, otherwise the VFD will respond to the 12-unit/min display steps with visible speed variation.

High-cycle-time interaction with high-speed counting

If the LOGO! program also contains a high-speed counter block (e.g., encoder pulse counting for positioning), the BM cycle time can extend into the tens of milliseconds, causing missed pulses on the rate counter at rates above ~100 Hz. Mitigation: separate the rate-counting program from the high-speed program onto different BMs, or use a dedicated CUB5 for the rate channel.

Commissioning and Verification

A commissioning procedure that verifies the implementation before connecting to the production line:

  1. Bench test with signal generator: Drive I1 with a function generator at 1 Hz (60 pulses/min). Confirm the displayed rate stabilizes at 60 ± 1 units/min within 40 seconds. Confirm the rate decays to zero within 10 seconds after the input stops (watchdog action).
  2. Threshold verification: Drive I1 at 0.5 Hz (30 units/min — the threshold boundary). Confirm Q1 is off. Increase to 0.6 Hz (36 units/min). Confirm Q1 turns on within 5 seconds. Reduce to 0.46 Hz (28 units/min — off threshold). Confirm Q1 turns off.
  3. Analog output verification: Connect a multimeter to AQ1. Confirm 0 V at zero rate, 5 V at 60 units/min (50% of 120 units/min range), 10 V at 120 units/min. If the VFD expects 4–20 mA, install a 250 Ω resistor and confirm 4 mA at zero rate.
  4. Cycle time check: In LOGO! Soft Comfort online mode, observe the cycle time. Confirm < 20 ms for the full program.
  5. Display verification: Confirm the BM or TDE displays the rate with one decimal place if required, and that the cursor keys can navigate between messages.
  6. Photoeye field test: Move a single object past the photoeye ten times in 10 seconds and confirm the rate shows 60 units/min (10 objects in 10 seconds = 60/min).
  7. Fault injection: Disconnect the photoeye cable and confirm the display does not freeze at the last value (watchdog timer must trigger and force the display to zero).
  8. VFD integration test: With the VFD in hand-off-auto mode, jog the line manually and confirm the VFD enable (Q1) tracks the threshold correctly. Confirm the analog speed reference (AQ1) follows the rate smoothly without visible stepping.
  9. Network verification: If the BM is networked, read the rate holding register from a Modbus TCP client (e.g., HMI, SCADA) and confirm the value matches the BM display within ± 1 unit/min.

Comparison Summary: LOGO! Implementation vs Dedicated Rate Indicator

Criterion LOGO! implementation Dedicated meter (e.g., CUB5)
Hardware cost Uses existing LOGO! BM; no incremental hardware $200–$500 per meter plus panel cutout
Update interval 5 s (configurable down to ~50 ms with shorter windows) 10 ms typical (configurable)
Display readability BM LCD is small; TDE larger; web interface unlimited Bright 5-digit LED, 13 mm digit height
Logic integration Native: rate tag available to PID, latches, networks Hard-wired outputs only
Network integration Modbus TCP, S7, web server (LOGO! 8) Optional RS-485 Modbus RTU
Spare parts One LOGO! program in cabinet; no spare parts unique Spare meter recommended
Programming skill Required (LOGO! Soft Comfort) Front-panel setup only
Best fit Rate is one of many functions in a larger machine Rate is the sole function; standalone panel

How do I make the rate indicator update within 5 seconds instead of 60 seconds on the LOGO!?

Use a moving-window algorithm (circular buffer of samples) with a 5-second window and 8 samples for averaging. The first non-zero display appears within one window after the first pulse, and full display value is reached within 8 windows (40 seconds). Add a watchdog timer to force the display to zero after 10 seconds of silence so the value does not hold a stale reading.

Can I use the LOGO! built-in display for the rate value?

Yes. Configure a Message Text block with a parameter placeholder (e.g., "Rate: %d units/min") and connect the rate tag. The integrated BM display shows up to 6 lines; the external LOGO! TDE provides the same content with a larger LCD and door-mountable form factor. The web server (LOGO! 8 with Ethernet) exposes the value in a browser without additional programming.

What sensor should I use for 60 units/min counting?

A PNP (sourcing) photoelectric sensor with dark-on logic is the typical choice. At 60 units/min, the pulse rate is 1 Hz, well within the 5 kHz capability of the LOGO! 8 high-speed inputs. For higher rates above 5 kHz, use a CUB5 or a PLC with faster counter inputs. For harsh environments (washdown, dust, vibration), an inductive proximity switch on a metal target is more robust than an optical photoeye.

How do I output the rate as a 4–20 mA analog signal to a VFD?

LOGO! BM provides 0–10 V analog outputs natively. For 4–20 mA, add a LOGO! AM2 AQ expansion module (current output), or install a 250 Ω precision resistor across the AQ1 terminals to convert 0–10 V to 0–20 mA, then offset the scaling in the VFD to interpret 4 mA as zero. Confirm the VFD's analog input type (voltage vs current) and DIP-switch settings before connecting.

Why does my rate value decay slowly when the input stops, and how do I fix it?

The decay is controlled by the moving-average buffer length: 8 samples × 5-second window = 40-second full decay. To force a faster decay, add a watchdog timer that resets the buffer when no pulse has arrived within 2 × window time. Alternatively, switch from a moving average to exponential smoothing with a moderate α (e.g., 0.3), which asymptotically decays in approximately 10 time constants.

Back to blog