• Skip to main content
  • Skip to primary sidebar

Homemade Circuit Projects

Need circuit help? Post them in the comments! I've answered over 50,000!

Blog | Categories | About | Hire Me | Contact | Calculators-online
You are here: Home / Electronics Theory / Sine wave PWM (SPWM) Circuit using Opamp

Sine wave PWM (SPWM) Circuit using Opamp

Last Updated on May 20, 2026 by Swagatam 140 Comments

SPWM refers to Sine Wave Pulse Width Modulation which is a pulse width arrangement in which the pulses are narrower at the start, which gradually get broader at the middle, and then narrower again of the end of the arrangement. This set of pulses when implemented in an inductive application like inverter enables the output to be transformed into an exponential sinewaveform, which may look exactly identical to an conventional grid sine waveform,

Table of Contents
  • Simulating a Sine waveform is not Easy
  • What is SPWM
    • Using two Input Signals
    • Creating an SPWM with Triangle wave and Sinewave
    • Opamp Processioning the SPWM
    • Circuit Diagram

Acquiring a sinewave output from an inverter can be the most crucial and the most advantageous feature for rendering maximum efficiency to the unit, in terms of its output quality. I have explained how to make sine wave PWM or an SPWM using an opamp.

Simulating a Sine waveform is not Easy

Achieving a sinusoidal wave output could be quite complex and may not be recommended for inverters, because electronic devices normally do not "like" exponentially rising currents or voltages. Since inverters are essentially made by using solid state electronic devices, a sinusoidal waveform is normally avoided.

Electronic power devices when forced to operate with sinusoidal waves produce inefficient results since the devices tend to get relatively more hot compared to when operated with square wave pulses.

So the next best option for implementing a sine wave from an inverter is by the way of PWM, which stands for Pulse width modulation.

PWM is an advanced way (digital variant) of putting forth an exponential waveform through a proportionately varying square pulse widths whose net value is calculated to exactly match the net value of a selected exponential waveform, here "net" value refers to the RMS value. Therefore a perfectly calculated PWM with reference to a given sine wave can be used as a perfect equivalent for replicating the given sinewave.

Furthermore, PWMs become ideally compatible with electronic power devices (mosfets, BJTs, IGBTS) and allow these to run with minimal heat dissipation.

However generating or making sinewave PWM waveforms is normally considered complex, and that's because the implementation is not easy to simulate in ones mind.

Even I had to go through some brainstorming before I could correctly simulate the function through some intense thinking and imagining.

What is SPWM

As explained at the beginning of the post, an SPWM is a digital equivalent of an analogue sine waveform. An analogue sine waveform has a gradually increasing waveform at the start, which grows maximum at the center of its travel, and then it gradually descends downwards towards the zero mark. In the same way an SPWM has thinner pulses at the start of the waveform, the thickness or the width of the pulses gradually get bigger and maximum at the center of the travel, and then the pulses slowly grow thinner towards the end of the waveform.

When this SPWM consisting of growing and shrinking pulse widths is applied to a transformer, the output from the transformer transforms this SPWM into an analogue equivalent which closely replicates an analogue sine waveform.

The easiest known method of generating a sinewaver PWM (SPWM), is by feeding a couple of exponentially varying signals to the input of an opamp for the required processing. Among the two input signals one needs to be much higher in its frequency compared to the other.

The IC 555 can also be used effectively for generating sine equivalent PWMs, by incorporating its built-in opamps and an R/C triangle ramp generator circuit.

The following discussion will help you to understand the entire procedure.

New hobbyists and even the professionals will now find it quite easy to understand regarding how sine wave PWMs (SPWM) are implemented by processing a couple of signals by using an opamp, let's figure it out with the help of the following diagram, and simulation.

Using two Input Signals

As mentioned in the previous section, the procedure involves the feeding of two exponentially varying waveforms to the inputs of an opamp.

Here the opamp is configured as a typical comparator, so we can assume that the opamp will instantly start comparing the instantaneous voltage levels of these two superimposed waveforms the moment these appear or are applied to its inputs.


