Arduino Power Inverter Circuits

In my resent college classes several of my students plan to study solar energy in particular how power inverters operate. This is a demonstration I setup for my class.

A DC to AC inverter changes 12 or 24 volts DC to 120 or 240 VAC. This is a version of this using the Arduino micro-controller. We have two variations as presented below and will use the exact same micro-controller program not only to drive the power conversion process but to monitor other functions as well. Other features include:
  • Monitor battery and input power condition and shutdown if battery voltage is too low. (Less than 11 volts.)
  • Monitor the transistor heat sink assembly and turn on a cooling fan if too hot.
  • Power up slowly to prevent huge current surges on the 12/24 volts source.
The drive output from digital pins 9 and 10 provide two square waves 180 degrees out of phase. In a normal 60 Hz. the AC half-cycle period is about 8.33 milli-Sec. pulse width. The frequency and pulse width are very important in determining power output. This was very easy to control with the delay routines in the software.
Both diagrams below were tested on a compact fluorescent lamp, a dual tube four-foot shop light, and a Black and Becker power drill. I also tested several transformer types while one transformer designed for a 400 watt uninterruptible power supply (UPS) provided best performance. See Wiki for more on a UPS.
In fact this is a recreation of a UPS. I only tested these circuits at 12 volts. The output is a modified square wave.
MOSFETs driving a transformer.
Figure 2.

In figure 2 above we use a 24-volt center-tapped transformer and drive this with N-channel power MOSFETs. I have tried to use bipolar transistors but the performance and output was poor. I used surplus IRFP450s and IRFZ46N types. Both worked well and must be heat sinked. By switching one-half of the transformer side at a time, we recreate the negative/positive half-cycles on the AC output.
If I used a 12 volt center-tapped transformer my output would be 240 volts. The 4N37 opto-isolators serve to isolate the micro-controller from the higher voltages and electrical noise of the output circuits. The MOSFETs can be simply paralleled source to source, drain to drain, and gate to gate for higher currents and power output. The 15k resistors are used to bleed the charges off the MOSFETs gates to turn the device off.
H-Bridge driving a power transformer.
Figure 3.

In figure three I used my H-bridge circuit to drive a transformer. It works a little better than figure 2 and has the advantage of using a non-center-tapped transformer. It does use more power MOSFETs. The MOSFETs can still be wired in parallel as shown in figure 2 for greater power.
Related:



/*

 This this outpute two squarewave pulses to drive
 inverter circuits using power MOSFETS driving
 a 24-volt CT transformer to output 120 volts AC.
 
 The period for a 60 Hertz sine wave is 16.666 mSec. 
 So each half-cycle is about 8.3 mSec.
 
 The programs below puts out two square waves one for wach half
 cycle, 180 degrees out of phaste.
 
 This also has a soft start feature to linit power surges on
 power up. 
 
 This also measure the voltage on the battery and disables
 output if the voltage drops below 10 volts.
 
 A 10k and 2.7k are in series and connected to the 12 volt
 battery bank or power supply (+ 12 connected to 10k) while
 one end of the 2.7k goes to ground. The 2.7k/10k junction
 goes to one of the Arduino ADCs and when the battery voltage 
 drops below a half-volt (about 10 volts on the battery) 
 is disabled until battery is recharged.
 
*/

#define MOSFET1  9
#define MOSFET2  10
#define EnablePower 2  // HV power on switch
#define batteryVoltage 0  // AD0
#define heatSink 1  // AD1
#define batteryGoodInd 12 
#define fanOnInd 11
#define HVON  13 // high voltage on blinks

int x = 0;  int y = 0; int z = 0;

void setup() {                

  pinMode(MOSFET1, OUTPUT); // MOSFET 1
  pinMode(MOSFET2, OUTPUT);  // MOSFET 2

  pinMode(EnablePower, INPUT); // N.O. switch
  digitalWrite(EnablePower, HIGH); // pull up enabled
  
  pinMode(HVON, OUTPUT);
  digitalWrite(HVON, LOW);
  
  pinMode(batteryGoodInd, OUTPUT);
  digitalWrite(batteryGoodInd, LOW);

  pinMode(fanOnInd, OUTPUT);
  digitalWrite(fanOnInd, LOW);

}

void loop() {
  y = analogRead(batteryVoltage);
  if (y > 150) digitalWrite(batteryGoodInd, LOW);  
// battery LED off
     else digitalWrite(batteryGoodInd, HIGH);  
// battery too low LED on
     
     
  if (analogRead(heatSink) > 500) digitalWrite(fanOnInd, HIGH); 
// cooling fan on
    else digitalWrite(fanOnInd, LOW); 

// cooling fan off  
     
  if ((digitalRead(EnablePower) == 0) && (y > 150))  {   
// check for closed enable switch, battery state
    SoftStart();  // bring power up slowly
    while ((digitalRead(EnablePower) == 0) && (y > 150))   {
      digitalWrite(MOSFET1, HIGH);   // MOSFET1 on
      delayMicroseconds(360);
      delay(8);  // wait for 8.3 mS
      digitalWrite(MOSFET1, LOW);  // MOSFET1 off

      digitalWrite(MOSFET2, HIGH);   // MOSFET2 on
      delayMicroseconds(360);
      delay(8);  // wait for 8.3 mS
      digitalWrite(MOSFET2, LOW);  // MOSFET2 off

      x++;
      if (x == 20) { // flash HVON LED
        toggle(HVON);
        y = analogRead(0); 
        x=0;
        if (analogRead(heatSink) > 500) digitalWrite(fanOnInd, HIGH); 
// cooling fan on
           else digitalWrite(fanOnInd, LOW);
// cooling fan off 
      } // end 2nd if

    } // end while

  } // 

}  // end loop


void toggle(int pinNum) {  
// toggle the state on a pin

  int pinState = digitalRead(pinNum);
  pinState = !pinState;
  digitalWrite(pinNum, pinState); 
}

//SoftStart allows power to come up slowly to prevent excessive surges
// time is about 2 seconds


void SoftStart(void)   {
  int y = 2;
  int x = 0;
  int z = 6;
  while (y < 8)   {

    digitalWrite(MOSFET1, HIGH);   // MOSFET1 on
    delayMicroseconds(360);
    delay(y);  // wait for 8.3 mS
    digitalWrite(MOSFET1, LOW);  // MOSFET1 off
    delay(z);

    digitalWrite(MOSFET2, HIGH);   // MOSFET2 on
    delayMicroseconds(360);
    delay(y);  // wait for 8.3 mS
    digitalWrite(MOSFET2, LOW);  // MOSFET2 off
    delay(z);

    x++;
    if (x == 30) { 
      y = y + 2;
      z = z - 2; 
      x=0;

    }
  }
}