Re: Optical Shaft Encoder, by, chuck

You can use the Optical Shaft Encoder to tell how far the robot has gone based on the number of rotations of the axle but, it will not tell you that the robot has gone 5 feet. The only thing the OPS tells you is how many rotations it has recorded. To find RPM you would have to divide the number of rotations by the time passed and this still won’t give you a very good idea of what the RPM of the robot is. If you reset the encoder every minute and took the number of rotations it was at before you reset it you would only get the average RPM for that minute. To get closer to a real time RPM you could reset the encoder every second and multiply the rotations by 60 and you would have the average RPM for that second, however since it’s only a second it would be more accurate. I’ll upload some code later with some of this in it.

I did a test of this and it worked ok for me. I recalculated the rpm every .1 sec. then I tried it at .01 sec and it seamed to work ok. There was a small amount of error due to the length of my code I think, but I was able to calculate the delay and compensate.

Also instead of revolutions per min I used revolutions per sec or even per mil sec. I did this because the print to screen command only allows integers and not float (aka no decimals)

I want to try what you are doing but I don’t know if it is possible. I guess it would depend on what you were doing with it. Every thing I have does not roll very easy and stops to quickly. Maybe if you had two optical encoders you could match there Revs per sec (with a gearing multiplier)…??? :slight_smile:

I am going to get a second one and try it. :smiley:

Glad I was able to help. Good luck.

now i know i can actually use what im buying for why i bought it