How to make my own IR sensor?

MaltiK

Member
I want to make my own IR Sensor simialer if not identical to the Sharp GP2D12, is this possible? Anyone have a materials list/schematic?

I'm gonna buy everything via MOUSER, so if anyone has parts numbers then cheers!

No I will not just go out and buy one, its beyond money, its for educational purposes.
 

BeanieBots

Moderator
Not really possible. The optics are critical and not just a simple lens.
It is more complicated than just measuring how much light is reflected. The voltage returned by the GP2D12 is almost immune to the reflective material and the angle of incidence. To create your own optics to do that would be virtually impossible unless you have lens grinding equipment. Even then, what's the lens design anyway?

Many years ago I did come across the design whilst 'surfing'.
In brief, it's a bit like a columnating fibre optic with the light sensing at the side. That's why the GP2D12 does not work well at close range. The reflected light must come in parallel such that the angle from the Tx can be measured. Very close objects can send light in at the incidence angle which gives the illusion of a distant object.
 
Last edited:

MaltiK

Member
Not really possible. The optics are critical and not just a simple lens.
It is more complicated than just measuring how much light is reflected. The voltage returned by the GP2D12 is almost immune to the reflective material and the angle of incidence. To create your own optics to do that would be virtually impossible unless you have lens grinding equipment. Even then, what's the lens design anyway?

Many years ago I did come across the design whilst 'surfing'.
In brief, it's a bit like a columnating fibre optic with the light sensing at the side. That's why the GP2D12 does not work well at close range. The reflected light must come in parallel such that the angle from the Tx can be measured. Very close objects can send light in at the incidence angle which gives the illusion of a distant object.
well it doesnt have to extremely accurate, but I am positive it can be done, in fact, is there an augmented version of something like this:



R1 = 150 ohms (calculate as above)
R2 = 220 Kohms (calculate as above, or use Pot for white line following)
R3 = 4.7 Kohms
R4 = 10 Kohms
OP1 = Operational Amplifier LM358 package includes two op amps.
Vcc = +5 Volts
 

BeanieBots

Moderator
Well, that's about as basic as you can get.
The IR is not modulated so it will be effected by background levels.
What are the optics?

Without optics and modulation a mirror will appear MUCH closer than a piece of black paper. Also, a piece of black paper at 90deg will look much closer than a mirror at 45deg. Depends what you want. The GP2D12 meausres distance. That's more about the optics than the circuit. That circuit can't tell anything other than how much IR light is received. Even if that light comes from a nearby bulb rather than its own transmitter. It would be fine in a closed system such as a wheel encoder but very little use for measuring distance.
 

westaust55

Moderator
Contructing own IR sensor - Sharp GP2D12 clone

Considering the difficulties that you have had with other recent PICAXE projects involving straight forward commerical modules and IC’s, each thread giving no indication that you have resolved these problems (and how were they resolved), I would respectfully suggest that you need to gain more experience in electronics before attempting to build you own sensors with any significant degree of difficulty involved.
See:
- SRF05 Doesnt work with Picaxe 28x1...
http://www.picaxeforum.co.uk/showthread.php?t=10809, and
- Driving one motor with l293D via Picaxe 28x1 board (Axe020 board)
http://www.picaxeforum.co.uk/showthread.php?t=10709
 

MaltiK

Member
Well, that's about as basic as you can get.
The IR is not modulated so it will be effected by background levels.
What are the optics?

Without optics and modulation a mirror will appear MUCH closer than a piece of black paper. Also, a piece of black paper at 90deg will look much closer than a mirror at 45deg. Depends what you want. The GP2D12 meausres distance. That's more about the optics than the circuit. That circuit can't tell anything other than how much IR light is received. Even if that light comes from a nearby bulb rather than its own transmitter. It would be fine in a closed system such as a wheel encoder but very little use for measuring distance.
It really is just a simple first project, Just basic object detection, or line following
 

moxhamj

New Member
Re "its beyond money,its for educational purposes"

The price is $12.50 here http://www.acroname.com/robotics/parts/R48-IR12.html

That represents exceptional value. Much cheaper than the cost of building this with discrete parts.

Yes, you can build one from parts. I did once and the circuit has a range of about a metre and it works fine even under flouro lights.

First, you will need a CRO.

Second, you need a protoboard and a good collection of 324 op amps and resistors and capacitors and some 4016 cmos switches and some switch controls based on 555s.

