请问霍尔传感器是如何获取无刷电机的速度的?下面是程序代码。
hall_change_time_sum+=isr_time_inc;
hall_change_time_sum-=hall_change_time[hall_change_time_index];
hall_change_time[hall_change_time_index]=isr_time_inc;
isr_time_inc=0;
hall_change_time_index++;
hall_change_time_index &=0x3;
hall_change_time_ave=hall_change_time_sum>>2;
speed_tmp = ((long)200000)/hall_change_time_ave;
system.now_speed = speed_tmp;
speed_no_change_inc=0;
}
else
{
speed_no_change_inc++;
if(speed_no_change_inc>1000)
{
speed_no_change_inc=0;
system.now_speed=0;
}
}
if(IsrTicker&0xff==0xff)
{
pid1_spd.Ref = system.speed_close_loop;
pid1_spd.Fdb = system.now_speed*3;
pid1_spd.calc(&pid1_spd);
} |