Let's Make Robots!

New ways of seeing things..

fritsl's picture

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.
I think the output from the LDR is what is being used to 'pulse' the LED
fritsl's picture

That was quite an interesting thought, I think; For the "long distance" (25-30 CM's) versions what i do now is just measuring perhaps 10 times, and calculate the average. Then switch LED on/off and do the same - to get the 2 values that are substracted from each other to form the all important Difference that we are only caring about & working with here.

However I have begun to work with old fashioned light bulbs for project FritsLDR now, replacing LED's. Reason is that I can make more light that way, much easier, simple old fashion flash lights. Of course it is not that practical because it is so slow to turn itself on / off, so the task is to wait just till it is full on before turning it off, and then measure.

Well.. Your idea, Zack, could improve this: Instead of knowing how long it takes for the bulb to be full on, it could just be measured, that might work!

Sounds like a good idea! Are you using regular flashlight (or torch as they say in UK!) bulbs?
fritsl's picture

Yes. And they give me distances of up to 30 CM - it seems like a wall - more than 30 CM is achievable, but only in controlled setups. In the hard world of reality, 30 CM is max max, 25 is normal max.

However, it still looks cool :D

(and of course I am looking into lenses etc)

I've been missing out on some cool stuff here!  Been a while since I visited LMR.  Cool work Frits! I love stuff like this!  Whatever your technique, I love the simplicity of it
Casca's picture

I think that this is a slick circuit that get's outside the box in a rather unorthodox way - and on the cheap. Well done and VERY under budget, which is even better.

 This might just fit the bill for a set of servo based grippers I've been planing -  

fritsl's picture

This trip continues @ http://letsmakerobots.com/node/1807

 

Let's see... You produce light of certain intensity, and the LDR "sees" it. Then you produce a bit less intensive light, and the LDR still is able to see it. Thus you gradually decrease light intensity until the LDR stops "seeing" it, and the last time you've caught the reflected light would roughly define the distance to the obstacle. Now the question is, how you control light strength. My guess is you just produce "sounds" of different frequensies...
asmith.id.au's picture

The process of converting from the digital microcontroller outputs to the continuously varying (analog) power input of the LED is called digital to analog conversion or DAC. There are a whole bunch of different ways that can be done.

For example, if you have four output bits available you can write a number in binary from 0 to 15 on the four bits and then run that through a network of resistors (e.g. an R-2R network) to produce an analogue voltage. Another method is to use a dedicated chip such as analog switch or one of the programmable resistor chips that are available from Microchip's website.

However in this case there is a really simple way to do it. You use pulse width modulation (PWM same as for motor control) to control the amount of power to the LED. Of course the LED will either be full on or full off but in this case it doesn't matter. The response time of the LDR to changes in light levels is so slow (typically around 100 hertz tops) that it will average out the pulses from the LED. (Otherwise you would have to "integrate" the signal using a resistor/capacitor combination to smooth it out.) Generating PWM at one kilohertz or more is easy enough, especially with the specialised PWM hardware that PICs have on board.

 

jip's picture

Nice one Frits!

This setup could very well make it into my new beer boat robot!

If you need faster response times than the LDR gives you, maybe you can use a phototransistor with an op-amp in a negative feedback setup like I did it here: http://letsmakerobots.com/node/240. You can get phototransistors that have response times in the order of a few nanoseconds and then the bottleneck lies with the ADC in the PIC which I would think needs a few microseconds to do a conversion.