Explainer
Why an analog input module cannot count encoder pulses
Short answer
Encoder channels produce edges; an analog input module samples voltage and returns one value per channel per scan, so any pulse between two samples is lost and position cannot be recovered. Put the encoder on a high-speed counter input rated above (RPM ÷ 60) × pulses per revolution in hertz, matched to the encoder's voltage class. On an S7-300, the documented route is the FM 350-1 or FM 350-2 counter module, or a compact CPU with integrated counting inputs.

On this page
An analog input module cannot count encoder pulses, and no program recovers them afterwards. The module samples a voltage and returns one number per channel per scan. A two-channel encoder produces pulses, and the position lives in how many edges arrived and in what order. A pulse that starts and ends between two samples leaves no trace, and the direction information sits in the offset between the two channels, not in any voltage level. The fix is hardware: put the encoder on a high-speed counter input rated above (RPM ÷ 60) × pulses per revolution in hertz and matched to the encoder's voltage class. On an S7-300 rack that holds an analog input module, an analog output module and no counter, that means adding counting hardware: the family's documented options are the FM 350-1 and FM 350-2 counter modules, or a compact CPU such as CPU 313C or CPU 314C that carries integrated counting inputs.
What a two-channel encoder sends, and what sampling destroys #
A Hall-effect rotary encoder with two channels switches channel A and channel B between two levels, once per pulse. The channels are offset by a quarter of a pulse cycle, so on forward rotation one channel leads and in reverse it trails. The pulse count per revolution is the encoder's resolution, and which channel leads is the direction. Both facts are edge facts: they describe transitions, not levels.
An analog input module measures a magnitude at an instant and delivers one converted value per channel, per scan. Three things happen to the encoder signal on the way through:
- A pulse that starts and ends between two samples never appears in any sample. One sample interval swallows one pulse or ten, and the samples cannot tell the difference.
- The value that does get sampled is a level, so it says nothing about order. Two level readings cannot establish that A led B by a quarter cycle.
- The error compounds. Position is the running total of edges, so every missed edge is a permanent offset that no later sample corrects.
The best an analog channel can do with a pulse train is a crude average over the sample window. That is an estimate of mean level, not a count, and it degrades exactly when it matters, as speed rises.
Software on a discrete input hits the same wall one step later. Edge detection in the program executes once per scan, and a standard S7-300 OB1 scan typically runs 5 ms to 20 ms, so a program watching an input registers at most one edge per scan — at best on the order of 50 to 200 edges per second, far below what a rotary encoder produces. The same limitation stops a PC that polls remote I/O across a network, which is why PC-polled remote I/O cannot count encoder pulses for SCADA either.
What a counter input does instead #
A high-speed counter input is digital hardware with one job: watch the channel and increment on every defined edge, whether or not the PLC is scanning. The count sits in a register the program reads, so the scan carries a finished number instead of racing the pulses. What the hardware does with two channels — up on one, down on the other, or evaluation of the quarter-cycle offset for direction — is set by the counting modes the module's documentation defines, and that manual is the authority, not an assumed edge multiplier.
On the S7-300 family the documented counting hardware is:
- FM 350-1, the family's single-channel counter module; its operating instructions show it terminating on a 40-pin front connector, and its rated input frequency is stated there.
- FM 350-2 (order number 6ES7350-2AH01-0AE0), with eight channels; its published technical data lists a 20 kHz count frequency and 24 V encoder support.
- Compact CPUs of the family, CPU 313C and CPU 314C, which carry integrated counting inputs whose rated frequency is in the CPU's operating instructions. A CPU 315-2 DP/PN carries none, so on that CPU the count has to come from a counter module.
Counter inputs are built for a defined encoder voltage class — 24 V class outputs and 5 V class TTL or RS-422 outputs are the common ones — and the module documentation states which class each input accepts. Matching that class to the encoder's output stage is part of the selection, not an afterthought.
Once the count is inside the PLC, keeping it there is a program discipline of its own: counting encoder pulses on a PLC without losing position covers where counts usually go missing.
The sizing rule the counter input must clear #
Every selection starts from one number, the highest pulse frequency the channel will deliver:
f (Hz) = (RPM ÷ 60) × pulses per revolution
One revolution delivers the channel's pulse count, RPM ÷ 60 converts shaft speed to revolutions per second, and the product is pulses per second, which is hertz. The counter input's documented rating must sit above that number — above it, not at it — because a rating is a maximum and the application should not lean on it. Two qualifiers apply:
- The rating holds for the documented voltage class only. Compare within the class the encoder actually uses.
- If the module's documentation defines a multi-edge counting mode, two or four edges per pulse cycle, the comparison frequency is the channel frequency multiplied by that documented factor. Take the factor from the module's manual; never assume one.
No software closes this gap. Code runs between scans and the edges do not wait. At the top of the range the numbers leave software behind entirely, which is why a CNC servo controller must count encoder edges above 1 MHz in hardware. The same trade between an input's response time and the count rate it can follow bounds any digital input; for absolute encoders, the input card's response time versus count rate sets the same limit.
Counting frequency for a 250 ppr encoder at 1200 RPM #
Inputs for the example:
- Pulses per revolution: 250, an illustrative value of the kind the encoder datasheet prints; substitute the figure for your own encoder.
- Maximum shaft speed: 1200 RPM, an illustrative top speed for the driven machine; substitute your application's.
- Counter candidate: FM 350-2, whose published technical data lists a 20 kHz count frequency, eight channels and 24 V encoder support; confirm the rating for your exact order number in the module's operating instructions.
The rule in words: pulses per second equals revolutions per second times pulses per revolution, and revolutions per second is RPM divided by 60.
The arithmetic:
1200 RPM ÷ 60 = 20 revolutions per second
20 revolutions per second × 250 pulses per revolution = 5000 pulses per second
5000 pulses per second = 5 kHz
Result: the channel delivers 5 kHz at top speed.
Decision: the input must be rated above 5 kHz, and the candidate's 20 kHz rating clears that bar with a four-times margin, so this example encoder fits the module on frequency. Frequency is not the whole fit: the encoder's output stage must sit in the module's documented voltage class, and direction needs the two-channel evaluation mode. If the real encoder carries more pulses per revolution or the shaft turns faster, redo the arithmetic — at twice the speed the answer is 10 kHz and the margin is down to two.
From selection to a verified count #
- Read the rack and the datasheet. Confirm the CPU order number and that it has no counting input of its own, then take three figures from the encoder datasheet: pulses per revolution, output voltage class and the two channel designations.
- Size the counter hardware. Rated above the calculated channel frequency, in the encoder's voltage class, with the two-channel mode documented.
- Wire both channels to the counter's terminals exactly as the module's terminal documentation shows, including the supply and reference connections; the FM 350-1, for example, lands on a 40-pin front connector. Do this wiring with the machine stopped and locked out per your site's lockout procedure.
- Configure the counting mode from the module's configuration package: counting behavior, direction evaluation and limit values as the manual defines them.
- Read the count value in the program and scale it to engineering units. If the count drops only when the axis runs one way, look at the program first — a double coil on a high-speed counter loses pulses in one direction and produces exactly that symptom.
- Verify at the machine. Rotate the shaft slowly in both directions and watch the count track and reverse cleanly; then run at maximum speed and confirm no counts are missed. A count that stalls in both directions points at wiring or supply, not at the encoder.
The analog input module keeps the job it was built for: process values, smooth signals, thresholds. The encoder belongs on counting hardware. The decision, in one line: if the channel frequency calculated from (RPM ÷ 60) × pulses per revolution sits below the counter input's documented rating in the encoder's voltage class, that input is the right home for both channels; an analog input is the wrong one at any speed above a few pulses per second.
Questions asked
Can a regular digital input on the PLC count the pulses instead?
Only at very low pulse rates. Software edge detection runs inside the scan, so it registers at most one edge per scan — on the order of tens of edges per second — and pulses arriving faster are lost. A dedicated counter input latches every edge in hardware, independent of the scan, which is what position counting needs.
Does a two-channel encoder need two counter inputs?
Yes, when you need direction. The two channels carry pulses at the same rate but offset from each other, and direction lives in which channel leads. A counter watching one channel counts transitions and cannot tell reverse from forward, so the counting mode that evaluates both channels needs an input pair, and the module's manual states how its channels are grouped.
Which voltage classes do counter inputs accept?
Counter inputs are documented for defined encoder voltage classes, commonly 5 V for TTL or RS-422 differential outputs and 24 V for HTL outputs; the FM 350-2's published technical data lists 24 V encoder inputs. Match the class to your encoder's output stage from its datasheet, and use only the interface conversion the encoder manufacturer documents where the classes differ.
Is an analog input usable if I only need speed, not position?
No, not for a pulse train in the kilohertz range. To see individual pulses at all, sampling would have to run well above twice the pulse frequency, which an analog input module cannot do at encoder rates. Measure speed the way the position is measured: count edges in hardware and evaluate the count over a fixed gate time, using a counter mode the module manual documents.
