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.

Light sensor with LED's

Status
Not open for further replies.

mcs51mc

Member
After reading a thread started by "The Mad Professor" I start to experiment with this light-sensing-LED-thing. You can find the original thread here: https://www.electro-tech-online.com/threads/now-thats-a-project.22064/

Circuit:
You can see the circuit I made in attached file "Circuit.jpg"

Measurements:
With a multimeter between Vout and GND one can measure:
1) +4.996V (Vcc) in full light.
2) Decreasing voltage with decreasing light intensity.
3) +2.514V (Vcc/2 ?) with LED’s completely covered.

So everything is looking good, decreasing light intensity equals decreasing voltage.

I feed a TLC549 ADC with this output voltage, write some code for a 80C31 µP and put the readings on a LCD display. What I saw on the LCD?
1) Fixed data 255 in full light.
2) Continuous varying data between 0 and 255 with decreasing light and no light at all.

I then placed a scope on Vout and that’s what I saw, very weird…
You can see the signals in attached file "Signals.jpg"

Questions:
These measurements solved the 0 and 255 ADC readings on the LCD but bring even more questions on. So, can some explain these signals to me?
1) Why constant Tlow= 5ms as long as 0 volt isn’t reached and then increasing from 5 to 10ms with Vout= 0V and still decreasing light?
2) Where is the 50Hz signal (no light) coming from? During the measurements, no power line light sources where on, only bright constant sunlight. Don’t tell me the sun is pulsing at 50Hz…
3) Are these signals typical for LED’s or is there something wrong with my opamp circuit? Even with other LED’s, red and green one’s, the same type of signals but with lower levels…
4) What do I need to “convert” such a signal to an averaged signal and stable ADC readout like the one on my multimeter (filter, caps, …)?
5) All suggestions to read such a signal in a µP with an ADC are welcome… …

Thanks for any reaction...
 

Attachments

  • Circuit.jpg
    Circuit.jpg
    75.8 KB · Views: 3,515
  • Signals.jpg
    Signals.jpg
    105.8 KB · Views: 1,973
What's your construction like?, it sounds like it may be picking up mains hum, is it built using shortest possible leads, and in a grounded metal box?.
 
I have two, both reacting the same way. One soldered on prototyping board, so very short leads, and one on a bread board, max lead length let say 5cm.
None of them are inside a metal box. I placed the prototyping board one in a plastic IP55 housing of a mains power outlet with the led's coming out of the three whole's (2 for power and 1 for earth).
It's powerd from mains 220Vac, transfo to 18Vac and finally 24 to 5V DC/DC converter.
So far for my construction...

"Picking up mains hum": never thought about that because of the varying Tlow. As long as the signal didn't reach 0V, Tlow is 5ms and Thigh is 15ms. Only when the output signal reach 0V Tlow start to increase to 10ms while Thigh decrease from 15 to 10ms. Writing this i'm realising that the period is always 20ms. So "mains hum"... possible.
You know what? I will power the circuit from a 9 V battery and 7805 and let you know about the outcome.

To be countinued :)
 
New measurements...

I removed the second opamp and did some measurements with only the first one battery and power supply operated.

The output of the first opamp is a DC signal varying from 4 to 450mV in ambient light with a 80mV peak to peak 50Hz ripple on the DC voltage.
How do I get rid of that ripple?
Btw: With a 60W lamp above the led's the output goes to 4.941V.

When I move my hand nearby the 20MOhm resistor that ripple get bigger. I then put some insulation tape tape on the resistor and wrap it in aluminium foil with the idea of making some shielding around that resistor. Even with the foil connected to ground, it was worse more ripple. So far for my shielding capability.
Any better ideas?

Let say I’m only interested in the range 0 to 250mV.
What is the right way to amplify that range to a 0 to 5V range and avoiding the problems I described in my previous post?

Thanks a lot for any suggestions…
 

Attachments

  • Circuit-2.jpg
    Circuit-2.jpg
    32.3 KB · Views: 1,251
