Author Topic: Comparator light sensor  (Read 4068 times)

0 Members and 1 Guest are viewing this topic.

Offline VibraniumTopic starter

  • Newbie
  • Posts: 2
Comparator light sensor
« on: January 17, 2013, 06:00:20 pm »
I have an older truck that dose not have automatic lights and I thought it would be cool if i could build my own board that could sense the amount of ambient light and switch the lights on when it was dark out. I was successful in building one on a bread board that used an lm324 (its the only comparator radioshack had) some resistors a trimmer resistor and a photocell. So I went and designed a board using the same basic circuit but I replaced the lm324 with a lm311 and made a board. However it dose not work smoothly when I have light shining on the photocell I hear a high pitched hum and i'm getting around 5.6volts on the output when I block the light the humming goes away and the output goes up to 12v like it should.Ii am not sure how to fix it. i do not own an oscilloscope so i cant check but i'm guessing its oscillating when there is light and that's why i hear the humming? Any input on how I could fix this would be appreciated. Thank you.

 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11694
  • Country: my
  • reassessing directives...
Re: Comparator light sensor
« Reply #1 on: January 17, 2013, 06:47:06 pm »
your hum is caused by mains powered light, 60Hz on and off your comparator is very good at comparating that hence 60Hz hum on your circuit.

solution 1:
i did almost exact problem as this one, so here it is, the "quick unproven but working" solution (see attached picture), the key is a diode and capacitor, you may skip the drain 10Mohm resistor. the hum will be reduced from few KHz BW to about 1Hz (on and off in one sec acceptable for my app). but better solution esp for your case will be to use 555 timer on the comparator output and probably some logic circuit, ie when comparator is off, you delay the on condition for a certain amount of time depending on your choice. i didnt use this better solution since i was really tight on space and components count, so i used the minimalistic acceptable solution earlier mentioned.

solution2:
point your photocell to a direction that less likely to be hit by artificial light.

solution3:
use multiple photocell that sense every different direction and use logic AND to turn the light ON, the probability of hum and false OFF will be lower. the only condition thats surefire to trigger all condition TRUE is during the daylight.

suggestion:
1) LM324 is not a comparator its an opamp, but no harm if you config it as comparator like your schematics. just letting you know.
2) put the 2N222 NPN on high 12V side, or change to PNP if you want to stick to that low side config (but you'll also need to switch comparator +ve and -ve input), NPN works better on high side and PNP on low side (you got them backward in your schematics). thats what my experience tells from my unproven experimenting.

someone else may give better solution as we both learning. cheers ;)
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline VibraniumTopic starter

  • Newbie
  • Posts: 2
Re: Comparator light sensor
« Reply #2 on: January 17, 2013, 08:06:05 pm »
Thank you for your help i will give the cap and diode a try because when i took it outside into the sunlight it was still humming and giving me about 5v out and that causes the relay to stick. odd I even used a battery to make sure it wasn't from my crappy wall power adapter lol.
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: Comparator light sensor
« Reply #3 on: January 17, 2013, 09:30:10 pm »
Also consider that some hysteresis in the triggering level could be a good idea. Otherwise the tiniest fluctuations in the light level could trigger the comparator (of course the delay would help but won't remove the issue).
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11694
  • Country: my
  • reassessing directives...
Re: Comparator light sensor
« Reply #4 on: January 17, 2013, 09:41:40 pm »
i thought hysterisis is something that built into the comparator. thanks Kremmen for giving the pointer...
http://www.ece.rochester.edu/courses/ECE216/Adding%20Extra%20Hysteresis%20to%20Comparators.pdf
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf