using interrupts with encoder library

Status
Not open for further replies.

spencoid

Well-known member
I am using a few endcoders in my project. Three are very slow mechanical types and one is a high speed optical. I think it is about 1000 counts per revolution. Everything works fine and because of the nature of my sketch it is not really critical if I miss a few steps now and then. I would prefer to not miss any steps and want to use interrupts. I am running the sketch on a 3.2 which is supposed to support interrupts on all inputs. I do not get any response from the encoder if I do not have the following in the code. If I comment out "do not use interrupts" it does not read them. Is there some magic combination of definitions or ??? that I need to use to enable interrupts? As I said, it really does not concern me if i miss a few encoder steps but on some other project it might so I am interested in learning how this works. Using the encoder library by Paul.

#define ENCODER_DO_NOT_USE_INTERRUPTS
#define ENCODER_OPTIMIZE_INTERRUPTS
#include <Encoder.h>
Encoder readEnc1(5, 6);// optical encoder
Encoder readEnc2(18,20); // first mechanical
Encoder readEnc3(7,17); // second mechanical
Encoder readEnc4(21,15); // third mechanical
 
Status
Not open for further replies.
Back
Top