New ways of seeing things..
2008-08-19 20:50
Hi all, I am so excited about this. It may not be much to anybody else, but to me it is!
You all know how we only have the IR's or the Ultra sound to work with when we want to check distance? Yeah, if we have millions we can also get a camera or two, and laser range finders..
However, I wanted something cooler.
This is not that, I am sorry.
However, I am working on something cooler (I hope, but it may be far fetched), and when doing so, as a spin off I made this.
And it is pretty wicked, I think.
The setup is simple, as simple as you can see it on the video; An LDR (Light Dependent Resistor) is hooked up with a 330 Ohm (or something) resistor, to the analogue input of a standard Picaxe 28 board with no extra modifications.
Also a speaker and a "white" (pale blue they are) LED are hooked up to the standard outputs, batteries, and that is it.
At first you may think that I have done nothing special.. LDR detecting light, or maby just pulsating light.. but then why don't you try to replicate it? I am going to be very surprised (and my day spoiled) if you can make something that works like this! ;)
I have made an LDR measure distance!
There you go, for less than half price of a Sharp IR range finder, and twice as fun, as you can actually see where the robot is focusing!
I am so excited to hear what you all think of this, and to hear if anyone can figure out how I did it, so I am not going to tell yet, but I will make a walkthrough, and am planning to make a robot (Start here-kind of project) that will not drive over the table's edge, and will navigate just by this.
..And while I am at it, I think I may have a look at giving that robot the ability to sense colors as well, so it can find say a red object amongst green on a black surface.. and then it can play ball :)
Because color detecting is also a spin off by this method! (Not on the setup on the video, and I have not tried it in real life yet, but I am pretty sure, and am going to prove it soon :)
And if not for color sensing, then for coolnes: Yes, the LED can be red as well (or any other color, possibly even IR, though I have not tried it yet) In fact it was red when I made the original test, but I swapped it to a "white" so you should not think it was the difference in color that did it. The flash light on the video has 3 LED's of same type & color..
How did I do this? Make me happy, throw me a theory, or try to duplicate :)
Thanks (I will tell later, but here is a chance to take me down first ;) Did I mention it is working in sunlight?

