# Copyright (C) 2012 Ronald Steven Sutherland # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Using gnuplot 4.4 to generate a plot that explains the # principle of 3phase intersective pwm. Run with: # gnuplot PWM.gnuplot # Change eps to png with: # convert -density 300 Pwm.eps Pwm.png # graph configuration set terminal postscript eps enhanced "Times-Roman" 14 color solid set encoding iso_8859_15 unset title set style line 1 lt 3 lw 3 pt 0 ps 0 set style line 2 lt 2 lw 3 pt 0 ps 0 set style line 3 lt 4 lw 3 pt 0 ps 0 set style line 4 lt 5 lw 3 pt 0 ps 0 set border 15 lt 7 lw 4 set grid xtics ytics set xlabel "" set samples 10000 set format x "" set bmargin 0 set tmargin 0 # equation of the sawtooth signal sawsignal(x) = x-floor(x) #equation of the sine signal freq=0.05 sinesignal_a(x) = 0.5+0.499*sin(freq*x*(2*pi)) sinesignal_b(x) = 0.5+0.499*sin(2*pi/3+freq*x*(2*pi)) sinesignal_c(x) = 0.5+0.499*sin(4*pi/3+freq*x*(2*pi)) #equation of the resulting pwm signal pwmsignal_a(x)=sawsignal(x)>=sinesignal_a(x)?0:1 pwmsignal_b(x)=sawsignal(x)>=sinesignal_b(x)?0:1 pwmsignal_c(x)=sawsignal(x)>=sinesignal_c(x)?0:1 #equation of the n-th intersection between sinesignal and # sawsignal (used to plot the tics on the x axis) #the following points are generated by python: #from scipy import * #freq= 0.05 #n=20 #for i in range(n): # def f(x): # return sin(freq*x*2*pi)-2*x+1+2*i # print i,",", optimize.fsolve(f,0), ",\" set xtics (0 , 0.592539223108 ,\ 1 , 1.76298640357 ,\ 2 , 2.89455246531 ,\ 3 , 3.97426347018 ,\ 4 , 5.0 ,\ 5 , 5.97664892031 ,\ 6 , 6.9124388806 ,\ 7 , 7.81668786014 ,\ 8 , 8.69875361032 ,\ 9 , 9.56769737702 ,\ 10 , 10.432302623 ,\ 11 , 11.3012463897 ,\ 12 , 12.1833121399 ,\ 13 , 13.0875611194 ,\ 14 , 14.0233510797 ,\ 15 , 15.0 ,\ 16 , 16.0257365298 ,\ 17 , 17.1054475347 ,\ 18 , 18.2370135964 ,\ 19 , 19.4074607769) set ytics ("0" 0, "1" 1) set output "Pwm.eps" set multiplot set ylabel "source signals" set origin 0,0.78 set size 1,0.21 plot [0:19][-0.25:1.25] sawsignal(x) ls 1 title '', \ sinesignal_a(x) ls 2 title '',\ sinesignal_b(x) ls 3 title '',\ sinesignal_c(x) ls 4 title '' set ylabel "PWM signal A" set origin 0,0.55 plot [0:19][-0.25:1.25] pwmsignal_a(x) ls 2 title '' set ylabel "PWM signal B" set origin 0,0.32 plot [0:19][-0.25:1.25] pwmsignal_b(x) ls 3 title '' set ylabel "PWM signal C" set xlabel "Time" set origin 0,0.09 plot [0:19][-0.25:1.25] pwmsignal_c(x) ls 4 title '' unset multiplot