Quadratic Encoder / 1,000 ppr / RPM to Serial & Velocity (0-5v)

Hello there,

Help Needed.

I have one of these (260907 - Series 07 incremental hollow shaft encoder up to 12 mm) and need help reading the RPM on Serial Monitor and also outputting as voltage (0-5v) for use in a DAQ.

Can someone please help. I've seen a couple of sample codes online but since my experience coding the Arduino UNO is very limited I've not been able to make much success setting this up.

Many solutions I found online use the digitalWriteFast, I was able to successfully read the Encoder on serial using the code here: http://yameb.blogspot.com/2012/11/quadrature-encoders-in-arduino-done.html

Result;
Encoder Ticks: 0 Revolutions: 0.00
Encoder Ticks: 0 Revolutions: 0.00
Encoder Ticks: 0 Revolutions: 0.00
Encoder Ticks: 9978 Revolutions: 2.49
Encoder Ticks: 9934 Revolutions: 2.47
Encoder Ticks: 9870 Revolutions: 2.46
Encoder Ticks: 9842 Revolutions: 2.46
Encoder Ticks: 9816 Revolutions: 2.45
Encoder Ticks: 9782 Revolutions: 2.44

I will really appreciate someone helping me out.

thanks.. eagerbeaver

Well one obvious problem with that code is that the function ParseEncoder is declared to return a value,
but doesn't end with a return 0; statement - that'll show up in the compiler warnings. It means that any
random value that happens to be on the stack at the time might end up being added to the _leftEncoderTicks variable.

Another problem is that _leftEncoderTicks is not read in a critical section in loop() so will sometimes
be garbled.

If you're only looking for RPM, you only need 1 interrupt pin and a much less complex program.

And its "quadrature", completely different from "quadratic". You'll get much better search results with
the correct term!