Offline
Sr. Member
Karma: 0
Posts: 451
I am a amateur.
|
 |
« on: June 21, 2012, 03:48:54 pm » |
Hello! I know that LEDs can produce a voltage when light shines on them. First, I connected the cathode (short pin) of my LED to the black lead of the multimeter, and the anode (long pin) to the red lead of the multimeter. I shined a flashlight on a green LED, and the voltage was >0.2V on the multimeter. Next, I connected my LED's cathode to Arduino's GND and anode to analog input A0. I used the default voltage reference, and did this operation on the analogRead() of the pin. voltage = rawADC * 5.0 / 1024.0;
I shined the same flashlight on the LED and the voltage was >1.5V! I tested it on my multimeter again. Why does the Arduino read the voltage as about 1.5V when the multimeter reads it as about 0.2V? Thanks!
|
|
|
|
|
Logged
|
|
|
|
|
Massachusetts, USA
Offline
Tesla Member
Karma: 96
Posts: 6372
|
 |
« Reply #1 on: June 21, 2012, 04:06:32 pm » |
Perhaps they have different input impedance.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 3
Posts: 1712
|
 |
« Reply #2 on: June 21, 2012, 04:14:19 pm » |
A depending on how directly you shine the light the multimeter definetly has too low impedance, unless you have a good one Take a peak with an oscilloscope, (1M impedance usually) and add large value resistors in parallel and watch the responses, its pretty cool the best thing you can do is use an opamp so the measuring impedance doesn't affect it also use a blue led or white and you'll get 3v full brightness,
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 0
Posts: 451
I am a amateur.
|
 |
« Reply #3 on: June 21, 2012, 04:19:00 pm » |
What is "input impendance"? Perhaps the LED's cathode potential is at +1.3 and the anode potential is at +1.5? The Arduino GND brings the cathode potential to 0, so the analogRead() result is 1.5V? I don't have an oscilloscope. I don't know how to use op-amps, and which op-amp to use.
|
|
|
|
|
Logged
|
|
|
|
|
Austin, TX
Offline
Faraday Member
Karma: 41
Posts: 5172
CMiYC
|
 |
« Reply #4 on: June 21, 2012, 04:50:13 pm » |
Input impedance: Your multimeter looks like a 100k or 1M resistor to the LED.
The Amalog Input looks like a 10k. correction from mike below.)
Also, you're using such a few number of bits on the a/d you'll have quantization error. You might try using the INTERNAL analogReference() which is 1.1V instead of 5.
|
|
|
|
« Last Edit: June 21, 2012, 07:50:21 pm by James C4S »
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 0
Posts: 451
I am a amateur.
|
 |
« Reply #5 on: June 21, 2012, 04:52:22 pm » |
Before posting, I also tried the 3.3V reference. The results were the same. But how come the Arduino can measure the voltage of an AA battery properly?
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 277
Posts: 25501
Solder is electric glue
|
 |
« Reply #6 on: June 21, 2012, 05:18:57 pm » |
The Amalog Input looks like a 10k. No you are mixing up the idealise source impedance with the actual input impedance. An arduino is likely to be in the range of 1M or so. But how come the Arduino can measure the voltage of an AA battery properly? Because the battery has a very low output impedance. That is it can supply far more current than an LED given the same voltage. It is rather like the difference between temprature and heat. A spark has a very high temprature but there is very little heat in it. So one can land on your hand with little damage. A cup of boiling water is about 100 times cooler than a spark but has much more heat ( specific heat ) so it burns you far more seriously.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
God Member
Karma: 9
Posts: 775
|
 |
