Category Archives: Tutorials

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

Plotting With Gnuplot And Parameter File

How do I set up Gnuplot so that the ouput will be safed to a file, what parameters influence the output.

#Title of the plotdes
set title “Verbrauchsdaten Strom und Gas”
#Title of the x-axis
set xlabel “Monat”
#Title of the y-axis
set ylabel “Strom-/Gasverbrauch in kWh”

#the x-axis is formatted as a date
set xdata time
#the data format for the x-axis data is “06/2006”
set timefmt “%m/%Y”
#the label of the x-axis shall be in the form of “Jun 06”
set format x “%b %y”
#the y-axis shall have 5 subdivisions of the main tics
set mytics 5
#on the x-axis only the months 07/2005 till 06/2006 shall be displayed
set xrange[“07/2005″:”06/2006”]
#the grid shall be behind the plotted data
set grid back
#the line width of the main grid shall be 2, of the sub grid 0,5
set grid mytics lw 2, lw .5
#for the x-axis no grid is displayed
set grid noxtics
#the data will be displayed as boxes which are 80% wide
set boxwidth 0.8 relative
#the boxes will be filled with a 25% intensity
set style fill solid .25
#the legend will be displayed left of the plot
set key left
#output to pdf file
set terminal pdf
#output file will be named “strom_und_gasverbrauch.pdf”
set output ‘strom_und_gasverbrauch.pdf’

#input data is in file “strom_und_gasverbrauch.csv”,
#for Gasverbrauch column 2 is x-axis and
# column 7 isy-axis
# in legend the plot will be described as ‘Gasverbrauch’,
# it will be display as box with color 3
# the second plot uses column 2 and 4 is labeled ‘Stromverbrauch’
# will be displayed as box and with color 1
plot\
‘strom_und_gasverbrauch.csv’ u 2:7 title ‘Gasverbrauch’ w boxes fs 3,\
‘strom_und_gasverbrauch.csv’ u 2:4 title ‘Stromverbrauch’ w boxes fs 1