eventhough the ckt is powered by bat: supply , if u stand near it, it can introduce 50Hz (u'll be acting like antenna) . so my suggestion ,power the ckt with a batt: , move the ckt as far as away from any ac power sources and you yorself keep a distance from , and monitor the cro. one more thing do u actualy need the 20M res ?, try it replacing with a 1M or 3.3M which will be sufficient to generate an o/p, also experiment with keep only 1 IR diode.
 
I have the answer!!

If your using a light source powered by the mains the source is actually flickering at 50Hz so your LED is picking this up, it might not look like it flickers to us but persistance of vision is the reason, use a torch or light source that runs of DC to test your circuit.:)

I was re-reading this thread and suddenly the answer hit me, it's so simple.

hope this helps:)
 
If your using a light source powered by the mains the source is actually flickering at 50Hz
he may be using an incandescent bulb, it won't flicker at 50Hz due to thermal inertia.
But that is a point to be noted by OP.
..Btw: With a 60W lamp above the led's the output goes to 4.941V...
 
akg said:
he may be using an incandescent bulb, it won't flicker at 50Hz due to thermal inertia.

He specified in the original post, that there were no electric lights turned ON, just sunlight.

In any case, incandescent bulbs do flicker at the mains frequency, they obviously don't go fully ON and OFF, due to thermal inertia, but their brightness does vary considerably at the mains frequency.

This effect is used for turntable strobe disks, for setting the speed accurately - incandescent lights work better than flourescent for this, and we used to have a table lamp specially for illuminating the strobe disk.
 
Amplification ?

akg said:
eventhough the ckt is powered by bat: supply , if u stand near it, it can introduce 50Hz (u'll be acting like antenna) . so my suggestion ,power the ckt with a batt: , move the ckt as far as away from any ac power sources and you yorself keep a distance from , and monitor the cro. one more thing do u actualy need the 20M res ?, try it replacing with a 1M or 3.3M which will be sufficient to generate an o/p, also experiment with keep only 1 IR diode.
I already experiment with 1, 2 and 3 diodes and several xM resistors. I used the actual configuration because I had the best signal out of the first opamp (around 500mV).
Then I added the second opamp to boost it to 5V to feed it into an ADC.

I think something went wrong adding that second opamp also. If you compare both circuits you will notice that pin 3 of the first opamp was first connected to ground and then to Vcc/2.
I did that because the output of the second opamp always kept the same level (can't recall 0 or 5V) even with a varying input signal. I think the design of the second opamp is not good but don't know how to make it good :(
What is the right connection for the second opamp to boost that 500mV signal to 5V using single voltage opamps?

If I can even boost that signal more I can reduce the 20M resistor and leave some led's out like akg suggested.

Analog electronics is not my thing so all help is much appreciated.
See you
 
Perhaps I don't quite understand what you're trying to do, but I think that you want to measure the light level with a LED. You seem to be trying to use an A/D converter for this, but when I checked into this a few weeks ago, that wasn't the right approach. The .pdf doc in the first post of the thread that you referenced here says, IIRC, that you need to simply measure the time that the LED takes to 'discharge' with your micro. IOW, 'charge' the LED capacitance, change your I/O to input, and start a timer. The LED's small capacitance that was just charged will discharge (through CMOS input pin) at a rate determined by the ambient light level. Time the amount of time until the I/O pin on your micro goes from high to low (the decreasing voltage crosses the 'VINlow' boundry and causes the pin to read low). This time is your ambient light level.

(All of this is how I THOUGHT this worked, recalling from memory, from my brief research and no testing... soooo I could be wrong...)

Rick
 
Single supply opamp designers needed

You're right Rick that was one way of working.
But in another file linked to there is also aonther way of working, amplify the very small LED current caused by incoming light. Starting from a small 'Dark Current' it will increase with increasing light level.
It work well except from the noise and amplification problems I encounter :(

Like AKG suggested I replaced the 20M resisitor by a 3.92M one and placed a small capacitor 22pF over it. That give me an output voltage after the first opamp of 4mV in dark stage up to 50mV in "normal" sunlight condition.
I placed a RC filter 100K/330nF on the output so that the 50Hz ripple is almost gone.
Now I need an ampifier to boost up the 50mV to I hope 5V but don't know if it's possible :confused:

I did some reading in a TI pdf about single supply opamp's and like I understood it, I need a "virtual ground", they propose Vcc/2. That way I can have a maximum working range of Vcc/2. All above it up to Vcc can be compared to the + range in dual supply opamp and all underneath it can be compared to the - range. Is this correct?
So I need a 50 gain inverting opamp design to amplify my 50mV to 5V with a minimum of 2.5V. My (negative, lower than 2.5V) input range 4 to 50mV will be amplified to 2.7 to 5.0V (positive, higher than 2.5V) output range, right? Is there really no way to amplify it over a larger range?
All suggestions for doing this the right way are welcome...
Thanks a lot.
 
You just need an opamp!, it's a very trivial task, assuming you only have the 5V supply?, a rail to rail one that will work off a single 5V supply would be needed, or do what my PIC tutorial does and use a 7660 to generate a -5V rail as well (this makes the choice of opamp far easier!).
 
Easy as 1 2 3

Once you got the right information...
No need of virtual ground, Vcc/2 and other things I reed first that :confused: me, or even a 7660 Nigel, but interesting to know they exist.
Just the other half of my OPA2336 and some resitors in the right architecture :)
Input range 4 to 75mV amplified to 0.2 to Vcc (approximate values)

Thanks and see you later guys, lets code now :):)

As far as my concern, case closed.
 
Once you got the right information...
No need of virtual ground, Vcc/2 and other things I reed first that :confused: me, or even a 7660 Nigel, but interesting to know they exist.
Just the other half of my OPA2336 and some resitors in the right architecture :)
Input range 4 to 75mV amplified to 0.2 to Vcc (approximate values)

