Go Down

Topic: IR Phototransistor pinout/hookup question (Read 15364 times) previous topic - next topic

interestingfellow

I'm trying to build an optical tachometer with a nano and IR components salvaged from an old ps2 ball mouse.

I have it set up and working on a breadboard, but I don't understand why the electrical connections on the IR phototransistor are working.

I had found several web pages that said you can hook up only the collector and emitter to generate a pulse when IR is detected, but couldn't get that to work.  I came to the arrangement in the picture by accident.

I have the collector current limited with a 150 ohm resistor and tied to ground with another 150ohm resistor, and the signal pin pulled high* with a 47k to the nano (because that's what I had lying around).
I was using another LED on the ouput of the IR detector (no 47k) to try to figure out the proper pinout of the phototransistor and accidentally figured out that the LED flashed signifigantly brighter with gnd tied to vcc. Why?

Should I have things hooked up differently?  I am using the code on this page to test the setup for now; KISS.





*I'm new to all this and think that is the proper term for what is going on

OldSteve

#1
Nov 13, 2015, 07:35 am Last Edit: Nov 13, 2015, 07:37 am by OldSteve
Quote
I have the collector current limited with a 150 ohm resistor and tied to ground with another 150ohm resistor
Do you? I don't see anything going to ground on the breadboard except the 47K resistor.

Quote
and the signal pin pulled high* with a 47k
Looks like it's pulled low to me.

I'm assuming that you're using the breadboard's red rail for +5V, and it's blue rail for 0V. Correct me if I'm wrong.
If I'm right, your description doesn't match the circuit on the breadboard.

If it's an IR photo-transistor, you connect the emitter to ground, connect the collector to the +5V rail through a pullup resistor, then take your output to the Arduino from the collector. It will go low when it receives IR input.
Please do not PM me for help. I am not a personal consultant.
And others will benefit as well if you post your question publicly on the forums.

TomGeorge

Hi,
Is there a part number on the IR transistor?

Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

interestingfellow

Tom, no, that would be way too easy! ;D

Oldsteve,
Now that I look at it again, the 47k resistor *is limiting the output of the phototransistor, so that would be a pull down, yes?
Yes, blue gnd and red 5v+.
How is the 150ohm resistor from vcc a pullup resistor and not just limiting current to the phototransistor? is it limiting current to the phototransistor?
The way it's hooked up now, it goes high when it receives ir input (i tried with the ir led I have and also the tv remote).  Is it common for phototransistors to be normally open or normally closed?

OldSteve

#4
Nov 13, 2015, 05:24 pm Last Edit: Nov 13, 2015, 05:27 pm by OldSteve
How is the 150ohm resistor from vcc a pullup resistor and not just limiting current to the phototransistor?
Do you know anything at all about phototransistors?
For one thing, they don't have Vcc, GND and OUT pins as you've labelled them. Usually, they have two pins, emitter and collector. Sometimes, the base is also drawn out to a pin. You don't need to connect to that at all.
As I mentioned earlier, usually the collector connects to the +ve supply via a pullup resistor, and the output is also taken from the collector. The emitter connects directly to ground. This is a 'common-emitter' configuration, no different to a normal transistor circuit, except light operates it rather than current into the base.

They can also be connected in 'common-collector' configuration, with the collector connected directly to the +ve supply, a pulldown resistor from the emitter to ground, and the output taken from the emitter. This is what you have put together, but you have an additional 150 ohm resistor between collector and the +ve supply, reducing the transistor's gain. And another 150 ohm resistor that seems to do nothing?

Quote
is it limiting current to the phototransistor?
The way it's hooked up now, it goes high when it receives ir input (i tried with the ir led I have and also the tv remote).  Is it common for phototransistors to be normally open or normally closed?
Rather than waste further time with explanations, I've drawn up a diagram. (A bit of reading would have explained all of this.)



The common-emitter circuit goes low in the presence of IR, the common-collector circuit goes high in the presence of IR.

All of this is based on the assumption that it's an NPN transistor. If it's PNP, the connections are reversed.
I also assume that it's a standard phototransistor as you claim, and doesn't have additional internal circuitry like an amplifier.
Please do not PM me for help. I am not a personal consultant.
And others will benefit as well if you post your question publicly on the forums.

interestingfellow

If a bit of reading were all it took for anyone to understand anything, then colleges, teachers, tutors, and forums would all be very unnecessary.

No, I know very little about electrical engineering when compared to most of the people on this forum. 

But, I do very much appreciate you taking time to answer my questions, and helping me better understand what I was missing.

Really: thank you.

OldSteve

If a bit of reading were all it took for anyone to understand anything, then colleges, teachers, tutors, and forums would all be very unnecessary.
Often, that's true, but in this case all you had to do was google "phototransistor circuit" or similar. Still, not to worry, you know how they work now. (Didn't mean to sound rude, but my patience gets stretched a little sometimes. :)

