Hi, I am working on a project on the Arduino Uno where I am planning to use a rotary encoder. I plan to have a non-time critical main loop and set up a timer interrupt to handle reading the encoder.
Is there any reference for the frequency at which I would need the timer interrupt to be called relative to the PPR of the encoder in order to have it be read accurately?
What is the encoder for? Is it a knob you turn by hand at 5rpm or is it a 1024-count encoder on a motor shaft spinning 50,000rpm?
If you used a timer, then you'd probably want to read the encoder at least 4 times faster than it would ever change one bit. For a knob turned by hand, this is big fractions of a second, so a timer is unnecessary. For a shaft turning fast then this is also a waste of time - use a pin interrupt and only read the encoder when it changes.
epalaima:
Hi, I am working on a project on the Arduino Uno where I am planning to use a rotary encoder. I plan to have a non-time critical main loop and set up a timer interrupt to handle reading the encoder.
Is there any reference for the frequency at which I would need the timer interrupt to be called relative to the PPR of the encoder in order to have it be read accurately?
quadrature encoders provide four changes in output (QUARTER-steps) for each Full-step.
So it depends on:
How many Full-steps per time do you want to count?
Then do at least four times as much readings in the ame time"
Let's assume a cheap mechanical rotary encoder with 18 PPR
= 18 full-Steps per rotation = 72 Quarter steps per rotation.
Ifyou want to count 18 Full-Steps per second, your interrupt for polling the A/B states fof the encoder would requireat least 72 timer interrups per second (72Hz), to read the A/B state of the endoder.