Show Posts
Pages: [1] 2 3
1  Using Arduino / Sensors / Re: Ways to improve optical mouse sensor tracking on: July 31, 2011, 07:09:54 pm
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 smiley ). 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!
2  Using Arduino / Sensors / Re: Ways to improve optical mouse sensor tracking on: July 27, 2011, 03:59:59 am
I use this:

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

Is this the slow kind?
3  Using Arduino / Sensors / Re: Ways to improve optical mouse sensor tracking on: July 27, 2011, 02:09:05 am
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:
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);
}
4  Using Arduino / Sensors / Re: Ways to improve optical mouse sensor tracking on: July 26, 2011, 07:39:47 pm
Thanks for the info! A few cms might be problematic given the diameter, especially if I want to get the phase for the second sensor. I'll check it out when the magnets arrive.

Unfortunately, the optics turned out to be a dead end - it works well while tested (so the setup and the software are OK, I believe), but at the working speed it stops picking up the impulses - the input value kind of flatlines, I guess the sensor is not fast enough so it just gets a grey blur... actually, when I look at it spinning, I get it, too.
5  Using Arduino / Sensors / Re: Ways to improve optical mouse sensor tracking on: July 26, 2011, 04:36:20 am
Got some (not much) time to play around with this again...

Obviously I am not the right person to do that. On the workbench it works fine, but when I get around to implement it, it's problems, problems, problems...

One of them is that lighting is a bit tricky - I have fitted two LEDs to light the area evenly, however, due to restricted space and surrounding (i.e. white glossy paint of the bike frame) it's hard to get good contrast - either two much light is reflected off the paper or it is too dim.

Anyway, I have started a bit too ambitious - I've put the encoding wheel with 24 sections (12 impulses per turn), but there was too much noise to establish the threshold value right. Now I've fitted 8-section wheel - this works well, but then the resolution is the measly 4 impulses per turn... Hall sensors look attractive again, but then I'd need to order the magnets. By the way, anyone has any experience with hall sensors and neodymium magnets? What's the typical distance they detect the field from? I do not want to space them too densely...
6  Using Arduino / Sensors / Re: Ways to improve optical mouse sensor tracking on: July 21, 2011, 04:52:26 pm
No time for a picture now, I'll post it later...

I did just as Magician said - on the internal side of the crankwheel (i.e. on the other side of the wheel with pedals). It could not be the freewheel, because, well, it's a freewheel.
7  Using Arduino / Sensors / Re: Ways to improve optical mouse sensor tracking on: July 21, 2011, 07:39:23 am
The "paper encoder" is brilliant! I've made a 2-bit chart and soldered the little buggers and it seems to work!

No time to program it yet, but I will get around to it...
8  Using Arduino / Sensors / Re: Ways to improve optical mouse sensor tracking on: July 20, 2011, 12:51:54 pm
I am not a native speaker of English, so I got the terms from the Internet - they might be wrong...

Here is the picture:


9  Using Arduino / Sensors / Re: Ways to improve optical mouse sensor tracking on: July 20, 2011, 11:47:28 am
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!

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

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...
10  Using Arduino / Sensors / Re: Ways to improve optical mouse sensor tracking on: July 20, 2011, 11:13:39 am
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.
11  Using Arduino / Sensors / Ways to improve optical mouse sensor tracking on: July 20, 2011, 09:47:26 am
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:
http://arduino.cc/forum/index.php/topic,66550.0.html

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...
12  Using Arduino / General Electronics / Re: Problem with rotary encoder on: July 20, 2011, 09:34:13 am
Yes, a mouse seems definitely the way to go... It still does not work as I would like to, though. But I think I will move it to another topic.
 
13  Using Arduino / Networking, Protocols, and Devices / 3dconnexion (3dxware) serial controller with Arduino on: July 19, 2011, 02:44:59 pm
I know it's a long shot, but worth trying...

I am amazed how well Arduino works with a ps2 mouse! I have begun wondering whether it might be possible with another serial controller - 3dconnexion SpaceBall (my model is 3003).

Of course, the protocol is for sure proprietary so it's possible it cannot be reverse engineered at all, but maybe someone did start working on it? My hopes are not high, as the hardware is ancient...
14  Using Arduino / General Electronics / Re: Problem with rotary encoder on: July 18, 2011, 06:15:25 pm
Unfortunately, I have failed miserably... I cannot construct a mechanism which would transfer the rotation reliably.

Therefore, I am reconsidering using Hall sensors or LED sensors. However, I have a problem with grasping the principle of the rotary encoding. I have looked at the diagram and the explanation above, I have read through the wiki several times and I still don't get it... For example, how does the code relates to the diagram here? If I read the PHR2 at the situation given in the diagram, I get... an indeterminate (between) state? Does Arduino wait till the sensor has a discrete value?
15  Using Arduino / General Electronics / Re: Problem with rotary encoder on: July 14, 2011, 06:33:05 pm
I am not sure if I follow - is the difference due to the fact that due to delay between IRQ and readout of the second sensor it has been either covered or opened?

Anyway, it is not possible this way...

For this to work tension must be applied to the chain around the place the sensor is located (otherwise sagging of the chain will confuse the sensor). The problem is that with the forward movement the tension is on the lower part of the chain and with the backward movement on the top part... Of course, this in itself could be an indication of the direction of movement, now just to couple it with the speed reading...

Oh: the sprocket! The wheel itself is free, but the sprocket is not! No problem with the tension, either.

I guess I will have to sleep it over!

P.S. One more thing I forgot to mention - the advantage of hooking the mouse wheel to the chain (or, rather a small sprocket attached to it) instead of the main wheel is that the gear ratio is much more palatable... The sprocket I've got is somewhat smaller than the bike sprocket (did not get around to count the teeth), but not below 1:2 - the wheel speed is typically around 4 rotations per second, so I guess it should work out OK.
Pages: [1] 2 3