Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Break Beam Sesnor / Optical Encoder

Status
Not open for further replies.

dselect

New Member
Let me first state that I am a newbie to all this stuff and pulling my hair out over it lol. I am trying to make a Break Beam Sensor to be used in an optical encoder. This is just for fun and to learn and this is how I would like to create the encoder. Anyhow, I have the IR emitter and receiver from Radio Shack, a comparator chip, resistors, capacitors, batteries, wires, etc and a breadboard to put it all together. That last part is where I cannot for the life of me figure it out. I run 5V red wire from battery to a resistor (? not exactly sure why but all the schematics did it with at least a 100 ohm resistor) and from there I run power to the emitter (long side) and the short end of it runs to ground. Just to keep it simple I use another 5V for the receiver and do the same thing, 5V to resistor to long end and short end of receiver to ground.

I still am not sure where the output of the receiver is... assuming the receiver allows voltage to flow when it detects an ir signal and does not when it doesn't, I then try to connect the short end of the receiver to one of the inputs on the comparator chip, which I power 5V and set to ground as well. The comparator chip is even more confusing to me. Some say it outputs digital signal of either 1 or 0 depending on if signal A > signal B. Yet I also read it simply acts as a switch, allowing current to flow from its V+ to GRD. If the latter is true, then why does it have an output? As it stands, I connected the short receiver end to input A, and a source I know to be larger, say a 9V battery to input B (? not sure which end to connect here, I'm assuming the + end and let the - end....dangle?). Now the output for the comparator should then not let any voltage through... but it does not matter how I wire the inputs.... I get the same voltage coming through no matter what. I am testing the voltage using a digital multimeter and testing the output of the comparator with the GRD of the comparator. Please help so I can get some sleep tonight lol
 
Let me first state that I am a newbie to all this stuff and pulling my hair out over it lol. I am trying to make a Break Beam Sensor to be used in an optical encoder. This is just for fun and to learn and this is how I would like to create the encoder. Anyhow, I have the IR emitter and receiver from Radio Shack, a comparator chip, resistors, capacitors, batteries, wires, etc and a breadboard to put it all together. That last part is where I cannot for the life of me figure it out. I run 5V red wire from battery to a resistor (? not exactly sure why but all the schematics did it with at least a 100 ohm resistor) and from there I run power to the emitter (long side) and the short end of it runs to ground. Just to keep it simple I use another 5V for the receiver and do the same thing, 5V to resistor to long end and short end of receiver to ground.

I still am not sure where the output of the receiver is... assuming the receiver allows voltage to flow when it detects an ir signal and does not when it doesn't, I then try to connect the short end of the receiver to one of the inputs on the comparator chip, which I power 5V and set to ground as well. The comparator chip is even more confusing to me. Some say it outputs digital signal of either 1 or 0 depending on if signal A > signal B. Yet I also read it simply acts as a switch, allowing current to flow from its V+ to GRD. If the latter is true, then why does it have an output? As it stands, I connected the short receiver end to input A, and a source I know to be larger, say a 9V battery to input B (? not sure which end to connect here, I'm assuming the + end and let the - end....dangle?). Now the output for the comparator should then not let any voltage through... but it does not matter how I wire the inputs.... I get the same voltage coming through no matter what. I am testing the voltage using a digital multimeter and testing the output of the comparator with the GRD of the comparator. Please help so I can get some sleep tonight lol

hi ds,
I think a picture is worth a thousand words, any chance you could post a diagram..?
 
hi ds,
The problem with continuous driven Emitter/Detectors is the ambient light.
The receiver can be easy saturated with ambient light, so that when the path is broken between the Emitter and Detector diodes, the detector will not respond.

I am guessing the comparator is a LM339, 393 or 311.???

What is the path length from Emitter to detector.?

Lots of questions.!
 
