How-to
Calculating Roller RPM From Encoder HSC Counts
Short answer
RPM equals 60 times the HSC count difference divided by the product of counts per revolution and the interval in seconds. A 512 P/R encoder counted fourfold gives 2048 counts per revolution, so the formula returns motor speed directly; behind the 1:25 gearbox, divide by 25 for roller RPM and multiply by the roller circumference for surface speed.

On this page
- What formula converts HSC counts into RPM?
- Does 512 P/R mean 512 counts per revolution?
- Which shaft speed does the encoder actually measure?
- How do you configure the HSC and the steps-per-revolution value?
- How long should the sample interval be?
- Do five encoders fit on one CPU at this count rate?
- What roller RPM and surface speed do the numbers give?
- Questions asked
You calculate roller RPM from HSC counts by dividing the count change over a fixed interval by the counts-per-revolution scale: RPM = 60 × count change ÷ (counts per revolution × interval in seconds). An A/B quadrature counter registers four edges per pulse cycle, so the denominator carries the fourfold scale, not the label value printed on the encoder. The 1435 rpm motor behind the 1:25 gearbox turns the 13 cm roller at 57.4 rpm, which is about 23.4 m/min of surface speed. The steps below set up the five HSCs, prove each scale, choose the sample interval and run the arithmetic for every drive.
What formula converts HSC counts into RPM? #
RPM equals 60 times the count difference divided by the counts-per-revolution scale and the sample time in seconds; the difference in counts becomes revolutions through the scale, the multiplication by 60 turns revolutions per second into revolutions per minute, and the sign of the difference carries direction. Both captures and the elapsed time must describe the same interval. The expression below is pseudocode with illustrative variable names, not a vendor instruction:
count_now : DInt; // HSC count read this cycle
count_prev : DInt := 0; // previous capture, 0 before the first sample
delta : DInt := count_now - count_prev; // signed counts in the interval
scale : Real := 1.0; // counts per revolution, set from the one-turn test
t_sec : Real := 0.1; // interval in seconds
rpm : Real := 60.0 * delta / (scale * t_sec);
The test that proves it: standstill must return 0 rpm, and exactly one revolution in exactly one second must return 60 rpm at any scale. When a machine needs accumulated revolutions rather than speed, the same difference sums into turns, the pattern shown in configuring a PLC revolution counter for bin turns.
Does 512 P/R mean 512 counts per revolution? #
No — an A/B quadrature counter registers every edge of both channels, four per pulse cycle, so this encoder's 512 P/R becomes 2048 counts per revolution, and 2048 is the number that belongs in the RPM denominator. P/R on the datasheet counts complete cycles of one channel per revolution; the counter's evaluation decides how many edges inside each cycle it registers:
| Evaluation | What is counted per cycle | Counts per revolution for this encoder |
|---|---|---|
| Single channel | rising edge of A | 512 |
| Double | rising edges of A and B | 1024 |
| Fourfold quadrature | every edge of A and B | 2048 |
Quadrature encoders are documented to generate four times their pulses as counts — a 2000 P/R model read fourfold is the standard example, at 8000 counts. Dividing by the label value while the counter registers every edge makes every speed reading four times too high. To prove the scale on the real machine, jog the encoder shaft through exactly one revolution with the machine in a safe, controlled state and take the accumulated magnitude; the reset pulse that occurs once per revolution gives the same check between two consecutive pulses. That proven number is the scale the rest of the arithmetic uses.
Which shaft speed does the encoder actually measure? #
The counter measures only the shaft the encoder sits on: mounted on the motor shaft it returns motor RPM, so the machine value is that reading divided by the 1:25 reduction; mounted on the gearbox output or roller shaft it returns machine RPM with no ratio applied. Motor RPM, gearbox-output RPM, roller RPM and material speed are four different quantities, and the mounting point decides which one the counter sees directly:
| Encoder mounting | The count directly measures | To reach roller surface speed |
|---|---|---|
| Motor shaft | Motor RPM | divide by the 1:25 reduction, then multiply by roller circumference |
| Gearbox output shaft, roller directly coupled | Roller RPM | multiply by roller circumference |
| Behind its own belt or gear drive | Encoder-shaft RPM | divide by that drive's ratio first |
Read the ratio off the gearbox nameplate: written 1:25 from motor to output it means 25 motor revolutions per output revolution, the interpretation used throughout. An encoder that picks up speed through a drive of its own multiplies in that ratio as well, the case worked through in mounting a motor encoder behind a belt reduction.
How do you configure the HSC and the steps-per-revolution value? #
Enable one HSC per encoder in the CPU's device configuration, select the A/B quadrature counting mode, assign each encoder's A and B to a permitted input pair, and where a positioning technology object uses the counter, enter the measured scale in its Steps per revolution field. Run the sequence once for the first drive, then replicate it:
- Record the CPU's order number and firmware from its device information, plus the engineering software version, so the project matches the installed hardware.
- Build an allocation table with one row per drive: encoder A input, B input, HSC number and evaluation mode. No input may appear twice.
- Set the digital-input filter above the encoder's top channel frequency — 12.25 kHz on this machine — so real pulses are not filtered away.
- Where a positioning technology object consumes the counter, open its Encoder on high-speed counter (HSC) configuration page and enter the proven scale under Steps per revolution; for a rotary incremental encoder that is the fourfold count from the evaluation table.
- Capture the HSC count every cycle of the chosen cyclic interrupt, take the signed difference in integer math, and do the division in Real arithmetic.
- On the first sample, store the baseline and publish no speed; from the second sample on, subtract the previous capture.
- Treat counter resets and range wraparound as discrete events: a jump equal to the full counter range is a wrap, not a speed spike.
- Convert encoder-shaft RPM to machine RPM with the mechanical ratio, then replicate the validated configuration for the other four drives, each with its own count history and timing.
How long should the sample interval be? #
Choose the interval from the resolution you need: one count is worth 60 divided by the scale times the interval, so at this encoder's fourfold scale a 0.1 s sample resolves 0.293 rpm while a 1.0 s sample resolves 0.0293 rpm. The controller's measuring functions document sampling intervals of 0.01, 0.1 and 1.0 s, and a cyclic interrupt of the same period does the identical job when you compute the speed yourself. A short interval reacts quickly but makes each count a bigger step in the reading; a long interval is smooth but lags. For these rollers the middle option refreshes ten times a second with jitter of a few tenths of an rpm at the motor shaft — invisible after the reduction — so take it, and drop to the fastest option only when a shaft is fast and its scale small.
Do five encoders fit on one CPU at this count rate? #
Five A/B encoders need five counters and ten inputs; the S7-1200 family provides up to six HSCs depending on the CPU, so the count fits, and the decisive constraint is whether each counter's permitted input pair can carry its encoder's A and B signals. The device configuration shows which physical inputs each HSC may use, so spread the five pairs across permitted assignments; where the onboard pairs run out, a counting signal board adds high-speed inputs. Check the electrical side before wiring anything: the encoder's supply and output circuit must match the input type, the voltage-level details covered in wiring a TTL quadrature encoder to drive encoder terminals.
Then check frequency. At full motor speed the channel rate is 512 × 1435 ÷ 60 = 12,245 Hz, about 12.25 kHz per channel, and fourfold counting makes the edge rate four times that, 49.0 kHz. Compare both figures with the maximum counting frequency the CPU's hardware specifications list for the chosen inputs — at this encoder's speed any pair specified at 100 kHz or more passes with a wide margin — and keep the input filter set above the channel rate.
What roller RPM and surface speed do the numbers give? #
With the encoder on the motor shaft, the counter gains 4898 counts per sample at full speed; the formula hands back the motor's nameplate speed, division by 25 gives 57.4 rpm at the roller, and the 13 cm roller turns that into 23.4 m/min of surface speed. The lines below are a calculated example for the stated inputs, not a measured result.
- Count rate at the motor shaft: 1435 ÷ 60 = 23.92 rev/s, times 2048 = 48,981 counts/s; one interval holds 4898 counts.
- RPM from those counts: 60 × 4898 ÷ (2048 × 0.1 s) = 293,880 ÷ 204.8 = 1434.96 rpm — within one count of the motor speed, which confirms scale and interval end to end.
- Through the gearbox: 1435 ÷ 25 = 57.4 rpm at the roller.
- Roller surface: π × 0.13 m = 0.408 m circumference, and 57.4 × 0.408 m = 23.4 m/min.
Decision for each case: encoder on the motor shaft — divide by the fourfold scale and by the reduction, and the roller value follows; encoder on the gearbox output — same scale, no reduction, but accept the coarser low-count reading or lengthen the interval; encoder behind its own drive — divide by that drive's ratio first. Where the machine needs travel distance instead of speed, the same count-to-distance scaling as calculating pulses per inch for a rack and pinion axis turns roller counts into millimetres.
Questions asked
Does the sign of the count difference show rotation direction?
Yes. The counter climbs in one direction and falls in the other, so a negative difference between two samples means the shaft turned the opposite way. If the sign contradicts what the machine is doing, swap the A and B connections at the input pair; the sign flips while the speed magnitude stays the same. Average the reading when a shaft reverses inside one interval, because the net difference then understates the motion.
Why can the RPM read zero while the shaft is clearly turning?
Integer division truncates toward zero: a small count difference divided by scale times interval in integer arithmetic becomes zero before the multiplication by 60 can rescue it. Take the difference as an integer so the full counter precision survives, convert both operands to real numbers, then divide and multiply in real arithmetic.
Can the once-per-revolution index pulse measure speed instead?
Yes, and it suits slow shafts better than edge counting. Time the gap between two consecutive index pulses and divide 60 by that time in seconds: a shaft completing one revolution every 1.05 s turns at 60 divided by 1.05, about 57 rpm. The reading updates once per revolution, so on a fast shaft return to counting edges over a fixed sample.
What changes if the encoder sits on the gearbox output shaft?
The counts per revolution stay the same, but the shaft turns 25 times slower than the motor, so each sample holds 25 times fewer counts and the reading gets coarser. At roller speed the fourfold scale fills roughly 1959 counts in a 1.0 s interval, which resolves the speed to about three hundredths of a revolution per minute. Keep the long interval there, or leave the encoder on the motor shaft where counts are plentiful.
