开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: uBit Encoder


 

开云体育

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

_._

On Sat, Mar 3, 2018 at 10:37 AM, Michael Hagen <motdog@...> wrote:

I have experimented with several Encoders on uBit.

A few types on their own PCB with the pullups (10K) and a 5 Pin Header connector.

I get strange results with all of them.?? Takes more steps, like it is missing pulses.? In the interrupt routine in the Rotary Library I know there is a #define to fix the difference between models.? But uBit has its own routine using 3 analog ports (as digital).

I think someone supplied the one that comes with uBit.? It might be an Alps from Mouser??

Anyone remember that post or had experience with uBit and Encoders?

TNX & 73's

Mike, WA6ISP


?
-- 
Mike Hagen, WA6ISP
10917 Bryant Street
Yucaipa, Ca. 92399
(909) 918-0058
PayPal ID  "MotDog@..."
Mike@...


-- 
Mike Hagen, WA6ISP
10917 Bryant Street
Yucaipa, Ca. 92399
(909) 918-0058
PayPal ID  "MotDog@..."
Mike@...

Join [email protected] to automatically receive all group messages.