It is the LM339; the emitter and detector are positioned very close to each other and I even tested by covering the entire receiver with aluminum foil and also by blocking it from ambient light as much as possible. I did at one point notice a difference of 0.02 V when the receiver was covered vs uncovered. Thanks so much for your quick replies!
 
It is the LM339; the emitter and detector are positioned very close to each other and I even tested by covering the entire receiver with aluminum foil and also by blocking it from ambient light as much as possible. I did at one point notice a difference of 0.02 V when the receiver was covered vs uncovered. Thanks so much for your quick replies!

OK.
I have a rough idea what you have connected up, I will produce a circuit diagram.
 
hi,
Are you able to build a circuit like this.?
If so we can expand the circuit as required, this was done using LTSpice in simulation.

The output is LOW when the IR receiver is detecting the TX IR.

Note: I have shown the pin numbers for a LM393, if you want to proceed let me know.

EDIT:
Showing the LM339 version.
 

Attachments

  • LM393RX1.gif
    LM393RX1.gif
    27.9 KB · Views: 238
  • LM339RX2.gif
    LM339RX2.gif
    27.2 KB · Views: 245
Last edited:
Well I can definitely try... I have to admit that I am very new to all of the symbols but I will have to learn at some point. I am more confused as to how I can test the comparator output. I will try what you have given me tonight and see what happens.
 
OK,
I need a little more from you.
Connect the IR receiver diode and a 100k or 470k in series [as shown ] in circuit, apply 9V to the free end of the resistor and 0V to the detector Anode [as shown]
Measure the voltage across the diode , when lit and dark,,, let me know.
 

Attachments

  • LM393RX1.gif
    LM393RX1.gif
    3 KB · Views: 226
Last edited:
Your IR receiver has only two wires. but most IR receivers have 3 wires. What is its part number?

The output of your IR reciever will never go low since it does not have its 0V pin connected to 0V. Then the A input of the comparator will always be high. Why do you use a 1k resistor in series from the positive supply for the IR receiver?

The B input of the comparator is at 9V so this input will do nothing since it is much higher than the A input will ever be and is much higher than the max input common-mode voltage (1.5V less than its 5V supply). At inputs that are 3.5V or more then the inputs will not work properly.

The datasheet for the comparator shows that its output is the collector of an NPN transistor that pulls a load to ground. It needs a resistor (its minimum current is only 6mA) connected to the 5V supply to make it go high.
 
Thank you everyone for the help so far. I am happy to say that I was able to get the comparator working last night. Never thought I would literally jump for joy at the sight of an LED going on/off. Your help and this picture are to thank:

**broken link removed**

Basically, I was assuming that the V+ and V- inputs on the comparator meant the + side of one battery and the - side of another for comparison. I then realized that V+ and V- are just variables representing two signals that the comparator compares. So I used the + side from both batteries, one 9V and the other 5V. Then I learned, mainly by tracing the wires on the picture, that everything needs to be grounded to the ground pin on the comparator. I also learned from a book by David Cook I have, that the Output of a comparator, at least in my interpretation, is not really outputting anything, but rather a switch which allows current to flow and complete a circuit or does not allow current to flow and complete a circuit. So my LED went from the same power source as the comparator, and was grounded to the comparator output pin. I used a 1K resistor between power for my LED, but it worked without the resistor as well. Boom! Everything worked. Now I know that it working does not necessarily mean that I did it the 100% correct way, but I am glad at least to have gotten SOMETHING working. I am guessing I made the same mistake with the grounding of the IR receiver, as audioguru pointed out. I am using an IR emitter/detector from radio shack.

**broken link removed**
 
hi ds,
The 1458 is a dual amplifier, not really a comparator.

Looking at your diagram I will post a pictorial view of the project board, you have gone a little OTT with your batteries.:D

EDIT:
From your pic of the diodes your not using a 'IR receiver' but a simple detector diode.
 
Last edited:
hi ds,
Look at this option.
 

Attachments

  • Image1.png
    Image1.png
    35.5 KB · Views: 230
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top