Go Down

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

Magician

Optics fast enough to transmit 100 GB/s over optical cable, something wrong with your hardware configuration. Can you post your schematic/drawings?

Jabberwock

#16
Jul 27, 2011, 09:09 am Last Edit: Jul 27, 2011, 09:12 am by Jabberwock Reason: 1
I am not sure the optics network guys use exactly the same photocells as I do...

I attach the diagram, hope it is clear enough.

The code is:

Code: [Select]
int PinA = 2;
int PinB = 3;
int Last = 0;
int n = 0;
unsigned long timeold;
int delta;
int distance;

void setup() {
Serial.begin(9600);
digitalWrite(A2, HIGH);
digitalWrite(A3, HIGH);
timeold = millis();
}

void loop(){
 
n = (analogRead(PinA) > 505);
if ((Last == 0) && (n == 1)) {
if (analogRead(PinB) > 500) {
distance++;
delta =  millis() - timeold;
timeold = millis();
}
else
{
// reverse
}
}
if (n == 1) {
Last = 1;
}
else
{
Last = 0;
}
Serial.print (analogRead(PinA));
Serial.print ("/");
Serial.print (analogRead(PinB));
Serial.print ("/");
Serial.println (delta);
}

MarkT

You must use photodiodes or phototransistors.  LDRs are incredibly slow.
[ I won't respond to messages, use the forum please ]

Jabberwock

I use this:

http://nettigo.pl/product/Fotorezystor,photocell#

Is this the slow kind?

Jabberwock

Great news for a change!

Hall sensors and magnets work perfectly! No skipping, no delay, no need for debouncing. They are so precise I just placed two sensors next to each other and I can detect the change of direction with just one pass of a magnet...

I've placed eight magnets around the wheel (the glued encoder chart from the previous solution was quite useful for this :) ). I think I could do even sixteen, but for now this is good enough - the time between the pulses is below 100 ms, which is comparable to analog game controllers.

Funny thing is, I've almost had another solution - I've recovered an IR phototransistor and emitter from an old mouse and wanted to count the teeth on the wheel. I've got the wiring part all done when the magnets have arrived...

Anyway, thank you all for invaluable help, I've learned heaps doing this!

Go Up