In order to enable the opamp to implement the required sine wave PWMs correctly at its output, it's imperative that one of the signals has a much higher frequency than the other. The slower frequency here is the one which is supposed to be the sample sine wave which needs to be imitated (replicated) by the PWMs.

Ideally, both the signals should be sinewaves (one with a higher frequency than the other), however the same can be also implemented by incorporating a triangle wave (high frequency) and a sine wave (sample wave with low frequency).

As can be seen in the following images, the high frequency signal is invariably applied to the inverting input (-) of the opamp, while the other slower sinewave is applied to the non-inverting (+) input of the opamp.

In a worst case scenario, both the signals can be triangle waves with the recommended frequency levels as discussed above. Still that would help you to achieve a reasonably good sinewave equivalent PWM.

The signal with the higher frequency is termed as the carrier signal, while the slower sample signal is called the modulating input.

Creating an SPWM with Triangle wave and Sinewave

Referring to the figure above, we can clearly visualize through plotted points the various coinciding or overlapping voltage points of the two signals over a given time span.

The horizontal axis signifies the time period of the waveform, while the vertical axis indicates the voltage levels of the two simultaneously running, superimposed waveform.

The figure informs us regarding how the opamp would respond to the shown coinciding instantaneous voltage levels of the two waveforms and produce a correspondingly varying sine wave PWM at its output.

The procedure is actually not so difficult to imagine. The opamp simply compares the fast triangle wave's varying instantaneous voltage levels with the relatively much slower sinewave (this can also be a triangle wave), and checks the instances during which the triangle waveform voltage may be lower than the sine wave voltage and responds by instantly creating high logic at its outputs.

This is sustained as long as the triangle wave potential continues to be below the sine wave potential, and the moment the sine wave potential is detected to be lower than the instantaneous triangle wave potential, the outputs reverts with a low and sustains until the situation reverts.

This continuous comparison of the instantaneous potential levels of the two superimposed waveforms over the two inputs of the opamps results in the creating of the correspondingly varying PWMs which may be exactly the replication of the sine waveform applied on the non-inverting input of the opamp.

Opamp Processioning the SPWM

The following image shows the slo-mo simulation of the above operation:

Here we can witness the above explanation being implemented practically, and this is quite how the opamp would be executing the same (although at a much fater rate, in ms).

The upper figure shows a slightly more accurate SPWM depiction than the second scrolling diagram, this is because in the first figure I had the comfort of the graph layout in the background whereas in the second simulated diagram I had to plot the same without the help of the graph coordinates, therefore I might have missed a few of the coinciding points and therefore the outputs looks a little inaccurate compared to the first one.

Nevertheless, the operation is quite evident and distinctly brings out how an opamp is supposed to process a PWM sine wave by comparing two simultaneously varying signals at its inputs as explained in the previous sections.

Actually an opamp would process the sine wave PWMs much more accurately than the above shown simulation, may be  a 100 times better, producing a extremely uniform and well dimensioned PWMs corresponding to the fed sample. sinewave.

Circuit Diagram

You'll also like:

  • What is Transistor Saturation
  • function of ICapacitor Inductor Calculations
  • MOVHow to Select MOV – Explained with a Practical Design
  • scr 2How Thyristors (SCR) Work – Tutorial

Filed Under: Electronics Theory Tagged With: Opamp, PWM, Sine, SPWM, Wave

About Swagatam

I am an electronics engineer and doing practical hands-on work from more than 15 years now. Building real circuits, testing them and also making PCB layouts by myself. I really love doing all these things like inventing something new, designing electronics and also helping other people like hobby guys who want to make their own cool circuits at home.

And that is the main reason why I started this website homemade-circuits.com, to share different types of circuit ideas..

If you are having any kind of doubt or question related to circuits then just write down your question in the comment box below, I am like always checking, so I guarantee I will reply you for sure!



Previous Post: « Automatic Sliding Gate Controller Circuit
Next Post: Simple Scrolling RGB LED Circuit »

Reader Interactions

Questions & Answers

Total Posts: 140
Newest Oldest
alex
July 13, 2015 • 11 years ago #32257

