Thanks Arv,
I have always used
interrupts, and use it on BitX40.? I can't use some of the
features of Allards software, because I only
re-wrote the code
changing frequency.
I like the interrupt
method because I can change the frequency in the interrupt or
set a flag.
Not much delay and
missing action.? I made a couple of signal generators too
using interrupts.
I used the Rotary
Library that is out there.? Used the 2 interrupt pins.
But why they did not
use them on uBit?
But now I want to run
the great software KD8CEC for uBit.? He a code Wizard!
So not wanting to
change CEC, I want to find the correct encoder the works with
his code.?
So far out of a dozen
encoders I have of 3 types, only the stock encoder seems to
function correctly.
I knew I had ones the
pulse per step is different.
I did look at the
signals with a scope, but will go through you supplied
information.
Maybe I can come up
with a test fixture to sort out my assortment of encoders.
Thanks, Mike
On 3/3/2018 10:00 AM, Arv Evans wrote:
Mike?
WA6ISP
Rotary
encoders can be a pain to work with, but in reality are quite
simple.
If
we assign the two outputs as out-A and out-B then rotation in
either direction
will
show phase offset between them depending on direction of
rotation.?
But
of course you already know that.?
It
is relatively easy to write your own encoder decoding software
for Arduino/AVR
systems.?
Problem comes when we try to handle an encoder and do other
things
at
the same time.? Capturing an encoder output in real-time is
difficult to do because
it
blocks the performance of other activity.? This is why we
usually use an interrupt
routine
to watch for encoder steps while letting the software do other
things at
the
same time.?
This
URL provides examples of reading encoders in real-time.? It
works if you
do
not need to have other tasks running in parallel with encoder
sensing.
The
URL shown below talks about using either real-time or
interrupt based
reading
of encoder outputs.?
To
evaluate mechanical encoders you can usually devise a way to
connect LEDs
to
the out-A and out-B pins and observe the output states as you
slowly rotate
the
shaft.? This allowed me to determine that some of the Ebay
sourced encoders
have
one state change per mechanical detent and others have two
state changes
per
detent.?
FYI:? A code
addition to swallow one state change allowed me to use the
two state change devices as one-state change devices.?
Once
you have a good understanding of both real-time and interrupt
methods for
reading
rotary encoder outputs it is easy to include your own decoding
routine
as
a function call and avoid having to use libraries like
encoder.h which may, or
may not, have unexpected results.? This also solves the
problem of having a
profusion of encoder libraries with the same or similar names
but different operating
methodology.?
Arv?
K7HKL
_._
--
Mike Hagen, WA6ISP
10917 Bryant Street
Yucaipa, Ca. 92399
(909) 918-0058
PayPal ID "MotDog@..."
Mike@...