pure sine wave inverter circuit diagram

sine wave inverter circuit diagram with complete step by step program and coding, In this article I will discuss how to use push pull converter, sinusoidal pulse width modulation, h bridge and low pass LC filter to make pure sine wave inverter circuit diagram. I have already discuss all these topics in following articles.I suggest you to go through following articles before reading this article.

Pure sine wave inverter circuit diagram working

In last article on SPWM generation I have discussed how to implement sinusoidal pulse width moudulation using microcontroller and how to select number of pulses and duty cycle of each pulse. I have used PIC16F877A microontroller to write code for SPWM. you can use any microcontroller you want.But procedure will remain same as I discussed in last article on SPWM generation.

I have used 100 pulses and frequency of each pulse is 20 KHz.Hence timer period of each pulse is equal to 2 * 50 us = 100 us. Therefore I have used 100 pulses and I have already mentioned in last articles. Greater the number of pulses, more pure sine wave will produce.I have calculated duty cycle for 100 pulses using same method which I discussed earlier.Array of duty cycle is :

duty cycle for hundred pulses = {0, 8, 16, 24, 31, 39, 47, 55, 62, 70, 77, 85, 92, 99, 106, 113, 120, 127, 134, 141, 147, 153, 159, 165, 171, 177, 182, 188, 193, 198, 202, 207, 211, 215, 219, 223, 226, 229, 232, 235, 238, 240, 242, 244, 246, 247, 248, 249, 250, 250};

Pure sine wave inverter circuit SPWM 

The code given below is written in Mikro C. Although everything is clear in code, but if you still have any issue feel free to ask me by comment on this post.

const unsigned char SinLkUpTab[50]= {0, 8, 16, 24, 31, 39, 47, 55, 62, 70, 77, 85, 92, 99,
106, 113, 120, 127, 134, 141, 147, 153, 159, 165, 171, 177, 182, 188, 193, 198, 202, 207,
211, 215, 219, 223, 226, 229, 232, 235, 238, 240, 242, 244, 246, 247, 248, 249, 250, 250};
unsigned short cnt,inc,dec,sqinc,cnt1;
void interrupt()

if (dec==0)
else if (dec==1)

TMR1IF_bit = 0; // clear TMR0IF
TMR1H = 0xFF; // Initialize Timer1 register
TMR1L = 0x76;
void main()

TRISB = 0; // designate PORTB pins as output
PORTC = 0; // set PORTC to 0
PORTB = 0; // set PORTC to 0
TRISC = 0; // designate PORTC pins as output
TRISA = 0; // designate PORTB pins as output
PORTA = 0; // set PORTC to 0
T1CON= 0b00000001; // Timer1 settings
TMR1IF_bit = 0; // clear TMR1IF
TMR1H = 0xFF; // Initialize Timer1 register
TMR1L = 0x76;
TMR1IE_bit = 1; // enable Timer1 interrupT
cnt = 0; // initialize cnt
*** Note: This is not a complete code

you can purchase complete code from me just in 40$. if you want to purchase complete code of pure sine wave inverter contact me at microcontrollerslabhub@gmail.com. If you need three phase sine wave inverter code you can also contact me.