As far as my concern, case closed.

I hope nobody has a problem with that I kick the case open, because I am curious what exactly the right architecture results are to get it working. I am working on something similar but cant find the final touch.

Thanks in advance
 
I hope nobody has a problem with that I kick the case open, because I am curious what exactly the right architecture results are to get it working. I am working on something similar but cant find the final touch.

Thanks in advance
What problems are you encountering? Are you using the same semiconductors in your circuit?

The circuits shown by the OP depend on extremely small input offset voltage and input bias current.
 
Gee, that’s an old one :D
Finally I dropped the LED’s and used an LDR to check ambient light since with LED’s the signal goes from 0 to 5V in about 30 minutes during dusk/dawn while with an LDR it was three times longer. During dusk the ADC value in the µC dropped from about 250 bits to 120 bits in 5 minutes, with an LDR the variation is more linear.
That LDR & DCF system controls my garden lights for more than 3 years now!
Thanks for reminding me that :p :)
I search my archive and found what could be the last version of the hardware with LED’s. Since I’m not sure it’s the last one I won’t post it here unless you explicitly ask for it.
 
Gee, that’s an old one :D
Finally I dropped the LED’s and used an LDR to check ambient light since with LED’s the signal goes from 0 to 5V in about 30 minutes during dusk/dawn while with an LDR it was three times longer. During dusk the ADC value in the µC dropped from about 250 bits to 120 bits in 5 minutes, with an LDR the variation is more linear.
That LDR & DCF system controls my garden lights for more than 3 years now!
Thanks for reminding me that :p :)
I search my archive and found what could be the last version of the hardware with LED’s. Since I’m not sure it’s the last one I won’t post it here unless you explicitly ask for it.

Please do. Or if you like it better to send my personally, I will send you my private email address if it is not visible.


Thanks.
 
Since you asked :)
You can find it **broken link removed**
But like I said I'm not sure this was the last good working version :(
Please also note that I end up with IR led's instead of "normal" coloured led's.
 
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top