Read an Encoder With Polling or Interrupts

Welcome to EDAboard.com
Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate yous demand to register. Registration is free. Click hither to register now.
- Forums
- Digital Design and Embedded Programming
- Microcontrollers
Y'all should upgrade or use an alternative browser.
counters or interrupts for rotary encoder?
- Thread starter mamech
- Start engagement
- Status
- Non open for further replies.
- #1

- Joined
- Nov 9, 2010
- Messages
- 176
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Bays points
- 1,296
- Activeness points
- 3,135
I am new to the globe of interfacing with rotary encoders with motion picture microcontroller. I searched and I read some codes, and I see that the efficient way is to use interrupts, simply my question is, volition I need to use interrupt on change on A / B pins ? or I volition demand to employ counter/timer TMR0 & TMR1 for example?
most of the code that I accept seen are using interrupts, will not be more efficient if i use counter to count pulses?
- #two
Merely that method doesn't worked for me, then i used timer interrupt and recorded the sequence of rotary encoder outputs and based on that i had done rest of the part.
- #3
Notation that some PICs accept congenital-in quadrature detectors which are platonic for sensing rotary encoder signals.
Brian.
- #4

- Joined
- Nov ix, 2010
- Letters
- 176
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,296
- Activity points
- three,135
'Polling' the encoder inputs without using interrupts presents the take chances that i of the signal changes is missed. It depends on the latency of the polling and how fast the encoder pulses arrive. For a paw operated encoder you lot can probably use polling, if information technology is an encoder on say a motor shaft where the pulse rate tin be very fast, I would only consider interrupts.
yes, i know this, that is why I excluded polling considering I know that it is inefficient. actually the trouble is that I am facing is to deal 7200 pulse per second encoder with a motor that rotates with 1.667 rotation per second , which equals : 7200*ane.667 = 12000 pulse per 2nd , and this tin not exist dealt with polling I think.
when I say to use counters/timers, I meant to use TMR0 as a counter to take hold of channel A, and to use TMR1 to catch channel B. I imagine that this volition reduce much the interrupts that happens to the primary programme , considering in this case interrupts will happen only when counter overflow happens.
the available micros that I accept does not have built-in detectors, I bargain mainly with pic16f887 and pic16f84a.
and then I am still wondering, will using TMR0 and TMR1 as counters instead of external interrupt on pins be more efficient?
- #5
If you are only using the encoder output to sense speed (as a tachometer) y'all can utilise just one of the outputs and measure its frequency. The easiest fashion to practice that is to use TMR1 as a pulse counter and TMR0 or TMR2 to count a time interval using the PICs own clock. From that y'all tin derive the number of pulses per second.
If management has to be checked, feed ane output to the interrupt pin and as soon as possible in the ISR, check the polarity of the other input. In one direction the input pin wil be high, in the other direction it will be low. Y'all can notwithstanding measure the speed by counting how fast the interrupts occur.
Brian.
- #vi

- Joined
- November 18, 2008
- Letters
- 2,123
- Helped
- 596
- Reputation
- 1,188
- Reaction score
- 573
- Trophy points
- i,393
- Location
- Norwich, Uk
- Activeness points
- xiii,069
- #seven
HTA
Advanced Member level i

- Joined
- Nov 17, 2011
- Letters
- 445
- Helped
- 108
- Reputation
- 216
- Reaction score
- 104
- Trophy points
- i,323
- Activity points
- 3,925
Savor your pattern work!
- Status
- Not open up for further replies.
Similar threads
- rotary encoder for proteus.needed
- Started by albert22
- Replies: three
- PIC18F452 Timers/Counters Interrupts,...
- Started by bobx
- Replies: 1
- rotary shaft encoder
- Started by raman00084
- Replies: half dozen
- Rotary encoder probleam
- Started past nick703
- Replies: three
- reading a rotary encoder
- Started past millwood
- Replies: ane
- Forums
- Digital Design and Embedded Programming
- Microcontrollers
- This site uses cookies to help personalise content, tailor your experience and to go along you logged in if you register.
Source: https://www.edaboard.com/threads/counters-or-interrupts-for-rotary-encoder.331142/
0 Response to "Read an Encoder With Polling or Interrupts"
ارسال یک نظر