I'm assuming it is pulsing
How can anyone make Picaxe
How can anyone make Picaxe fast enough to detect the speed of light??
If we had that kind of speed in the procoessors it would be great. But as it is now, I think the ray of light would have to travel something across europe for the picaxe to have time to measure anything!
Thanks for guessing, wrong, please come again :)
Wrong Fritsl
The speed of light isn't the issue. If you do the maths you'll find that light only travels a few tens of metres in the time that it would take a fast eight bit microcontroller to react, never mind one that operates in the hundreds of megahertz or gigahertz range. The limiting factor is actually the response time of the light dependent resistor which takes milliseconds to react to changes in light levels. However phototransistors and photodiodes don't have that problem so you can use them instead.
Strength and Speed
I thought "strength of reflected light" too but that can't be it if it works in sunlight as well as the dark.
I doubt it's measuring the length of time to reflect the light: With the speed of light being about 300 million metres per second, and the CPU (presumably a PIC) working at 20MHz, the smallest distance it could measure would be 60 metres (and that would also be its resolution: 60 metre steps).
I'm going to call you "Barnes Wallace" from now on
Here's a theory...
No. That was before I saw the video. That's not how it's done. It's definitely some really neat-o outside-the-box thinking, though.
I'm guessing once the LDR detects light, you start a timer, then switch the light off until the LDR no longer detects light, then figure out how long the light persisted. The longer it persists, the closer the reflective surface. If you used alternative samples as baselines for the subsequent ones, this would work in variant ambient brightnesses where the ambient light is weaker than the LED focal point.
How am I doing so far?
I dont know what you are opn
Bouncing Bomb
Barnes Wallance invented the "bouncing bomb" which was dropped from a known height. The height was established by focussing two lights on a point on a lake and the aircraft was at a known height when teh light reflected back was strongest. Obviously this would only work for one given distance, though and you appear to have achieved a distance measuring thingy.
Both relevant and humorous, I thought.
Well it is not it under all
Need more clues...
Are you switching the LED off when the LDR detects light?
When the reflective surface is not perpendicular to the light, does your sensor "think" it's further away?
It's not a geodimeter. The PIC wouldn't be fast enough to measure the wavelength.
No lenses. No phase shift measurements. No interference patters.
I'm stuck.
A: That would be answred
A: That would be answred best by "yes and no" :)
B:That would be answered best by "No but yes"
Sorry, it really is the best answers I can give.
Let's see... You produce
I personally think this is
Another theory..
Looks awesome!! :D
Another theory..
By using a 330 Ohm resistor you are causing a delay in the LDR enough to calculate the reflection distance.. so instead the speed of light, you have something like the speed of sound !?
And, if you use the LED with PWM (instead of a steady light) and change the frequency, this slight change could be enough for the LDR, and he "knows" that the light wich is coming in his direction belongs to the LED
???
I'm with guibot, if you send
I'm with guibot, if you send pulses to the led, then have the picaxe only pay attention to the pulses that come in from the LDR ignoring the ambient (fairly constant) light.
To put it short; There is no
To put it short; There is no calculation of time / speed of light / delay involved in the most basic form, at the "oh is that really all"-place in here.
I would be too stupid to make anything like this, and I think the Picaxe would not be fast enough or precise enough to work with these things.
The closer you move the LED
The closer you move the LED to the LDR the greater the light intesnsity is and therefore the lower the resistance at the LDR. Intensity is a direct function of distance in this circuit and Bob's your uncle.
As to the resistor value on the LDR... well, I would use a calculation something like this -
Vo = 5*RL / (RL+3.3) (taken from some old data sheets) to derive voltage (substitute the R value in koms for atenuation).
and then...
Lux = (2500/Vo - 500)/3.3 substituting the R value in koms as needed to atenuate the circuit. This calculation will give you intensity.
For better rejection, I might even create a pulse train similiar to that used on an IR reciever, because the picaxe could care less how the pulse train was recieved - but I don't think that this circuit uses a pulse train.
no fair some of us were
"The closer you move the LED
"The closer you move the LED to the LDR the greater the light intesnsity is and therefore the lower the resistance at the LDR"
That is right, and that is one parameter of how distance is measured here!
I do not understand the rest of your post, sorry.
You will find that light
You will find that light dependent resistors are more sensitive to green LEDs than other colours, so using a green LED would use less power. Other than that, you are right, the colour probably doesn't really matter. (I corrected this after reading the Wikipedia article.)
Also, it would be more useful if you could get it to work under mains powered artificial lights.
Actually it turns out that a
Actually it turns out that a red LED is giving remarkably more signal than any other, including the White.
Infra red still not tested.
Dang! That's what my own
Dare I say practice VS
Dare I say practice VS science? :D
Sorry, I know it was too easy a joke to make, and you are already shot down because you could not figure out how I did it, and GroG could AHAHAaa.. oh, sorry ;)
Fritsl you're being very
Fritsl you're being very childish, but I'll persevere anyway.
It's interesting that you think that GroG's suggestion matched what you did, but it does not at all. Taking measurements repeatedly at fixed intervals of time is more useful than your haphazard method of just taking two samples at a time. The main reason that this is true is that it provides an additional relationship between the series of observations which you can use to improve noise immunity. For what it's worth, the same principle applies in PID control theory, especially with regard to the differential component which is the most sensitive to measurement noise.
Now yesterday I said that it would not be possible to extract the signal of the LED against a background of noise from mains powered lighting. My reasoning was that the response time of the LDR is too low and you could not separate it from the low frequency of the mains interference. Well I've been thinking about it some more and I'm happy to say that there may be a solution after all.
You would have to use two LDR's instead of one and deploy them the same way as the two microphones that are used to make a directional microphone. The second LDR senses the ambient light by pointing slightly away from where the LED and the first LDR are pointing. You use a differential amplifier to remove the second signal from the first one and then pass it through a large value capacitor to filter out the DC component.
I hope that this is clear enough for you to understand and get it working for yourself. If not, I've still got some LDR's in my junk box here, so I might just make one myself anyway.
Of course I am childish - I
Of course I am childish - I am an adult making fun little robots :D
I know that GroG really was only 90% there.. However, he was 90% at the right direction where the rest was some 0%, he's input would have made me make it, so I did not see any reason for taking it any further without showing you how I did it :)
Regarding the "it would not be possible to extract the signal of the LED against a background of noise from mains powered lighting" - well..
Intensity
My math is not as good as
My math is not as good as Casca's.
and I am microcontroller challenged ....
but I'll take a stab at it.. I think Casca got it at an "instant", however, I think the circuit works on comparing two analog pulses. You've got the microcontroller sampling at some constant rate. The differences in the samples will give you a relative intensity value.
It would work well in different ambient light conditions, since the saturation is relatively constant, most sunlight and other bright sources would be filtered out, since your only sampling the differences.
maybe a little clever filtering in software too ...
A twist on this would be to look for the LOW and HIGH of the LED switching OFF then ON - if you know when the LED is supposed to be OFF and when it is supposed to be ON, you can measure difference betweent the two intensities. The different intensities are propotionately related to proximity.
Just a shot in the dark :D
GroG
my robots
my garden
THIS IS THE ANSWER
Well.. It may be a shot in the dark, GroG.. and you may put it in other words than I would.. But you are absolutely right!!
My way of saying this would be:
Point the whole thing out towards outer space, and no difference is reflected to the LDR if the LED is doing it or not.
Point the LED to an object that reflects the light, and THE DIFFERENCE in the amount of returned energy is the same..
..even if the general level is higher (more light on) or lover (black night) - because the LDR is "lifted" to be somewhat "in the middle of the scale between black night and bright daylight" with the mounted resistor, and measuring is in word-variable-resolution (picaxe language: readadc10)
Of course it has reading-problems on black mat surfaces. However, primary testing shows that it can easely be set up to detect black things as well, however thinking they are further away than white ones. But this also goes for IR-detectors, only here you can acually see it all. My experience of working with a SHARP IR rangefinder is that it makes the robot very "analouge" - it is not really distance that is measured, but sort of a feeling of it..
The strenght of the LED / LED's means a lot to the effective distance we can measure / detect with this method. That is also why I am actually working on some other method. At test time, I tried to over power a red LED, and boy, ow we where talking; It could measure the distance to my hand at up to 50-60 CM!
I will make some test with both more LED's at the sme time, and also putting the LDR into the "shiny metal thingey" of an old flashlight.
The really interesting thing here IMO is that having multi coloured LED's and making more samples pr cycle (one for R, G, B, none for instance) will provide color info on the target - and then a white LED may better judge distance now that we know the color.. and knowing color and distance by a couple of LED's, an LDR and a few lines in a sub routine to be called any time is quite handy!
As asmith.id.au points out: "if you could get it to work under mains powered artificial lights" - well the first test showed that i'd have to reduce sensivity quite some for it to work straight under a light bulb; The 50 Hz did course interferrence if we work with EVERY little difference - and that is nice to do. So I may have a look at filtering this either by "morse-code" in the on/off, or by something with the more colors of LED.
An extra feature is laser: Hook up a laser(pen) to the output of the LED, and you get insane sharp results when pointing the laser at the LDR! The laser does not work to reflect the light, but with this you can have a laser-beam that you can detect no matter it it is sun is out or not.. for the price of an LDR :)
Thanks for participating! The answer was all in the programming;Use 2 cycles, one on one off, work with difference. When Jklug80 wanted to detect if some object on the floor was a bottle cap or a tables leg, I suggested the same; 2 cycles. A) Measure the distance to the object B) make something poke the object, and measure again. If it has moved it can be picked up :)
(And NICE ONE GroG, you have been granted STREET CREDIT AND RESPECT :D)
Still wrong!
Sorry Fritzl, you're still wrong because you are just guessing about what your circuit and program are measuring. Until you can make an accurate graph of the results and interpret them you won't be able to figure out what's really going on in your circuit, even though you think you know now.
The first part of GroG's suggestion is actually bang on the money. That your circuit works at all is just a fluke because of the constant time gap between your two measurements. However if you were to continuously measure the output from the LDR and analyse the resulting curves you might be able to get a more noise resistant result which might be useful in some environments. You would need to use a fast fourier transform and while it can be done an 8-bit PIC, it can't be done fast enough to be useful here. There is sample code written in assembly language that you can download from Microchip's website if you want to try it for yourself.
However you are still not going to be able to do anything in the presence of mains powered artificial light. The reason is simply because the LDR can't operate at more than around 100 hertz which is the same spectrum (50 to 100 hertz) as mains powered lights. That's why range finders use phototransistors and operate them at 40 kHz. The receiver uses a band pass filter to extract the real signal and then measures the amplitude of the result.
I could go and on but I won't. I think it's clever what you've done, but it is unfortunately neither novel or more than a curiosity.
How can I be "wrong"? Wrong
How can I be "wrong"? Wrong in what? The question here is how I did what is on the video, and I have answered that - wrong? Hmm? :)
I am going to make a robot that navigates with this alone, and uses it to not fall off a table.. so I may be wrong to the clever people, and my robot may be wrong as well.. but if it works, then I would say that it is right :)
You are wrong in the sense
You are wrong in the sense that you have made a proximity sensor that can only work in the dark. You have not made, as you claimed, a useful new kind of rangefinder.
If you were to actually measure what you are getting instead of just listening to the speaker, you would have realised that the results are too wildly inaccurate to be used for range finding. I really hate to rain on your parade (well may be just a bit but only because you were being a jerk the way you were teasing everybody earlier) but until you accept that subjective observation is worthless, you won't get anywhere.
Objective observation means taking the time and effort to take painstaking measurements and then analyze them. For example the graph that I just posted for the behaviour of the motors of my Ozone robot showed me why it wasn't possible to control modified servo motors accurately using the software that I'd been writing up to that point. Maybe I can still develop a sophisticated enough model of the motors to control them, or maybe not, but at least I am no longer guessing about why my control software didn't work.
In the broader sense, this approach to solving problems is called The Scientific Method. Without employing it, the only inventions that you can come up with will be little better than snake oil.