Thank u Mr Swagatam for ur explanation . Everytime I read ur commentsd I understand this sine wave concept better sir. Now I know what is SWPWM fully. In ur inverter circuit that uses the high frequency SQUARE wave signal produced by the 555 and compared with the triangle wave at pin 7 of the 555 pwm ic what is this concept called sir. Alex

Reply
SwagatamAdmin
July 14, 2015 • 11 years ago #32265

Thanks Alex, in the inverter circuit using 555 IC the square are not compared with the triangle, rather the square are used to create triangle waves and these triangle are compared with potential at pin5 of the same IC….the potential at pin5 preferably should be a slow sine wave or a slow triangle wave.

Reply
Ainsworth Lynch
December 10, 2016 • 10 years ago #47225

Just thinking would I have to use a sinewave generator to get a sinewave input to the opamp I dont know any regular chips that produce sinewave.

Reply
Ainsworth Lynch
December 11, 2016 • 10 years ago #47233

I found a sinewave generator circuit using the 555 timer, If I am to use that circuit that would be the one that is at about 50hz and then I could use a triangle wave for the 200hz, also the triangle wave generators I see the output voltage is normally low like about 0.5v so I was thinking I could connect pin 3 to the base of a bc547 and then send then send the 5v to 12v going to the supply of the 555 to the collector of the npn transistor its emmiter would be connected to gnd and I could connect the leg of the opamp in between the emmiter and gnd of the bc547.

Reply
SwagatamAdmin
December 11, 2016 • 10 years ago #47237

sinewave generator is not strictly required, triangle wave generator will just enough….

you will need a 555 IC based 50 Hz astable, and another 200Hz astable, and connect these two with the inputs of the opamp….
simply connect the inputs of the opamp with the positives of the capacitors of the two astable circuits….but make sure that the 200Hz is connected with the (-) of the opamp and 50Hz with the (+) of the opamp.

also do not forget to connect the grounds of all the 3 circuits in common with the negative supply.

Reply
Ainsworth Lynch
December 11, 2016 • 10 years ago #47243

Ok I understand that but the other issue was the voltage level being very low on the circuits I found, I mentioned a transistor method which you didn't say anything about or probably you have another method.

Reply
SwagatamAdmin
December 12, 2016 • 10 years ago #47259

triangle wave from a 555 IC astable will never be low….it will be around 3/4th of its supply voltage…so if the supply is 12V you an expect the voltage across the 555 capacitor to be around 8V (peak)

Reply
Ainsworth Lynch
December 12, 2016 • 10 years ago #47267

Seems ill have to find a reliable triangle wave circuit I made a squarewave generator the minimum was 76hz I assume I could get it lower with a higher value pot than 100k I didnt have any though but I added an rc netwrok to it with a 1k resistor and a 470nf capacitor I got the triangle wave out but I cant read the frequency, so i just assumed its gone too high where I cant read it.

Reply
SwagatamAdmin
December 12, 2016 • 10 years ago #47272

you can use the second software from this article to set the frequency to the desired level along with the frequency

https://www.homemade-circuits.com/p/ic-555-calculator.html

Reply
Ainsworth Lynch
December 14, 2016 • 10 years ago #47321

ok in that case I could use a 1k for r1 and a 500k pot for R2 and a 0.1uf capacitor that way I should have a 50% duty cycle and be able to adjust frequencies between 15hz to about 300hz at atleast 8v output.

since triangle wave is a analoge wave form do u think I should use a decoupling capacitor at pin 3 to block the dc output or should I leave it as is?

Reply
SwagatamAdmin
December 14, 2016 • 10 years ago #47322

pin3 will always give you square waves….triangle waves will need to picked right across the capacitors pins, or from pin6/2 and ground.

Reply
Ainsworth Lynch
December 14, 2016 • 10 years ago #47330

I understand what ur saying and I'm aware but you still didn't answer what I asked. Yes pin 3 will have a square wave output and I'll use a capacitor across it and gnd to get my triangle wave which if I test with a multimeter I'll get both ac and DC with a similar value, so I am now asking you if it's necessary to add another capacitor which this time will be electrolytic to block the DC output entirely and just have an ac output.

