Go Down

Topic: my photodiode doesn't seem to detect anything (Read 2130 times) previous topic - next topic

iridium239

alright, so I think i have my circuit right but my photodiode still won't detect anything.  I think its in my software because i can't seem to get it to work.  

my circuit is an LED to pin 9 (i can make it blink it works fine)  IR LED to pin 2 ( it works, checked with digital camera)  and a photodiode wired as follows-- 5V+  to - diode on photodiode then from the + diode to a resistor then from the resistor to analog input pin 1.



int ledPinGreen = 9;
int sensorPin = A1;
int sensorState = 0;

void setup() {                
 // initialize the digital pins as an output.
 pinMode(2, OUTPUT);
 pinMode(ledPinGreen, OUTPUT);
 pinMode(sensorPin, INPUT);
}

void loop() {
 
   digitalWrite(2, HIGH);   // set the LED on
   
   sensorState = analogRead(sensorPin);
 
   if (sensorState > 10) {
     digitalWrite(ledPinGreen, HIGH);
   }
     
   else  {
     digitalWrite(ledPinGreen, LOW);
   }  

}

what am i doing wrong???  

retrolefty

Quote
and a photodiode wired as follows-- 5V+  to - diode on photodiode then from the + diode to a resistor then from the resistor to analog input pin 1.


That doesn't sound correct, but it would be better if you could draw it out. The should be a path from ground, through the resistor and photodiode and +5vdc. Then you just tap off from the diode end of the resistor to an analog input pin. Even that may not work depending on the resistor value and the specific photodiode you are using (datasheet link?). A phototransistor may be a better device to use.

Also are you using current limiting resistors in series with the other leds you are wiring to output pins, hopefully?

Again a schematic drawing is worth a thousand words in helping problem like this. It is the universal language of electronics.

Lefty

iridium239

Will do as soon as I get back home. How bout a diagram and an actual picture.


iridium239

#4
Nov 14, 2010, 04:16 am Last Edit: Nov 14, 2010, 04:17 am by iridium239 Reason: 1
here is the spec sheet


Features

IR LED (TSFF5210 - Vishay Semiconductors)
Package type: leaded
Dimensions : ø 5mm
Leads with stand-off
Peak wavelength: [ch955]p = 870 nm
High reliability
High radiant power
High radiant intensity
Angle of half intensity:  = ± 10°
Low forward voltage
Suitable for high pulse current operation
High modulation bandwidth: fc = 24 MHz
Good spectral matching with Si photodetectors

IR Photodiode (BPV10NF - Vishay Semiconductors)
Package type: leaded
Dimensions : ø 5mm
Leads with stand-off
Radiant sensitive area (in mm2): 0.78
High radiant sensitivity
Daylight blocking filter matched with 870 nm to 890 nm emitters
High bandwidth: > 100 MHz at VR = 12 V
Fast response times
Angle of half sensitivity: ± 20°

Folderol

#5
Nov 15, 2010, 11:34 pm Last Edit: Nov 15, 2010, 11:36 pm by zaphil Reason: 1
Junction of photo diode and resistor should go to A1.
Free end (now) of resistor should go to ground.

Can't see from the picture what this resistor value is. A good starting value would be 100k.

Everything else looks OK.

You might need to play about with this value, and also the switching value obtained from the analog read.

Folderol


Jogi

Dear iridium, (and others with similar problems)

first you should know a little bit about the basics !

1.) When you connect an IRED or LED (or whatever) to an output pin of the Arduino (ATmega), you should be aware, that the current, that might flow, is within the bounds, of what the ATmega could handle !

The absolute maximum rating for the DC current of an ATmega output is 40mA (and when watching the graphs for some output characteristics, you will notice, that they all stop at 20mA !). So be aware, not to go any further.

To calculate the current (YES, you should do some calculations to prolong the life of your Arduino) through the IRED, you have to know the voltage over the IRED, when a current will go through (Sorry for my English; I'm German ...).
You will find this in the datasheet of the IRED => typ. 1.5V at 100mA.

Now you can take a look in the ATmega datasheet and you can find out, that the output voltage at 20mA will be around 0.5V at LOW and about 4.5V at HIGH.

That's all what you need: 4,5V output going to the resistor going to the IRED (which looses 1,5V here), which is connected on the other side to ground (=0V).

The current is I=U/R  - For "U" you should calculate, which voltage will be over the resistor. That is 4.5V - 1.5V = 3.0V

When looking at your picture, it seems, that you are using 8.2 Ohm resistors all over, right ? (color code: grey/red/golden/golden => grey=8, red=2 gold=multiplier 1/10 and last gold for the tolerance of the resistor (here ±5%; but don't care)).

Let's calculate the current => I=3V/8.2 Ohm = 0,366A = 366mA (uuups)

You can easily see: that's much to much for the ATmega and for your IRED (max. current=100mA continuous)  !!!
(By the way: If your Arduino would be strong enough to handle such currents, your IRED and also your LEDs will be gone - and they might be !). Your LEDs can take about 20mA; even 10mA will be enough to see them shining.

To calculate the correct resistor for the IRED you use "R=U/I"

 => R=3V/20mA = 3V/0.02A => R= 150 Ohm = brown/green/brown/gold or silver

If you want to push more current through the IRED, you should use a driver like the ULN2803 or other things to amplify the current. For your first experiments, 20mA will be a enough.


2.) To connect a photo diode or a photo transistor to the Arduino, you should know, that the input resistance of an input pin of the ATmega is quiete big (and anyway not inevitably the same at each ATmega type and might fluctuate with the temperatur and and and ...).

When connecting the photo diode directly from 5V to an input pin, this input pin will probably just go up to 5V (or whatever), as there is nearly no current flowing into the input. To get a reliable reading out of the photo diode, you have to get a little but noticable and reproducible current (for bigger currents use a photo transistor) flow through the photo diode and use the ATmega to measure this current. But: The ATmega is only able to measure a voltage, so you better let the current flow through a resistor (same what Folderol said already). That mean, that you have to connect the photo diode and a resistor in a row from 5V to 0V and put the input pin of the ATmega just to the middle (=to the connection point of photo diode and resistor). For the resistor, you have to choose a pretty big one to keep the current low enough. I don't know, what the photo diode can take or deliver, but start with less than 0,01mA. So the 100,000 Ohm or even more for the resistor are the choice to take (a lttle bit "Try and Error" is the way to go here), but never 8.2 Ohm !


3.) Take into consideration, that
a) your Arduino might be completely dead  - or -
b) might be dead on just the output pins you used  - and/or -
c) your IRED is dead - and/or -
d) your LEDs are dead.

Before you try any other things, you should clarify, which of your "toys" is still alive. If you are lucky, all parts survived, because the Arduino was very gentle to you - but don't count on that ...


Best Regards  Jogi
_______________
You haven't failed, until you've given up.

Go Up