The library look like it is the best way for me to get Pin Change interrupts working.
My next problem is figuring out how to do the calculations for the encoder:
Each gearbox has an optical quadrature encoder with a resolution of 1000 state changes per 3 revolutions of the output shaft (333.33 pulses per revolution).
How do I edit the code below?
Do I change
if (rpmcount >= 20)
to
if (rpmcount >= 333) {
PART TAKEN FROM THE PLAYGROUND:
if (rpmcount >= 20) {
//Update RPM every 20 counts, increase this for better RPM resolution,
//decrease for faster update
rpm = 30*1000/(millis() - timeold)*rpmcount;
timeold = millis();
rpmcount = 0;
}
Thanks in Advance.