代码拉取完成,页面将自动刷新
import numpy as np
import matplotlib.pyplot as plt
# from scipy import signal
import clark_park as cp
SQRT_3 = np.sqrt(3)*32767
Tpwm = 2400 #pwm arr
Udc = 12 #母线电压
K = int(SQRT_3 * Tpwm / Udc/32768)#np.sqrt(3) * Tpwm / Udc #调制系数怎么得出来
def svpwm_creat(Ualpha, Ubeta, elec_angle):
#求出判断扇区的三个变量
Ua, Ub, Uc = cp.svpwm_alpha_beta_to_Uabc(Ualpha, Ubeta)
# print(K)
a = Ua.copy()
a[a>0] = 1
a[a<=0] = 0
b = Ub.copy()
b[b>0] = 1
b[b<=0] = 0
c = Uc.copy()
c[c>0] = 1
c[c<=0] = 0
sentor = 1 * a + 2 * b + 4 * c
# print(sentor)
#求出计算占空比的三个电压量
ARRa = []
ARRb = []
ARRc = []
for i in range(len(elec_angle)):
# 举例
# T7 = (T - Tx -Ty) / 2
# Ta = Tx + Ty + T7 = (T +Tx + Ty) / 2 最长
# Tb = Ta - Tx 中间
# Tc = Tb - ty 最短
# Ua = b , Ub = a - b , Uc = -a - b
if sentor[i] == 3:#N=3 S=1 Tx = T4 Ty = T6
# Tx = K * (np.sqrt(3) * Ualpha[i] - Ubeta[i]) / 2 #T4 (a - b)
# Ty = K * Ubeta[i] #T6 b
Tx = K * Ub[i] #T4 (a - b)
Ty = K * Ua[i] #T6 b
# a b---c
ARRa.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRb.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRc.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
elif sentor[i] == 1:#N=1 S=2 Tx = T2 Ty = T6
# Tx = K * (-np.sqrt(3) * Ualpha[i] + Ubeta[i]) / 2 #T2 -(a - b)
# Ty = K * (np.sqrt(3) * Ualpha[i] + Ubeta[i]) / 2 #T6 -(-a - b)
Tx = K * -Ub[i] #T2 -(a - b)
Ty = K * -Uc[i] #T6 -(-a - b)
# b a---c
ARRb.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRa.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRc.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
elif sentor[i] == 5:#N=5 S=3 Tx = T2 Ty = T3
# Tx = K * Ubeta[i] #T2 b
# Ty = K * (-np.sqrt(3) * Ualpha[i] - Ubeta[i]) / 2 #T3 (-a - b)
Tx = K * Ua[i] #T2 b
Ty = K * Uc[i] #T3 (-a - b)
# b c---a
ARRb.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRc.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRa.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
elif sentor[i] == 4:#N=4 S=4 Tx = T1 Ty = T3
# Tx = K * -Ubeta[i] #T1 -b
# Ty = K * (-np.sqrt(3) * Ualpha[i] + Ubeta[i]) / 2 #T3 -(a - b)
Tx = K * -Ua[i] #T1 -b
Ty = K * -Ub[i] #T3 -(a - b)
# c b---a
ARRc.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRb.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRa.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
elif sentor[i] == 6:#N=6 S=5 Tx = T1 Ty = T5
# Tx = K * (-np.sqrt(3) * Ualpha[i] - Ubeta[i]) / 2 #T1 (-a - b)
# Ty = K * (np.sqrt(3) * Ualpha[i] - Ubeta[i]) / 2 #T5 (a - b)
Tx = K * Uc[i] #T1 (-a - b)
Ty = K * Ub[i] #T5 (a - b)
# c a---b
ARRc.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRa.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRb.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
elif sentor[i] == 2:#N=2 S=6 Tx = T4 Ty = T5
# Tx = K * (np.sqrt(3) * Ualpha[i] + Ubeta[i]) / 2 #T4 -(-a - b)
# Ty = K * -Ubeta[i] #T5 -b
Tx = K * -Uc[i] #T4 -(-a - b)
Ty = K * -Ua[i] #T5 b
# a c---b
ARRa.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRc.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRb.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
Da = np.array(ARRa)
Db = np.array(ARRb)
Dc = np.array(ARRc)
Da = Da / Tpwm
Db = Db / Tpwm
Dc = Dc / Tpwm
plt.figure("U alpha beta")
plt.plot(elec_angle, Ualpha, label='Ualpha')
plt.plot(elec_angle, Ubeta, label='Ubeta')
plt.ylabel('alpha, beta')
# plt.legend()
plt.figure("U Ua Ub Uc")
plt.plot(elec_angle, Ua, label='ux')
plt.plot(elec_angle, Ub, label='uy')
plt.plot(elec_angle, Uc, label='uy')
plt.ylabel('X Y Z')
# plt.legend()
plt.figure("ARR a b c")
plt.plot(elec_angle, ARRa, label='A')
plt.plot(elec_angle, ARRb, label='B')
plt.plot(elec_angle, ARRc, label='C')
plt.ylabel('svpwm arr')
# plt.legend()
plt.figure("duty a b c")
plt.plot(elec_angle, Da, label='A')
plt.plot(elec_angle, Db, label='B')
plt.plot(elec_angle, Dc, label='C')
plt.ylabel('svpwm duty')
# plt.legend()
return Da, Db, Dc
def svpwm_creat_if(Ualpha, Ubeta, elec_angle):
#求出判断扇区的三个变量
Ua, Ub, Uc = cp.svpwm_alpha_beta_to_Uabc(Ualpha, Ubeta)
# print(type(Ua))
print(K)
a = Ua.copy()
a[a>0] = 1
a[a<=0] = 0
b = Ub.copy()
b[b>0] = 1
b[b<=0] = 0
c = Uc.copy()
c[c>0] = 1
c[c<=0] = 0
sentor = 1 * a + 2 * b + 4 * c
# print(sentor)
#求出计算占空比的三个电压量
ARRa = []
ARRb = []
ARRc = []
''' 未验证
for i in range(len(elec_angle)):
if c[i] > 0:
if b[i] > 0:
#sentor = 2
Tx = K * -Uc[i] #T4 -(-a - b)
Ty = K * -Ua[i] #T5 b
# a c---b
ARRa.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRc.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRb.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
else:
if a[i] > 0:
#sentor = 1
Tx = K * -Ub[i] #T2 -(a - b)
Ty = K * -Uc[i] #T6 -(-a - b)
# b a---c
ARRb.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRa.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRc.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
else:
#sentor = 6
Tx = K * Uc[i] #T1 (-a - b)
Ty = K * Ub[i] #T5 (a - b)
# c a---b
ARRc.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRa.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRb.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
else:
if b[i] > 0:
if a[i] > 0:
#sentor = 3
Tx = K * Ub[i] #T4 (a - b)
Ty = K * Ua[i] #T6 b
# a b---c
ARRa.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRb.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRc.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
else:
#sentor = 4
Tx = K * -Ua[i] #T1 -b
Ty = K * -Ub[i] #T3 -(a - b)
# c b---a
ARRc.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRb.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRa.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
else:
#sentor = 5
Tx = K * Ua[i] #T2 b
Ty = K * Uc[i] #T3 (-a - b)
# b c---a
ARRb.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRc.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRa.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
'''
# '''
for i in range(len(elec_angle)):
# sentor[i] = 0
if a[i] > 0 :
sentor[i] = 1
else:
sentor[i] = 0
if b[i] > 0 :
sentor[i] = sentor[i] + 2
# else:
# sentor[i] = 0
if c[i] > 0 :
sentor[i] = sentor[i] + 4
# else:
# sentor[i] = 0
# 举例
# T7 = (T - Tx -Ty) / 2
# Ta = Tx + Ty + T7 = (T +Tx + Ty) / 2 最长
# Tb = Ta - Tx 中间
# Tc = Tb - ty 最短
# Ua = b , Ub = a - b , Uc = -a - b
if sentor[i] == 3:#N=3 S=1 Tx = T4 Ty = T6
# Tx = K * (np.sqrt(3) * Ualpha[i] - Ubeta[i]) / 2 #T4 (a - b)
# Ty = K * Ubeta[i] #T6 b
Tx = (K * Ub[i])/256 #T4 (a - b)
Ty = (K * Ua[i])/256 #T6 b
# a b---c
ARRa.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRb.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRc.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
elif sentor[i] == 1:#N=1 S=2 Tx = T2 Ty = T6
# Tx = K * (-np.sqrt(3) * Ualpha[i] + Ubeta[i]) / 2 #T2 -(a - b)
# Ty = K * (np.sqrt(3) * Ualpha[i] + Ubeta[i]) / 2 #T6 -(-a - b)
Tx = (K * -Ub[i])/256 #T2 -(a - b)
Ty = (K * -Uc[i])/256 #T6 -(-a - b)
# b a---c
ARRb.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRa.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRc.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
elif sentor[i] == 5:#N=5 S=3 Tx = T2 Ty = T3
# Tx = K * Ubeta[i] #T2 b
# Ty = K * (-np.sqrt(3) * Ualpha[i] - Ubeta[i]) / 2 #T3 (-a - b)
Tx = (K * Ua[i])/256 #T2 b
Ty = (K * Uc[i])/256 #T3 (-a - b)
# b c---a
ARRb.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRc.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRa.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
elif sentor[i] == 4:#N=4 S=4 Tx = T1 Ty = T3
# Tx = K * -Ubeta[i] #T1 -b
# Ty = K * (-np.sqrt(3) * Ualpha[i] + Ubeta[i]) / 2 #T3 -(a - b)
Tx = (K * -Ua[i])/256 #T1 -b
Ty = (K * -Ub[i])/256 #T3 -(a - b)
# c b---a
ARRc.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRb.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRa.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
elif sentor[i] == 6:#N=6 S=5 Tx = T1 Ty = T5
# Tx = K * (-np.sqrt(3) * Ualpha[i] - Ubeta[i]) / 2 #T1 (-a - b)
# Ty = K * (np.sqrt(3) * Ualpha[i] - Ubeta[i]) / 2 #T5 (a - b)
Tx = (K * Uc[i])/256 #T1 (-a - b)
Ty = (K * Ub[i])/256 #T5 (a - b)
# c a---b
ARRc.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRa.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRb.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
elif sentor[i] == 2:#N=2 S=6 Tx = T4 Ty = T5
# Tx = K * (np.sqrt(3) * Ualpha[i] + Ubeta[i]) / 2 #T4 -(-a - b)
# Ty = K * -Ubeta[i] #T5 -b
Tx = (K * -Uc[i])/256 #T4 -(-a - b)
Ty = (K * -Ua[i])/256 #T5 b
# a c---b
ARRa.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRc.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRb.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
# '''
'''
for i in range(len(elec_angle)):
# 举例
# T7 = (T - Tx -Ty) / 2
# Ta = Tx + Ty + T7 = (T +Tx + Ty) / 2 最长
# Tb = Ta - Tx 中间
# Tc = Tb - ty 最短
# Ua = b , Ub = a - b , Uc = -a - b
if sentor[i] == 3:#N=3 S=1 Tx = T4 Ty = T6
# Tx = K * (np.sqrt(3) * Ualpha[i] - Ubeta[i]) / 2 #T4 (a - b)
# Ty = K * Ubeta[i] #T6 b
Tx = K * Ub[i] #T4 (a - b)
Ty = K * Ua[i] #T6 b
# a b---c
ARRa.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRb.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRc.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
elif sentor[i] == 1:#N=1 S=2 Tx = T2 Ty = T6
# Tx = K * (-np.sqrt(3) * Ualpha[i] + Ubeta[i]) / 2 #T2 -(a - b)
# Ty = K * (np.sqrt(3) * Ualpha[i] + Ubeta[i]) / 2 #T6 -(-a - b)
Tx = K * -Ub[i] #T2 -(a - b)
Ty = K * -Uc[i] #T6 -(-a - b)
# b a---c
ARRb.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRa.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRc.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
elif sentor[i] == 5:#N=5 S=3 Tx = T2 Ty = T3
# Tx = K * Ubeta[i] #T2 b
# Ty = K * (-np.sqrt(3) * Ualpha[i] - Ubeta[i]) / 2 #T3 (-a - b)
Tx = K * Ua[i] #T2 b
Ty = K * Uc[i] #T3 (-a - b)
# b c---a
ARRb.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRc.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRa.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
elif sentor[i] == 4:#N=4 S=4 Tx = T1 Ty = T3
# Tx = K * -Ubeta[i] #T1 -b
# Ty = K * (-np.sqrt(3) * Ualpha[i] + Ubeta[i]) / 2 #T3 -(a - b)
Tx = K * -Ua[i] #T1 -b
Ty = K * -Ub[i] #T3 -(a - b)
# c b---a
ARRc.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRb.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRa.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
elif sentor[i] == 6:#N=6 S=5 Tx = T1 Ty = T5
# Tx = K * (-np.sqrt(3) * Ualpha[i] - Ubeta[i]) / 2 #T1 (-a - b)
# Ty = K * (np.sqrt(3) * Ualpha[i] - Ubeta[i]) / 2 #T5 (a - b)
Tx = K * Uc[i] #T1 (-a - b)
Ty = K * Ub[i] #T5 (a - b)
# c a---b
ARRc.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRa.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRb.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
elif sentor[i] == 2:#N=2 S=6 Tx = T4 Ty = T5
# Tx = K * (np.sqrt(3) * Ualpha[i] + Ubeta[i]) / 2 #T4 -(-a - b)
# Ty = K * -Ubeta[i] #T5 -b
Tx = K * -Uc[i] #T4 -(-a - b)
Ty = K * -Ua[i] #T5 b
# a c---b
ARRa.append( (Tpwm + Tx + Ty) / 2 ) #计算总控比计数值
ARRc.append( (Tpwm + Tx + Ty) / 2 - Tx)
ARRb.append( (Tpwm + Tx + Ty) / 2 - Tx - Ty)
'''
Da = np.array(ARRa)
Db = np.array(ARRb)
Dc = np.array(ARRc)
Da = Da / Tpwm
Db = Db / Tpwm
Dc = Dc / Tpwm
plt.figure("alpha, beta")
# plt.title('alpha, beta')
plt.plot(Ualpha, label='Ualpha')
plt.plot(Ubeta, label='Ubeta')
plt.ylabel('alpha, beta')
# plt.legend()
plt.figure('X Y Z')
plt.plot(Ua, label='ux')
plt.plot(Ub, label='uy')
plt.plot(Uc, label='uy')
plt.ylabel('X Y Z')
# plt.legend()
plt.figure('svpwm arr')
plt.plot(ARRa, label='A')
plt.plot(ARRb, label='B')
plt.plot(ARRc, label='C')
plt.ylabel('svpwm arr')
# plt.legend()
plt.figure('svpwm duty')
plt.plot(Da, label='A')
plt.plot(Db, label='B')
plt.plot(Dc, label='C')
plt.ylabel('svpwm duty')
# plt.legend()
return Da, Db, Dc
def svpwm_yb(Ualpha, Ubeta, elec_angle):
K_svpwm = 1.5
da = []
db = []
dc = []
ARRa = []
ARRb = []
ARRc = []
sersenList = []
for i in range(len(elec_angle)):
Va_abs = np.abs(Ualpha[i])
Vb3_abs = np.abs(Ubeta[i] / np.sqrt(3))
if Ualpha[i] >= 0 and Ubeta[i]>=0 and Va_abs>=Vb3_abs:
#sentor 1
d4 = K_svpwm * (Ualpha[i] - Ubeta[i]/np.sqrt(3)) / Udc
d6 = K_svpwm * (Ubeta[i] * 2 / np.sqrt(3) ) / Udc
d7 = ( 1 - d4 - d6) / 2
da.append(d4 + d6 + d7) #A相高电平占空比
db.append(d6 + d7) #B相高电平占空比
dc.append(d7) #C相高电平占空比
sersenList.append(1)
elif Ubeta[i]>=0 and Va_abs<=Ubeta[i]/np.sqrt(3):
#sentor 2
d6 = K_svpwm * (Ualpha[i] + Ubeta[i]/np.sqrt(3)) / Udc
d2 = K_svpwm * (-Ualpha[i] + Ubeta[i] / np.sqrt(3) ) / Udc
d7 = ( 1 - d2 - d6) / 2
da.append(d6 + d7) #A相高电平占空比
db.append(d2 + d6 + d7) #B相高电平占空比
dc.append(d7) #C相高电平占空比
sersenList.append(2)
elif Ualpha[i]<=0 and Ubeta[i]>=0 and Va_abs>=Vb3_abs:
#sentor 3
d2 = K_svpwm * (2 * Ubeta[i]/np.sqrt(3)) / Udc
d3 = K_svpwm * (-Ualpha[i] - Ubeta[i] / np.sqrt(3) ) / Udc
d7 = ( 1 - d2 - d3) / 2
da.append(d7) #A相高电平占空比
db.append(d2 + d3 + d7) #B相高电平占空比
dc.append(d3 + d7) #C相高电平占空比
sersenList.append(3)
elif Ualpha[i]<=0 and Ubeta[i]<=0 and Va_abs>=Vb3_abs:
#sentor 4
d1 = -K_svpwm * (2 * Ubeta[i]/np.sqrt(3)) / Udc
d3 = K_svpwm * (-Ualpha[i] + Ubeta[i] / np.sqrt(3) ) / Udc
d7 = ( 1 - d3 - d1) / 2
da.append(d7) #A相高电平占空比
db.append(d3 + d7) #B相高电平占空比
dc.append(d1 + d3 + d7) #C相高电平占空比
sersenList.append(4)
elif Va_abs<=-Ubeta[i]/np.sqrt(3):
#sentor 5
d1 = K_svpwm * (-Ualpha[i] - Ubeta[i] / np.sqrt(3) ) / Udc
d5 = K_svpwm * (Ualpha[i] - Ubeta[i] / np.sqrt(3) ) / Udc
d7 = ( 1 - d5 - d1) / 2
da.append(d5 + d7) #A相高电平占空比
db.append(d7) #B相高电平占空比
dc.append(d1 + d5 + d7) #C相高电平占空比
sersenList.append(5)
elif Ualpha[i]>=0 and Ubeta[i]<=0 and Va_abs>=Vb3_abs:
#sentor 6
d4 = K_svpwm * (Ualpha[i] + Ubeta[i] / np.sqrt(3) ) / Udc
d5 = -K_svpwm * (2 * Ubeta[i] / np.sqrt(3) ) / Udc
d7 = ( 1 - d5 - d4) / 2
da.append(d4 + d5 + d7) #A相高电平占空比
db.append(d7) #B相高电平占空比
dc.append(d5 + d7) #C相高电平占空比
sersenList.append(6)
else:
print("err", i, len(elec_angle))
ARRa.append(Tpwm * da[-1])
ARRb.append(Tpwm * db[-1])
ARRc.append(Tpwm * dc[-1])
plt.figure("svpwm U alpha beta")
plt.plot(Ualpha, label='Ualpha')
plt.plot(Ubeta, label='Ubeta')
plt.plot(elec_angle, label='theta')
plt.ylabel('alpha, beta')
plt.legend()
# plt.figure("U Ua Ub Uc")
# plt.plot(elec_angle, Ua, label='ux')
# plt.plot(elec_angle, Ub, label='uy')
# plt.plot(elec_angle, Uc, label='uy')
# plt.ylabel('X Y Z')
# plt.legend()
plt.figure("svpwm ARR a b c")
sersenListBig = [i * 100 for i in sersenList]
plt.plot(ARRa, label='A')
plt.plot(ARRb, label='B')
plt.plot(ARRc, label='C')
plt.plot(elec_angle, label='theta')
# plt.plot(sersenListBig, label='C')
plt.ylabel('svpwm arr')
plt.legend()
plt.figure("svpwm duty a b c")
plt.plot(da, label='A')
plt.plot(db, label='B')
plt.plot(dc, label='C')
plt.plot(sersenList, label='C')
plt.plot(elec_angle, label='C')
plt.ylabel('svpwm duty')
plt.legend()
# return Da, Db, Dc
#输入三相电压,输出三相占空比
def svpwm_out(ARRa, ARRb, ARRc):
print(ARRa)
if __name__ == "__main__":
rpm_in = 1000
pole_in = 5
Pwm_frq = 16000
eRpm = rpm_in * pole_in / 60
eStep = 16384 * eRpm / Pwm_frq
print("rpm_in", rpm_in, "pole_in", pole_in, "eRpm", eRpm, "eStep", eStep)
elec_angle = np.arange(0, 1000, 1)
elec_angle = elec_angle * 2 * np.pi / 1000
elec_angle = elec_angle - np.pi
dem_Uq = 6.9 #Uq的最大值是 Udc/sqrt(3) cos30 * 2/3 Udc = sqrt(3)/2 * 2/3 * udc = udc/qurt(3)
dem_Ud = 3
dem_Uq = np.sqrt(Udc*Udc/3 - dem_Ud*dem_Ud)
print("cal :", dem_Uq, dem_Ud, Udc)
Ualpha, Ubeta = cp.park_inverse_conversion(dem_Uq, dem_Ud, elec_angle)
# plt.figure("Iq Id to alpha-beta")
# plt.plot(elec_angle, Ualpha, label='Uafla')
# plt.plot(elec_angle, Ubeta, label='Ubeta')
# plt.ylabel('alpha-beta')
# plt.legend()
# ARRa, ARRb, ARRc = svpwm_creat(Ualpha, Ubeta, elec_angle)#旧计算方式
svpwm_yb(Ualpha, Ubeta, elec_angle)
# svpwm_out(ARRa, ARRb, ARRc)
plt.show()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。