quick and dirty ac to 5v regulator -- will this work?

Suppose i need about 60mA of approximately 5V, and I don’t want a transformer involved.
Can I feed this circuit with full-wave rectified AC mains? (60V positive-only output from a rectifier bridge)
The idea is that when the zener Z1 starts conducting because the voltage across C1 is over 5V, Q1 opens, which closes the depletion-mode Q2. Load then depletes the capacitor until Q1 closes, Q2 opens, and C1 starts charging again.
With luck, I’m thinking this will stay around 5.5V output (assuming G-S voltage to turn Q1 on is 0.5V) with some ripple.

In the end, I want to run a 328 and a 40 mA relay coil off this. I may be OK using a 3.3V regulator to feed the 328 a solid voltage, but I don’t want a lot of heat generated (<1W overall loss, I hope)

I didn’t take this from a book; just drew it up, so it probably has some flaw where it will oscillate like crazy or something, but I’d like any comments you can give before I order some depletion mode FETs to try it out myself :slight_smile:

And, you know, the actual circuit smudge/diagram...

https://www.dropbox.com/s/ji0ugrxk68x1pir/IMAG0350.jpg

full-wave rectified AC mains? (60V

How come 60v and not 330 or 150?

Whatever a non-isolated hook up to mains is not a good idea.


Rob

Garynomad: Whatever a non-isolated hook up to mains is not a good idea.

RIGHT !!! A direct connection to the AC line is VERY DANGEROUS, unless the system is totally enclosed and insulated, and there is absolutely no way anybody can connect to the circuit, or touch the circuitry.

The worst case is if the AC line gets reversed. (This can happen with a mis-wired socket or with a non-polarized extension cord.) In that case, you will still have 5V across your output terminals, but the "ground" on the "low-voltage" side will have the full 125VAC referenced to earth ground. If you touch your low-voltage "ground" and earth ground at the same time you could get the full 120V across your body.

Can I feed this circuit with full-wave rectified AC mains? (60V positive-only output from a rectifier bridge)...

120V RMS has positive & negative peaks of around 170V (340V peak-to peak).

Without getting into the math, RMS is something like an average and it turns-out that you get the same power (watts) from RMS and DC of the same value. i.e. A light bulb connected to 120VAC will glow with the same brightness if you connect it to 120VDC.

Wont it not matter the polarity as the rectifier will straighten it out regardless? And be carfeul, perhaps you should use a gfci outlet for testing purposes so in case you do get shocked it will trip by itself

Wont it not matter the polarity as the rectifier will straighten it out regardless?

No you have one side connected directly to mains. In the UK building such a circuit is, quite rightly, illegal. However, if you try it you only get prosecuted if you live, so you are safe, from prosecution that is.

Wont it not matter the polarity as the rectifier will straighten it out regardless?

The polarity is fine. The 5V won't be reversed, and you will have 5V on your circuit (referenced to your low-voltage ground), and it will work fine* as long as you don't connect to something else (like a computer, etc.) For example, if you build a digital thermometer and put it entirely inside a plastic case, everything would probably be OK.

The problem is you will have a 120V difference between your low-voltage ground and earth ground. If you connnect a light bulb between those two "grounds", it will light-up. If you connect yourself between those two grounds you will 'light up"! :D

*Assuming your "quick-and-dirty" regulator works as expected, and I have not studied your design.

You should be able to get a transformer for about $10 USD. I strongly advise you to use one! If you want to build your own (low voltage) regulator, go for it! That might be a fun (and safe) learning exercise.

First of all, any circuit that runs from AC mains without an isolating transformer should be double-insulated from the user. This implies (amongst other things):

  • no connections from the unit to anything else (sensors, PC for debugging, etc.)

  • unit enclosed in a plastic case with no metal screws or other parts on the outside

  • any input devices must have an appropriate insulation voltage rating. Potentiometers and pushbuttons with plastic bushes/nuts and plastic spindles may be OK but you need to check.

  • any display devices will probably require extra glass or plastic over the top of them to meet insulation requirements.

etc. etc. (this list is NOT exhaustive!)

I've never run an mcu or a relay from a non-isolated supply but I did build an electronic unit along these lines many years ago. I used capacitive touch sensing through the plastic case instead of push buttons to avoid the need for holes in the case or special pushbuttons. I was starting from 240v and I used a capacitor, resistor, bridge rectifier, zener diode, and smoothing capacitor to provide around 12v for some CMOS logic and a triac driver.

Using a capacitor to drop most of the voltage is much more efficient than dropping the voltage in a resistor, transistor or mosfet. However, to keep the capacitor value reasonable (bearing in mind that it has to be rated for AC mains voltage), you need to keep the current requirement low. 40mA for a relay is much too large, with this type of supply you should use a triac instead, assuming the load permits.

Unless you are experienced in handling AC mains voltage and know exactly what you are doing, I strongly advise against this approach. You will need to isolate it from the mains to debug it anyway.

First: Thanks for all the safety warnings! I do appreciate them. I think I’m already OK with that part (it’ll be plastic wrapped and then put in a plastic enclosure where I need it).

Second: Regarding a transformer: This is a space issue, not a cost issue. A depletion mode FET costs more than a full-on regulator would! Plus it’s a learning issue – I’d like to know if this will work, or if the magic smoke will escape while on the bench (or in the wild). With surface mount components, this circuit could be a lot smaller than a transformer based one.

Third: Regarding polarity: I’m not in the general habit of tying low-power circuits to mains ground, and don’t plan on doing it here. I don’t think there’s a “right” or “wrong” polarity here, because the pins will switch galvanic connection with the phase of the AC supply power. When it’s in up-swing, the bridge connects the dead wire to ground; when it’s in down-swing, the bridge connects the hot wire to ground.
Even when using an isolation transformer, you have a similar problem, AFAICT, unless you use a center-tap transformer. (And two rectifier bridges, I guess? Which I’ve seen no power supply actually do, perhaps because I don’t have that kind of budget when shopping :slight_smile:

Fourth: 120 V AC is 120 V RMS positive-to-negative-swing. In the US, this is delivered as two counter-phase live wires at 240 V (or, more usually, 235V, and 117V, respectively) and dead (zero) wire is derived from ground on the site IIRC. (Europe gets three-phase at something like 400V RMS, lucky bastards :slight_smile: The RMS for a pure sine wave means that the peak voltage is square root of two higher, IIRC – this means peak might be about 117*1.41 or about 165V. The rectifier then cuts that in half, so peak-to-peak voltage would be about 83V, and a non-sinusoidal shape after rectification.

The fact is, my circuit depends on this! The chopped power availability, forcing an “off” every 8 milliseconds (120 Hz) means that it will have to reset whatever charge is built up in the FET gates. Similarly, because there is a small amount of time where the voltage in is lower than 5.5V, the capacitor needs to be able to power the load through that interval. The values of the capacitor and the resistors are chosen with this behavior in mind.

However, the circuit does depend on actually staying in oscillation, rather than finding an equilibrium. If it reaches equilibrium, the depletion-mode FET will just act as a burn-off resistor, and quickly overheat, plus the circuit will be burning much more than the desired < 1W, leading to terrible inefficiency. In the best case, the circuit gyrates between something like 5.4V and 5.6V, behaving a little bit like a switching power supply. Except instead of a shaped square wave, it just derives the on/off cycle from load and voltage drop. I also depend on the capacitor to “short out” the higher supply voltage while being charged, so I don’t see 80V on the output terminals. The Zener will then ensure that the voltage is limited, because when it’s too high, the FETS conspire to turn off the power.

So, the real question remains: Any chance this will work? Or will it reach an intermediate equilibrium and just burn up? Or will the capacitor not be good enough at filtering/pulling down the voltage while charging, until Q1 starts telling Q2 to turn off?

There are a couple of mistakes in your reasoning. First

"The RMS for a pure sine wave means that the peak voltage is square root of two higher, IIRC -- this means peak might be about 117*1.41 or about 165V. The rectifier then cuts that in half, so peak-to-peak voltage would be about 83V, and a non-sinusoidal shape after rectification."

No, the rectifier doesn't cut the peak voltage in half, the peak voltage is still 165v. If you use a half wave rectifier and no smoothing capacitor, then the average voltage is what the rectifier cuts in half. [EDIT: that's the average or the absolute value of the voltage. The peak-to-peak voltage is cut in half, but then the peak-to-peak voltage of a 120v mains supply is around 340V to start with.]

Secondly, unless you can control the switching of the mosfet very precisely so that it only turns on when the voltage across it is small (near the start and/or end of the mains half cycle), and it is turned off at all other times, there will be quite a lot of power dissipated in the mosfet and you will have to get rid of a lot of heat, which isn't easy in a small space. Otherwise you are looking at power dissipation of around 100v * 50mA (assuming 50mA total current requirement), i.e. 5W.

Regarding a transformer: This is a space issue,

I which case a 200V 470uF capacitor is going to be about twice the size of a miniature mains transformer.

@jwatte

So installing a transformer is an issue. What about installing a DC barrel jack just like the Ardiuno UNO have ? That take no space, and use a wall wart ( AC adapter ) or any from the garbage and open the adapter and use the transformer and make a separated box for the transformer. reectifier, filter cap. Most consumer electronics product use that technique anyway. ← look at you printer main power supply for example. If you want to use a dirty regulator like a zener diode of 5.1 V is fine in your enclosure. But the main PSU is outside and use a transformer.

Using MAIN DIRECTLY is BAD… realy BAD <— :astonished:

Because that idea using MAIN directrly make us scare and worry. For it is… when I play with main, safety come first.

dc42:
the peak-to-peak voltage of a 120v mains supply is around 340V

I’m off by a factor of two – drawing it out on paper makes that clear. Thanks! :slight_smile: That doesn’t change what I’m asking, though.

there will be quite a lot of power dissipated in the mosfet and you will have to get rid of a lot of heat, which isn’t easy in a small space. Otherwise you are looking at power dissipation of around 100v * 50mA (assuming 50mA total current requirement), i.e. 5W.

The theory is that that power is only on for a small amount of time, while charging up C1 to > 5.5V. And most of that power goes to charging C1, rather than being dissipated in heat. Then it gets turned off until C1 drops < 5.5V and the gate charge in Q1 and Q2 dissipates. If there is no loss in any other part, I would look at 100V * 50 mA * (5.5 / 100) duty cycle, or about 1/20th of the full duty cycle. I think of it as a switching power supply with something like a self-regulating on/off cycle. However, whether it will actually oscillate correctly the way I intend is still not clear.

I appreciate your continuing engagement on this question, and if I’m off by some factor in this particular reasoning as well, I’d like to be called on it (hence, why I post this question).

Btw: It seems you can buy a non-isolated, non-transformer, AC->DC power converter for board mount for about $6 at DigiKey.
http://search.digikey.com/us/en/products/BP5034D5/BP5034D5-ND/658551
It’s somewhat small, a little over an inch, so perhaps that will solve my problem without having to try this thing out myself. On the other hand, trying this out myself would probably be fun :slight_smile:

I can’t use a wall wart, because the size of that counts against the total size.

I wired this up, and it “worked” somewhat in the sense that I wanted it, but it also “failed” in the sense that the amount of switching was small, and it mostly ran in the “burn-off” mode where the depletion mode FET was half-conducting instead of being fully-on/fully-off.
And, to be sure, I tested it with a 20 VAC input current (about 30 V p2p) rather than going to 120V straight away :slight_smile:

So, I now understand why switching power supplies use an explicit PWM generator :slight_smile: Although I bet I could add a comparator (such as LM339) to the existing circuit and maybe get it to switch a bit faster/more, rather than stabilize in linear mode.

I attach three photos:

  • the ripple of the output (somewhat saw-tooth-shaped)
  • the circuit with 180 ohm load
  • the amount of “buck voltage” lost across the depletion mode mosfet – I would have wanted this to be more square-wave-gated-half-sine shape

Next step: Building a switch mode power supply with a MC34063 controller and some inductors. A k a: “Capitulating to convention” :slight_smile:

Looks nice,
gotta agree with your conclusion, I’ve found that there’s usually a reason why everybody do certain things
its always fun to have a learning experience tho XD