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
For the ak components:
If k = 0
For the bk components:
If k is even
If k is odd
With peak = h instead of π
If k is even
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[0].real = peak/2.0;
for (j = 1; j < 500; j++)
{
c[j].imag
= 0;
if (j % 2 == 0)
{
else
{
}if (j % 2 == 0)
{
c[j].real
= 0;
c[j].imag = -peak * 2.0 / Math.PI / j;
}c[j].imag = -peak * 2.0 / Math.PI / j;
else
{
c[j].real
= 0;
c[j].imag = 0;
}c[j].imag = 0;
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.
C# Demo Project Fourier signals