如题;现在启动的时候需要手拨动几下才转起来。。。感觉是启动定位问题,但启动时转子的定位程序在第一次启动时没问题。以下是按键停启的程序
void mo_zuan_qt_key(void)
{
if(GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_13) == 0 )
{
delay(10000);
if(GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_13) == 0 )
{
qt_bz++;
dl_zf_key=0;
mo_zuan_qt=1;
TIM_CtrlPWMOutputs(TIM1,ENABLE);//TIM1方波输出使能
TIM_ITConfig(TIM1, TIM_IT_COM, ENABLE);//TIM2中断使能
TIM_Cmd(TIM2,ENABLE);//打开霍尔捕获定时器
TIM_ITConfig(TIM2, TIM_IT_CC1, ENABLE);
TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);//TIM1中断使能
TIM_Cmd(TIM6,ENABLE);
TIM_ITConfig(TIM6,TIM_IT_Update,ENABLE);
BLDC_Hall_Conifg();//转子定位程序
}
}
else
{
qt_bz=0;
TIM_Cmd(TIM2,DISABLE);
TIM1->CCER=0x3888;
TIM_GenerateEvent(TIM1,TIM_EventSource_COM);
TIM_CtrlPWMOutputs(TIM1,DISABLE);
TIM_Cmd(TIM2,DISABLE);
TIM_Cmd(TIM6,DISABLE);
}
}
void BLDC_Hall_Conifg(void)
{
switch(ReadHallState())
{
//*
case 0x01:{
TIM1->CCER=0x3890;//3,6 cb
TIM_GenerateEvent(TIM1,TIM_EventSource_COM);
};break;
case 0x05:{
TIM1->CCER=0x3098;//2,3 ab
TIM_GenerateEvent(TIM1,TIM_EventSource_COM);
};break;
case 0x04:{
TIM1->CCER=0x3089;//2,5 ac
TIM_GenerateEvent(TIM1,TIM_EventSource_COM);
};break;
case 0x06:{
TIM1->CCER=0x3809;//4,5 bc
TIM_GenerateEvent(TIM1,TIM_EventSource_COM);
};break;
case 0x02:{
TIM1->CCER=0x3908;//1,4 ba
TIM_GenerateEvent(TIM1,TIM_EventSource_COM);
};break;
case 0x03:{
TIM1->CCER=0x3980;//1,6 ca
TIM_GenerateEvent(TIM1,TIM_EventSource_COM);
};break;
default:break;
}
} |
您好,我最近在做无刷直流电机控制,能请教您几个问题吗