As an Amazon Associate we earn from qualifying purchases.
A 7 level inverter converts DC voltage into an AC output that rises and falls in seven distinct voltage steps instead of a single on/off square wave. This page covers the idea behind it and shows the circuit, simulation and hardware videos, and output waveforms. It also includes the microcontroller program (mikroC) that switches the eight power switches in the right order.
What is a 7 level inverter?
A multilevel inverter builds its output from several smaller voltage steps. A basic H-bridge produces only +V, 0 and -V. A 7 level inverter adds more steps between those extremes, so the output looks like a staircase that follows a sine wave more closely.
The seven levels are:
- zero
- three positive levels (v1, v2 and v1+v2 in the program below)
- three matching negative levels
For all seven levels to be different, the two DC sources must not have the same value. If v1 equals v2, the steps v1 and v2 collapse into one and you get fewer levels.
Why use more levels?
- Closer to a sine wave. Smaller steps mean less harmonic content than a square wave or a three-level output.
- Smaller filter. A cleaner raw output usually needs less filtering to reach a usable sine wave.
- Lower voltage steps. Each switching event changes the output by only a fraction of the full voltage, which is gentler on the load and on the switches.
The cost is more switches and more control logic. This design uses eight switches, so the gate-drive circuitry and the timing need more care than in a simple inverter.
Hardware and simulation videos
The first video shows the hardware prototype. The next two show simulations: the 7 level design this page is about, and a 9 level version for comparison.
circuit (7 level)
The circuit uses two DC sources and eight switches, labelled S1 to S8 in the program. The microcontroller drives the switches directly from its output pins. In a real build, each switch needs a suitable gate driver or isolation stage, and the switch ratings must match the DC voltages you use. Follow the connections in the diagram below when wiring or simulating it.
WAVE FORMS
The waveforms below come from the simulation. Instead of one jump from zero to full voltage, the output climbs through the positive levels, comes back down through the same levels, and then repeats the pattern on the negative side. The step at the peak is held longer than the others, which shapes the staircase.
How the program works
The code is written for mikroC with a 16 MHz crystal. The LATx and TRISx register names suggest a PIC microcontroller. It sets the pins connected to the eight switches as outputs and then repeats two routines forever: one for the positive half cycle and one for the negative half cycle.
In each half cycle the program steps through the levels in this order:
- zero level
- second level (v1)
- third level (v2)
- fourth level (v1+v2), held for two delay periods
- back down through v2, v1 and zero
The negative half uses the same sequence with the opposite switch pattern. Between every step, off_all_switch() turns all eight switches off for a moment. This short gap helps prevent two switches that should never conduct together from overlapping while the pattern changes, so keep it in place.
Output frequency
Each delay is 1200 µs. One half cycle lasts 8 delay periods (the peak step counts as two), which is about 9.6 ms. A full cycle is about 19.2 ms, or roughly 52 Hz. The real figure is slightly lower because the code itself takes time to run. For a 50 Hz output, a delay of about 1250 µs is a better starting point, which you can then fine-tune on an oscilloscope.
PROGRAM (COMPILER – MIKRO C)
The pin comments below have been corrected so each define matches its own switch.
//crystal of 16 MHz
#define s1 LATE.F0 //S1
#define s2 LATE.F1 //S2
#define s3 LATE.F2 //S3
#define s4 LATE.F3 //S4
#define s5 LATE.F4 //S5
#define s6 LATE.F5 //S6
#define s7 LATD.F0 //S7
#define s8 LATD.F1 //S8
void delay(void);
void zero_level(void);
void second_level(void);
void third_level(void);
void fourth_level(void);
void second_negative_level(void);
void third_negative_level(void);
void fourth_negative_level(void);
void off_all_switch(void);
void second_half_cycle(void);
void first_half_cycle(void);
void main()
{
TRISE.F0=0;TRISE.F1=0;TRISE.F2=0;TRISE.F3=0;
TRISE.F4=0;TRISE.F5=0; TRISD.F0=0; TRISD.F1=0;
off_all_switch();
while (1)
{
first_half_cycle();
second_half_cycle();
}
}
void first_half_cycle(void)
{
zero_level(); off_all_switch();
second_level(); off_all_switch();
third_level(); off_all_switch();
fourth_level(); off_all_switch();
third_level(); off_all_switch();
second_level(); off_all_switch();
zero_level(); off_all_switch();
}
void second_half_cycle(void)
{
zero_level(); off_all_switch();
second_negative_level();off_all_switch();
third_negative_level(); off_all_switch();
fourth_negative_level();off_all_switch();
third_negative_level(); off_all_switch();
second_negative_level();off_all_switch();
zero_level(); off_all_switch();
}
void delay(void)
{
delay_us(1200);
}
void zero_level(void) //0v
{
s1=0;s2=0;s3=0;s4=0;
s5=0;s6=0;s7=0;s8=0;delay();
}
void second_level(void) //v1
{
s1=0;s2=1;s3=0;s4=1;
s5=1;s6=0;s7=0;s8=1;delay();
}
void third_level(void) //v2
{
s1=1;s2=0;s3=0;s4=1;
s5=0;s6=1;s7=0;s8=1;delay();
}
void fourth_level(void) //v1+v2
{
s1=1;s2=0;s3=0;s4=1;
s5=1;s6=0;s7=0;s8=1;delay(); delay();
}
void second_negative_level(void) //v1
{
s1=0;s2=1;s3=0;s4=1;
s5=0;s6=1;s7=1;s8=0;delay();
}
void third_negative_level(void) //v2
{
s1=0;s2=1;s3=1;s4=0;
s5=0;s6=1;s7=0;s8=1;delay();
}
void fourth_negative_level(void) //v1+v2
{
s1=0;s2=1;s3=1;s4=0;
s5=0;s6=1;s7=1;s8=0; delay(); delay();
}
void off_all_switch(void)
{
s1=0;s2=0;s3=0;s4=0;s5=0;s6=0;s7=0;s8=0;
}
Tips before you build it
- Simulate first and compare your waveform with the ones above before touching hardware.
- Test with a low DC voltage and a small resistive load before moving to higher power.
- Check the switch patterns against the circuit. A wrong pattern can short a DC source.
- Add a low-pass filter at the output if you need a smooth sine wave rather than a staircase.
Related inverter projects
If you want to compare topologies, the cascaded 7 level inverter is built and simulated in MATLAB Simulink on this site. For a higher step count, see the 9 level cascaded design. To understand the basics first, start with the 3 level full bridge inverter or the H-bridge square wave inverter. For a microcontroller-based sine output with a different approach, try the sine wave inverter using Arduino.
FAQ
What does the number of levels mean in a multilevel inverter?
It is the number of different voltage values the output can take in one cycle, including zero and the negative values. A 7 level inverter produces zero, three positive and three negative levels.
Is a 7 level inverter better than a normal H-bridge inverter?
It gives a smoother output with less harmonic content, which can reduce filter size. In exchange, it needs more switches and more complex control, so it suits cases where output quality matters.
Why does the program turn all switches off between levels?
The short off state gives the switches time to turn off before the next pattern turns others on. This helps avoid overlapping conduction that could short a source.
How do I change the output frequency?
Change the value in delay_us(). A longer delay lowers the frequency and a shorter one raises it. With the fixed step pattern above, about 1250 µs per step gives a frequency close to 50 Hz.