The theory is that every bit of IR light is superimposed on a 50hz waveform from indoor lights, and the waveform is much bigger than the signal you are looking for.

So you sample the light level, store that level in a sample and hold, then send out an IR pulse, then sample it again during the middle of that pulse, and then compare the two voltages and store that difference in a third sample and hold. A picaxe might be able to simplify this - it depends on the sample speed of the ADCs relative to the 50hz waveform. You do need a CRO for this sort of work as you need to see that waveform to visualise how to capture the data. Just put a CRO on the output of that opamp circuit you posted and fire some IR pulses in and see what happens.

Start with that circuit you posted and let us know how it performs on the protoboard.
 
Last edited:

BeanieBots

Moderator
It really is just a simple first project, Just basic object detection, or line following
Well the first thing to do is make your mind up what you want this "sensor" to do.
The GP2D12 measures distance.
It CANNOT do line following. It's main feature is the fact that it cannot tell the difference between black and white.

Line following is a much simpler task because you can do it in a semi controlled environment (under the robot) avoiding the necessity for the type of circuitry described by Doc above. A "good" line follower would still use a similar type of circuit.

For a FIRST object detector, you should be looking at bump switches.
Did you ever get the motor drive working?
How are you ever going to get both motors (which produce noise) and a sensitive home-made sensor working in the same robot. Still, it will be good learning excersise of why things are not as simple as just the theory of opperation.
 

MaltiK

Member
For a FIRST object detector, you should be looking at bump switches.
Did you ever get the motor drive working?
How are you ever going to get both motors (which produce noise) and a sensitive home-made sensor working in the same robot. Still, it will be good learning excersise of why things are not as simple as just the theory of opperation.
I am glad you mentioned that, I did get it to work, but I did not use the TTL ports, I figured out that the portc's on the Picaxe board worked as well because they arent connected to the transistor array, so yes, I did get them to work, I am just focusing on making this IR sensor, and figuring out which MCU to use, I have between an ATmega8 and a Picaxe28x1, which is probably an overkill, but its a spare so :D.

I cant afford CRO, so Ill just have to go without one of those, I am sure it wont be too difficult, if so, I will just use my universities, but we'll see. As for the other materials, they are obtained:

IR Sender module
IR Transiever module
LM358 (2 opamps)
and various resistors
and a 5v regular, will that be needed (im using maybe a 9v?)

is that it?, or do I need more?
 

BeanieBots

Moderator
As for the other materials, they are obtained:

IR Sender module
IR Transiever module
LM358 (2 opamps)
and various resistors
and a 5v regular, will that be needed (im using maybe a 9v?)

is that it?, or do I need more?
Read the replies and then you tell us.
Please let us know how you get on with all your projects.
It's very frustrating never knowing if the issue was ever solved.
 

boriz

Senior Member
“make my own IR Sensor simialer if not identical to the Sharp GP2D12”
-Very very tricky. Expensive and pointless when you can buy one off the shelf. I am a great deal more experienced that you with electronics in general and Picaxe in particular, and I would not start such a hard project without good reason (and plenty of time/recources).

“Just basic object detection”
Much less tricky, but still not trivial. Very Picaxeable though.

“or line following”
Less tricky again. A good place to start. You can use IR if you wish, but it’s just going to complicate things. Better with a normal red LED and LDR.
 

MaltiK

Member
How can you possibly say that? That IR object detection is difficult to make... it may not be the easiest but it certianly isnt the most difficult, I have made two before, one only sensed objects a couple CM ahead, and the next I just used for a wheel encoder... I used this schematic:

 

BeanieBots

Moderator
MaltiK, you need to make up your mind what you want to make.
Your thread started with wanting to make your own version of GP2D12.
Quite frankly, that is NEVER going to happen. Even some of the larger corporate organisations simply don't have the required resources to do that.

Then you talked about object detection.
That's feasable, but it won't be very good with what you've described.

Then there was line following.
Covered well by Boriz. Not very clever to use IR for a line follower. You can actually get "IR paint" to draw the line with, but it's seriously expensive.

Then you go on about encoder sensors. The circuit you've described is best suited to that type of sensor. Shrouded away from other IR sources that might upset it.

So, what's it to be?
Why don't you try it and tell us how it went?
 

MaltiK

Member
MaltiK, you need to make up your mind what you want to make.
Your thread started with wanting to make your own version of GP2D12.
Quite frankly, that is NEVER going to happen. Even some of the larger corporate organisations simply don't have the required resources to do that.