« Reply #7 on: June 21, 2012, 06:46:15 pm » |
I don't know anything about using LEDs as light sensors... I would guess it's unreliable or it would be done more often...
The simplest way to eliminate the impedance issue is to hook-up the multimeter and the Arduino at the same time.
If the LED is acting like a high-impedance voltage source (like I said, I don't know), you could be picking-up noise. (The noise should be about the same with the light shining on it or not.)
It's likely that the multimeter has some filtering to smooth-out noisy readings. So with a noisy signal, the meter reading could be lower and more stable even if they are both reading the exact same voltage at the exact same time. (If you had an oscilloscope you could see if there is noise.)
|
|
|
|
« Last Edit: June 21, 2012, 07:14:19 pm by DVDdoug »
|
Logged
|
|
|
|
|
Anaheim CA.
Offline
Edison Member
Karma: 31
Posts: 2308
Experienced old Whitebeard with a Full head of Hair...
|
 |
« Reply #8 on: June 21, 2012, 07:10:32 pm » |
and note if the Arduino's response changes, should you measure a different voltage with the Arduino connected you will have your answer...
Doc
|
|
|
|
|
Logged
|
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
|
|
|
|
Offline
Edison Member
Karma: 3
Posts: 1712
|
 |
« Reply #9 on: June 21, 2012, 07:39:10 pm » |
Unless you are shining a light directly into it very brightly the led will only put out 4mv with ambient light kinda cool you can see the switching frequency of flourescent bulbs with an led detecting ambient light and an oscilloscope
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 0
Posts: 451
I am a amateur.
|
 |
« Reply #10 on: June 21, 2012, 07:57:41 pm » |
kinda cool you can see the switching frequency of flourescent bulbs with an led detecting ambient light and an oscilloscope I'm not sure if the LED responds fast enough. Another way to to measure light with an LED is to hook it up backwards (anode to GND, cathode to digital pin). First, the digital pin turns into output and HIGH. That will charge up the LED's "parasitic capacitor". Then, the pin switches to input, and the Arduino times how long the "parasitic capacitor" takes to discharge. In complete darkness, it can be more than a second, but in direct bright light, it takes only about 0.02 seconds. I got that from http://provideyourown.com/2011/cheap-alternative-for-hard-to-find-cds-light-sensor/. This is the code: class AmbientLightSensor { public: AmbientLightSensor(int ledPin) : mLedPin(ledPin), mMeasureAnalog(false) {} void setAnalogMeasurement(int thresholdLevel); // measure from an analog pin void setDigitalMeasurement(); // measure from a digital pin (default) int measure();
protected: int mLedPin; bool mMeasureAnalog; int mAnalogThresholdLevel; // (0 to 1023) void charge(); void discharge(); int measureUsingAnalogPin(); int measureUsingDigitalPin(); }; void AmbientLightSensor::setAnalogMeasurement(int thresholdLevel) { mAnalogThresholdLevel = thresholdLevel; mMeasureAnalog = true; } void AmbientLightSensor::setDigitalMeasurement() { mMeasureAnalog = false; } void AmbientLightSensor::charge() { // Apply reverse voltage, charge up the pin and led capacitance pinMode(mLedPin, OUTPUT); digitalWrite(mLedPin, HIGH); } void AmbientLightSensor::discharge() { // Isolate the diode pinMode(mLedPin, INPUT); digitalWrite(mLedPin, LOW); // turn off internal pull-up resistor, see http://arduino.cc/en/Tutorial/DigitalPins } int AmbientLightSensor::measure() { charge(); delay(1); // charge it up discharge(); return (mMeasureAnalog)? measureUsingAnalogPin() : measureUsingDigitalPin(); } int AmbientLightSensor::measureUsingDigitalPin() { long startTime = millis(); // Time how long it takes the diode to bleed back down to a logic zero while ((millis() - startTime) < 2000) { // max time we allow is 2000 ms if ( digitalRead(mLedPin)==0) break; } return millis() - startTime; } int AmbientLightSensor::measureUsingAnalogPin() { long startTime = millis(); // Time how long it takes the diode to bleed back down to a logic zero while ((millis() - startTime) < 2000) { // max time we allow is 2000 ms if ( analogRead(mLedPin) < mAnalogThresholdLevel) break; } return millis() - startTime; } AmbientLightSensor led(12); // LED is hooked up to digital pin 12 int led2 = 9; // led to indicate darkness is hooked up to digital pin 9 void setup() { Serial.begin(9600); pinMode(led2, OUTPUT); }
void loop() { analogWrite(led2, map(constrain(led.measure(),0, 400), 0, 400, 0, 255)); Serial.println(led.measure()); } This way is more sensitive, but slow responding and note if the Arduino's response changes, should you measure a different voltage with the Arduino connected you will have your answer... What?
|
|
|
|
|
Logged
|
|
|
|
|
Anaheim CA.
Offline
Edison Member
Karma: 31
Posts: 2308
Experienced old Whitebeard with a Full head of Hair...
|
 |
« Reply #11 on: June 21, 2012, 08:19:07 pm » |
Yeah it is also an issue as the Fluorescent Lights actually turn off and on 60 times a second and this has to be filtered for some light detection schemes. My employer was an engineer, he came to me one day and explained that a photo detector he made "Hummed" but only at night and when I got through chuckling I told him to put a 100 uf cap on the output of the detector switch and add a diode and resistor to discharge the cap.... I made a color detector 25 years ago that fit in a hollow cane (aluminum tubing) for the blind... It would work nicely at night to detect which traffic light was on, Red, Yellow or Green. I used the 60 hz signal on the led's output to detect the traffic light but it was easily "Falsed" by Neon signs. LED's are much higher in intensity and sensitivity is much better now. I have a night light that uses 170uA and works well on a 2032 Lithium coin cell so I don't kill myself going to the WC at night. But with 35 - 40 mA driving it it makes a great blue flashlight... too bright for me to sleep. 20 Candela's advertised (20,000 milli candelas) and about $0.10 each. An LMC6022 and a couple of resistors makes a nice, Very low current photo-detector that will swing rail to rail from a 9V battery. Great @ 5V too I used them a lot.
Doc
|
|
|
|
|
Logged
|
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
|
|
|
|
Offline
Edison Member
Karma: 3
Posts: 1712
|
 |
« Reply #12 on: June 22, 2012, 06:17:57 am » |
Well I know the led responds fast enoughbecause I've seen it, lol not only the 60hz but the multiple Khz switching frequency, which we would never see fluctuating with our eyes but the led can see
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 0
Posts: 451
I am a amateur.
|
 |
« Reply #13 on: June 22, 2012, 02:43:05 pm » |
Well I know the led responds fast enoughbecause I've seen it, lol not only the 60hz but the multiple Khz switching frequency, which we would never see fluctuating with our eyes but the led can see
I meant detecting light, not lighting up.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 3
Posts: 1712
|
 |
« Reply #14 on: June 22, 2012, 03:25:40 pm » |
Well yeah, I mean with just an led hooked up to an oscope, you can see the switching frequency of the flourescent, from that led detecting it
|
|
|
|
|
Logged
|
|
|
|
|
|