Wiring and Programming Omron CP1H/CP1E High-Speed Counters with Incremental Rotary Encoders
1. High-Speed Counter Architecture: CP1H vs CP1E
In industrial conveyor tracking and cut-to-length packaging, rotary encoders generate pulse trains in the 10 kHz to 100 kHz range. Standard PLC digital input filters and CPU scan cycles (1-5 ms) miss these rapid transitions. Hardware High-Speed Counters (HSC) execute independently from the CPU scan loop: - Omron CP1H: Provides 4 independent HSC channels (Counter 0 to 3) capable of counting up to 100 kHz (Differential Phase x4 = 400 kHz) or 500 kHz with Line Driver input. - Omron CP1E (N-Type): Delivers 2 HSC channels at 100 kHz and 4 channels at 10 kHz.
2. Rotary Encoder Hardware Wiring (Phase A, B, and Z)
| Encoder Signal | CP1H Terminal (Counter 0) | CP1E-N Terminal (Counter 0) | Functional Description |
|---|---|---|---|
| Phase A | Terminal 0.00 (CIO 0.00) | Terminal 0.00 | Primary pulse train incrementing position steps |
| Phase B | Terminal 0.01 (CIO 0.01) | Terminal 0.01 | 90° phase-shifted pulse detecting rotation direction (CW/CCW) |
| Phase Z (Index) | Terminal 0.04 (CIO 0.04) | Terminal 0.04 | Single pulse per revolution for zero-datum hardware reset |
| Power +24V / 0V | External 24VDC SMPS | External 24VDC SMPS | Regulated DC supply for NPN Open Collector outputs |
3. CX-Programmer PLC Settings Configuration
Under Settings -> Built-in Input in CX-Programmer: 1. Enable High-Speed Counter 0. 2. Set Input Mode to Differential Phase (4x) to multiply resolution by 4 (a 1,000 PPR encoder yields 4,000 counts per turn). 3. Select Linear Mode (-2,147,483,648 to +2,147,483,647) for linear motion, or Ring Mode for rotary index tables. 4. Configure Reset Method as Software Reset or Phase Z + Software Reset.
4. Essential Instructions: PRV (Read Pulse/Frequency) and INI (Reset)
// --- 1. Resetting Counter PV via INI Instruction ---
// Syntax: INI P C D
// P = Port specifier (#0000 = High-Speed Counter 0)
// C = Control code (#0003 = Change Current PV)
// D = Source word with new value (D100 = 0, D101 = 0)
[ P_On ] -------- [ INI #0000 #0003 D100 ]
// --- 2. Reading Real-time Counter PV via PRV Instruction ---
// Syntax: PRV P C D
// P = Port specifier (#0000 = High-Speed Counter 0)
// C = Read mode (#0000 = Read Counter PV)
// D = Destination for 32-bit value (D200 = Low word, D201 = High word)
[ P_On ] -------- [ PRV #0000 #0000 D200 ]
// --- 3. Reading Pulse Frequency (Hz) for RPM / Speed Calculation ---
// C = #0010 (Read instantaneous pulse frequency in Hz)
// D = D210 (Low word) and D211 (High word)
[ P_On ] -------- [ PRV #0000 #0010 D210 ]5. Real-Time Hardware Interrupts: Target Value Comparison (CTBL)
Evaluating target distance in cyclic ladder scans (`D200 >= Target`) causes severe position jitter proportional to conveyor speed variations. Engineered Solution: Use the CTBL (Comparison Table Register) instruction to register target thresholds in hardware. When the counter value matches the table, the hardware immediately triggers an Interrupt Subroutine (Task 02), bypassing ladder scan delays and firing digital outputs within 10 microseconds for ±0.1 mm repeatable cut accuracy.
Mitigating Electrical Noise (EMI) on Long Encoder Runs
High-speed pulse signals routed parallel to VFD motor cables are prone to capacitive and inductive EMI coupling, producing spurious 'ghost' pulses. Countermeasures: 1. Always install Braided Shielded Twisted Pair (STP) cables. 2. Terminate the shield braid to Functional Earth (FE) at the control cabinet end only (Single-Point Grounding). 3. For cable lengths exceeding 10 meters, specify Line Driver (RS-422) differential encoders rather than open collector interfaces.
- Check input response time constants in PLC settings: overly aggressive software filtering will attenuate high-frequency pulses.
- Verify common polarity: NPN encoders require PLC COM terminals wired to +24V (Sinking input configuration).
- Use PRV2 instruction on CP1H for automated high-speed conversion directly to engineering units (RPM / mm/s).