Tag Archives: Spannungsquellen

Generate Modulated PWM with LTSpice

LTSpice knows different signal sources. Unfurtunately there is no modulated PWM. This article shows how to generate a voltage controlled PWM.

zwei-spannungsquellen

At first we need two normal voltage sources “voltage”. One voltage source generates the modulation voltage, the other generates the clock for the PWM.

For this example we want to generate a PWM with 20 kHz clock that is modulated by a sine wave of 2000 Hz.

As modulation source every other voltage form is usable too.

sinus-spannungsquelle-2kHz

The voltage source that generates the sine wave will be set acordingly to the requirements. The PWM shall be 5 V peak voltage and single ended (ground based). That’s why the sine gets an offset voltage of 2.5 V and an amplitude of 2.5 V. That causes the PWM to a middle value of 50%. The maximum modulation of the PWM depends only on the amplitude of the sine wave. At 2.5 V amplitude the modulation will be 100%.

dreieck-spannungsquelle-20kHz

The second voltage source generates the clock of the PWM. To achieve an actual PWM this voltage source must generate a triangular voltage. For 20 kHz the period duration is 50 µs, one ramp has a duration of 25 µs. The amplitude of this source is also set to 5 V.

Up to now this is not a PWM yet. Now both voltages need to be connected.

zwei-spannungsquellen-mit-werten

For this a common ground needs to be defined and each voltage needs a unique name. The voltage sources are connected to ground with their “-” terminal. The “+” terminal is connected to a short wire. These wires are open on the other end. Each wire is given a unique name. In our example they are named “sine” and “ramp”.

Now only the combination of both voltages to a PWM is missing.

For that combination we use the “arbitrary behavioural voltage source”. These voltage sources generate a voltage that is defined by formulas and functions.

For our use a simple IF-function will suffice: if the value of the sine wave is higher than the triangular voltage a voltage will be put out. If the value is lower 0 will be put out. For our example we choose 5 V for the peak value of the PWM.

This voltage source must be connectet to ground too. That the PWM does not stand for itself the output is connected to a simple RC low pass filter.

The last figure shows all voltages as the result.

  • Red: the sine wave,
  • Blue: the triangular voltage,
  • Green: the PWM and
  • Yellow: the voltage from the PWM after the low pass filter

komplette-simulation

simulationskurven

Generation Of Saw Tooth Or Triangular Voltages With SwitcherCAD

One who needs to simulate a circuit will sooner or later stumple across SwitcherCAD. This article shows how to generate a saw tooth or triangular voltage.

The company Linar Technology provides on its web site the tool SwitcherCAD for free.
It is a Spice base simulation tool that is uses to simulate curcuits. Unfortunatly it is only available for the Windows platform.

Generations Of Saw Tooth Or Triangular Voltages

From the component dialog choose a voltage source “voltage” and place it in the schematic with OK.
SwitcherCAD component dialog
With a right click on the voltage source in the schematic open the dialog für the voltage source.
SwitcherCAD voltage source dialog
In this dialog click on Advanced to open the advanced dialog.
Choose the function “PULSE”. To generate a saw tooth the parameters “T rise” “T fall” “T on” and “T period” are important.
For this example we want to generate a saw tooth with 20 Hz.
“T period” needs to be 50 ms.
“T rise” could be set to 50 ms and “T on” and “T fall” to 0, but this can leed to strange simulation results. It has been proved to set “T on” and “T fall” at least to 1 ns and substract this times from “T on”. The result must be entered for “T raise”. Of course you need to enter a value for “Von” higher than 0 to have a voltage that can be measured.
SwitcherCAD voltage source dialog advanced
The result should then look like this:
SwitcherCAD sawtooth voltage source
SwitcherCAD sawtooth voltage plot

To generate a triangular volage only a little modification is necessary. “T raise” will be set to 25 ms, “T on” to 0 and “T fall” will also set to 25ms.
SwitcherCAD triangular voltage plot