The above is from the Bourns data sheet for the PEC11R Series - 12 mm Incremental Encoder.
It makes a huge difference, without it you can get too many spurious interrupts.
The filtered circuit used is the one shown above, and the unfiltered circuit uses the pins connected via internal pull up directly to the encoder.
The values 1 and -1 indicate direction, clockwise and counter-counterclockwise. The value of zero indicates an invalid reading. You can clearly see for the same number of pulses generated, the filtered had a lot less invalid results. The benefit is that your micro-controller is not wasting time servicing an interrupt that it does not need to process.
Below is the extract from the main code posted on Interfacing A Rotary Incremental Encoder to an Arduino _Part 1
prevRot = curRot; intOccured=true; } void loop(){ //Do stuff here } // my main code actually checks every 20 msec, so that // is why i have this delay delay(20); if (intOccured){ Serial.println ( positionTrack[positionIndex] ); intOccured=false; }
No comments:
Post a Comment