Rotary Encoder

Moderator: RevPiModIO

Post Reply
Posts: 3
Joined: 22 Jan 2024, 06:12

Rotary Encoder

Post by Adineh »

Title: Seeking Advice on Reliable Encoder Count Reading Without Missing Pulses**

1. Encoder Information:
  • Encoder type: incremental
  • Signal type: HTL pulse, quadrature
  • Operating voltage: 24V DC
  • Pulses/rev: 2048
  • Max rotation speed: 40 RPM
  • Expected maximum pulse frequency: < 1,400 Hz
2. Project Overview:
  • Special control system for an electrically driven drum.
  • Core controller is written in Python.
  • Core control reads other sensor data via a serial protocol and communicates with PLC via Ethernet.
  • Tasks are written in threads.
Problem Statement:
I need to add a new thread function/class to read the encoder.

1. What is the best option for I/O configuration: direct, counter, or encoder?
2. Will reducing the `.core.iocycle` increase the chances of reading all counts?
3. I have implemented two `.reg_event(…, as_thread=True)` to watch changes in the I/O pin connected to the encoder. At very low speeds, I can read all counts (2048 per revolution), but at higher speeds, counts are missed. The datasheet suggests we can detect up to 2kHz, but this seems unattainable. Is this due to the inherent slowness of Python? Can you provide advice on how to read the I/O in a single thread without missing pulses at around 2kHz, whether in Python or C?
Post Reply