Simple Light Sensor (because I am lazy) - Capacitor Drop Supply - Page 1
Forum section: electronics / projects

author: paul_g_787
author_rank: Frequent Contributor
timestamp: January 16, 2022, 08:50:46 pm
content: I am working on a little light sensor, it is a very simple project to detect when a light comes on in a rack cabinet at work.(This way I can hear it from the bottom of the stairs and don't have to run all the way up just to check one dang light all the time).I have designed it out of parts I have knocking about.I am not sure what value the LDR is though, it is unlabelled, but I just used trial and error to find a working voltage divider combination.The LDR measures over 200MΩ in the dark and 0Ω in the light...The breadboard version is working great so far on a 9V battery!It uses 14mA when idle and 39mA when the buzzer and LED come on! (practically nothing).Next is to put it in a case and make a power supply.I have an old faulty mains battery charger which I would like to use as a project case. It is a wall-wart type device that has been sitting in my box of broken junk for ages.It already has 3 see-through plastic windows in the front of the casing which I can use for the LDR and 2 indicator LEDs and the hole from the original wire can be used to let the sound out from the buzzer.I think this would be a great casing as once it is assembled it will be impossible to actually touch any of the components unless you unplug it and unscrew the casing! so pretty safe (safer than some of the LED light bulbs I have seen).So I have settled on this as the casing as a winner!Next I need to supply the circuit with 9V. I would like to use a capacitor dropper supply for this for cheapness and simplicity.So I re-used my design from my LED light bulb project, however this is still experimental and there are a few bits I would like people's opinions on:C1 (Class X2 dropper cap) - I need to pick a value but when I calculated this the same as I did for my LED project I ended up having to use the next value up. is 470nF enough?C2 - is 47µF large enough here to smooth the ripple?ZD1 - Is a 9.1V 0.5W zener going to be sufficient here? (1N4739A is the one I have)R3 - I thought this would be good as a load resistor? Is this even required?

author: mariush
author_rank: Super Contributor
timestamp: January 16, 2022, 09:06:12 pm
content: You don't need a bridge rectifier, a single diode for half wave rectification would be plenty for this project. You can bump the smoothing capacitor up to something like 220uF 25v or even higher... they're not much bigger in volume.I'd encourage you to find a buzzer that works at lower levels like 5v because you're wasting a lot of current on the resistors limiting current to leds, you could make it much more efficient with a lower voltage.ex:https://www.digikey.com/en/products/detail/pui-audio-inc/AI-1027-TWT-5V-R/1745429I nearly said "go get a greeting card with some melody" and run everything at 1.5-3v but the greeting card is probably expensive and you already have a buzzer.Microchip has an application note about transformerless power supplies:http://ww1.microchip.com/downloads/en/AppNotes/00954A.pdfIt's a bit controversial as the formulas are not quite correct, but eh, good enough and the schematics can be helpful :

author: paul_g_787
author_rank: Frequent Contributor
timestamp: January 16, 2022, 09:22:53 pm
content: Quote from: mariush on January 16, 2022, 09:06:12 pmI will give that a try to see however I may keep the rectifier as I could still see the LED flickering on my LED Lamp circuit I made before. I just try it and see what it looks like.I have a few other caps to try. I will measure the ripple and see what it looks like.Quote from: mariush on January 16, 2022, 09:06:12 pmI could run it on 5V yes as I actually have a spare 6V buzzer! I will make a new version that runs on 5-6V and see what the current difference is.

author: mariush
author_rank: Super Contributor
timestamp: January 16, 2022, 09:38:02 pm
content: Well, it's simple math ... let's say the green led has a 2.2v voltage drop and you feed led+resistor 9v ... that means the 470 ohm resistor has to drop 9v-2.2v = 6.8v ... V = I x R => 6.8v = I x 470 -> I = 5.8 /470 = 0.0144 A or 14 mA and the power wasted in the resistor is P = IxIxR = 0.014 x 0.014 x 470 = 0.09 wattsDrop the voltage to 5..5.5v (ex if you use a 5.6v zener diode) and use the same 470 ohm resistor ... now your green led will do 5mA and your resistor will only dissipate 0.01 wattsThe green led will still be visible at only 5mAWith a full bridge rectifier, you can sort of estimate the minimum capacitance you'd need for a current amount with the formula C = Current / [ 2 x ac frequency x ( Vdc peak- Vdc min desired) ]So let's say for 50mA and minimum 5v all the time and a peak voltage of 9v (if 9v zener is used) then C = 0.05A / (2 x 50 hz x (9v -5v) ) = 0.05 / 400 = 0.000125 F or 125uFOf course with half wave rectification, you'd need a higher capacitance value ... but 220/330/470uF capacitors should be very common and easy to get or you should have one around.

author: magic
author_rank: Super Contributor
timestamp: January 16, 2022, 10:54:51 pm
content: It's all kind of questions that a small simulation could answer in no time.IIRC, I found 470nF to be adequate for average current of ~7mA on 230V mains.I don't think full bridge buys you anything except smoother current delivery (twice denser pulses, half charge per pulse).14mA idle doesn't seem like "practically nothing", where are you burning it? The green LED?Regarding zeners, they have a somewhat hard life in this circuit because their current is not steady state but pulsed.

author: langwadt
author_rank: Super Contributor
timestamp: January 16, 2022, 11:03:47 pm
content: Quote from: paul_g_787 on January 16, 2022, 09:22:53 pmand then you can power it from a USB port

author: paul_g_787
author_rank: Frequent Contributor
timestamp: January 16, 2022, 11:11:47 pm
content: Which simulation software would you reccomend I use? I used a piece of software called Livewire at school for windows XP but I can't find this anymore. I don't think they make it anymore.I use linux mint and I use kicad and eeschema to draw my schematics.The 13mA is in the green LED yes. It is a regular 20mA LED and I am running it slightly lower current as it doesnt need to be full brightness. 10mA would be acceptable but in my testing lower than that it looks too dim. The LED is visible as low as about 6.5mA but very dim.

author: paul_g_787
author_rank: Frequent Contributor
timestamp: January 17, 2022, 07:25:53 pm
content: So I re-built this circuit today to work on 5V. I first used a 5V USB power bank to create the circuit. It is working great like this.I lowered the LED resistors to 330R as they were too dim to see properly at 5V with 470R.The power LED uses 10mA. The buzzer and warning LED use approx 15mA. (25mA total approx).I changed the C2 capacitor to 100µF which gives me approx 0.09V ripple with no load.So I re-designed the power supply with the suggestions made in mind and this is great, and has 5.09V with no load!However when I connect my circuit to it, it drops to 4.25V and this is causing the circuit to not work properly. Why such a huge drop in Voltage?

author: magic
author_rank: Super Contributor
timestamp: January 17, 2022, 08:08:55 pm
content: ZD1 should be to the left of D1. I can't see how it would work at all as drawn.Current flows to the left through the cap: ZD1 sources it from neutral, D1 blocks negative voltage from the load and prevents discharging of storage capacitor.Current flows to the right through the cap: ZD1 limits voltage, D1 permits current to the load and storage capacitor.As for simulation, I use LTspice. It will run on Windows, it will run on Linux with wine. It's reasonably easy to operate and you draw the schematic graphically.I think Kicad was supposed to have some simulation functions too? Never used it.

author: paul_g_787
author_rank: Frequent Contributor
timestamp: January 17, 2022, 08:17:43 pm
content: Quote from: magic on January 17, 2022, 08:08:55 pmAh OK thank you. Yes I see you are quite right! I moved the zener diode, however I am now getting 4.7V without the load.Is this because it is clamping the peak voltage at 5.1V?Do you think I need to use a larger Zener to increase the voltage to 5V? Maybe 6.2V?Will do some more testing tomorrow.

author: magic
author_rank: Super Contributor
timestamp: January 17, 2022, 08:41:07 pm
content: Output is less than nominal ZD1 voltage because of forward loss in D1. A higher zener will compensate for that.Another thing is that the 330nF cap is essentially a current source. Its right side is more or less at 0V all the time, its left side varies ~650Vpp → there is 650V·330nF of charge injected into the load per mains cycle (20ms). Or 650V·330nF·50Hz of average current. So the cap needs to be sized for the expected load current.Load voltage is less important, it will work about the same as long as it's much less than mains voltage.

author: langwadt
author_rank: Super Contributor
timestamp: January 17, 2022, 09:38:53 pm
content: Quote from: paul_g_787 on January 17, 2022, 07:25:53 pmif it works from USb why not power it from a random charger from the junk pile?

author: paul_g_787
author_rank: Frequent Contributor
timestamp: January 17, 2022, 10:16:07 pm
content: Quote from: magic on January 17, 2022, 08:41:07 pmAh yes I see!! I didn't even think of that. How silly of me, it is obvious now you pointed it out!Quote from: magic on January 17, 2022, 08:41:07 pmWhat do I need to look for in the capacitor datasheet to see if it it can handle the load current?I just did the maths for different values of capacitors and now I understand that this is where the rest of my voltage drop is coming from as the 330nF is barely providing enough current! I think a 470nF would be more suitable to provide a little more.

author: paul_g_787
author_rank: Frequent Contributor
timestamp: January 17, 2022, 10:28:25 pm
content: Quote from: langwadt on January 17, 2022, 09:38:53 pmI could very well do that yes, however I saw this as a perfect oppurtunity for a practical project to use what I have been learning about capacitive dropper supplies.Theory is one thing and I find that I learn much better putting things into practice. I have already learned a few things from my design mistakes already!I think the capacitive dropper supply is an important topic to understand due to the potential dangers in such a design if done incorrectly.

author: magic
author_rank: Super Contributor
timestamp: January 17, 2022, 10:52:50 pm
content: Quote from: paul_g_787 on January 17, 2022, 10:16:07 pmI only mean that capacitance must be sufficient.The caps have some maximum current ratings too, but they are many amps, no problem.

author: paul_g_787
author_rank: Frequent Contributor
timestamp: January 17, 2022, 11:11:17 pm
content: Quote from: magic on January 17, 2022, 10:52:50 pmOk I misunderstood, I thought you meant there was another rating I was not aware of.

author: John B
author_rank: Frequent Contributor
timestamp: January 18, 2022, 01:32:53 am
content: Why would you go with a capacitive dropper circuit though? They're used inside PIR relays and smoke alarms because they are dirt cheap, but they have terrible efficiency (and power factor, though I guess the effect is negligible).I wouldn't make a project like this in a work setting and leave it connected to the mains 24/7 unsupervised. If you use an off the shelf adapter, the isolation is taken care of by an approved device. I wouldn't automatically assume that means you're free from liability, but a DIY mains connected device would certainly seem to open you to liability on multiple fronts.

author: langwadt
author_rank: Super Contributor
timestamp: January 18, 2022, 01:40:34 am
content: Quote from: John B on January 18, 2022, 01:32:53 amyeh, there is a reason why manufacturers use wall-warts/AC-adapters when ever they can

author: Berni
author_rank: Super Contributor
timestamp: January 18, 2022, 09:27:09 am
content: I have built capacitive dropper powered circuits before and they work pretty well for low powers.I usually use it in places where i am doing something with mains, like switching things with a triac, so there is already dangerous mains potentials on the board anyway. The capacitive dropper lets me make a tiny, simple and reliable power supply for it. But you want your power consumption to be under 10mA average or your dropper cap gets rather big physically(negating the point of this tiny PSU type).How i typically do it is Mains->Fuse->Inrush resistor->Dropper cap-> Halfwave rectifier->Zenner 10V->Filtering cap->Small 5V linear regulator. Gives a nice clean stable 5V even during short surges of current draw (that's why the zenner is set at 10V). The ones i built have been running for many years and survived trough quite a few thunder storms just fine (where lightning blew up other electronics). The efficiency is not that bad with these really. A transformer at these powers is worse, only well designed small SMPS supplies are better. Yes these cap droppers have a lot of apparent power draw, but very little of it is actual real power. That reactive power that they do draw is capacitive and nicely sinewave, so it helps balance out the mostly inductive reactive power in the mains network.As for your circuit. That always on LED is a huge waste of energy. If you need that much current trough a LED for it to be visible, then you have a really crappy low efficiency LED. A good modern high brightness green LED at 10mA will be so bright that its uncomfortable to look at indoors at a distance. These modern LEDs only need about 0.5mA to be plenty bright enough for use as an indicator.However you should NOT be messing with these if you are not experienced with mains electronics. They are very dangerous things.

author: magic
author_rank: Super Contributor
timestamp: January 18, 2022, 09:58:23 am
content: You can save one diode by using the "zener to ground followed by forward diode" configuration. It also means that if the zener goes open circuit, the supply will simply stop working rather than blow up the load.OTOH, small 0.5A USB chargers are getting really small these days. Particularly if you don't need the safety and are willing to crack their case and extract bare PCB.

author: Berni
author_rank: Super Contributor
timestamp: January 18, 2022, 10:58:26 am
content: Yeah my designs used a separate diode for rectification. Once of them actually went swimming in water because it was mounted outdoors and a corner of the plastic box got damaged, giving it a crack that let rain start collecting inside. There was supposedly a bang inside and it stopped working. What i found was a black mess around the PSU cirucit. I think the fuse was blown, inrush resistor blown, the zenner blown and perhaps a diode here or there. But i do remember that the 7805 regulator and all the circuitry afterwards was fine, so it was an easy fix to clean up the board, replace a fuse and some cheep common parts.I have also use taken apart 5V chargers and soldered them down to the board as a "PSU module"(I think you can actually buy them as potted bricks these days too). The one downside is that these cheep little chargers is that they get killed by lighting the easiest of all mains powered devices. I tried to make them a bit more robust by adding a series resistor on the mains input and it worked so far. The current draw on the mains side is really small so it doesn't get very hot while it helps absorb some of the surges.In terms of long term reliability oldschool iron transformers are probably the best, but very rare these days (SMPS is both smaller and cheaper)

author: Terry Bites
author_rank: Super Contributor
timestamp: January 18, 2022, 04:02:52 pm
content: https://www.tdk-electronics.tdk.com/en/373562/tech-library/articles/applications-cases/applications-cases/everything-for-capacitive-power-supplies-from-a-single-source/1380514Reccomended reading fom TDK -stay safe

author: paul_g_787
author_rank: Frequent Contributor
timestamp: January 20, 2022, 12:47:54 pm
content: Thanks for all the useful information everyone, I am now understanding this all a lot better thanks to all the help!I now understand the concept behind the fusible resistor and also now understand the concept of constant current source and how the Zener diode is 'regulating' the voltage.I have been having a look at LEDs to find some lower current ones as suggested, I think this would be a great idea. Although almost all of the LEDs I can get are nominal current 10mA, max current 20mA.I have found some 3mm LEDs that are 5mA nominal current, max current 10mA but these would be too small for my project and it would look a bit odd. 5mm Seems to be the size I need.Am I looking at the right thing here?Also, I have recently come across this neat little calculator! This is quite helpful for double checking my calculations.http://www.nomad.ee/micros/transformerless/index.shtmlThose that are worried, I appreciate the concern and yes I do understand the dangers of this type of circuit and that the circuit is always at mains voltage (with respect to ground and therefore me as well). I do know that working with mains voltages can kill me if I am not careful. If I was not confident I could do so safely I would not work on this.If it will put your minds at rest, while I have been working on this project I have taken some safety precautions:I have been using a plug-in RCD GFCI type adapter to connect to the mains voltage.I have been running the live via a 1A fuse before connecting my circuit as a back-up fuse.I have been un-plugging from the outlet before touching the circuit.I have been checking with my volt meter that the capacitors are discharged every time before touching the circuit.I have also been wearing rubber gloves and my rubber-soled slippers and sitting on a wooden chair.

author: mariush
author_rank: Super Contributor
timestamp: January 21, 2022, 12:24:21 am
content: The test current will be 10mA or 20mA but the amount of light emitted will be different at various currents.For example :1.https://www.digikey.com/en/products/detail/inolux/INL-3AG30/7604619datasheet:https://www.inolux-corp.com/datasheet/Display/Through-Hole-Display/Round-Lamp/INL-3AX30%20series.pdfmin 11000 mcd, max 18000 mcd at 20mA test current, but at page 6 you have current vs relative luminous intensity so if you run at 10mA you can expect around 80% of intensity and at 5mA around 40-50%2.https://www.digikey.com/en/products/detail/w%C3%BCrth-elektronik/151033GS03000/4490000datasheet:https://www.we-online.com/katalog/datasheet/151033GS03000.pdfThey're nice enough to give you mcd vs current on page 4 ... so as an idea this led claims to do 4000mcd at 5mAand now you can compare it with cheaper led :1.https://www.digikey.com/en/products/detail/w%C3%BCrth-elektronik/151031VS06000/4489988datasheet :https://www.we-online.com/katalog/datasheet/151031VS06000.pdfSee same graph again at page showing 15 mcd at 10mA ... far from 4000mA at 5mA , or around 5000 mcd at 5mA for the first.or the one available in biggest quantity on digikeyhttps://www.digikey.com/en/products/detail/tt-electronics-optek-technology/OVLBG4C7/827110datasheet:https://www.ttelectronics.com/TTElectronics/media/ProductFiles/Datasheets/OVLBx4C7.pdf50% luminous intensity at 10mA , around 25% at 5mA ... and the intensity is claimed to be minimum 4360, max 8400 ....

author: Berni
author_rank: Super Contributor
timestamp: January 21, 2022, 06:33:13 am
content: Quote from: paul_g_787 on January 20, 2022, 12:47:54 pmYes small LEDs are typically rated for up to 10 to 20mA of current. But the efficiency of cheep LEDs is way worse, so it means the good quality high brightness LED might produce 10x to 100x more light at the same 20mA current. This means if you run a 100x more efficient 20mA rated LED at only ~0.2mA you will get the same amount of light out of it as the cheap one at 20mA. The spec to look for is the milicandelas of light coming out since the light is what you want from a LED. So just buy a really bright led and reduce the current until the LED is at the desired brightness. Tho the highest candela LEDs are typically clear lens narrow angle ones, those are not the best indicator lights because they are hard to see at an angle(all the light if focused straight forwards), so the best ones for indicators are actually the non clear, milky plastic LEDs with a wide beam angle.The highest efficiently LEDs at 20mA can actually be painfully bright to look at up close. So you don't even want to run those at full rated current unless you like seeing colored blobs in your vision after looking at the LED.

author: paul_g_787
author_rank: Frequent Contributor
timestamp: January 28, 2022, 08:53:29 pm
content: I have been playing with some other LEDs I have lurking. I have found these 3 pin common cathode red/green bi-colour LEDs in my parts bin! They are a wee bit brighter than my regular LEDs so I can run them at lower current!I was thinking another way to cut current consumption would be to toggle between the two halves of the bi-colour LED and that way only one LED would be on at a time and this would reduce power consumption!So I threw together this little circuit very quickly to experiment.I tried running the buzzer from the base of Q4 to GND in parallel with the red LED, but in this configuration the buzzer is always on even though the LEDs still toggle just fine. So I had to add Q2 and Q3 to drive the buzzer and Q4 separately from each other.Then I had the problem that if I drove Q2 from the divider (R1 and VR1) directly the buzzer didn't turn cleanly on, it would kind of go "mmmmmeheeeehhhhhh" for a bit before the LED would lightSo I had to add Q1 to prevent this and get a "clean" switch on of the buzzer at the same time as the LED.Is there any way to simplify this at all that I am not seeing? I tried all sorts of configuration but only ended up with the circuit not working properly.

author: Berni
author_rank: Super Contributor
timestamp: January 29, 2022, 12:01:59 pm
content: You are not going to get more light out of a LED by toggling it, tho if they blink at a rapid pace (like 5 Hz) they are much more noticable.Just go to your typical electronics parts supplier and look for a LED that claims to be "super bright" you it will be plenty bright at even under 1 mA. Also most blue LEDs are ridiculously bright (and sometimes ugly when overused on a product) because they are a newer technology that is bright to begin with. Most of the cheep red and green LEDs are 30 year old tech that is still being pumped out by factories that kept the old machines.

author: paul_g_787
author_rank: Frequent Contributor
timestamp: January 31, 2022, 07:01:38 pm
content: Quote from: Berni on January 29, 2022, 12:01:59 pmNo you misunderstand. I am not flashing the LED on and off?? I am simply switching off the green LED when the Red LED is lit because I don't need both on at the same time.I bought some "super bright" LEDs. The green ones are blinding at 2mA but the red and orange still need about 4-5mA to be bright enough to be an indicator as they are just too directional.They only appear to kick out light dead straight, even with the diffused lenses, so you cannot see them at more than about a 25-30° angle.These dual colour LEDs I have found are a comfortable brightness at approx 3.75mA for red and green as opposed to the other older type I have that were too dim below 10mA.So this way instead of 20mA to light both LEDs I am only using approx 3.75mA at any one time as only one colour is ever lit.So I think the dual ones are a good compromise between the two types.I bought a 5V buzzer and it was rubbish! super quiet and could barely here it when it was drawing 20mA!!!And if I put it in parallel with the Red LED (and of course the Red LED's resistor), it would latch the circuit on somehow. Not sure why exactly.The HCM1212BX 12V buzzer which I was using originally is much louder and does not cause unwanted latching. It works fine at 9V 3.2mA. So I have designed the circuit around a 9V battery again for now.I am going to make further tweaks and then look at the power supply again.

author: paul_g_787
author_rank: Frequent Contributor
timestamp: January 31, 2022, 09:03:13 pm
content: Alright so I finally have a fully working design.To fix the LED not switching cleanly between off and on states I did some searching online and learned about hysteresis and schmitt triggers.I found this design here which I adapted to work with my PNP transistors rather than NPN:https://www.mikrocontroller.net/topic/437427This is what I was missing all alongThis is my v4 design:Now I can use the schmitt trigger to drive Q3 which simply toggles the LED and buzzer.I can adjust the sensitivity to light by adjusting R3 (which I will probably use a trimmer resistor for in the final circuit).I can adjust the brightness of the LEDs by changing R8.And I can adjust the volume of the buzzer by changing R9.I may tweak these values later but I am pretty happy with the LED brightness as it is now.R8 is also acting as the pull down resistor for the base of Q3 and also for the collector of Q2 via the green LED.I have amended my capacitive dropper circuit to provide approx 7.4mA 8.55V to the circuit by using a 150nF X2 capacitor and a 9.1V Zener.I needed this higher voltage to drive my buzzer correctly.This is now working great and only using approx 7.2mA with the buzzer on and 3.65mA with the buzzer off! Much better than the original 10-35mAI could always change the circuit later but as the unit will only be on during working hours and switched off at night I think this is a good design now.What does everyone think of my latest schematic?Any other changes I could make apart from maybe changing the LEDs later on?

author: magic
author_rank: Super Contributor
timestamp: January 31, 2022, 09:40:14 pm
content: This looks simpler nowQ3 circuit is interesting because it looks like the green LED draws Q3 base current. I don't think R7 is useful for anything here, it only adds a few mV voltage drop. Q3 base current is limited to a safe value by R8. In practice Q3 base current will be only as low as necessary, because saturation of Q3 pulls the common cathode of the LEDs up, reducing green LED current and hence Q3 base current. In fact, you have built something a bit like a bandgap voltage reference: Vce of Q3 equals Vbe of Q3 minus the difference in LED forward voltages, while the LEDs run at approximately constant current ratio equal to β of Q3. This circuit is power efficient, using only as much base current as necessary to keep the output voltage in regulation as described above.I wonder if you could get rid of Q1 and take positive feedback to Q2 base from Q3 collector. Perhaps some resistors would need swapping, or maybe Q2 would become NPN with collector pullup to the positive rail, whatever.editI see one potential issue: red LED is subjected to ~7V reverse voltage when green LED lights up. Breakdown voltage of LEDs is not very high. In the event that breakdown occurs, reverse current is limited by R9, but I don't know if the LED won't degrade after prolonged operation as a zener.edit editOkay, I found this post which suggests that actual reverse breakdown voltage may be a lot higher than the common datasheet rating of 5V. So maybe it would be enough to test for leakage with this particular LED and just let it be if there is no problem.https://electronics.stackexchange.com/questions/257064/maximum-reverse-voltage-applied-to-a-resistor-led-configuration

author: Berni
author_rank: Super Contributor
timestamp: February 01, 2022, 06:42:20 am
content: Looking good there.I would also be worried about the base of Q2 getting pulled down by the LED. Might want to add an extra transistor there just for driving the LED

author: magic
author_rank: Super Contributor
timestamp: February 01, 2022, 09:46:09 am
content: I wonder if this would work?Fewer parts and D2 is definitely protected from reverse breakdown by Q2.editI think it may be possible to remove R2 and move R1 in its place. Q1 base current will flow through the buzzer, but if you limit it to <0.1mA (which is enough) I doubt that the buzzer will sound.Nope, I'm pretty sure the circuit would latch in the "red" state and never go green. Too much positive feedback

author: Berni
author_rank: Super Contributor
timestamp: February 01, 2022, 10:43:05 am
content: Ah neat trick passing the signal trough the LEDs. If they have a similar enough forward voltage it should work since this is using the property of a BJTs saturation voltage being lower than the diode drop on the base.EDIT:Btw green LEDs typically have a larger drop than a red LED, if it makes it stop working then just swap the LEDs, to give the right LED more drop. Or perhaps just add a regular silicon diode in series to increase the drop

author: paul_g_787
author_rank: Frequent Contributor
timestamp: February 02, 2022, 06:22:21 pm
content: Quote from: magic on February 01, 2022, 09:46:09 amI like this design for it's simplicity however after bread-boarding it IRL I have found a couple drawbacks.The LED doesn't switch over to red exactly when the buzzer comes. on. It kinda fades in slowly.This is the problem I was having before the schmitt trigger idea which provided a clean simultaneous switch for both the LED and buzzerThe other problem is it is not very sensitive at all!. I can turn all my lights on in the room and it won't sense the light at all. It only picks up my super bright army torch when it is about 20cm away directed exactly at the LDR. (Which blinds everyone in the room).I tried increasing the value of R1 to 220K but then the green LED is on at half brightness and the buzzer is partially on.Any way to solve these issues with this design?

author: magic
author_rank: Super Contributor
timestamp: February 02, 2022, 07:43:07 pm
content: Hmm, I tried to reproduce something like your old Schmitt trigger and it looks like it worked OK for the buzzer, but not for the LEDs.I guess we can put the LEDs one step further. BTW, D3 may be unnecessary if forward voltage of D2 is sufficiently higher than of D1. And there is again the problem of reverse voltage across D1, but maybe it's not a problem if there is no leakage in the real world.Regarding R1, it had to be 100k to give Q1 enough base current. To increase R1, Q1 collector resistance must be increased and then Q1 can't drive LEDs.What's the LDR resistance you want to detect? In my example, thresholds are 23k/33k.

author: magic
author_rank: Super Contributor
timestamp: February 03, 2022, 02:17:06 pm
content: I wondered if a simple differential pair comparator could be made with enough hysteresis to switch cleanly in such application. Well, maybe, or maybe almost...A limitation is that current must be equal in both branches, so the buzzer has to go in series with one LED and supply voltage is increased to 12V. On the other hand, current consumption goes down to 3mA and the X2 cap could be smaller. No problems with LED reverse voltage too.I also swapped the LDR with R1 to increase sensitivity and adjustment range. R0 protects from the LDR shorting out the PSU and disabling the buzzer in strong light. This circuit ends up using a lot more resistors, but at least it's still only two PNPs. I would have no idea how to do it with one.

author: paul_g_787
author_rank: Frequent Contributor
timestamp: March 07, 2022, 04:29:07 pm
content: Back to this project now I have time.I had a tinker with those suggestions but I couldn't really get them to work as well as my "v4" schematic from above. The LED would not switch cleanly between on and off like with my schmitt trigger "v4" design I cobbled together.I have built the prototype of the "v4" schematic and it is working well, however I am having some trouble with the power supply ripple triggering the sensor.If the light is too dim the circuit will oscillate due to the power supply ripple so I have to compromise the sensitivity of the light sensor.Obviously with a battery this does not happen because there is no ripple.I have tried with a full-bridge rectifier and the single diode rectifier but there is no noticeable difference.I also tried increasing C2. A minor improvement with 330µF but no difference if I go higher (I tried 1000µF).I also tried a 9V switch mode AC adapter from an old router instead of my capacitive dropper supply but again the same issue occurs so I think some other solution is needed.What can anyone suggest to try? Perhaps increasing the hysteresis would work but I need a little help with this as I am only just grasping this concept.

author: Berni
author_rank: Super Contributor
timestamp: March 07, 2022, 05:50:13 pm
content: Larger caps are more of a brute force solution.I typically used a small TO-92 package 5V linear regulator to smooth out something like a 10V capacitive dropper supply down to 5V. This allows a much larger ripple on the capacitor so that more of its energy storage capability is used despite being small.

author: paul_g_787
author_rank: Frequent Contributor
timestamp: March 07, 2022, 06:17:05 pm
content: Quote from: Berni on March 07, 2022, 05:50:13 pmThat is not a bad idea.My circuit ideally could use 12 or 9V over 5V but I have a whole kit of 78xx regulators.I could use a larger Zener in the capacitive dropper, say 16 or 18V, and feed it into a 7812 regulator.I will breadboard it and see.