这个无刷电机是三相直流无刷电机,低转速,用以作为云台控制。
我使用DRV8313,也就是半H桥来驱动它,每个半H桥由上下两个N沟道功率MOSFET构成,现在我使用这位大哥
http://www.berryjam.eu/2015/04/driving-bldc-gimbals-at-super-slow-speeds-with-arduino/#comment-5238
的方案,可是我的电机每次转到一个小角度以后会突然折回。
以下是我的部分程序
int main(void)
{
TIM3_Init(255,200);
TIM3_PWM_Init();
TIM_Cmd(TIM3, ENABLE); //使能TIM3
while(1)
{
}
}
这是改变占空比的中断函数
void TIM3_IRQHandler()
{
static u8 Counter_sine_1=0,Counter_sine_2=16,Counter_sine_3=32;
static u16 Duty_Cycle_sinewavetable[]={511,444,379,315,256,200,150,106,68,39,17,
4,0,4,17,39,68,106,150,200,256,315,379,444,
511,578,643,707,767,822,872,916,954,983,1005,1018,
1022,1018,1005,983,954,916,872,822,767,707,643,578,511};
static u8 Duty_Cycle_sinewavetable_1[]={127, 138, 149, 160, 170, 181, 191, 200, 209, 217, 224,
231, 237, 242, 246, 250, 252, 254, 254, 254,
252, 250, 246, 242, 237, 231, 224, 217, 209,
200, 191, 181, 170, 160, 149, 138, 127, 116,
105, 94, 84, 73, 64, 54, 45, 37, 30, 23, 17,
12, 8, 4, 2, 0, 0, 0, 2, 4, 8, 12, 17, 23,
30, 37, 45, 54, 64, 73, 84, 94, 105, 116 };
u8 PWM_factor=1;
if ( TIM_GetITStatus(TIM3,TIM_IT_Update)==SET)
{
Counter_sine_1++;
Counter_sine_2++;
Counter_sine_3++;
if(Counter_sine_1>71) Counter_sine_1=0;
if(Counter_sine_2>71) Counter_sine_2=0;
if(Counter_sine_3>71) Counter_sine_3=0;
TIM_SetCompare4(TIM3,Duty_Cycle_sinewavetable_1[Counter_sine_1]/PWM_factor);
TIM_SetCompare2(TIM3,Duty_Cycle_sinewavetable_1[Counter_sine_3]/PWM_factor);
TIM_SetCompare3(TIM3,Duty_Cycle_sinewavetable_1[Counter_sine_2]/PWM_factor);
}
TIM_ClearITPendingBit(TIM3,TIM_FLAG_Update);
}
这是我在KEIL中仿真用软件出来的SPWM波形:
|