# Comparing sine wave and triangular for spwm using comparator

i am trying to generate sinusoidal PWM by comparing sine and triangular wave.

First i just tried to compare sine wave with reference voltage in order to check the working of op-amp. I get a problem in using op-amp(741) as a comparator at high frequency, so i used comparator by the suggestions from electronics stack exchange. enter link description here

Which work great for comparing sine with reference voltage. Later i noticed that there is a offset problem. Input waveform having an offset of 0 volt, but when i connect my input (both sine or triangular wave) to a comparator. The input waveform get changes by it dc offset to 6 volt.

Input waveform before connecting to a comparator

Offset voltage = 0 volt

Input waveform after connecting to a comparator

Offset voltage = 6 volt

How to compensate the offset voltage to zero volt after connecting with comparator.

Circuit.. Triangular Waveform...

Comparing triangular wave reference voltage...

Without connecting with comparator

How to compensate the offset voltage to zero volt after connecting with comparator.

• Just curious. But what about generating the PWM by comparing against a sawtooth instead of a triangle? Also, can you provide more details about the exact application here? – jonk Apr 8 '19 at 7:23
• Standard "comparators" produce LOGIC LEVEL outputs, because the comparator converts analog to digital. Do you need +-6 volts out of the comparator? – analogsystemsrf Apr 8 '19 at 8:07
• @analogsystemsrf - I just want the input waveform of the offset value as to not change. In order to get a linear output, (i,e) i want the input to not vary while connecting with the comparator. – Bud Apr 8 '19 at 8:41
• @jonk - I need sinusoidal pulse width modulation by analog circuit for motor application. I came to know that triangular wave is better than sawtooth wave for this comparison or application. By comparing sine wave (modulating signal) with triangular wave (carrier wave) will produce an spwm, which will be more useful for motor drives. [link] shodhganga.inflibnet.ac.in/bitstream/10603/33606/10/10_chapter5.pdf – Bud Apr 8 '19 at 8:48