Hopefully you understand what I mean

Reply
SwagatamAdmin
December 15, 2016 • 10 years ago #47341

there's never an AC in DC circuits…it's only a pulsating DC in the form of either square or triangle wave…so a blocking capacitor will be never be required in these circuits. blocking capacitors are required in audio amplifier circuit only, because an audio signal could be an AC.

adding a capacitor at pin3 to get a triangle wave is unnecessary when you are already getting the same across the timing capacitor of the IC 555.

Reply
Ainsworth Lynch
January 28, 2017 • 10 years ago #48451

This might sound strange but just to reply to your comment… In the full electronic field even though the name is pulsating DC all signals are classified under analog and digital electronics, isn't pulsating DC an analog signal, something a transformer can use and something you place your meter on ac to read?

Reply
bhavin patel
January 27, 2017 • 10 years ago #48427

sir i'm working on multilevel inverter. is it possible to compare sinewave and triangular wave obtained from controller through op amp..???

Reply
SwagatamAdmin
January 28, 2017 • 10 years ago #48440

bhavin, it is possible to compare sine and triangle wave for creating SPWM, but SPWM is not used in multilevel inverter concept as far as I have learned.

You can refer to this example circuit which shows how to create multilevel waveform using a simple circuit

https://www.homemade-circuits.com/2015/12/simple-5-level-cascaded-sine-wave.html

Reply
Sherwin Baptista
July 21, 2017 • 9 years ago #51893

Dear Sir,
I tried this circuit but the 555 is not generating perfect triangle waves, on the oscilloscope the waveform seems a bent triangle with curves on the positive and negative peaks of the waveform.

If we collect the outputs from pins6,2 and GND we are disturbing the the actual waveform processing of the internal comparator which takes effort to generate the square wave. This in turn doesn't provide an output which is stable and the 555 working gets disturbed.

I think we are disturbing the efficient astable working circuit of 555 by not collecting the output from pin3 and rather taking from other pins.
I were stuck at this part.

Reply
SwagatamAdmin
July 22, 2017 • 9 years ago #51901

Dear Sherwin, that's not true….the triangle wave from a IC 555 pin6/2 is never a perfect wave due to its sudden discharge, and slow charging rate.

The opamp inputs have high impedance so that can have no impact on the IC 555 pinouts

By the way perfect triangle waves is not required for creating SPWMs.

Reply
Sherwin Baptista
July 21, 2017 • 9 years ago #51895

Dear,
When i connected an LRC circuit at the output of 555, i could get perfect triangles on the oscilloscope. So, the LRC circuit at the output works good for getting triangle waves from 555. I have tried this perfectly.

Reply
SwagatamAdmin
July 22, 2017 • 9 years ago #51902

you can do that, but as I said perfect triangle wave is not crucial for generating SPWMs

Reply
Sherwin Baptista
July 21, 2017 • 9 years ago #51897

Now i wish to know how to go about getting the SPWM 50Hz and 50% Dutycycle from the output pin6 of 741 Opamp,

What should be the output parameters of the 555 to feed the 741 opamp since i would have to build two of them and then integrate their outputs appropriately?

Would a buffer transistor be required by chance in case current is too small at the output of pin6 of 741?
Thanks

Reply
SwagatamAdmin
July 22, 2017 • 9 years ago #51903

If the slow triangle waves are set at 50Hz then the SPWMs will shape-up from narrow to broad and vice versa at the 50Hz rate, but it will not alternate…for getting alternating SPWM you will have configure it with another circuit and apply it at the gates of the mosfets or the associated BJTs.

Reply
SwagatamAdmin
July 22, 2017 • 9 years ago #51904

you can implement it with a single opamp and two IC 555 circuits…I'll try to design it if possible and present it soon.

Reply
Sherwin Baptista
July 22, 2017 • 9 years ago #51907

Dear,
Yes please, I need an alternating SPWM design for my inverter circuit. I would be greatly thankful for that.
Regards

Reply
SwagatamAdmin
July 22, 2017 • 9 years ago #51910

Hi Sherwin, I'll try to present it soon as a new article.

