@Rezo @mjs513 it has been a long time since I have done anything with encoders. I used them on some Rovers back a long time ago.
And during the later time of that I used a RoboClaw (BasicMicro) handle the encoders. Please pardon in advance my not too concise writing below.
Earlier when I was doing it manually (either in basic on a BasicMicro processor, or later Atmega328)
How to detect direction. As
@mjs513 mentioned the library does it for you. There are several webpages out there that give some basic
understanding on how this works, like:
RPM: as mentioned, you capture how many encoder events that happen over some specific period of time, and then do the math,
that converts to RPM: (encoder count)/(counts per revolution) = revolutions ...
Measuring counts per revolution. As you mentioned, I would maybe try to get the count of encoder events that happen over some number of revolutions. For example, like 10 revolutions. And then divide by 10. For me this sometimes helped me when I was doing it manually, as if I end and not 100% accurate on start and stop location, doing multiple revolutions helped minimize the impact of this.
As for expected counts coming out of a motor, lets say that is installed on a rover. It may depend on how the encoder in connected.
I have had some where something is connected to the actual wheel being driven and an optical encoder that works off of that.
So if you have something like 100 marks on the wheel you would get the count of 100 per revolution...
However others like:
Description Lynxmotion 12VDC 200rpm, 0.78Kg-cm GHM-16 DC Gearmotor w/ rear shaft Nominal Voltage: 12V Stall Current / Torque: 1.5 A / 83 oz-in Shaft Diameter: 6 mm Compatbile avec Lynxmotion Quadrature Motor Encoder V2 (w/Cable) The Lynxmotion 12VDC 200rpm, 0.78Kg-cm GHM-16 w/ rear shaft can be...
www.robotshop.com
with:
Description Quadrature encoder with two output signals Designed specifically for the Lynxmotion 12VDC 200rpm, 0.78Kg-cm GHM-16 w/ rear shaftand 7.2VDC 291RPM 11oz-in GHM-03 Spur Gear Head Motor (w/ Rear Shaft) Mounts to the output shaft of the gearbox Cable is included Motor and mount are not...
www.robotshop.com
This encoder mounts to the rear of the motor, which runs at the speed of the actual motor, but the motor here
has something like a 30 to 1 reduction built in. For every revolution of your wheel, you would receive about 3000 cycles.
And as for reading being about 4 times to high, As mentioned in the Sparkfun link above as well as the Lynxmotion encoder, there are about 4 counts per cycle... Which may be what you are counting here.
Sorry again if this is complete incoherent.
