Go Down

Topic: Ways to improve optical mouse sensor tracking (Read 3 times) previous topic - next topic


I am starting a new topic, as I believe it is better suited here (and it strays from my original topic). Generally, I want to implement a two-way high resolution rotation counter for my training bike; more details here:

I have tried a mechanical rotary encoder and found out it is not best suited for my purposes, so I've switched to optical sensors. I've tried the ps2 library with two of my mice and it works great! At least until I actually try to implement it...

The problem is that the tracking distance for the mouse sensor is very short (it almost has to touch the tracking surface). There are not many places on the bike itself where it can be placed - the wheel is not suitable, as it is freewheel. The width and depth of the chain is too large - i.e. the mouse tracks it with interruptions. This leaves only the big sprocket (crankwheel), with enough surface to work on. However, it is still rather unreliable (hard to position the mouse exactly) and the mouse is hard to fit due to space restraints. Getting the electronics out of the body makes it unoperable - probably because it's the body that aligns the lens precisely to the sensor.

Any way to make it more reliable at longer distance? I've seen several projects where people use the mouse sensor without such problems, but no clear explanation how they did that...


Optical mouse is overkill for such project. If you know how regular bike computer measure a speed, they place a magnet on a spoke and read revolution per second/minutes from reed switch positioned on the frame.
In your situation, as for some reason you need to know direction of rotation, just place two reed switches slightly shifted, let say 10-20 mm apart, so when magnet approaches from one side one triggered first, if magnet coming other way - second switch triggered first. In general, it would be mechanical rotary encoder build from parts. Any software library written for rotary encoder should be able to process signals from your two switches, and give on output direction and PPM.


Oh... It seems the basics of the project are described in yet another forum.

I am using Arduino to convert the training bike speed into signal for a digital potentiometer for an axis in a computer gaming driving wheel. In other words, if I want to win computer game races, I need to pedal really fast.

I am using a setup similar to the one you describe - it came with the bike (it's mechanical, but it does not matter much). However, it generates only one impulse per wheel turn, about four times per second. This is far from satisfactory - the response time is low, it is very diffcult to maintain speeds lower than 100% etc. Moreover, I cannot brake with the pedals - it is a freewheel, so the signal is registered only for one direction.

That is why I wanted to increase the resolution. Two-way measurement would be nice as well. Everything works great on the electric/software side of things, but the mechanical setup is way more difficult than I thought...

I have considered placing a number of magnets on the crankwheel and using Hall sensors (which I happen to have), but given the past experiences I am a bit afraid that the precise placement of magnets and sensors as well as phasing the encoding will not be that easy.


To win a game you don't have to pedal at all, just take a PWM 50% duty from arduino, 490 PPM!
Why placing two/three magnets on the wheel would require precise phasing? It's not a rocket technology  :)


To win a game you don't have to pedal at all, just take a PWM 50% duty from arduino, 490 PPM!

I think you miss the point here... If I don't pedal, why use the training bike at all? Fun + exercise = win!


Why placing two/three magnets on the wheel would require precise phasing? It's not a rocket technology  :)

Two magnets won't cut it, for the reasons I have stated above. The crankwheel is twice as big as the sprocket, so on the average there are two turns per second. With eight magnets the response for braking (change of direction) would be almost 1/8 s - passable, but not great...

Go Up