void setPhaseVoltage(float Uq, float Ud, float angle_el) {
int sector = (angle_el / _PI_3) + 1; // 扇区判断
float T1 = _SQRT3 * _sin(sector * _PI_3 - angle_el) * Uq / driver.voltage_limit;
float T2 = _SQRT3 * _sin(angle_el - (sector - 1) * _PI_3) * Uq / driver.voltage_limit;
float T0 = 1 - T1 - T2; // 零矢量作用时间
float Ta, Tb, Tc;
switch (sector) {
case 1:
Ta = T1 + T2 + T0 / 2;
Tb = T2 + T0 / 2;
Tc = T0 / 2;
break;
// 其他扇区类似处理...
}
// 更新PWM占空比
driver.setPwm(Ta, Tb, Tc);
}
|