PWM
In the circuit given below, the switches are operated using the bipolar pulse width modulation technique with a switching frequency of $1\,$kHz. The modulation voltage is $m(t)=0.8\,\cos (100\,\pi\,t)$. What is the width of the longest pulse in the output $v_{BC}$ of the inverter?In [1]:
from IPython.display import Image
Image(filename =r'pwm_8_fig_1.png', width=550)
Out[1]:
In [2]:
import numpy as np
import matplotlib.pyplot as plt
import gseim_calc as calc
from setsize import set_size
f_tri = 1.0e3
f_sin = 50.0
T_tri = 1/f_tri
T_sin = 1/f_sin
n_div = 40000
t = np.linspace(0.0, 2.0*T_sin, (n_div+1))
m = 0.8
omg_sin = 2.0*np.pi*f_sin
x_sin = m*np.cos(omg_sin*t)
x_tri_min = -1.0
x_tri_max = 1.0
slope = (x_tri_max-x_tri_min)/(0.5*T_tri)
l_x_tri = []
for i, t1a in enumerate(t):
t1 = t1a % T_tri
if t1 < 0.5*T_tri:
x_tri_0 = x_tri_max - slope*t1
else:
x_tri_0 = x_tri_min + slope*(t1-0.5*T_tri)
l_x_tri.append(x_tri_0)
x_tri = np.array(l_x_tri)
x_pwm = np.where(x_sin > x_tri, 1.0, 0.0)
l_t_change = []
l_low_to_high = []
for k in range(1,len(t)):
y_1 = x_pwm[k-1]
y_2 = x_pwm[k]
if (y_1 != y_2):
l_t_change.append(t[k])
l_low_to_high.append(y_1 == 0.0)
l_low_to_high_width = []
l_high_to_low_width = []
l_low_to_high_time = []
l_high_to_low_time = []
for k in range(len(l_t_change)-1):
width = l_t_change[k+1] - l_t_change[k]
if l_low_to_high[k]:
l_low_to_high_width.append(width)
l_low_to_high_time.append(l_t_change[k])
else:
l_high_to_low_width.append(width)
l_high_to_low_time.append(l_t_change[k])
w_max_low_to_high = 0.0
w_max_high_to_low = 0.0
t_max_low_to_high = -1.0
t_max_high_to_low = -1.0
for k in range(len(l_low_to_high_width)):
t0 = l_low_to_high_time[k]
w0 = l_low_to_high_width[k]
if w0 > w_max_low_to_high:
w_max_low_to_high = w0
t_max_low_to_high = t0
for k in range(len(l_high_to_low_width)):
t0 = l_high_to_low_time[k]
w0 = l_high_to_low_width[k]
if w0 > w_max_high_to_low:
w_max_high_to_low = w0
t_max_high_to_low = t0
print("w_max_low_to_high:", "%11.4E"%(1e3*w_max_low_to_high), "msec")
print("t_max_low_to_high:", "%11.4E"%(1e3*t_max_low_to_high), "msec")
print("w_max_high_to_low:", "%11.4E"%(1e3*w_max_high_to_low), "msec")
print("t_max_high_to_low:", "%11.4E"%(1e3*t_max_high_to_low), "msec")
fig, ax = plt.subplots(2, sharex=False)
plt.subplots_adjust(wspace=0, hspace=0.0)
set_size(6, 4, ax[0])
for k in range(2):
ax[k].set_xlim(left=0.0, right=2.0*T_sin*1e3)
ax[k].grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)
ax[0].plot(t*1e3, x_tri, color='dodgerblue', linewidth=1.0, label="$t$")
ax[0].plot(t*1e3, x_sin, color='blue', linewidth=1.0, label="$s$")
ax[1].plot(t*1e3, x_pwm, color='red', linewidth=1.0, label="$x_{pwm}$")
plt.tight_layout()
plt.show()
w_max_low_to_high: 8.9100E-01 msec t_max_low_to_high: 3.9059E+01 msec w_max_high_to_low: 8.9700E-01 msec t_max_high_to_low: 9.5520E+00 msec
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.
In [ ]: