Go Down

Topic: AdaEncoder: a library for use with simple quadrature encoders (Read 5 times) previous topic - next topic

vasquo

I've encountered a bug with the AdaEncoder (old version).

So you power up, turn the encoder CCW... the counter decrement. All is good.

You stop turning, and then turn one click CW... the counter instead of incrementing as expected, instead decrements! 
Turn it again by another click CW, then the counter increments correctly.

Stop turning. Turn encoder one click CCW... same bug. The counter will increment again, instead of decrementing (since we turned CCW).
Turn it again by another click CCW, now the counter decrements correctly.

It seems to be getting "lost" during that first click when you change from CW to CCW (and vice versa). It still thinks it was going the previous direction.

Does this update fix this bug? 

Thanks.

vasquo

Well, I tried using the 0.7beta.  And changed the necessary lines in my code to match the new format of Adaencoder 0.7beta.  Compiled successfully and all that.

But I can't get it to work properly. My program just crashes when I turn the encoder using the 0.7beta... as if somebody pressed the reset button. I'm going back to 0.5.

---
I do have a few questions on the sample MyEncoder in 0.7beta

On Line# 15, we have this code
AdaEncoder encoderA = AdaEncoder('a', ENCA_a, ENCA_b);

but nowhere else in the program is "encoderA" used. What's the purpose of line#15?

Then on line#30, I see this
AdaEncoder *thisEncoder=NULL;

*thisEncoder is used in the loop() program.  But how does Arduino know how *thisEncoder is setup?  We defined encoder pins 2 and 3 for "encoderA", not "thisEncoder".

I'm confused.

vasquo


I've encountered a bug with the AdaEncoder (old version).

So you power up, turn the encoder CCW... the counter decrement. All is good.

You stop turning, and then turn one click CW... the counter instead of incrementing as expected, instead decrements! 
Turn it again by another click CW, then the counter increments correctly.

Stop turning. Turn encoder one click CCW... same bug. The counter will increment again, instead of decrementing (since we turned CCW).
Turn it again by another click CCW, now the counter decrements correctly.

It seems to be getting "lost" during that first click when you change from CW to CCW (and vice versa). It still thinks it was going the previous direction.

Does this update fix this bug? 

Thanks.



It turns out, not all Bourns encoder are the same with regards to detent position.
See PEC09 series and PEC11 series.  The library works fine with PEC11 series encoders but requires a slight change with PEC09 series.
Here's the mod I did in the library to work with my particular Bourns encoder.
http://arduino.cc/forum/index.php/topic,138403.0.html



GreyGnome


I've encountered a bug with the AdaEncoder (old version).

So you power up, turn the encoder CCW... the counter decrement. All is good.

You stop turning, and then turn one click CW... the counter instead of incrementing as expected, instead decrements! 
Turn it again by another click CW, then the counter increments correctly.
...
Does this update fix this bug? 



I don't think the update fixes that bug- not directly anyways. The bug actually came from the PinChangeInt library, which was not properly testing the state of the pins when interrupts came in quickly. If you have bouncing switches (yes- if you have a mechanical encoder, then you do have bouncing switches), then quite likely you had some issues.  I recommend you continue to use AdaEncoder 0.5 but update PinChangeInt to 2.19beta or greater.

vasquo

Thanks for the reply. It's got nothing to do with the PinChange or AdaEncoder library.

It turns out some Encoders have different states at their detent positions. 

For example, your Adaencoder works perfect with Bourns PEC11 series but has the weird behavior with PEC09 series.

I think it's because the AdaEncoder assumes that both A and B lines are both LOW at the Detent position.
But some encoders (like the PEC09), both A and B lines are HIGH at the Detent positions.

Maybe, create a function in AdaEncoder to let the user select what kind of encoder they have... A/B low at Detent position, or A/B high at Detent position.


Go Up