IMDHMIControls LibraryShop main store

How-to

Configure a CP1H high-speed counter for an encoder input

Controllers and I/O Published 5 min read

Short answer

The CP1H gives you four built-in high-speed counter inputs: single-phase counting to 100 kHz and differential-phase 4x counting to 50 kHz input frequency, with a 32-bit range in linear or ring mode. Wire the encoder's phase outputs to the counter input terminals, set the mode and range in CX-Programmer, and prove the count on a known rotation before you use it for control.

On this page
  1. Match the encoder to the counter limits
  2. Wire the encoder to the counter inputs
  3. Set the counting mode and range in CX-Programmer
  4. Scale the count into engineering units
  5. Read the count in ladder logic
  6. Verify the count before you trust it
  7. Questions asked

The CP1H counts an encoder on four built-in high-speed counter inputs, numbered 0 to 3, that count independently of the program scan. Single-phase counting runs to 100 kHz input frequency, differential-phase 4x counting to 50 kHz, with a 32-bit count range in linear or ring mode; some CPU types in the lineup give two of the axes a 1 MHz rating. You set the counting mode, range and input filter in CX-Programmer, wire the encoder outputs to the counter input terminals, and prove the count on a known rotation before control logic uses it. The job is five steps: match, wire, configure, scale, verify.

Match the encoder to the counter limits #

Each counter runs in one of two documented modes, and the mode fixes both the ceiling and the resolution:

Counting mode Maximum input frequency Counts per line pulse
Single-phase 100 kHz 1
Differential phase, 4x 50 kHz 4

The number that decides fit is the encoder's line frequency: PPR (pulses per revolution) × rpm ÷ 60. Run it first. Differential-phase mode registers all four edges of the A and B pair in each electrical cycle, which is where the 4x multiplier and the direction sense come from — the same effect behind why quadrature counters log four counts per input cycle. An encoder above the single-phase ceiling does not fit these inputs at all: it calls for one of the CPU types whose lineup lists two counter axes at 1 MHz.

Wire the encoder to the counter inputs #

Take the terminal assignments and input circuit ratings from the CP1H CPU Unit Operation Manual's input wiring section; they are printed per counter, and inferring them from terminal numbers is the fastest route to a dead input. What holds for every job: a differential line-driver encoder feeds both phases and their complements to the counter input, while a single-ended encoder output drives one signal, which pairs with single-phase counting. Reference the encoder supply common to the PLC input common as that section specifies, and route the encoder cable shielded and away from drive output cabling.

Set the counting mode and range in CX-Programmer #

The counter settings belong to the CPU's built-in input setup in CX-Programmer, not to ladder:

  1. Open the PLC settings for the CP1H and find the high-speed counter setup for the built-in inputs.
  2. Assign the counter you wired: differential-phase 4x with both phases connected, single-phase with one.
  3. Set the numeric range: linear mode counts through the 32-bit range for absolute travel; ring mode wraps at a ring value you set, for repeating cycles.
  4. Set the input filter for that counter. A filter tightened against noise also attenuates fast edges, so re-test counting at full speed after any change.
  5. Download the settings to the CPU with the program, then confirm the counter increments before writing scaling logic.

Scale the count into engineering units #

Worked example, using an illustrative 1024 PPR differential encoder on a 100 mm diameter measuring roller, in differential-phase 4x mode, with belt position wanted in millimetres:

  • Counts per revolution: 4 × 1024 = 4096.
  • Belt travel per revolution: π × 100 mm = 314.2 mm.
  • Scale factor: 314.2 mm ÷ 4096 counts = 0.077 mm per count, or 4096 ÷ 314.2 = 13.0 counts per mm.
  • Speed ceiling: 50,000 Hz ÷ 1024 = 48.8 rev/s = 2,930 rpm. Single-phase counting of one channel would allow 100,000 Hz ÷ 1024 = 97.7 rev/s = 5,860 rpm, with no direction.
  • Running point: a 0.5 m/s belt turns the roller 500 mm/s ÷ 314.2 mm = 1.59 rev/s, so the line frequency is 1.59 × 1024 = 1.63 kHz and the count rate is 4 × 1.63 kHz = 6.5 kHz.

Position in millimetres is counts × 0.077. The arithmetic is the same straight-line conversion as scaling a 4-20 mA analog input to engineering units in CPM2 ladder, with counts on the raw side instead of a current value. Decision at these numbers: differential-phase mode fits with roughly a 30:1 frequency margin — commit to it. Above about 2,900 rpm, drop to single-phase counting and take direction from the machine state, or change the encoder.