Quote
No, I know very little about electrical engineering when compared to most of the people on this forum.
You're one step further up the ladder now. 

Quote
But, I do very much appreciate you taking time to answer my questions, and helping me better understand what I was missing.

Really: thank you.
No problem.
Please do not PM me for help. I am not a personal consultant.
And others will benefit as well if you post your question publicly on the forums.

interestingfellow

#7
Nov 17, 2015, 04:35 am Last Edit: Nov 17, 2015, 04:37 am by interestingfellow
OldSteve....I'm sorry for being a noob and asking noob things, but I'm stuck.

After tinkering quite a bit with the salvaged components unsuccessfully, I decided to eliminate potential problems 1 at a time.  I bit the bullet and bought an IR emitter/detector set from radiocrack and I still can't get this breadboard and sketch to work.  I tried both common emitter and collector arrangements that you provided above, and am going insane trying to figure out why it won't work.
AND, I did read several sources on my own trying to figure it out, but I'm still missing something.

When I use the code below:
Code: [Select]
void setup() {
  pinMode(4,INPUT);
  Serial.begin(9600);
}
void loop() {
  Serial.println(digitalRead(4));
  delay(100);
}


In common collector configuration, I get only "1" (high) over the serial monitor unless I unplug the phototransistor, and then it changes to "0".

In common emitter configuration, I get only "0"(low) in the serial monitor.  .  The only way I can see a change in serial monitor is if I unplug the sense wire to pin 4 and short it to the vcc rail.

I have verified that the IR led is emitting using my phone camera.
I have verified polarity of the emitter and the detector.
I have tried only 1 150ohm resistor driving the emitter to make it brighter.
I have tried 47k, 1k, and 150ohm on the detector in both configurations.
And, of course, I have tried it with the lights in the room on and off.
I used a hotel keycard in the paper sleve to block the emitter.
I also tried removing the emitter completely.
And I still get the same results.

Wth am I doing wrong?

OldSteve

#8
Nov 17, 2015, 06:02 am Last Edit: Nov 17, 2015, 06:11 am by OldSteve
OldSteve....I'm sorry for being a noob and asking noob things, but I'm stuck.

After tinkering quite a bit with the salvaged components unsuccessfully, I decided to eliminate potential problems 1 at a time.  I bit the bullet and bought an IR emitter/detector set from radiocrack and I still can't get this breadboard and sketch to work.  I tried both common emitter and collector arrangements that you provided above, and am going insane trying to figure out why it won't work.
AND, I did read several sources on my own trying to figure it out, but I'm still missing something.

When I use the code below:
Code: [Select]
void setup() {
  pinMode(4,INPUT);
  Serial.begin(9600);
}
void loop() {
  Serial.println(digitalRead(4));
  delay(100);
}


In common collector configuration, I get only "1" (high) over the serial monitor unless I unplug the phototransistor, and then it changes to "0".

In common emitter configuration, I get only "0"(low) in the serial monitor.  .  The only way I can see a change in serial monitor is if I unplug the sense wire to pin 4 and short it to the vcc rail.

I have verified that the IR led is emitting using my phone camera.
I have verified polarity of the emitter and the detector.
I have tried only 1 150ohm resistor driving the emitter to make it brighter.
I have tried 47k, 1k, and 150ohm on the detector in both configurations.
And, of course, I have tried it with the lights in the room on and off.
I used a hotel keycard in the paper sleve to block the emitter.
I also tried removing the emitter completely.
And I still get the same results.

Wth am I doing wrong?
For one thing, an IR LED has a Vf of about 1.2V to 1.5V. Allowing for 1.2V, that means there will be 3.8V across the resistance.
An IR LED should be driven with much more current than a standard LED. Most want about 100mA continuous.
3.8V/100mA=38 ohms. So for maximum brightness from a constantly on IR LED you could be using a 39 ohm resistor, instead of the pair of 150 ohm resistors. At the moment, you only have 11mA going through the LED.
(You should double-check the datasheet of the IR LED, for Vf and for continuous current rating, then select a resistor accordingly.)

