Count pulses over a fixed one second gate and the count you copy out is the frequency in hertz. Scale it with the sensor's formula, compare it against an operator-adjustable trip point, then reset the counter for the next gate. The worked example checks the trip resolution for a 1 to 125 Hz pulse signal before any ladder is written.
Count pulses for a fixed interval and the interval does the measuring. With a one second gate, the number you copy out of the counter is the frequency in hertz, with no conversion step. From there the job is arithmetic and comparison: scale the hertz value with the sensor's formula, compare it with the trip setpoint, drive the outputs, and reset the counter so the next gate starts clean. This article walks through that sequence on a high-speed counter input, with a wind lockout as the worked case: a pulse-output anemometer, a 55 mph trip point, and two relays that disconnect the machine from its drive and set the brake. The arithmetic that decides the gate length is worked out in full, so you can check the trip resolution before writing a single rung.
Why the ordinary input loses pulses at 125 Hz
At the top of the range the sensor pulses too fast for the program scan. A 125 Hz square wave completes a cycle every 8 ms (1000 ms / 125), high for 4 ms and low for 4 ms. A filtered digital input whose filter time sits near 4 ms or above never lets the line change state. Even with the filter out of the way, the program reads the input once per scan: at a 10 ms scan time, pulses arriving 8 ms apart slip whole pulses between two reads, and the count comes back low.
The high-speed counter hardware counts edges on its own, between scans, up to the maximum input frequency its manual lists. For a 1 to 125 Hz signal the answer is yes, use it: the bottom of the range would survive a plain filtered input, the top will not, and one counter mode covers the whole range with margin at both ends.
What you need
- A PLC with a high-speed counter input, and the PLC manual that lists the input's rated voltage and the counter's maximum input frequency.
- The sensor's calibration sheet, with the formula that turns hertz into the unit you act on.
- A repeating timer in the PLC to define the measurement gate.
- A working register for the copied count, kept separate from the counter's own value.
- An operator panel or another way to adjust the trip setpoint.
- Shielded cable for the sensor run, landed the way the manual shows.
Wire the input and prove it counts
- Wire the sensor output to the terminal the counter documentation designates for high-speed counting, and match the sensor's signal level, 24 V DC in this case, to the input's rated voltage.
- Set the counter mode in the PLC configuration: count up, one count per rising edge. The documentation names the terminal that mode counts, so confirm that terminal before trusting the lights on the module.
- Prove the count before building anything else. Put the counter value on a monitor screen, spin the sensor by hand, and watch the count climb, then stop and hold. A pulsing status light on an input is evidence of signal, not proof that the counting mode is accumulating it; only the counter value tells you the mode is on the right terminal.
Set up the gate, the copy, and the reset
- Add a self-resetting timer that finishes once every 1 second and starts again. That timer is the gate.
- On the timer's done pulse, run two instructions in this order: copy the counter value into the working register, then reset the counter with its documented reset instruction. Copy first, reset second. The documented reset defines the boundary between gates; a plain write of zero does not.
- Compute frequency from the copied value: hertz equals count divided by gate seconds. With a 1 second gate the count is the hertz, so the copied register feeds the scaling rung directly. Hertz and pulses per second are the same measure here; PLC pulse counter frequency, hertz to pulses per second explained works through the conversion in more depth.
- Keep every later step on the copied register. The counter keeps counting the next gate while the ladder works on the copy, which is what stops gates from overlapping. The copy-before-reset discipline matters for any counter you recycle; saving the previous count before a PLC counter reset covers the traps.
Worked example: a 1 to 125 Hz anemometer and a 55 mph trip
The case: a pulse-output anemometer on a small windmill feeds the counter input, and the machine must lock out above 55 mph.
Inputs:
- Pulse signal: 1 to 125 Hz, 24 V square wave, from the sensor's specification.
- Gate: 1 second, from the timer set up above.
- Calibration: wind speed in mph = (1.711 x Hz) + 0.78, from the sensor's calibration sheet.
- Trip: above 55 mph, adjustable at the panel; the comparison is strictly greater than.
The rule in words: with a 1 second gate the copied count is the frequency in hertz, so solve the calibration for the frequency that matches 55 mph and compare the count against it.
The arithmetic:
- Trip frequency: (55 - 0.78) / 1.711 = 54.22 / 1.711 = 31.69 Hz, so a count of 32 is the first that trips.
- Count 31 reads (1.711 x 31) + 0.78 = 53.82 mph. Count 32 reads (1.711 x 32) + 0.78 = 55.53 mph. Each whole count moves the reading 1.711 mph.
- Full scale, 125 Hz, reads (1.711 x 125) + 0.78 = 214.66 mph, which is why the display scale matters before anyone trusts the number.
Result: the lockout executes on the first count above 31.69, which is 32, so the trip lands at 55.53 mph, 0.53 mph above the mark, and any wind change is seen within 1 second.
Decision: half a mph of trip error and up to 1 second of detection delay are acceptable for a mechanical windmill brake, so keep the 1 second gate. If the trip must land within about 0.2 mph of the setpoint, gate for 4 seconds: the step becomes 1.711 / 4 = 0.43 mph per count, the trip count is 127, which is 127 / 4 = 31.75 Hz and (1.711 x 31.75) + 0.78 = 55.10 mph, and the cost is up to 4 seconds of detection delay. The counter's documented rate-measurement mode is the third path; the gate interval is entered in the counter's configuration and the hardware reports frequency without the copy-and-reset rungs.
Recommendation: start with the 1 second gate. It makes the copied count the frequency in hertz with no division and reacts within 1 second, and a windmill brake tolerates the trip step this gate produces. Re-run the two counts around your own trip point before writing the comparison. Move to a 4 second gate, or to the counter's documented rate-measurement mode, only when the trip has to land within about 0.2 mph and the longer detection delay is acceptable.
Scale the value and the setpoint the same way
The calibration produces fractional mph, so pick one integer scale and apply it to both sides of the comparison. In tenths of a mph, count 32 becomes 555 and the setpoint becomes 550, and the trip test is a plain integer compare. Comparing a scaled value against an unscaled panel entry moves the trip by the whole scale factor, so prove the pair the first time you run. Give the panel entry low and high limits so a mistyped value cannot park the trip at 5 or 500 mph; validating high and low HMI setpoints before they reach the PLC covers that check. Configure the panel to show one decimal and the unit, so the crew reads 55.5 mph and not a bare register value.
Drive the two outputs from one comparison
One comparison bit drives both outputs. Above the setpoint, open the relay feeding the drive and close the brake relay. At or below the setpoint, close the drive relay and open the brake relay. Equality belongs to the run side because the trip is strictly greater than. Drive both coils from the one comparison result every scan, never from two separate rungs, so a half-tripped state cannot appear.
Before the panel's setpoint is allowed to move real outputs, prove the write path with the load disconnected: change the setpoint at the panel, watch the PLC register follow, and watch both outputs change state while the drive cannot be energized. Testing the operator panel's writes before they reach motion is the standing procedure.
How to check it worked
- Steady wind, two gates in a row: the copied counts should agree within a count or two. Counts that wander point to wiring, a marginal signal level, or a reset at the wrong moment in the sequence.
- Reference check: count pulses by hand over 10 seconds with a stopwatch, divide by 10, and compare that hertz figure with the copied count.
- Trip check with the load still disconnected: lower the panel setpoint below the current reading and watch both relays change, then raise it and watch them return.
- Scale check: the panel display and the PLC's computed value agree through the tenths digit.
- Reset check: after each timer done pulse the counter restarts from near zero, and the copied value holds until the next boundary.
Show the speed where the rest of the floor can see it
The trip panel answers the operator at the machine. If the rest of the floor needs the number, a separate shop-floor screen can carry the same computed value; how to display a PLC counter value where operators can see it covers the register and display side. A screen mounted away from the cabinet can take its low-voltage power from a rail-mount supply, and we list a 24 V DC DIN-rail supply for exactly that kind of feed.
Questions
Does a one second gate work at the bottom of the range?
Weakly. At 1 Hz the gate catches a single pulse, so on the example sensor the reading steps from 2.49 mph at one count to 4.20 mph at two counts. If the decision matters at low speed, lengthen the gate below a speed threshold, or switch to period measurement: time one pulse and compute frequency as 1 divided by the period in seconds.
Can the counter overflow between gates?
Check the largest count one gate can hold against the register range. The example tops out at 125 pulses per gate, far below the 32,767 a 16-bit register carries, so nothing overflows. A faster source, an encoder producing 20,000 counts per second for instance, still fits a single one second gate but leaves little margin, so read the counter manual's behavior at its maximum count before trusting the copy.
How do I read rpm instead of hertz?
Multiply the hertz value by 60 and divide by the pulses the sensor emits per revolution. A wheel sensor emitting 12 pulses per revolution that counts 125 in the one second gate spins at 60 x 125 / 12 = 625 rpm. The gate, copy, reset and comparison sequence is unchanged; only the scaling step differs.
Planning information, not legal or engineering advice. Rules differ by place: check codes and permits with your local authority and your licensed trades.