Read the count in ladder logic #

The counter hardware counts whether or not the scan looks at it; your program reads snapshots. A documented working pattern is PRV(881) with port specifier #0010 and control data #0, executed from an always-ON flag such as P_On, refreshing the counter's present value into the result words you designate. The range is 32 bits, so allocate a double word — illustrative here: D100 with D101, both cleared to 0 on the first scan — and run the position math on the pair. Reading every scan costs nothing and gives speed calculations an even sample interval.

That split between hardware counting and software snapshots is also why PC-polled remote I/O cannot count encoder pulses for SCADA: every pulse between polled reads is gone, while the built-in counter never misses one within its rating.

Verify the count before you trust it #

  1. Rotate the roller exactly 5 revolutions by hand or jog: the example encoder must read 5 × 4096 = 20,480 counts, and the belt must move 5 × 314.2 mm = 1,571 mm.
  2. Briefly drive the machine the other way: the count must fall. Fix your positive direction here and keep it consistent with the scaling sign.
  3. Run at maximum working speed and compare the speed computed from the count against a known belt speed or a tachometer; agreement to within one count interval confirms the chain end to end.
  4. A count that sticks or jumps at speed points to wiring and shielding first, the input filter second, and the logic last.
  5. Repeat the rotation check after any encoder replacement — a silent change in resolution or output type breaks the scaling.

A miscounting channel is a measurement fault, not a protection: the emergency stop and machine interlocks stay hardwired and independent of this counting logic.

Questions asked

Will a 2500 PPR encoder at 3000 rpm work on a CP1H counter?

No, not on the 100 kHz axes. 3000 rpm is 50 revolutions per second, and 50 × 2500 gives a 125 kHz line frequency — above the 100 kHz single-phase limit and well above the 50 kHz differential-phase limit. Use a CPU type from the lineup with 1 MHz counter axes, an encoder with fewer pulses per revolution, or count a slower shaft.

Why do I get four counts for every encoder pulse?

Differential-phase mode counts all four edges of the A and B signals in one electrical cycle, so a 1024 pulses-per-revolution encoder reports 4096 counts per revolution. That is the multiplier doing its job, not a fault. Keep the mode and put the factor into your engineering-unit scaling rather than trying to defeat it; you gain resolution and direction from it.

Should I use linear or ring counting mode?

Use linear mode when you treat position as absolute travel: the count runs through the 32-bit range without wrapping. Use ring mode when position repeats each machine cycle, such as a rotary indexer: set the ring value to the counts in one cycle — for the example encoder, 4096 per revolution — and the count wraps there instead of growing forever. Decide at configuration time, because logic written for one mode assumes it.

The count runs backwards. What do I change?

Swap the A and B phase wires at the counter input. Direction in differential-phase mode comes from which phase leads, so reversing the pair reverses the counted direction without changing resolution or the frequency limit. Re-run the known-rotation check afterwards so the scaling sign and any direction-dependent logic still agree with the machine.

Keep reading

  • Troubleshooting

    Why PC-polled remote I/O cannot count encoder pulses for SCADA

    A 100 PPR quadrature encoder on a line at 200 m/min produces 333 Hz on channel A, about 1.3 kHz once the counter decodes quadrature at 4x. No PC poll, and no 4 ms discrete input, can follow that rate. Count the pulses in a PLC high-speed counter input and let the SCADA sample the accumulated register.

    Controllers and I/O

  • Troubleshooting

    Wiring a 1769-OF2 analog output to a PowerFlex 753 input

    Wire it directly: the 1769-OF2 channel sources the loop current and the PowerFlex 753 analog input set to current mode is a passive 93 Ω receiver, so no isolator is needed. Set the card's power switch to backplane, land only two wires on AI+ and AI-, and hunt repeated input-card failures in a second 24 V source, a shared 24 Vdc/0 Vdc common, or an unverified replacement card.

    Controllers and I/O

  • How-to

    Wiring four drives to a shared 1756-OF8 analog return

    Yes, the four drives can share the return, because the 1756-OF8 already shares it internally: every RTN terminal is one common node, so all four loops sit on a single reference. Run a separate return conductor from each 1336 signal common to the module, and give each drive its own output channel.

    Controllers and I/O