Reset Encoder.h Library

olf20

Member
I'm using Encoder.h in a sketch and have a need to reset
the Encoder count. I've tried various suggestions and none
have compiled.
The value has to be in the library as if I shut the power off to
the encoder the value still remains in the sketch.
Thanks for any assistance!
olf20 / Bob
 
Tried it and got the error below.

encoder.write(desiredPosition);

class Quadrature_encoder<0, 1>' has no member named 'write'

olf20 / Bob
 
You probably should show your code. You don't seem to be using either the Encoder library or the QuadEncoder library, because neither has a class by that name.
 
Should I post the whole sketch?
I'm using Encoder.h as my encoder library.
Everything works as it should but I can't reset
the encoder value as needed in my sketch.
Thanks for your reply / help!
olf20 / Bob
 
Attached is a simple sketch that uses
Quadrature.h that illustrates my problem of
not being able to reset the encoder values.
I've included several solutions offered to resolve
to no avail. I added the I2C lcd as I had it already
setup.
Thanks for any help.
olf20 / Bob
 

Attachments

  • Encoder_Reset_Test.ino
    2.9 KB · Views: 21
Attached is a simple sketch that uses
Quadrature.h that illustrates my problem of
not being able to reset the encoder values.
I've included several solutions offered to resolve
to no avail. I added the I2C lcd as I had it already
setup.
Thanks for any help.
olf20 / Bob
Your sketch is using a library called QuadratureEncoder, so it is not using either of the two Teensy-compatible encoder libraries (Encoder and QuadEncoder), and it does not even appear to be using Teensy. Are you using Arduino Uno? Shouldn't you be asking your question on the Arduino forum or on the github page for the QuadratureEncoder library?
 
The reason I posted on this forum is because of the author of the library.
I'm not using Teensy.
I'm seeking information on how to reset the encoder count using Paul's
library.
Thanks for any help!
olf20 / Bob
 
Paul's library is Encoder. Let's say your encoder variable is named myEncoder. You would set the value to 0 as shown below. You can learn more about the library by looking at the library example programs.

Code:
myEncoder.write(0);
 
I had tried that with no results. I did find a solution
from another forum. It involved modifying the library.
I inserted this in the public area of the library.
void reset() {
noInterrupts();
ct = 0;
old_ct = 0;
out_val = 0;
interrupts();
}
Then called myencoder.reset(0);
Thanks for your reply.
I've learned alot during this journey working
with encoders.
olf20 / Bob
 
Back
Top