Reply
Uday
April 3, 2018 • 8 years ago #59525

Thank You Swagatham for the detailed explanation,

How can we implement the 3 phase(120 degrees apart) SPWM circuit, where we can have the freedom of varying the amplitude of reference 3 waves compared to the carrier wave.

Thanks in advance
Uday

Reply
SwagatamAdmin
April 3, 2018 • 8 years ago #59529

You are welcome Uday,
For implementing 3 phase SPWM we can use 3 separate opamps, feed their non-inverting inputs with 3 phase sine carrier waves derived from the respective 3 phase channels, while the inverting inputs could be supplied through a common high frequency triangle waves. The amplitude of these triangle wave could be varied for changing the PWM response accordingly.

Reply
Uday
April 5, 2018 • 8 years ago #59571

Good idea, But how do we ensure the 120degree phase shift between the 3 individual sine waves?
Also, what if we want to vary the frequency?

Thanks in advance
Uday

Reply
SwagatamAdmin
April 5, 2018 • 8 years ago #59573

Hi Uday, I was assuming the 3 phase signals are taken from an existing 3-phase supply input.

If it needs to be from an electronic source then the idea using IC 4035 3-phase generator could be tried. The clock input frequency could be changed to alter the the output 3 phase frequency.

and to make the square wave output into sine wave we may have to put an RC integrators across the 3 outputs of the circuit.

Reply
Dayo
August 21, 2018 • 8 years ago #62595

Is it possible to make spwm with one ic 555 and an opamp. Thanks

Reply
SwagatamAdmin
August 21, 2018 • 8 years ago #62596

No, that may not be possible, but using one 4060 and one opamp may be possible.

Reply
Dayo
August 22, 2018 • 8 years ago #62612

I didn’t get any circuit for 4060 and opamp. Can I use two 741 ICS for spwm generation

Reply
SwagatamAdmin
August 23, 2018 • 8 years ago #62615

2 IC 741 will not work, you will have to use 3.

Reply
Dayo
August 23, 2018 • 8 years ago #62622

Thank you Engineer Swagtagam, please which one produce bette waveform between 2 555 ic with an opamp and 3 opamps spwm

Reply
SwagatamAdmin
August 23, 2018 • 8 years ago #62627

Both the versions can be used for creating good SPWMs, IC 555 also uses opamps internally for all the processing

Reply
Dayo
August 25, 2018 • 8 years ago #62665

I tried the 555based spam but the output from the opamp 741 was 2v which was not able to trigger the but stage, but without the spwm the inverter came up, please how can I solve this.

Reply
SwagatamAdmin
August 25, 2018 • 8 years ago #62668

you will strictly need an oscilloscope for the adjustments…

Reply
Dayo
August 25, 2018 • 8 years ago #62670

I calculated the fixed resistors values and capacitors, to get the frequency, should I incorporate a variable resistors instead of fixed ones.

Reply
SwagatamAdmin
August 25, 2018 • 8 years ago #62673

You can use a variable resistor for experimenting with the frequencies

Reply
Dayo
August 26, 2018 • 8 years ago #62694

Thank you, I don’t know why the MOSFETs(1 for each side,) were getting hot when the spwm was connected, but no issues when the spwm was not connected but the oscillator was connected directed.

Reply
SwagatamAdmin
August 27, 2018 • 8 years ago #62700

try keeping the fast frequency of the SPWM to 350Hz, not more than this. try adding a 1K resistor across gate/source of each mosfet

Reply
Dayo
August 29, 2018 • 8 years ago #62736

Thanks Swag, I have made the fast frequency to be 350hz, it is not getting hot any more, when I connected the spwm the humming sound from the trafo was not good, I tried to set the preset for the frequency with the sound( which I do easily without the spwm) because my frequency meter is bad presently.

The sound for modified sine inverter is quiet and cool at average frequency of 50hz, but for the spwm connected, it was harsh and coarse, please any advice.

Reply
SwagatamAdmin
August 30, 2018 • 8 years ago #62743

