I have been looking into inverter designs and already posted few circuit designs using CD4047 multivibrator IC and Arduino. Just yesterday I wrote a note on simple inverter with Arduino and before that I wrote about CD4047 based Inverter design and long before that How to Build an Inverter with Arduino. I also wrote about Inverter design with 555 Timer.
Here I am writing about a new inverter design with Arduino. This one uses SPWM(Sinusoidal Pulse Width Modulation) method for generating sequences of pulses on two pins 10 and 9 which are out of phase, that is 180 degree shifted.
The following is the circuit diagram of Arduino based SPWM inverter.
This inverter circuit is designed to convert 12V DC to 220V AC using an Arduino, a pair of 2N2222 NPN transistors, IRF540 MOSFETs, and a center-tapped transformer. The core idea is to simulate an alternating sine wave using SPWM (Sinusoidal Pulse Width Modulation).
🔧 Main Components
-
Arduino – generates SPWM signals
-
2N2222 (NPN transistors) – signal amplifiers for gate driving
-
IRF540 (N-channel MOSFETs) – switches for high-current output
-
12-0-12 V Transformer – steps up low voltage to high AC voltage
🔄 Circuit Operation Breakdown
1. SPWM Generation by Arduino
-
The Arduino outputs two alternating SPWM signals on digital pins D9 and D10.
-
These signals are generated by rapidly switching each pin HIGH and LOW with varying delays.
-
The variation in pulse width is based on a lookup table (
SpwmArry[]
), creating a waveform that mimics a sine wave.
This forms a push-pull waveform, switching between two output pins.
2. Signal Amplification Using 2N2222 Transistors
-
Each Arduino output pin is connected to the base of a 2N2222 NPN transistor through a resistor (typically 220Ω–1kΩ).
-
The emitter of each transistor is grounded.
-
The collector connects to the gate of an IRF540 MOSFET through a pull-down resistor (typically 10kΩ to GND).
-
When Arduino outputs HIGH:
-
The transistor turns ON.
-
It pulls the gate of the MOSFET LOW (to ground), turning the MOSFET ON.
-
-
When Arduino outputs LOW:
-
The transistor turns OFF.
-
The MOSFET gate is pulled HIGH through a resistor to +12V, turning it OFF.
-
This creates a non-inverting buffer stage for each MOSFET, ensuring safe and sharp switching.
3. MOSFET Switching and Power Conversion
-
The two IRF540 MOSFETs are each connected to one end of the center-tapped winding of the 12-0-12V transformer.
-
The center tap is connected to +12V DC.
-
When one MOSFET turns ON, current flows from the +12V supply through one-half of the winding to GND.
-
This alternating action between the two MOSFETs causes AC-like current to flow through the transformer's primary winding.
-
The transformer steps up this waveform from 12V to approximately 220V AC at its secondary.
⏱️ Timing and SPWM Behavior
The pulse widths of the switching signals vary according to a predefined array (like a sampled sine wave), producing quasi-sinusoidal output rather than a pure square wave. This improves the quality of the AC signal and reduces losses and noise in inductive loads like motors and transformers.
📊 Functional Summary
Block | Role |
---|---|
Arduino | Generates alternating SPWM signals |
2N2222 | Acts as gate driver for power MOSFETs |
IRF540 | Switches 12V DC through transformer windings |
Transformer | Converts 12V push-pull to 220V AC output |
🔐 Safety Note
-
The secondary side of the transformer outputs dangerous 220V AC. It must be properly insulated and handled with care.
-
A fuse and protective circuitry are recommended to prevent damage or hazards.
Arduino Code
const int SpwmArry[] = {500,500,750,500,1250,500,2000,500,1250,500,750,500,500};
const int SpwmArryValues = 13;
const int sPWMpin1 = 10;
const int sPWMpin2 = 9;
void setup() {
pinMode(sPWMpin1, OUTPUT);
pinMode(sPWMpin2, OUTPUT);
}
void loop() {
for (int i = 0; i < SpwmArryValues; i++) {
// Turn on pin1, off pin2
digitalWrite(sPWMpin1, HIGH);
digitalWrite(sPWMpin2, LOW);
delayMicroseconds(SpwmArry[i]);
// Turn off pin1, on pin2
digitalWrite(sPWMpin1, LOW);
digitalWrite(sPWMpin2, HIGH);
delayMicroseconds(SpwmArry[i]);
}
}