Let's Make Robots!

New ways of seeing things..

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?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

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 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 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..

  • I think your solutions sounds way too complicated for me. And not very good at a distance.
  • If it was a problem I would just take 3 samples on / 3 samples off for each cycle, and use average on each. It would still be as fast as an SRF05 for every cycle.
  • So far it has not been a problem, but eventually I will try to optimize so that it can go as close as possible to any light source, so I will insert some leveling out in later versions.
  • As you can see here, I am aparently already doing the impossible ;)
All LEDs are not created equal. It may be that the red LED has a higher intensity of light than the green. A bright light is always going to be brighter than a dim light regardless of its colour.

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

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:

  • Make the LED flash on and off each time the LDR is measuring.
  • Work with 2 samples in every cycle instead of just measuring the input: Sample one where the LED is On and one where it is Off.
  • The 2 inputs are substracted from each other, and..
  • THE DIFFERENCE between the two is what we work with here :)

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)

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 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 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.

Well.. I have tested this in broad sunlight, and it works. Even in conditions where I cannot see the light myself.

Me, being a human, I cannot tell if there is 250 or 350 meters to something just looking at it. But I still drive a car. My robo's purpose is not to measure distance excact (i'd use a laser distance meter) - but to navigate. And I think it is cool that you can see where it navigates (when the lights are off)

The example code of the SRF05 to the Picaxe has some calculations so you know how many inches or centimeters things are in front of it. I always strip that part of the code, I just need a number, and I make the robot navigate from that.

i understand and respect that you cannot cope with this way of thinking, you clearly belong to the clever side of us. However, I make a robot navigate and avoid obstacles with this.. in broad daylight. Or at least I make it avoid falling off tables.. in broad daylight.

So wrong or inacurate or whatever - I make robots, they navigate etc. And because of this method I can now make a robot that navigates using LDR and LED to measure distance (if you like it or not :) You can deny it all day, it may not be right, but..