Dayo, It can be difficult for me to troubleshoot without having a practical look at it, and moreover without an oscilloscope it can too difficult to judge the accuracy or issues with an inverter waveform…you will have to get an oscilloscope to diagnose it correctly

Reply
Dayo
September 5, 2018 • 8 years ago #62822

Please Can I use a comparator instead of opamp to process the waveforms

Reply
SwagatamAdmin
September 5, 2018 • 8 years ago #62826

yes you can, just make sure to use a pull up resistor with the output of the comparator

Reply
Dayo
September 6, 2018 • 8 years ago #62842

Thanks I tried the comparator, I used the fast frequency on pin 2, the output pwm was good , but when connected to the bjt stage , the inverter didn’t come on. I removed the pwm stage, The inverter came up, I then changed the fast frequency to pin 3 , no output from pwm.no variable resistor was use. Please any advice.

Reply
SwagatamAdmin
September 6, 2018 • 8 years ago #62845

Dayo, I am sorry, It seems I have a made a mistake by choosing NPN for the PWM chopping, please replace the lower BC547s with BC557s.

Connect the emitters with the bases of the buffer transistors, collectors with the ground line and base with the SPWM inputs.

Can you please tell me where those diagrams are located, I may have to go and correct each one of them…thank you for alerting me regarding the issue.

Reply
Dayo
September 6, 2018 • 8 years ago #62848

https://www.homemade-circuits.com/sg3525-pure-sinewave-inverter-circuit/.

Thanks sir

Reply
SwagatamAdmin
September 6, 2018 • 8 years ago #62849

OK great, I have added the warning message under the particular diagram.

Reply
Dayo
September 9, 2018 • 8 years ago #62897

Thanks for the correction, you said for spwm use bc557, what of pwm, is bc547 OK for that.

Reply
View Older Comments

Need Help? Please Leave a Comment! We value your input—Kindly keep it relevant to the above topic! Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar



Categories

  • Arduino Projects (95)
  • Audio and Amplifier Projects (134)
  • Automation Projects (18)
  • Automobile Electronics (103)
  • Battery Charger Circuits (89)
  • Datasheets and Components (109)
  • Electronics Theory (150)
  • Energy from Magnets and Earth (40)
  • Games and Sports Projects (11)
  • Grid and 3-Phase (20)
  • Health related Projects (27)
  • Home Electrical Circuits (13)
  • Indicator Circuits (16)
  • Inverter Circuits (100)
  • Lamps and Lights (163)
  • Meters and Testers (72)
  • Mini Projects (28)
  • Motor Controller (68)
  • Oscillator Circuits (30)
  • Pets and Pests (15)
  • Power Supply Circuits (91)
  • Remote Control Circuits (50)
  • Security and Alarm (65)
  • Sensors and Detectors (107)
  • SMPS and Converters (46)
  • Solar Controller Circuits (62)
  • Temperature Controllers (44)
  • Timer and Delay Relay (50)
  • Voltage Control and Protection (44)
  • Water Controller (37)
  • Wireless Circuits (31)



Circuit Simulator

circuit simulator image



Subscribe to get New Circuits in your Email



Other Links

  • Privacy Policy
  • Cookie Policy
  • Disclaimer
  • Copyright
  • Videos
  • Sitemap

People also Search

555 Circuits | 741 Circuits | LM324 Circuits | LM338 Circuits | 4017 Circuits | Ultrasonic Projects | SMPS Projects | Christmas Projects | MOSFETs | Radio Circuits | Laser Circuits | PIR Projects |



Recent Comments

  • Swagatam on 2 Cool 50 Watt Inverter Circuits for Students and Hobbyists
  • way on 2 Cool 50 Watt Inverter Circuits for Students and Hobbyists
  • Swagatam on 2 Cool 50 Watt Inverter Circuits for Students and Hobbyists
  • Swagatam on The Perfect FM Radio Circuit using TDA7000 IC
  • Swagatam on 9 Simple Sine Wave Generator Circuits Explored

Social Profiles

  • Twitter
  • YouTube
  • Instagram
  • Pinterest
  • My Facebook-Page
  • Stack Exchange
  • Linkedin

© 2026 · Swagatam Innovations