Want to make a reliable night light for your nights behind enemy lines? Look no further!
But first I have to thank Circuit Specialists for providing me with some magnificent tools I was craving for. Make sure to visit them for the equipment you need and use the promotion code “ElectroBOOM” for an additional 5% discount till the end of February 2016.
What I think every electronics lab should have are these two:
Well, like I said this circuit is a bit of an overkill but it is a good educational piece never the less. Below is the schematic of the circuit.
There are three parts to the circuit which I explain:
- The power supply circuit
- The sensor circuit and,
- The power switch circuit
Power Supply Circuit
You need to provide a low and stable voltage for your control circuit to run on and for that you need a low DC voltage. 5V is not a bad level to choose, although this circuit doesn’t necessarily need 5V and can run on more. To create the 5V you need to step down and rectify the 120VAC from the power line.
To step the 120VAC down I am using a capacitor divider circuit, which is made of C1 (470nF) and C2 (2.2uF). It works the same as a resistor divider but works for AC signals only. The benefit of such divider is that it doesn’t waste power in form of heat, like a transformer but with capacitors. C2 being the larger value would create a smaller impedance and so a smaller voltage across it. The AC output of this circuit would be Vin x (C1/(C1+C2)) or around 21VAC. But this is if this divider is not loaded at all. But since this circuit provides power to the control circuit the voltage across C2 drops much more bringing it to even a safer level for the circuit.
So as I measured in the video, with all the circuit together, the rectifier output is between 7V to 13.5V.
The AC from C2 goes through D1 which is a bridge rectifier and is rectified to DC having C3 (100uF) at its output.The bridge is a full wave rectifier which results in smaller output ripples. But you could also make a simpler rectifier using two diodes as half wave rectifier.
Now you might ask, since C3 is so large, how come it doesn’t effect the divider so much. Well it does at the beginning when it is charging. But as it charges up, the rectifier starts to isolate it from the divider and so it slowly gets out of the picture and only draws from the input when it needs to be charged again, which is every cycle of AC. The reason is that while AC is oscillating between high and low, at some level all diodes turn off and only C3 provides current to the circuit and hence the ripples across C3 as shown below.
The rising side of the ripple is due to when the input voltage is rising close to the peak charging the capacitor, and the falling side is when the input wave is too low and so C3 is isolated from input and provides power to the circuit and discharges.
When C3 is being charged by the input, it draws much current which added to the normal draw of the control circuit results is loading of the capacitive divider. This loading shows as flat peaks at the divider across C2 as shown below.
The output voltage of the rectifier significantly changes by the amount of loading from the circuit. So you need to know what your maximum and minimum voltage would be based on loading and ensure it doesn’t rise too far to blow circuits, or too low that the circuits shut down. To prevent over voltage across C2, you can place a bi-directional TVS or zener diode across C2 which would clamp the voltage across C2 below a suitable level. But that would waste power as heat. So it is better if the diode won’t conduct under normal operation and is only for over voltage protection.
So now voltage across C3 is fed into a 5V regulator that provide a nice and fixed output voltage isolating the input fluctuations.
Sensor Circuit
I am using a photo sensor. It is a type of diode, which is kind of like a variable resistor that changes resistance based on the amount of light, or another way to look at it is a current source that changes its current based on light. More light results in more current.
This diode needs to be reverse biased. It is placed series with R1 (1M Ohm) resistor between the supply. So the voltage between them rises and falls depending on the amount of light. Capacitor C5 reduces the reaction time of the sensor to the light changes and fluctuations. Because this sensor is very fast reacting and can even see the flickers in light coming from 60Hz city power lines and could effect the output. I also made it specially slow (C5 = 470nF) so that we can see the light blinking in the video as the light feeds back into the sensor. But you can choose a smaller capacitance like 100nF.
The sensor output is fed into a comparator circuit with a positive feedback. This circuit is a Schmitt Trigger comparator that has hysteresis. This means the output switches high when input falls below V1 voltage but switches low when input rises above V2 level. The reason for two levels is the positive feedback from comparator output via R2 (390k Ohm) that results in a different voltage at positive input of the comparator depending on the output state. Adjusting the potentiometer POT1 (100k Ohm) changes these levels up and down, so you can adjust the circuit trigger level based on the desired environment light.
Also hysteresis is generally beneficial to prevent noise changing output quickly. If there was only one threshold and the signal was sitting on the threshold with some noise, the output would switch quickly. But with two thresholds spread apart it is much harder for the noise to false trigger the circuit.
Power Switch Circuit
There are different ways to switch the power. The important thing is that you don’t necessarily want to mix the AC line to your control lines depending on the circuit you have. For this circuit, you can’t mix them for sure as the power lines are already not directly connected to control circuit and pass through the rectifier diode.
You could use different ways to provide isolation between power lines: use relays, or use opto-isolators.
A relay is not a bad idea but the problem is that the relay coil generally draws large amounts of current that pulls the supply across C3 way down shutting down the circuits. Opto-isolators are good for providing insulation because with small amounts of current (<5mA) their outputs can switch.
But what is this part I’m using? You need to understand a component called TRIAC. It is a bidirectional part where when it is on, it can let current through both ways and when it is off, it blocks both ways. So It is ideal for an AC signal.
The opto-TRIAC turns on when the internal LED turns on. The regular TRIAC (Q1) turns on when the voltage between gate-T1 terminals is the same direction as T2-T1 voltage and the current running through the gate is greater than a threshold. (hope that makes sense!)
When the TRIAC is turned on, it remains on as long as the current running between its terminals (T1 and T2) is above zero (for exact level you should see the datasheet). So even if the gate current is turned off, the TRIAC only turns off again if the current through it drops significantly.
Now with this circuit I put together, if OPTO1 is off, there is no gate current through Q1 and it is off. But if OPTO1 is on, as the AC line oscillates, the gate current through R4 turns Q1 on and with it the light.
Now, to turn the opto on, we need around 5mA through the LED for reliable trigger, and that current is what causing the rectifier output to drop from 13.5V to 7V.
I pass the circuit to one of my Patreon patrons. You could win such MAGNIFICENT goodies too if you support me, and make my projects easier too. Thanks!
And here’s the bill of material for my circuit:
- C1: 0.47uF 250V (non-polarized)
- C2: 2.2uF 25V (non-polarized)
- C3: 100uF 16V
- C4: 10uF 16V
- C5: 0.47uF >10V
- D1: DF02M (Diode Bridge)
- D2: PD204-6C (Photo Diode)
- Opto1: MOC3023 (Opto-TRIAC)
- POT1: 100k Ohm single turn
- Q1: BT136-600D,127 (TRIAC)
- R1: 1M Ohm
- R2: 390k Ohm
- R3, R4: 820 Ohm
- U1: UA78L05CLP (5V regulator)
- U3: MCP6542-E/P (Comparator)
Sir i dont know about electronic but i want this that in your hand this circuit how can i ?
Dearest Mehdi:
May you and family be well
On your video you mentioned that you do not have an isolation transformer
I suggest a 120 and 220 volt
Or perhaps with more taps
If you wish, we can trade an isolating transformer or maybe another type of instrument or component for a digital oscilloscope that you kindly give away for my work and research
I enjoy and pay attention to your videos
I design, modify and repair medical, scientific, industrial and educational instruments
Among other disciplines
My best and thank you, Mariol
Let me know if you travel here
So that I may show you my Laboratories
Mario Lagunez Otero
Subida del Club 20
Colonia Reforma, 62260
Cuernavaca, Morelos, Mexico
527773270540 / lagunez7@gmail.com
Hi, Mehdi how did you solve the problem with the feedback as the light turns on and the photo sensor turns off the output??
i doubt you just point the sensor to the direction that the light is not shining at
Great video !
So i understand that when the TRIAC Q1 has current flowing it is closed and thus the light bulb start to shine. This is of course triggered when the OPTO1 is on.
But why does the light go out once OPTO1 is off. Is the Q1 closing on the negative cycle of the 120 AC supply as no current flows through it and thus the light goes out and stays out ?
Sir…Big fan of your work. Thank you for all your hardwork. I don’t understand when people use the terms in power electronics —“under full load condition and half load…and so on.” Could you please explain about it in your upcoming video.
You make everyone laugh and at the same time enlighten them,which I feel only few people have that talent.
Than you once again and Have a great day 😊!
Is there any replacement for comparator IC MCP6542-E/P .this IC of this no. Is not available here…what will change in the circuit if there is any replacement.plz reply.
you can use any operational amplifier that works with single power supply at 5v or above (like a generic lm358n)
What parameters must be changed to design this circuit for 240VAC input?
C1 and C2
how about in 220 volts? what should i change?
i suggest to read carefully the post (where he clearly explains how he reduces the input voltage) before even attempting to make this circuit since we are talking about mains voltage there is a high risk of electrocution
Use step down x-mer almost 12 0 12
Then use exact circuitry
That also works
I’m impressed, I must say. Rarely do I encounter a blog that’s both equally educative and amusing, and let me tell
you, you’ve hit the nail on the head. The problem is an issue that too few folks are speaking intelligently about.
I am very happy that I found this in my hunt for something relating to this.
dmxcaosd;laosdll,asdolc
Shoma daneshmand divane hasti, agha!
Pingback: Butt Light, Powering Electronics Remotely | ElectroBoom
Hi all. I have had some troubles to calculate the resistir R4 used in the TRIAC, i would like to know if anybody could tell me the formula (or a webpage or boor which is explained) to calculate that resistor R4, please? Regards
Pingback: Make an Industrial Grade Night LightViral Raid | Viral Raid
sir can u explain me how capacitor pass AC?
Pingback: Failed to Fix Your Cell Phone? Make a RobotViral Raid | Viral Raid
Thank you for giving so many good laughter
In my country its 230v rms voltage . to create 12v dc what should be the value of capacitances please reply quick … Thank you . and yes iam a great admirer of your videos ….
And frequency of 50hz
You should specify the voltage output (12vdc) AND current.
A simulation on LTspice with 230Vac@50Hz and C1 = 0.22µF gives 12Vdc@8mA and 28Vdc@0mA. The maximum voltage on C2 is 21Vac when the output is not loaded.
Don’t forget to choose your components with the tolerance of the line voltage in mind (typically plus-minus 10%).
Hallo from across the pond.
I was wondering if you will do a FAQ with the electrical symbol key for circuit diagrams, for the benefit of noobs and those of us who do not read such diagrams yet?
Meanwhile, I tinker a little with electronics, but at far lower voltages and usually attached to the GPIO pins on a Raspberry Pi (and controlled by Python). I wonder what you would do with a £4 ($5) Raspberry Pi Zero? Apart from blow it up, that is…
I think that this is the first time I watched an entire video. This is really good stuff, and you explain it all very succinctly. I too have shorted out an instrument using the ‘wrong’ ground (when I was a kid) – too funny.
Are you insane? This is a very dangerous circuit to publish for beginners. The entire circuit is running at mains potential and is lethal. Bear in mind that powerboards, cabling and adapters can reverse the polarity of the mains, making the earth point 120VAC. This is to save a couple of dollars on a transformer that would make this completely safe.
A better approach is to repurpose an old mobile phone charger which often has a 5V regulated output and will power this circuit without getting hot and is very efficient (ie no heat). This would make the circuit completely safe. Also consider a LED or halogen light so it can be safely powered at low voltage.
But then again, it would probably not go boom 🙂
Are also insane look at the name of his channel before you say that to him. His making himself electroshock to tell the viewers what will happen if you connect this if you touch this etc i think he lives up to his name channel
hay mahdi
i really loved your videos you are awesome man XD …
i have a question for you , in my country the voltage is near 220v AC 50Hz
what are the values should i use to rectify it to 12v DC ??
and if i want to deliver a high current lets say near 6 – 5 amp max ??
thanks a lot 😀
This circuit is no good for such high currents. It is only meant for milli-amp levels. For that much power you need a regular transformer or a switching regulator.
.ویدیو شما دیدی عالی دوست دارم شما ایران من ناشنوا هنرکده هستم
Kheyli mamnoon!
If any ‘Mercan, Canadian Eh, British I Say, and other English-speakin’ folks are wondering what was said in the above conversation, fear not! Through the flawless power of electronics, Google Translate ( https://goo.gl/jU6c9g ) makes all languages one:
First guy: .vydyv You a stunning view of Iran’s like you I am deaf studio
Mehdi: Thank you!
“C2 being the larger value would create a smaller inductance and so a smaller voltage across it”
Didn’t you mean a smaller impedance?
Great videos by the way
Damn it! I thought that word sounded strange. Fixed!
Might be good to point out that the c1 and c2 have to be non-polar capacitors (i.e., not electrolytic) — a lot of caps of those specs are. Though the effect would make a good addition to your video. 😉
I’ve never thought of using capacitors as an AC voltage divider before, brilliant!
Very good point! Added to my BOM.
what is the max current for The power supply circuit?
Not much! maybe 10mA would end it. For more current, you need to reduce or remove C2 and if you need even more, need to increase C1. But then you need to make sure your current draw is consistent, otherwise if it drops the input can rise significantly. In such cases you can put a zener at rectifier output to clamp over voltage. But the zener could die if the current is too high.
I Realy like these 5V Power Suply, i think this have a wise usage, like a arduino and 555 CI. Tanks !
I really dislike this 5V power supply, I think it has wise usage, like power supply for killing large livestock.
Please, I beg you, don’t use non-isolated supplies for home projects.
Yeah, it would be ok only for devices that are well and truly isolated from any user fingers, such as one that’s inside a plastic box and has no controls. Even then, the mains capacitors should have an X2 rating or something like that, which this article doesn’t mention at all.
Still, the circuit has many concepts that are useful to know. And once you truly understand how the capacitive divider works and why, and how to calculate its parameters, you understand a lot.