Other Parts Discussed in Thread: CONTROLSUITE, INSTASPIN-BLDC
目前在调试无感BLDC控制
例程参考:HVBLDC_Sensorless及InstaSPIN_BLDC
我是在TMS320F28335上调试的,由于InstaSPIN_BLDC中使用的C28x_InstaSPIN_BLDC_Lib.lib只支持定点控制器,所以编写代码的时候参考了两个例程,过零点检测使用了HVBLDC_Sensorless中的“com_trig.h”。
目前调试的情况是,仅速度闭环,从一定占空比的开环强拉到速度闭环,都是正常的。
在正转基础上,增加了反转,运行异常,表位为强拉结束后进入速度闭环,母线电流迅速增加,硬件电路过流报警。
硬件平台是自己设计的,目前已经完成了:
1.PMSM无位置传感器控制,使用增强型滑膜观测器eSMO;
2.BLDC电机带霍尔传感器的转速电流双闭环控制、正反向控制
3.BLDC电机无位置传感器速度环控制、正向运行
鉴于此,我想硬件平台应该没有问题,目前BLDC无位置传感器速度环控制反向运行异常可能不是硬件电路的原因,伪代码如下,请大家帮我看看是哪里的问题
__interrupt void
BLDC_MainISR(void)
{
static Uint32 IsrTicker = 0;
// Verifying the ISR
IsrTicker++;
// Initial Rotor Alignment Process
if( g_AlignFlag != 0 )
{
转子位置对其处理;
}
else
{
母线电流采集;
母线电压采集;
// Connect inputs of the RMP module and call the Ramp control macro.
g_rc1.TargetValue = g_SpeedRef;
RC_MACRO(g_rc1)
// ------------------------------------------------------------------------------
// Connect inputs of the MOD6 module and call the Modulo 6 counter macro.
// ------------------------------------------------------------------------------
// Switch from open-loop to closed-loop operation by Ramp3DoneFlag variable
if(g_SpeedRef > _IQ(0.0))
{
g_mod_dir1.CntDirection = _IQ(1.0);
}
else
{
g_mod_dir1.CntDirection = _IQ(-1.0);
}
g_PreviousState = g_mod_dir1.Counter;
MOD6CNTDIR_MACRO(g_mod_dir1) // 使用instaSPIN_BLDC中的moddir宏函数
// ------------------------------------------------------------------------------
// Set the speed closed loop flag once the speed is built up to a desired value.
// ------------------------------------------------------------------------------
//while counting up we want positive speed
if( ( g_mod_dir1.Counter == 5 ) && ( g_PreviousState == 4 ) && g_mod_dir1.TrigInput)
{
g_speed1.TimeStamp = g_VirtualTimer;
SPEED_PR_MACRO(g_speed1);
g_SpeedLoopFlag = TRUE;
}
//while counting down we want negative speed
else if( ( g_mod_dir1.Counter == 0 ) && ( g_PreviousState == 1 ) && g_mod_dir1.TrigInput )
{
g_speed1.TimeStamp = g_VirtualTimer;
SPEED_PR_MACRO(g_speed1);
g_speed1.Speed = _IQmpy(g_speed1.Speed,_IQ(-1.0));
g_SpeedLoopFlag = TRUE;
} // 该部分代码参照instaSPIN_BLDC例程
// ------------------------------------------------------------------------------
// Connect inputs of the COM_TRIG module and call the Commutation trigger macro.
// ------------------------------------------------------------------------------
g_cmtn1.Va = AdcMirror.ADCRESULT2 * IQ12TOFLOAT - g_offset_Va;
g_cmtn1.Vb = AdcMirror.ADCRESULT3 * IQ12TOFLOAT - g_offset_Vb;
g_cmtn1.Vc = AdcMirror.ADCRESULT4 * IQ12TOFLOAT - g_offset_Vc;
g_cmtn1.CmtnPointer = g_mod_dir1.Counter;
g_cmtn1.VirtualTimer = g_VirtualTimer;
CMTN_TRIG_MACRO(g_cmtn1) // 该部分代码参照HVBLDC_Sensorless
g_mod_dir1.TrigInput = g_cmtn1.CmtnTrig; // 参照instaSPIN_BLDC例程增加了这条语句
if( ( g_rmp3.Ramp3DoneFlag == 0) || ( g_SpeedLoopFlag == FALSE ) )
{
// Connect inputs of the RMP3 module and call the Ramp control 3 macro.
g_rmp3.DesiredInput = g_CmtnPeriodTarget;
g_rmp3.Ramp3Delay = g_RampDelay;
RC3_MACRO(g_rmp3)
// Connect inputs of the IMPULSE module and call the Impulse macro.
g_impl1.Period = g_rmp3.Out;
IMPULSE_MACRO(g_impl1)
// ------------------------------------------------------------------------------
// Connect inputs of the MOD6 module and call the Modulo 6 counter macro.
// ------------------------------------------------------------------------------
g_mod_dir1.TrigInput = g_impl1.Out;
} // 该部分代码参照instaSPIN_BLDC例程
// ------------------------------------------------------------------------------
// Connect inputs of the RMP2 module and call the Ramp control 2 macro.
// ------------------------------------------------------------------------------
g_rmp2.DesiredInput = g_DfuncTesting * FLOATTOIQ15;
RC2_MACRO(g_rmp2)
// ------------------------------------------------------------------------------
// Connect inputs of the PID_REG3 module and call the PID speed controller macro.
// ------------------------------------------------------------------------------
g_pid1_spd.Ref = g_rc1.SetpointValue;
g_pid1_spd.Fbk = g_speed1.Speed;
PI_MACRO(g_pid1_spd)
if( g_SpeedRef >= 0 )
{
if( g_pid1_spd.Out < 0 )
{
g_pid1_spd.ui = 0;
g_pid1_spd.i1 = 0;
}
}
else if( g_SpeedRef < 0 )
{
if( g_pid1_spd.Out > 0 )
{
g_pid1_spd.ui = 0;
g_pid1_spd.i1 = 0;
}
}
// ------------------------------------------------------------------------------
// Connect inputs of the PWM_DRV module and call the PWM signal generation
// update macro.
// ------------------------------------------------------------------------------
// Switch from fixed duty-cycle or controlled Speed duty-cycle by SpeedLoopFlag variable
if( g_SpeedLoopFlag == FALSE )
{
g_pwm1.DutyFunc = (int16)g_rmp2.Out; //速度开环时,由斜坡函数给定占空比
g_pid1_spd.ui = _IQ(0.0);
g_pid1_spd.i1 = _IQ(0.0); //速度开环时,控制器清0
}
else
{
g_pwm1.CmtnPointer = g_mod_dir1.Counter;
g_pwm1.DutyFunc = _IQmpy(g_pid1_spd.Out * FLOATTOIQ15,g_mod_dir1.CntDirection);
BLDCPWM_MACRO(1,2,3,g_pwm1)
}
.......
}
// Reinitialize for next ADC sequence
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1; // Reset SEQ1
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; // Clear INT SEQ1 bit
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Acknowledge interrupt to PIE
}