I can't see your photo-transistor well, but you say "flat=cathode". A photo-transistor doesn't have a cathode, only a collector and an emitter, (if it's 2-pin). still, assuming you have the emitter to ground, with a resistor to +5V, and the output taken off the collector, it should go low when exposed to IR.

And although weak, I would have thought that since the IR LED and the IR photo-transistor are so close together, it would still work. Try a much smaller resistor on the IR LED, between 39 ohms and 100 ohms, (check the datasheet first for specs), and change the 47K resistor on the photo-transistor to 4K7, or even 2K2. 47K is a bit too high a value.

I don't know what else to suggest if that fails. This is so simple, that if connected properly nothing can really go wrong, unless the phototransistor has been shorted/overloaded and is dead. Did you buy several? If so, try another. If not, you should have. :) Putting 150 ohms on the collector as a load resistor wasn't a good idea. That's 33mA, and they're not typically rated anywhere near that high. Good chance it is dead. Edit: Correction, it's probably not dead - since in CE configuration, it stays low, it's staying switched 'on'. A dead transistor usually goes open and would stay high with a pullup resistor.
Don't just try random values on things - everything must be calculated, according to the datasheets.

Of course, this setup, even when working, is no good for any practical purpose, since it's not immune to ambient light/remote controls/fluorescent lights.
Ideally, you would drive the IR LED with a 38kHz or 40kHz carrier, modulate that carrier with codes, then use an IR receiver to 'demodulate' the carrier leaving just the codes (inverted). That's how an IR remote control does it.

By coincidence, I'm working with an IR LED and a receiver myself today, making an IR homing beacon and receiver for my robot car. (Using a 38kHz carrier and demodulating receiver.)
Please do not PM me for help. I am not a personal consultant.
And others will benefit as well if you post your question publicly on the forums.

liuzengqiang

I'm a little puzzled. I have some IR stuff. The emitter is not painted black and the phototransistor is usually painted black. An IR LED sees visible and UV as well as IR so if it's not painted black, it will respond to room light. With what you have, you seem to have swapped the IR LED and the phototransistor. You have with the black one two 150 ohm resistors meaning you treated it as an IR LED. I thought at was wrong.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

OldSteve

#10
Nov 17, 2015, 10:59 pm Last Edit: Nov 17, 2015, 11:07 pm by OldSteve
I'm a little puzzled. I have some IR stuff. The emitter is not painted black and the phototransistor is usually painted black. An IR LED sees visible and UV as well as IR so if it's not painted black, it will respond to room light. With what you have, you seem to have swapped the IR LED and the phototransistor. You have with the black one two 150 ohm resistors meaning you treated it as an IR LED. I thought at was wrong.
My IR LEDs are dark-coloured, but not completely black, (I'm using one here right now). I don't think his is 'black' either, I think it's just the light. Also, he did say "I have verified that the IR led is emitting using my phone camera."

Quote
the phototransistor is usually painted black
Usually, but not always. I have some IR photo-transistors here that are in a water-clear case.
See here:- Infrared Phototransistor
And I already said "since it's not immune to ambient light /remote controls/fluorescent lights."

Please do not PM me for help. I am not a personal consultant.
And others will benefit as well if you post your question publicly on the forums.

polymorph

Yes, there is still some IR in other sources of light.
Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8
Multitasking: forum.arduino.cc/index.php?topic=223286.0
gammon.com.au/blink - gammon.com.au/serial - gammon.com.au/interrupts

liuzengqiang

OK I didn't catch the "checked with camera part". Then paint the water clear phototransistor black already! I would use a black wet-erase marker and go over it several times. Let it dry and do another coating :) One of my POV displays was made using IR sensing. Now I remember the phototransistor was clear.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

OldSteve

OK I didn't catch the "checked with camera part". Then paint the water clear phototransistor black already! I would use a black wet-erase marker and go over it several times. Let it dry and do another coating :) One of my POV displays was made using IR sensing. Now I remember the phototransistor was clear.
You're still right that this is puzzling. He did say that he's tried it with the lights off. And despite the fact that the IR LED series resistance is way too high at 300 ohms total, at that range it should still work.
I reckon the photo-transistor must be a dud, or possibly not really a photo-transistor. I got some water-clear IR LEDs from eBay last week, and when I tested them yesterday, they were normal red (visible) LEDs - refund pending. :D

And just as a final bit of proof regarding the dark-coloured IR emitter LEDs, I've attached a pic of the one I'm currently using. In my pic, you can see that it's not completely black, but very dark.
Please do not PM me for help. I am not a personal consultant.
And others will benefit as well if you post your question publicly on the forums.

polymorph

It makes no difference the color of the case of the LED - only the receiver. You want it to appear black, because that is an IR pass/visible block filter.

liudr, are wet erase black markers transparent to IR?

I would just buy an IR phototransistor. If it doesn't have a black casing, it isn't only IR.

Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8
Multitasking: forum.arduino.cc/index.php?topic=223286.0
gammon.com.au/blink - gammon.com.au/serial - gammon.com.au/interrupts

Go Up