circuit diagram

Transistors: FDP18N50

Optocouplers: EL817B

I have been struggling with this for several days. I want to make a 230V AC/230V AC inverter that extends the wave to control the speed of a blower. When I have 12VDC from the power supply on the input and a 10W 12V light bulb on the output, everything works fine, but when I put 230V AC on the input (it's actually 247V because I have a photovoltaic system) and a 116W light bulb (eventually it should be an 85W 230V AC motor) on the output, everything burns out and blows the fuses. What am I doing wrong?

I inserted those diodes there because without them the light bulb was very dim and the upper transistors were getting very hot. I don't know why but it works.


Arduino code:

    void setup() {
      pinMode(9, OUTPUT);
      pinMode(10, OUTPUT);
    double val, t;
    double freq = 2;
    const double pi2 = 2.*3.1415;
    const double amplitude = 255;
    bool flip = true;
    void loop()
      t = millis();
      val = amplitude*sin(pi2*(freq/1000)*t);
      if (Serial.available()) {
        String txt = Serial.readStringUntil('\n');
        txt.replace(",", ".");
        freq = txt.toDouble(); 
      if (val > 0) {
        if (!flip) {
          flip = true;
        analogWrite(9, val);
        analogWrite(10, 0);
      else {
        if (flip) {
          flip = false;
        analogWrite(9, 0);
        analogWrite(10, -val);


After numerous warnings from your side, and especially after seeing the video sent by "@Lorenzo Donati supporting Ukraine", I gave up on create a inverter. I decided to modify the project so that triac control would be sufficient. The controller has been working for several weeks now and I am very satisfied with the results.

I would like to thank everyone for their great interest, your answers were very helpful.

  • 7
    \$\begingroup\$ Errm - the gates you are nonchalantly connecting correspond to sources you want approx. 340 V apart. \$\endgroup\$
    – greybeard
    Mar 15, 2023 at 4:29
  • \$\begingroup\$ What is the 12V? \$\endgroup\$
    – user253751
    Mar 15, 2023 at 21:35
  • \$\begingroup\$ At the time of the test, it was a 9V+1.5V*2 batteries. Finally, there was supposed to be a transformer 230v/12v there. \$\endgroup\$ Mar 15, 2023 at 22:36

3 Answers 3


Disclaimer first: what you are doing is dangerous, and will kill you if you so much as look at it the wrong way. Everything I say here is for your education, not because I think you should continue with this project, because I actually think you should not. If you implement anything I suggest here, and something bad happens, like a fire, or damage or injury, that's on you.

Your rectifier setup produces 340V DC, not 240V. That means your H-Bridge is applying +340V, or -340V across the load. I doubt this is what you intended.

Put a fuse somewhere in the path of mains current to protect everything.

The upper transistors in the bridge have common drains, and are operating as source followers. The name says it all, source potential follows gate potential, but a few volts lower. That means +12V at the gate produces about +9V at the source, not +340V. The consequence is that the remaining 331V are between drain and source, and anything over a few milliamps of current through that transistor will fry it very quickly. For example, \$P = IV = 10mA \times 331V = 3.3W\$.

As source followers, not only do you need +343V at the gate to switch them fully on, you also need near 0V to switch them fully off. That's a big ask. Your best bet is to replace both upper transistors with P-channel devices. Then you will require their gates to be +340V to switch them off, and +330V or so to switch them on, a difference of only a few volts.

The lower transistors do not have this problem, because they are connected in "common-source" configuration. The existing arrangement applying 0V or +12V to their gates is sufficient.

I'll illustrate this behaviour difference below. Left is common-source (as used by your lower two transistors), and right is common drain (or source-follower, the configuration employed by your upper transistors):


simulate this circuit – Schematic created using CircuitLab

Here are plots of the input IN (blue), OUT1 (common-source, orange) and OUT2 (source-follower, tan):

enter image description here

The important features of the common-source setup (orange output signal) are:

  • The output is more "digital", on or off, and extends all the way to each supply potential.

  • The output is inverted, with respect to the input. Low input, high output, and vice versa.

The main points to note for the source follower (tan output) are:

  • The output is always 4V below the input, "following" variations in input.

  • The output is not inverted with respect to the input.

  • The transistor is never fully on. the output is unable to reach +20V unless the input rises well beyond 20V.

The reason you are tripping breakers is almost certainly because you are failing to ensure that there is never the condition where two MOSFETs on the same side (the two FETS down the left side, or the two right-hand ones) are simultaneously on (even only partially). If that happens, you have a very small resistance across your 340V source, permitting huge currents to flow. This is called shoot-through.

This problem is exacerbated by the fact that your circuit switches MOSFETs off very slowly, causing them to spend considerable time in some intermediate, partially conductive state. This is because gate capacitance in these devices is 2nF or worse, and combined with 10kΩ gate resistances, the gate discharges over a period of about \$R\times C = 2nF \times 10000\Omega = 20\mu s\$. At a guess, I'd say that if you switch these MOSFETS on and off at more than a kilohertz or so, they are going to spend a large percentage of their time partially conductive, causing shoot-through, and getting very hot.

Those issues aside, here's an implementation employing P-channel MOSFETs at the high side:


simulate this circuit

It uses two independent 12V batteries, one for obtaining gate potentials between +340V and +328V (for the upper PMOS transistors), and the other for obtaining gate potentials between 0V and +12V. The additional battery allows us operate the upper MOSFETs with appropriately high gate potentials.

You will require each transistor gate to be driven by its own opto-isolator, since you may no longer connect the gates of diametrically opposed transistors together. Remember, now they are operating at potentials well over 300V different from each other.

I can't stress this enough: don't ever switch M1 and M2 on at the same time, or even allow their transition from one state to the other to overlap. Same goes for M3 and M4. Avoid shoot-through by ensuring all MOSFETs are off prior to switching any MOSFET on. In other words, introduce a delay between switching MOSFETs off and switching others on, a delay we call "dead-time". I estimate that this delay should be at least 20μs, probably longer due to the slow response of the opto-isolators.

I reiterate that what you are trying to do is dangerous, even reckless. I recommend you don't build my circuit, because I haven't tested it, never will, and make no promises about it. The only reason I answered your question is to illustrate some important concepts you should become familiar with.

  • 19
    \$\begingroup\$ @KRyan The combination of "amateur" and "using mains without galvanic isolation"..Actually, even without the "amateur" ingredient I would still worry. \$\endgroup\$
    – tobalt
    Mar 15, 2023 at 15:09
  • 6
    \$\begingroup\$ @KRyan Please understand, I have to say those things, to protect EESE and myself. I don't mean to patronise, just covering asses. I don't know how well you understand the hazards of dealing with big voltages, or high power dissipation. I don't know if you are taking proper precautions. As for not building those circuits, I feel that your design, and mine, are flawed in a few respects. We haven't addressed stability, dead-time, failure mitigation, handling inductive loads and transients. \$\endgroup\$ Mar 15, 2023 at 15:22
  • 7
    \$\begingroup\$ @KRyan fair enough. 340VDC can kill you if you touch it, especially if you have a heart condition. If you happen to touch opposite potentials with different hands, it's likely to cause heart damage. With kids around you have to be really careful. An errant cable can arc, it's easy to start a fire. An exploding component can take your eye out. That kind of thing. \$\endgroup\$ Mar 15, 2023 at 16:24
  • 10
    \$\begingroup\$ @KRyan Here's my interpretation of the warning: While it's clearly possible to safely design and build circuits working on 240V — and even possible as an amateur — it is not at all clear that it is possible for this question's poster to do so. The evidence is right there in the title: this circuit's failure "blows the fuses in my house". That's very scary. If the poster didn't think to put a fuse in his power supply, what other basic safety precautions is he also omitting? \$\endgroup\$ Mar 15, 2023 at 18:00
  • 7
    \$\begingroup\$ @KarolSzymczak With a distance of several meters you are much less likely to die, but then I wonder what the point is, as you probably want this circuit to do something and I guess you don't want to be standing several meters away holding the emergency off button every time it's doing something? Electrocution is not the only risk - the next biggest is fire - maybe you decide the circuit is done so you put it in a plastic box (then it can't electrocute you) but maybe one day it breaks and catches fire when you're not looking and your house burns down. \$\endgroup\$
    – user253751
    Mar 15, 2023 at 21:38

As it stands your MOSFETs are heating up and burning out from switching too slow, partially conducting rather than fully conducting when they do finish switching (for the high-side MOSFETs), and shoot-through whenever you change from one current direction to the other.

  1. No high-side gate drive. You are using NMOS on both high side and low, and NMOS is controlled by the difference in voltage between the gate and source pins. Yet, you apply the same ground-referenced voltage to drive both high-side and low-side NMOSFETs when their source pins do not share a common potential.

    You're lucky it ever worked at all. What you did is similar to giving the same ladder of a particular length resting on the ground floor to both a person on the ground floor and a person on the second floor and hoping it would work for the both of them. If both people need to climb up 2m and the 2nd floor was 10m above the ground floor, it would work if you had a 12m ladder. But if your ladder is anything less than the person on the 2nd floor would not have enough ladder. In the same way you are unlikely to have a 12m ladder, it is unlikely you provide enough ground-referenced gate drive voltage to be able to drive both high-side and low-side NMOS off the same voltage.

    Having too much ladder never killed anyone but this is not true of MOSFETs: At 247V it is impossible to use the same ground-referenced voltage to drive both high and low-side because the high-side NMOS source pin will be near 247V when properly conducting so the required ground-referenced gate drive voltage will be greater than that. That voltage applied to the gate of the low-side NMOS will immediately fry it.

    The normal approach would be to give a 2m ladder resting on the ground floor to the person on the ground floor, and a separate 2m ladder resting on the 2nd floor to the person on the 2nd floor. The fact that this ladder rests on the 2nd floor and goes 2m above the 2nd floor is what high-side gate drive is. You provide a gate drive voltage referenced to the source pin of the high-side NMOS, not ground since its source pin is not connected to ground.

    Those nonsensical diodes are symptomatic of this issue. Get rid of them. Connect the ground of the 12V gate supply to the ground rail of the H-bridge where it is supposed to go and provide a proper floating high-side gate drive.

  2. The gate drive you do have is slow. Optos, unless specifically designed to do so, do not provide enough current to quickly charge the MOSFET's gate-source capacitance to kick it into fully conduction quickly. 10K pull-down resistors are certainly too slow to discharge the MOSFET's gate source capacitance to kick it into zero conduction quickly. So every time the MOSFET transitions, it spends a lot more time than it needs to between full conduction and zero conduction in the region in between where it dissipates a lot of heat as a resistor. This is often sufficient to burn out MOSFETs.

    For PWM where you switch frequently, generating extra heat each time, you require gate drivers which come as ICs or in their discrete form are some manner of push-pull transistor pairs where a transistor is responsible for pulling up the MOSFET gate and another transistor is responsible for pulling down the MOSFET gate. No pull resistors, which are subject to RC time constant delays and requires a trade off between power dissipation or transition times.

  3. No precautions against shoot-through. All things be equal, MOSFETs tend to take longer to stop conducting than to start conducting. That means there can be conditions where both high-side and low-side MOSFETs on the same side of the bridge can be conducting or partially conducting and cause a short-circuit. Having a slow gate drive also exacerbates this problem. This is why you either drive all transistors independently so you can accommodate for the differences, or have circuitry that fiddles with the rise and fall times asymetrically (think diodes used to selectively send charge o discharge currents through different components) if you do drive high-side and low-side conducting MOSFET pairs with the same signal.

These are all the most common H-bridge mistakes so now that you know the issues you should be able to find plenty of resources about them.

  • \$\begingroup\$ Thank you very much for such a comprehensive answer. I am an amateur, I need some time to process it. \$\endgroup\$ Mar 15, 2023 at 2:06

STOP NOW. You are going to kill someone.

Among many issues (far from exhaustive):

  • This connects the 12V source and everything attached to it at potentially lethal voltages.
  • The capacitors are unspecified and nothing tells they are rated for mains usage, nor the about 400V DC that would be required. They could explode, catch fire, emit harmfull chemical.
  • There's no fuse on the left of the diode bridge (but one or even two would not make the thing much less potentially lethal).
  • The inrush current and high-frequency current on the mains side is unlimited (there should be something in series on the diodes/bulk capacitor path for this kind of things).
  • Dangerous voltage can remain long after mains is disconnected.
  • It takes precautions to safely use safe optocouplers.
  • Power Factor Correction, harmonics filtering, these are concerns (if not safety ones).
  • The schematic for driving the H-bridge is wrong, and can't be fixed with the transistors used and a single auxiliary power (we need P-channel mosfets on the positive, or something more positive).
  • Any glitch hardware or software that drives the two optocoulers at the same time, or with not enough delay in-between, will blow things up.
  • It's very doubtful that the very principle rectifier + H-bridge is suitable for the kind of motor/blower at hand. That depends heavily on the nature of the motor and existing electronics (if any) to drive it.
  • \$\begingroup\$ (can't be fixed with the transistors used and a single auxiliary power note the use of P-channel at the high side.) \$\endgroup\$
    – greybeard
    Mar 16, 2023 at 10:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.