What’s the purpose ?
You’ve gotten a low energy tool (generally battery powered, or on UPS) that wish to locate if the principle energy is misplaced. How do you do this successfully ?
What’s the problem ?
When coping with alternating present and a microcontroller, you’re out of the blink led instructional. If the voltage at the line is upper than than 50V, it turns into hazardous to maintain, you MUST TAKE ALL POSSIBLE CARE ELSE YOU’LL BE KILLED.
You don’t wish to spend a Watt for detecting if energy is there, since each and every Watt, 24/7 prices you extra than 1€ according to 12 months.
If you want to watch greater than a unmarried line, then the best answer is most popular.
Some fundamental answer comes to the usage of a resistor divider adopted through a diode (or higher, a diode bridge) like this:
Even though you place up your divider R2/R1 in order that the voltage on R1 is so much underneath your microcontroller’s allowed enter pin voltage, you’ll burn it.
Within the former case, the voltage on NODE1 is measured w.r.t the AC’s Flooring, within the later case, it’s measured w.r.t the Virtual Flooring.
Most of these circuits have a lot of disadvantages.
Energy fed on
They consumes everlasting energy within the resistors, and the diodes. As an example, in case your microcontroller is 5V tolerant, within the 230V case, you’d want VR1 upper than two diode threshold voltage plus the minimal to locate the output at the microcontroller (let’s say 2.5V). VR1 if so must be no less than 5V (2.5V for the microcontroller, plus 1.2V according to diode), so R1/(R1+R2) should be set to 0.022. The present that flows during the diodes should be top sufficient to make sure the diode will transfer, and occasional sufficient in comparison to the present that is going during the resistor. Let’s say you wish to have 4mA within the bridge heart, you’ll want no less than 16mA within the divider. So, the present in R2 might be 16mA, which provides R2 = 14kΩ, R1 = 314Ω.
The ability dissipated within the resistor might be 3W in R2, and 200mW within the bridge.
The resistor R1 is there to be sure that, when no load is provide within the bridge, the voltage at the diodes is restricted to what the diode may just improve.
Non proof against line variation
The differential voltage between AC energy line can transform as top as 400V in Europe.
With the above computation, if it both occurs, then the bridge will transmit this over voltage to its load, your microcontroller. This may occasionally most likely kill it.
Non proof against part dying.
If a diode is killed, and shorts itself (PN junction generally shorts themselves when burnt), then your microcontroller might be killed within the subsequent fast.
If a resistor is killed (generally R2), then it’s secure.
2nd obtrusive answer
It’s worthwhile to use a AC/AC Transformer to keep away from the loss within the divider and feature the voltage you wish to have at the bridge. It’s a lot more secure, transformers are very dependable.
On the other hand, they have got a horrible energy loss, much more when the weight may be very gentle.
Usually potency for such transformer is between 20% to 80% (it’s underneath 0 when no load is hooked up to the secondary). So in case your transformer is rated 230V/5V 1A, it may devour between 1W (for the best) to 4W for the fewer environment friendly.
That easy USB transformer will value you greater than 16€ in 4 years only for detecting if the ability used to be loss.
Any other answer
For the reason that energy loss is an extraordinary match, you need to be tempted to make use of a 230V relay to locate such match (230V at the relay commuter, and 5V at the different facet). A 230V relay consumes steady present (generally 5mA on 230V, so just about 1.2W).
The most productive answer
An element like VOS628A-3T or PS2505 are AC optoisolator that improve AC enter on their gentle emitting diode, and a classical silicon based totally phototransistor on their “secondary” circuit.
The design will appear to be this:
Relying at the Optocoupler selected, you want to regulate the inductance Z0 (most likely through converting C0) with a view to have a present within the diode has shut as conceivable to the minimal specified within the datasheet. Usually, forthe really useful present within the diodes is between 5mA to 10mA. Resolving the equation provides C0 round ~160nF for 10mA, and ~80nF for 5mA. C0 should be rated for 400V.
The intake for such circuit may be very low (within the tens of mW vary), but supplies the most efficient insulation you need to be expecting when coping with AC energy line.
At the different facet of the Optoisolator, you have got a classical NPN transistor which can also be without delay attached for your microcontroller with a present proscribing resistor. Relying at the microcontroller, the inner pull up for virtual enter might be sufficient to energy the transistor and locate its standing (saturated or no longer).