Inverter circuits are often needed where it is not possible to get AC supply from the grid. An inverter circuit is used to convert DC power to AC power and it can be divided into two types that is Pure Sine Wave Inverters or Modified Square Wave Inverters. These pure sine wave inverters are very expensive, where the modified square wave inverters are inexpensive. Learn more about different types of inverter here.

In a previous article, I have shown you how not to make a modified square wave inverter by addressing the problems associated with it. So in this article, I will be making a simple pure sine wave inverter using Arduino, and explain the working principle of the circuit. 

If you are making this circuit, please note that this circuit features no feedback, no overcurrent protection, no short circuit protection, and no temperature protection. Hence this circuit is built and demonstrated for educational purposes only, and it’s absolutely not recommended to build and use this type of circuit for commercial appliances. However you can add them to your circuit if required, the commonly used protection circuits like

Over Voltage Protection, Overcurrent Protection, Reverse polarity Protection, Short Circuit Protection, Hot Swap controller, etc. have already been discussed.

CAUTION: If you are making this type of circuit, please be extra careful about high voltage and voltage spikes generated by the switching signal to the input.

What is SPWM (Sinusoidal Pulse Width Modulation)?

As the name suggests, SPWM stands for Sinusoidal Pulse Width Modulation. As you may already know, a PWM signal is a signal in which we can change the frequency of the pulse as well as the on-time and off-time, which is also known as the duty cycle. If you want to learn more about PWM, you can read it here. So, by varying the duty cycle, we alter the average voltage of the pulse. The image below shows that-

SPWM Signal Waveform

If we consider a PWM signal which is switching in between 0 - 5V which has a duty cycle of 100%, we will get an average output voltage of 5V, again if we consider the same signal with a duty cycle of 50%, we will get the output voltage of 2.5V, and for the duty cycle of 25%, it's half of that. That sums up the basic principle of the PWM signal, and we can move onto understanding the basic principle of the SPWM signal.

sine voltage is primarily an analogy voltage which alters its magnitude over time, and we can reproduce this behaviour of a sine wave by continually changing the duty cycle of the PWM wave, the below image shows that.

Sine Voltage

If you look at the schematic below, it will see there is a capacitor connected at the output of the transformer. This capacitor is responsible for smoothing out the AC signal from the carrier frequency.

The utilized input signal will charge and discharge the capacitor according to the input signal and load. As we have used a very high-frequency SPWM signal, it will have a very small duty cycle which is like 1%, this 1% duty cycle will charge the capacitor a little, the next duty cycle is 5%, this will again charge the capacitor a little more, following pulse will have a duty cycle of 10% and the capacitor will charge a little bit more, we will apply the signal until we have reached a duty cycle of 100% and from there, we will go back down to 1%. This will create a very smooth curve like a sine wave at the output. So, by providing proper values of the duty cycle at the input, we will have a very sinusoidal wave at the output.

How the SPWM Inverter Works

Driving Section of SPWM Inverter

The above image shows the main driving section of the SPWM inverter, and as you can see, we have used two N-channel MOSFETs in half-bridge configuration to drive the transformer of this circuit, to reduce unwanted switching noise and to protect the MOSFET, we have used 1N5819 diodes parallel with the MOSFETs. To reduce any harmful spikes generated in the gate section, we have used the 4.7 ohms resistors parallel with 1N4148 diodes. Finally, the BD139 and BD 140 transistors are configured in a push-pull configuration to drive the gate of the MOSFET, because this MOSFET has a very high gate capacitance and requires a minimum of 10V at the base to turn on properly. Learn more about the working of Push-Pull amplifiers here.

SPWM Inverter Circuit

To better understand the working principle of the circuit, we have reduced it to a point where this section of the MOSFET is ON. When the MOSFET is on the current, first flows through the transformer and then gets grounded by the MOSFET, thus a Magnetic flux will also be induced in the direction in which the current is flowing, and the core of the transformer will pass the magnetic flux in the secondary winding, and we will get the positive half cycle of the sinusoidal signal at the output.

SPWM Inverter Working Circuit

In the next cycle, the bottom part of the circuit is on the top part of the circuit is off that is why I have removed the top part, now the current flows in the opposite direction and generates a magnetic flux in that direction, thus reversing the direction of the magnetic flux in the core. Learn more about the working of MOSFET here.

Now, we all know that a transformer works by magnetic flux changes. So, turning both the MOSFETs on and off, one inverted to another and doing that 50 times in a second, will generate a nice oscillating magnetic flux inside the core of the transformer and the changing magnetic flux will induce a voltage in the secondary coil as we know by the faraday's law. That is how the basic inverter works. 

The complete SPWM inverter circuit used in this project is given below.

SPWM Inverter Circuit Diagram

Components Required to Build SPWM Inverter

Components Required to Build SPWM Inverter

Sl.NoPartsTypeQuantity
1Atmega328PIC1
2IRFZ44NMosfet2
3BD139Transistor2
4BD140Transistor2
522pFCapacitor2
610K,1%Resistor1
716MHzCrystal1
80.1uFCapacitor3
94.7RResistor2
101N4148Diode2
11LM7805Voltage Regulator1
12200uF,16VCapacitor1
1347uF, 16VCapacitor1
142.2uF,400VCapacitor1

SPWM Inverter Circuit Construction

SPWM Inverter Circuit Construction

For this demonstration, the circuit is constructed on Veroboard, with the help of the schematic, At the output of the transformer, a huge amount of current will flow through the connection, so the connection jumpers need to be as thick as possible.

Arduino Program for SPWM Inverter

Before we go ahead and start to understand the code, let's clear out the basics. From the above working principle, you have learned how the PWM signal will look like at the output, now the question remains how we can make such a varying wave at the output pins of the Arduino.

To make the varying PWM signal, we are going to use the 16-bit timer1 with a prescaler setting of 1, which will give us 1600/16000000 = 0.1ms time for each count if we consider a single half-cycle of a sine wave, that fits exactly 100 times within a one-half cycle of the wave. In simple terms, we will be able to sample our sine wave 200 times.

Next, we have to divide our sine wave to 200 pieces and calculate their values with a correlation of the amplitude. Next, we have to convert those values to timer counter values by multiplying it with the counter limit. Finally, we have to put those values into a lookup table to feed it to the counter and we will get our sine wave.