在线时间13 小时
UID3393018
ST金币64
蝴蝶豆5
注册时间2017-8-30
该用户从未签到
初级会员
- 最后登录
- 2020-10-19
|
发表于 2018-11-29 09:29:33
|
显示全部楼层
楼主,能不能分析一下 FOC 2.0 无感启动过程啊?
void STO_Start_Up(void)
{
s16 hAux;
#ifdef NO_SPEED_SENSORS_ALIGNMENT
static u32 wAlignmentTbase=0;
#endif
switch(Start_Up_State)
{
case S_INIT:
//Init Ramp-up variables
if (hSpeed_Reference >= 0)
{
hFreq_Inc = FREQ_INC;
hI_Inc = I_INC;
if (wTime == 0)
{
wStart_Up_I = FIRST_I_STARTUP *1024;
}
}
else
{
hFreq_Inc = -(s16)FREQ_INC;
hI_Inc = -(s16)I_INC;
if (wTime == 0)
{
wStart_Up_I = -(s32)FIRST_I_STARTUP *1024;
}
}
Start_Up_State = ALIGNMENT;
break;
case ALIGNMENT:
#ifdef NO_SPEED_SENSORS_ALIGNMENT
wAlignmentTbase++;
if(wAlignmentTbase <= SLESS_T_ALIGNMENT_PWM_STEPS)
{
hFlux_Reference = SLESS_I_ALIGNMENT * wAlignmentTbase /
SLESS_T_ALIGNMENT_PWM_STEPS;
hTorque_Reference = 0;
Stat_Curr_a_b = GET_PHASE_CURRENTS();
Stat_Curr_alfa_beta = Clarke(Stat_Curr_a_b);
Stat_Curr_q_d = Park(Stat_Curr_alfa_beta, SLESS_ALIGNMENT_ANGLE_S16);
/*loads the Torque Regulator output reference voltage Vqs*/
Stat_Volt_q_d.qV_Component1 = PID_Regulator(hTorque_Reference,
Stat_Curr_q_d.qI_Component1, &PID_Torque_InitStructure);
/*loads the Flux Regulator output reference voltage Vds*/
Stat_Volt_q_d.qV_Component2 = PID_Regulator(hFlux_Reference,
Stat_Curr_q_d.qI_Component2, &PID_Flux_InitStructure);
RevPark_Circle_Limitation();
/*Performs the Reverse Park transformation,
i.e transforms stator voltages Vqs and Vds into Valpha and Vbeta on a
stationary reference frame*/
Stat_Volt_alfa_beta = Rev_Park(Stat_Volt_q_d);
/*Valpha and Vbeta finally drive the power stage*/
CALC_SVPWM(Stat_Volt_alfa_beta);
}
else
{
wAlignmentTbase = 0;
Stat_Volt_q_d.qV_Component1 = Stat_Volt_q_d.qV_Component2 = 0;
hTorque_Reference = PID_TORQUE_REFERENCE;
hFlux_Reference = PID_FLUX_REFERENCE;
Start_Up_State = RAMP_UP;
hAngle = SLESS_ALIGNMENT_ANGLE_S16;
}
#else
Start_Up_State = RAMP_UP;
#endif
break;
case RAMP_UP:
wTime ++;
if (wTime <= I_STARTUP_PWM_STEPS)
{
wStart_Up_Freq += hFreq_Inc;
wStart_Up_I += hI_Inc;
}
else if (wTime <= FREQ_STARTUP_PWM_STEPS )
{
wStart_Up_Freq += hFreq_Inc;
}
else
{
MCL_SetFault(START_UP_FAILURE);
//Re_initialize Start Up
STO_StartUp_Init();
}
//Add angle increment for ramp-up
hAux = wStart_Up_Freq/65536;
hAngle = (s16)(hAngle + (s32)(65536/(SAMPLING_FREQ/hAux)));
Stat_Curr_a_b = GET_PHASE_CURRENTS();
Stat_Curr_alfa_beta = Clarke(Stat_Curr_a_b);
Stat_Curr_q_d = Park(Stat_Curr_alfa_beta, hAngle);
hAux = wStart_Up_I/1024;
hTorque_Reference = hAux;
hFlux_Reference = 0;
/*loads the Torque Regulator output reference voltage Vqs*/
Stat_Volt_q_d.qV_Component1 = PID_Regulator(hTorque_Reference,
Stat_Curr_q_d.qI_Component1, &PID_Torque_InitStructure);
/*loads the Flux Regulator output reference voltage Vds*/
Stat_Volt_q_d.qV_Component2 = PID_Regulator(hFlux_Reference,
Stat_Curr_q_d.qI_Component2, &PID_Flux_InitStructure);
RevPark_Circle_Limitation();
/*Performs the Reverse Park transformation,
i.e transforms stator voltages Vqs and Vds into Valpha and Vbeta on a
stationary reference frame*/
Stat_Volt_alfa_beta = Rev_Park(Stat_Volt_q_d);
/*Valpha and Vbeta finally drive the power stage*/
CALC_SVPWM(Stat_Volt_alfa_beta);
STO_Calc_Rotor_Angle(Stat_Volt_alfa_beta,Stat_Curr_alfa_beta,MCL_Get_BusVolt());
if (IsObserverConverged()==TRUE)
{
PID_Speed_InitStructure.wIntegral = (s32)(hTorque_Reference*256);
STO_StartUp_Init();
State = RUN;
if ((wGlobal_Flags & SPEED_CONTROL) != SPEED_CONTROL)
{
hTorque_Reference = PID_TORQUE_REFERENCE;
hFlux_Reference = PID_FLUX_REFERENCE;
}
}
break;
default:
break;
}
}
/*******************************************************************************
* Function Name : STO_StartUp_Init
* Description : This private function initializes the sensorless start-up
* Input : details the input parameters.
* Output : details the output parameters.
* Return : details the return value.
*******************************************************************************/
void STO_StartUp_Init(void)
{
//Re_initialize Start Up
Start_Up_State = S_INIT;
hAngle = 0;
wTime = 0;
wStart_Up_Freq = 0;
bConvCounter = 0;
} |
|