[button-green url=”http://store.microcontrollerslab.com/product/pure-sine-wave-inverter-code-and-circuit-diagram/” target=”_self” position=””]Buy code in 40$[/button-green]

 pure sine wave inverter circuit simulation results

In above array I have used 50 values instead of 100. Because I have implemented the code in such a way that it will take rest of 50 values  by itself in reverse order after peak value 250. I do this just to save memory of microcontroller. Greater the number of entries in array, greater place it will take in memory and common microcontrollers have less memory.

Pure sine wave inverter circuit of SPWM

the Diagram below shows the circuit diagram of sinusoidal pulse width modulation with two output both are on alternatively after every 10 ms.

spwm circuit diagram
spwm circuit diagram

Output of SPWM circuit diagram

SPWM output
SPWM circuit output

Gating signals  for H bridge

Now I will discuss how to use above circuit for generating 4 gating signals for H bridge which I have already discussed in above articles. I have taken two more outputs from same circuit  to generate four gating signals for H bridge. Circuit diagram is shown below:

Gating signals for H bridge
Gating signals for H bridge

Output of SPWM circuit gating signals for H bridge:

Output of SPWM circuit gating signals for H bridge:
Output of SPWM circuit gating signals for H bridge

Use above circuit to drive Mosfet of H-bridge through Mosfet drivers IR2110. I have explained each and every thing about pure sine wave inverter using switch mode technique. Starting from basic overview of pure sine inverter and its types.After that I have discussed voltage mode PWM controller SG3525 use and its applications, then I explained MOSFET driver IR2210 and its use, Dc to DC converter using push pull topology and how to make H bridge using 1R2110. have written a detailed article on sinusoidal pulse width modulation. Now you can use all the knowledge you gained to make pure sine wave inverter. Just connect a low-pass filter at the output of h bridge. You will get neat and clean pure sine wave at the output.

I have got pure sine wave in my final year project ” hybrid pure sine wave inverter ” after connecting a LC filter at the output of H Bridge.I have LC values L= 2mH and C= 3.3uf .Diagram of pure sine I have got in my final year project is shown in figure below:

sine wave inverter circuit
pure sine wave inverter implementation and circuit diagram

NOTE: Its difficult to simulate this circuit in Proteus . you can easily get a pulsating waves output result in Proteus. But when you connect LC filter at the output of H Bridge, Proteus will not simulate your circuit. I suggest you to make this circuit on hardware and verify results.

It take me almost 3 days to write 10 articles on pure sine wave inverter circuit using microcontroller. I hope that It will be helpful for all of you. Its all effort from my side. Now its your turn. let me know with your issues. I will be happy to reply to your comments. kindly share it on social media that’s what you can do for me in return. Remember me in your prayers. Best wishes for your project 🙂

164 thoughts on “pure sine wave inverter circuit diagram”

    I appreciate your efforts in providing complete explanation. It is really loud and clear I would say. May ALLAH Almighty Bless You and support you in all your endeavors.

    • Ameen 🙂 Thanks for nice words.It pleasure for me.
      Now I am writing series of articles on GSM interfacing with microcontrollers and 2-3 projects related to GSM like home automation system, wireless temperature sensor etc. Keep visiting my blog for more information on GSM.

      • AOA
        Dear brother, Hope you are fine. I’m final year student at UET Taxila. I’m working on a project “VFD” in which I’m using the same method you described above, but I’ve never worked on PIC microcontrollers, I’m familiar with AVR mega32 micro controller only. I need to generate the same waveform of 50Hz SPWM for VFD so I need code for ATmega32 micro controller. I’m using AVR Studio 6 as compiler. Plz contact me if you can help. I need it ASAP. Thanks in advance. Stay blessed.

    I was been trying to design a Sine Wave Inverter for a long time. Initially, I had issues with using IR2110. I’m settled with that now. My hardware is already same as yours. I tried using your code. My output is not even closer. Sine wave looks like it gradually increases, then flatted at the top and just few spikes at the negative half cycle. I also designed a filter and I’m satisfied with its filtering. But One will hardly believe it is a sine wave. Could you please help me with this?

    • There might be issue with your h bridge. First debug your H bridge.Follow these step:
      1) check gating signals to IR2110
      2) check output from IR2110. level of your gating signals should increase to about 10 volt. voltage level of spwm should be 5 volt from microcontroller.
      3) check input singals to gate of mosfet and its voltage level
      4) Check output at drain at output of H bridge. there should be two spwm singals and should be on at alternatively after 10ms.
      5) now check output after connecting Low pass LC filter
      if you are not getting any of above results .then There is a issue with your H bridge. Fix it first..


    Was just referring your code and found this.
    why don’t you just

    PORTB.B1 = 0;
    PORTB.B2 = 1;

    and generate 2 complementary square waves

    else if (cnt==0 &&dec==1)
    PORTB.B1 =~PORTB.B1;
    PORTB.B2 =~PORTB.B2;

    This would eliminate the need of a NOT gate right?

    I’m really happy that you helped me. My problem was with the driver. And I successfully solved it. I’m now able to get a pure and clean sine wave. Thank you for your support.

        • I didn’t understand what you want to ask?
          you mean how to use scope to see sine wave at the output of pure sine wave inverter?
          simply connect oscilloscope across capacitor of LC filter.
          if you asking any other thing , you are welcome to comment again.

    • connect LC filter at the output of H bridge and connect scope one terminal with common point of LC filter and other any other terminal of LC filter. In other words connect scope across capacitor of scope. DC ground of battery should have no connection with output of LC filter

    • You must had connected across same terminals. There might be issue with your LC filter connection. You wasn’t made LC filter connections properly.. Post picture of your LC filter connection with H bridge

  5. Hello Sir i see u are giving us a lot of help which we dont get online its like top secrct nobody wants to help on sine wave inverter. I am trying to build a sine wave from analog components sir if i get ur email I can send u the circuit so u can check through for me because I am having some heating in the fets Sir and I would really appreciate ur help thank u

    • sorry!! Your email had been deleted mistakenly. Send me circuit diagrams again on my email id. I will check your analog base inverter circuit tomorrow.

    • There are two ways to use feedback in this inverter
      1) First way to provide Feedback is through dc dc converter stage of inverter. Whenever voltage fall from certain level at the output of dc dc converter duty cycle can be adjusted to raise voltage to same dc bus voltgae value which is 311 volt in this inverter to produce 220 volt AC . When regulated voltage 311 volt is fed to H bridge , always 220 volt AC is produced at the output of inverter.
      2) Second way to provide feedback is through programming by using different sine wave lookup tables each having increasing duty cycle if pulses. But I think its useful to use first method. Because its easy is to implement for non programmers but second can also be implemented.

  6. Dear Bilal,

    I am working on a project that requires me to control the duty cycle of the SPWM, which is generated using FPGA. Could you help me in this regard?

  7. hellow bilal bhai
    plz tell me abt what should be the dead time between two waves generated for spwm.
    and in the code of spwm which u have provided , i m having a problem in running it , it gives error even when i have copied ur code same to same.
    the error is as such
    “reentrancy is not allowed,pwm1_set_duty called from two threats”

    • Hi, zeeshan
      Your fix the problem, if you remove the line “PWM1_Set_Duty(0);” or remove char “\” in above line
      Line above [” PWM1Init(20000); // Initialiye PWM1 module at 20kHz \ “] is ended “\” causing the program microC comment next line …

  8. Hi,
    Ihave a similar project, I would be interesed in your sine wave output, as you tested him use your burden? and at what voltage? From my project, I observed some anomalies when I try inventor at 12 V DC my LC filter has a value of about 3mH and 3,3uF and load is about 200Ohms when i Have a nice sine wave. Once the raise voltage on 325V DC my LC filter operating at 12V DC generally does not filtred the output I have square wave. But When adjustment LC filter 3mH and 100nF a sine wave is show. Once raise C in LC sine wave is deformed. Do you have any experience with this problem? Sorry for my bad english.

  9. hello…i have try your code..but i have trouble in pwm1_set_duty..it shows “error could not find definition of symbol ‘pwm1_set_duty’ in file.

  10. hello there,
    its a very detailed information out there, it helps me a lot, job well done!
    i want to make this inverter. i just wondering how can i make it capable to drive a 250 watts motor?
    thanks for the time.

  11. Hey I wanted to know how you selected the values of the inductor and capacitor for the the low pass filter? As in which formula did you use, how did you calculate your cut off frequency?

  12. hi please i want to know how you implemented your feedback system and can you use a triac to control battery charging voltage please if you have any ideas it would be very much appreciated

  13. Assalam o Alaikum bro……
    bro i am trying to make SPWM but i am facing just failure…..
    my xtal freq=22.1184Mhz….and pwm is 20khz….
    i didnot understand y u Initialize the timer 1 with h=ff and l=76…..
    please help me i am stuck here in generating spwm….
    thanks in advance

  14. Hello..I have tried this code,but their is error. It shows , reentrancy Is not allowed. ‘PWM_SET_DUTY’ called from two threads..

  15. Hi Bilal
    as soon as I add the H-bridge in the simulation I get ‘time step too small’ error in the proteus…
    please help me
    what to do to remove this error??

  16. I could not found IR2110 in my proteus,what to do?
    I tried with IR2112 but I think I am not getting the correct waveform at the output,
    What kind of waveform should I get at the HO and LO pin of IR2110/IR2112?

      • dear sir
        I have gone through your block on the spwm programming . But I
        cant understand why you have used TMR1H=FFH and TMR1L=76H and how theinterrupt is working.
        It will be immensely helpful if you kindly make me clear of those doubts.
        Sir please reply me. why u choose TMR1H=FFH and TMR1L=76H and how the
        interrupt is working

  17. Hi Bilal

    The output of the push-pull DC-DC converter stage falls drastically from 360VDC to 288VDC when w e connect a load.
    Even though we have a feedback ckt. The feedback is through resistor divider.

    Using SG3525 to generate PWM.

  18. Sir,I have downloaded program into Pic IC, I have done the connection in breadboard,I m nt getting output at pin 34.if I connect their wat ever dc supply 5v given to pic that only dc line we r getting plz help me.thanks in advance..

  19. Assalam O Alikum Sir how to calculate Values of inductor and capacitors of low pass filter for pwm inverter

  20. Could you please explain why did you initialize timer with TMR1H=0xFF; TMR1L=0x76. According to this I calculated that interrupt will occur after ( 1/(20MHz / 4) * (256-118) ) = 27.6us. Interrupt should occur after 25us, am I right? Please help me to understand where is the mistake.

  21. Aoa,
    Your article has been very useful to my final year project as I needed to implement pure sine wave inverter of rating 220V I am facing a problem which is that the circuit works fine if I dont connect the LC filter at the output but when I connect an LC filter at the output to extract 50Hz component the the micro controller resets after I cross 80V. I am using inductor of 500 microH and capacitor of 60 microF. What can be the reason. Did you face the same problem? If no then can you suggest the possible reasons and solutions for it. I’d be grateful> i really need answer for it in few days and I appreciate your help already.

  22. thanks for your perfect artile ,,i really enjoyed it, i used that code on pic16f628A and modified it not to use the not gate like that


    while (1) { // endless loop

    if (cnt==49 && dec==0)

    else if (cnt==0 &&dec==1)
    PORTB.B1 =~PORTB.B1;

    i simulate it on proteus and it works fine, i would use this circuit without the H -bridge and trigger the two mosfets to a centre tapped transformer ,,THE QUESTION IS CAN I PUT THE FILTER ON THE TRANSFORMER OUTPUT AT THE 220V SIDE AND HOW TO CALCULATE THE VALUES OF THE FILTER

    • Hi,
      I use PIC16F877A Microcontroller. This program is not working for PIC16F877A. Is that progarm is for PIC16F877A or Not.? If it is not for PIC16F877A then Please help making SPWM Program for PIC16F877A.
      Please help to solve this problem.

  23. Dear Bilal,

    I like your blog, thank you.

    Currently i am repairing an old UPS (SAFT NIFE 901-220-20) where it still use an analog component for the SPWM as well as protection circuit. I believe that it will be great if you also post a complete tutorial using analog component. In my case there is no manual or wiring documentation available. I almost get done but there is one alarming led giving information “common fault”, do you have idea what is causing this alarm message in an old ups?

    I also find out that the resistor of snubber circuit on the power switch module (using R & C coupling +dc and -dc rail) get burn after i power up the UPS with no load, i check the capacitors with volt-ohm meter and no indication of short. is it common the snubber RC causing short circuit on dc rail caused by the capacitor? since there are only one Resistor and 6 capacitors (parallel of 3 pairs)


  24. hi sir,
    i tried to build your program in MPLAB IDE.
    the PIC i used was 16F877A.
    its showing some errors and not getting build successully in to hex file… please help me to find a solution…
    also can you help me to write a code for SVPWM(space vector PWM)..
    Thank you

  25. assalamu alaikum bilal bhai,

    i’m already asked you to give a SPWM code in for CCS C compiler.
    any possibility?

  26. thank you very much sir for a wonderful work here you have really try and God will reword the work of your hand.
    my question is this sir, i we to connect the lowpass filter across the two output of the H-bridge or or each output with ground?


    I appreciate your efforts in providing complete explanation of the inverter.
    may I ask if you can provide the above code(written in Mikro C. ) to control the 2 gate drivers in arduino version?
    Thank so much!
    my email is chrisfwy@gmail.com

    Best wishes,

  28. what are the functions of cnt, cnt1,dec,inc, sqinc in the code.i don’t understand the code plz explain it.thanx

  29. dear bilal,
    will u plz confirm that if i want higher frequency (100khz aprox) on output of the inverter, then what changes i have to do in coding and hardware

  30. Please Can I design this cct without the use of the H bridge because the more I look at the H bridge design the more confused I become.

  31. Salam Sir: can u give me the software setup of mikro c in which you have compile the code and i want to ask that this inverter is of how many watts ?

  32. Hello there, i got something in inverter circuit you shared with us, by increasing or decreasing frequency, AC magnitude changes as well on DMM. can you explain about it.

  33. Thank you sir. I am really benefiting from your materials. God(Allah) will bless you and your family in His infinite mercy. Thank you very much.

  34. AKM..
    Sir i successfully converter 12 volt to 260VDC using sg3525 now i want to convert 260VDC to AC , made your circuit used atmega16 & gates but ir2110 n 2112 (fromcollege road rawalpindi) both are cheap they do not work correctly what should i do , should i test 2113 , m student of apcoms semester 3 affiliated with uet , rawalpindi

  35. Hi bilal thank you for your great effort
    can you please share the simulation file in proteus , my circuit is pretty much similar and program also but its giving this error
    [SPICE] TRAN: Timestep too small; timestep = 1.25e-019: trouble with node #00039.

    need you help for this

  36. HI,
    I will like to build up this device soon.
    I would like to see the final schematics digram and have the final code.
    Could you please post them to me plese ?
    My mail is: iw2fvo@yahoo.com.
    Thanks in advance .

  37. Hi, i am researching the invecter circuit, but not successful .. please help me to write code for pic 16f877A (220VAC – 50HZ) offline. I look forward to your help … thank you

  38. I really wanted to compose a simple comment so as to say thanks to you for those wonderful instructions you are posting on this site. My particularly long internet lookup has at the end of the day been paid with pleasant insight to write about with my good friends. I would say that many of us site visitors actually are definitely lucky to exist in a very good site with so many wonderful professionals with insightful points. I feel quite grateful to have discovered the webpages and look forward to plenty of more amazing times reading here. Thanks once more for all the details.

  39. Hello sir,
    thanks for this blog .
    i want run up to 1000watt real time ac appliances by using pure sine wave invert-er .
    is it possible by using your circuit and code??
    is it reliable bz i want to use for run my home real time ac appliances.

  40. Good day Mr Bilal Malik
    I am doing a final year project with this title design and construction of 48V DC TO 240V AC conversion adapter for home appliances. I just what to know if it is possible to use integrated circuits like SG3525 OR other types instead of PIC micro controllers to generate pulse width modulation for the mosfets H bridge circuit. because I have not enough knowledge in programming the PIC. I am using switch mode power supply topology in my project. in addition which type of simulation software can I use for my project.

  41. hello sir ,
    i am doing a project for speed control of single phase induction motor using pic16f877a , if u please tell me for which driver and inverter circuit can i use this project


Leave a Comment