Then you talked about object detection.
That's feasable, but it won't be very good with what you've described.

Then there was line following.
Covered well by Boriz. Not very clever to use IR for a line follower. You can actually get "IR paint" to draw the line with, but it's seriously expensive.

Then you go on about encoder sensors. The circuit you've described is best suited to that type of sensor. Shrouded away from other IR sources that might upset it.

So, what's it to be?
Why don't you try it and tell us how it went?
I already stated that my final goal is to make it for basic object detection
 

moxhamj

New Member
Object detection?

How far away? You will have no problems up to a couple of centimetres. Then you will suddenly find your sensor gets confused. That is when you will need to get out the CRO and test the circuit under daylight, dark, flouro lights and incandescent lights.

If the aim here is to get a robot working, buy the pre-made sensor.

If the aim is to put the robot aside for a while and learn a lot about op amps and electronics in general, this circuit could be a great start. But it will take several months and it is not simple.

I should add that in addition to my description of the circuit I have built, you need to add metal tubes 5mm in diameter and 2cm long on both the IR transmitter and receiver leds. That way, the leds are looking "forward" and the receiver is shielded from the direct light coming from the transmitter.

If you want to learn about electronics, maybe start by having a play with the 4016 cmos switch chip. Use a 1uF polycarbonate ('greencap') capacitor and run it into a LM324 voltage follower and see if you can get a sample and hold to work.
 

BeanieBots

Moderator
How can you possibly say that? That IR object detection is difficult to make... it may not be the easiest but it certianly isnt the most difficult, I have made two before, one only sensed objects a couple CM ahead, and the next I just used for a wheel encoder...
OK, so we're sticking with basic object detection.
The referece to GP2D12 was just a "red herring".
You've already made two before, and they obviously worked.
So, what was the question again?

As both the Doc and I have pointed out, to get more than a few CM range, the optics are just as important as the electronics. Without some sort of modulation it quite simply won't work (reliably).

Doc, the 4066 is much better than the 4016. From memory, pin for pin replacement.
 

moxhamj

New Member
Good point bb - agree the 4066 is better.

And any robot does need more than a few cm range. Otherwise there isn't enough room to stop!
 

MaltiK

Member
Alright, so say I want 10 CM, is this plausible, how about with the schematic I mentioned? If not, any others?
 

bgrabowski

Senior Member
I would suggest the Hamamatsu S4282-51 or similar would be the best solution for both object detection and line following. It is a digital device so it is ideal for connecting to a Picaxe. It uses visible light and, most importantly, is not affected by background lighting. This sensor is used in successful line following robots and micromouse maze solvers.
 

BeanieBots

Moderator
Except that MaltiK wants to MAKE his own sensor.
For some reason, we are finding it hard to explain why it's not simple.

I've got a few spare logic gates. Think I'll just pop off and make my own PICAXE. Anyone got a circuit I can use?
 

BeanieBots

Moderator
Indeed, that type of sensor (without modulation as per MaltiKs diagram) work very well with distances of a few mm underneath a robot. Completely usesless over a few Cm though unless in a darkened room where all objects are made of the same material and are all at the same angle of incidence to the robot:rolleyes:
 

slurp

Senior Member
With modulation my guess is that you can push reliable detection to about 5cm but you are still going to see a variation based on lighting conditions and target opbects.

I never got round to trying the modulation circuits R.A.Penfold has in the old books of circuits for robots as I ended up using all sorts of off the shelf detection instead. While range of TV IR is specified as upto 300m you don't really see that with reflected IR for object detection and it's down to 10's of cm's.

I belive the current UK Minisumo champ uses an A/D on the IR reciver and measures the difference between ambiant and IR LED lit. Again range is based upon target and lighting condidtions.

regards,
Colin
 

BeanieBots

Moderator
Absolutely Slurp.
Even with modulation, you can't use it to measure distance very well. You can only determine (to a better degree) if the light you sent out has come back. The max possible threshold "distance" goes up but it is still a function of the reflectivity of the object. It requires very special OPTICS to measure distance with or without complex electronics.
That's why micromouse competitions have very strict rules about the paint used on the walls.
 

MaltiK

Member
Whoever posted the IR Locater from ROBOCLUB, thank you, whoever did edited/deleted the link, but I got the schematic first, I will see how this works, thanks mate!
 
Top