Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/17/00 08:27
Read: times


 
#2719 - RE: Rotary Encoder and an 8051
Buzz, regarding the output sequence you posted above your encoder has a "two channel quadrature output" (AB output).

The algorithm to check if a click (event that triggers a counter increment/decrement) must be generated is fairly simple.

Definition:
-----------------
CURRENT ; current AB output
OLD ; old AB output value
NEW ; new AB output value

Initialisation:
--------------------
- save CURRENT as OLD

Do this in a loop:
----------------------------
loop:
- if (OLD =! CURRENT) ; rotation detected
{
- save CURENT as NEW
- if (OLD =! 00) -> goto no_click
- if (NEW == 00) -> goto no_click
- if (NEW == 11) -> goto no_click
- if (NEW == 01) -> click up detected (increment)
else -> click down detected (decrement)
}
no_click:
- save NEW as OLD
- goto loop


Sorry for mixing C and assembler syntax to show the principle but painting some flowchart with ASCII is hard to do.
Even though coded in C I used this to poll 4 encoders on a front panel with some kHz (87C592@16MHz).

If you count some clicks into the same direction before doing anything you get a "dead angle" on the knob. Good for the user with Godzilla hands.

List of 14 messages in thread
TopicAuthorDate
Rotary Encoder and an 8051            01/01/70 00:00      
RE: Rotary Encoder and an 8051            01/01/70 00:00      
RE: Rotary Encoder and an 8051            01/01/70 00:00      
RE: Rotary Encoder and an 8051            01/01/70 00:00      
RE: Rotary Encoder and an 8051            01/01/70 00:00      
RE: Rotary Encoder and an 8051            01/01/70 00:00      
RE: Rotary Encoder and an 8051            01/01/70 00:00      
RE: Rotary Encoder and an 8051            01/01/70 00:00      
RE: Rotary Encoder and an 8051            01/01/70 00:00      
RE: Rotary Encoder and an 8051            01/01/70 00:00      
RE: Rotary Encoder and an 8051            01/01/70 00:00      
RE: Rotary Encoder and an 8051            01/01/70 00:00      
RE: Rotary Encoder,bouncing problems            01/01/70 00:00      
RE: Rotary Encoder,bouncing problems            01/01/70 00:00      

Back to Subject List