generating sine wave

Thread Starter

elengr

Joined Feb 5, 2011
15
I am working on pure sine wave inverter. My skills are of beginner level. Will integrating a triangular wave form a sine wave?
 

bertus

Joined Apr 5, 2008
23,026
Hello,

Did you already think of SPWM (sinusoidal pulse width modulation) ?
Here is a page from the EDUCYPEDIA with several links on the subject:
SPWM

Bertus
 

CDRIVE

Joined Jul 1, 2008
2,219
One of the function generators that Heathkit produced in the 70's produced a square, sine and triangle. All three were formed by the triangle osc.
 

someonesdad

Joined Jul 7, 2009
1,583
A triangle wave is a collection of straight lines and the integral of a straight line is a quadratic. But Bill's right -- it's a pretty good fit to a sine wave. Here's some python/numpy/matplotlib code that generates the attached plot that shows you qualitatively what's going on:

Rich (BB code):
from __future__ import division
from pylab import *

n, num_periods = 1000, 3
# Create square wave
y = zeros(n//2) + 1
y = concatenate((y, zeros(n//2) - 1))
# Show a few periods
y = concatenate([y]*num_periods)
# Plot
plot(y, label="Square wave")
y = cumsum(y)
y /= max(abs(y))/2
range = max(y) - min(y)
y -= range/2  # Center it symmetrically about the x axis
plot(y, label="Triangle wave")
y = cumsum(y)
y /= max(abs(y))
plot(y - 0.05, label="Integrated triangle wave (offset a bit)")
# Subtract from a sine and plot the difference
t = arange(0, 2*pi, 2*pi/n)
t = concatenate([t]*num_periods)
y1 = -sin(t)
plot(y, label="True sine")
diff = y - y1
plot(diff, label="Integrated triangle minus sine")
legend(loc="upper left")
ylim(-1.1, 2.2)
title("Integrated Triangle Wave")
grid(True)
show()
Note I had to offset the integrated triangle wave a bit -- otherwise the two become nearly indistinguishable.
 

Attachments

someonesdad

Joined Jul 7, 2009
1,583
What was interesting was that I was going to roast Bill for making such a dumb statement. But then I thought I should check it out first. After writing that script, I had a strange feeling of deja vu. Then it slowly dawned on me that two or three decades ago I remember being a bit of a disbeliever when someone else made the same comment and I had to see if it was true. I had forgotten all about it.

That, of course, is the canonical definition of experience: it lets you recognize that you just made the same dumb mistake again. :p
 

wayneh

Joined Sep 9, 2010
18,183
What was interesting was that I was going to roast Bill for making such a dumb statement. But then I thought I should check it out first.
Hah! What a concept; think first, flame second. :p

Your comments on experience ring true. More than once in my career I found myself working on something vaguely familiar. Digging into my files would uncover that I had solved the same thing 5-10 years earlier. Very oddly, it was often on the same date, just years earlier. It was almost as if my interests were seasonal. Anyway, a few experiences like that taught me the value of documenting your work, if not for others, for your future self. Ten years later, it reads like someone else wrote it, but it sure is helpful compared to nothing.
 

Wendy

Joined Mar 24, 2008
23,869
Another way of looking at this is as a filter. A single integrator is a simple 1st order filter, two of them is a 2nd order filter. Add enough filtering anything becomes a sine wave.

The diode shaper is something else, it is fundamentally a logarithmic amplifier.
 

THE_RB

Joined Feb 11, 2008
5,438
If your triangle wave has the top and bottom peaks clipped (with diodes or PSU limits etc) it requires even less filtering to get a "sine" output. :)

To Elengr, I have built inverters that produced a decent sinewave out of the transformer, but they always needed waveforms very UN sine like driving the power components...

It also depends a bit on the type and current of the load. Maybe you should say what the load is and why you need to make a sinewave inverter?
 

Audioguru

Joined Dec 20, 2007
11,248
An inverter is NEVER made from an amplified sine-wave because the amplifier is always linear and wastes a lot of power making lots of heat.
Instead a sine-wave inverter uses Pulse-Width-Modulation at a high frequency where the output Mosfets switch completely on and off at a high frequency then the high frequency is simply filtered away with an LC filter.
Since the Mosfets switch completely on and off then they do not waste much power and do not get hot.
 

THE_RB

Joined Feb 11, 2008
5,438
An inverter is NEVER made from an amplified sine-wave because the amplifier is always linear and wastes a lot of power making lots of heat.
...
Actually they are. :) It's not common these days and it has never been a good idea with high power inverters, but there are linear sine wave inverters out there AG.

The last one I made was for a small "antique" clock with a 60Hz AC mains synchronous motor.
 

Thread Starter

elengr

Joined Feb 5, 2011
15
If your triangle wave has the top and bottom peaks clipped (with diodes or PSU limits etc) it requires even less filtering to get a "sine" output. :)

To Elengr, I have built inverters that produced a decent sinewave out of the transformer, but they always needed waveforms very UN sine like driving the power components...

It also depends a bit on the type and current of the load. Maybe you should say what the load is and why you need to make a sinewave inverter?

I want to use sine wave inverter in UPS so that I can run my computer in case of power failure.
 

kubeek

Joined Sep 20, 2005
5,796
A computer will run fine with square wave or anything in-between, as the voltage is rectified and filtered to make a steady DC voltage for the SMPS. The electromagnetic noise will be higher with the square wave, but it shouldn´t affect the computer.
 

Audioguru

Joined Dec 20, 2007
11,248
AC motor speed controls don't work properly from a square-wave.
Many electronic products also don't work properly from a square-wave because they rely on the 1.414 times higher peak voltage of a sine-wave.
 

Thread Starter

elengr

Joined Feb 5, 2011
15
Another way of looking at this is as a filter. A single integrator is a simple 1st order filter, two of them is a 2nd order filter. Add enough filtering anything becomes a sine wave.

The diode shaper is something else, it is fundamentally a logarithmic amplifier.

Can you please upload a schematic of integrator circuit which at least converts square wave into triangular wave?
 

Audioguru

Joined Dec 20, 2007
11,248
Can you please upload a schematic of integrator circuit which at least converts square wave into triangular wave?
An old 741, LM358 or LM324 opamp makes a triangle wave by integration when you have a frequency that exceeds its very low slew rate.

I think an integrating opamp circuit makes a triangle wave when its input is a square wave.
 
Top