Sawtooth signal

The sawtooth signal is used to generate a PWM control signal or generally to build the control signal for semiconductor controls.
 
See Pulse-width_modulation wiki


It is a classic signal of the Electronic science :-)


Sawtooth
Sawtooth

For the ak components:


Sawtooth
Sawtooth

Sawtooth

If k = 0


Sawtooth


For the bk components:
 


Sawtooth
Sawtooth


If k is even
 


Sawtooth


If k is odd
 


Sawtooth


With peak = h instead of π

If k is even


Sawtooth
Sawtooth


Quite a simple formulation after all :-)


In a simple function:



private void Sawtooth(double peak)
{
int j;
c[0].real = peak/2.0;
for (j = 1; j < 500; j++)
{
c[j].imag = 0;
if (j % 2 == 0)
{
c[j].real = 0;
c[j].imag = -peak * 2.0 / Math.PI / j;
}
else
{
c[j].real = 0;
c[j].imag = 0;
}
}
}




Creates the spectrum


Sawtooth


And if all the harmonics are put together, we get the signal shape. The brightest line is the base frequency. The next darker is the base frequency plus the first harmonic, then comes the same plus the next harmonic … and so on. The more harmonics are included, the closer the shape approximates the origin shape.


Sawtooth


C# Demo Project Fourier signals
  • FourierSignals.zip


  • Java Demo Project Fourier signals
  • FourierSignals.zip