在sample code上有一個地方不太懂意思:
s16 CalcIm(s16 hId_input)
{
s32 wTemp1;
s32 wTemp2;
s16 hIm;
hIm = ((s16)(wIm / 65536));
mul_q15_q15_q31(qK_EULER,hId_input,&wTemp1);
mul_q15_q15_q31(qK_EULER,hIm,&wTemp2);
wTemp1 -= wTemp2;
wTemp1 /= EUL_SENS;
wIm += wTemp1;
hIm = ((s16)(wIm / 65536));
return (hIm);
}
static s32 wIm = ((K_RAD_PULSE_HI + 1)*65536) ;
#define K_RAD_PULSE_HI (s16)(K_RAD_PULSE / 65536)
#define K_RAD_PULSE (s32)(((65536/(2 * PI))/(ROTOR_TIME_CONSTANT * 0.000001 *SAMPLING_FREQ))*65536)
#define ROTOR_TIME_CONSTANT ((u32)54307) /*Lr/Rr [usec]*/
#define SAMPLING_FREQ ((u16)PWM_FREQ/((REP_RATE+1)/2)) // Resolution: 1Hz
我想請教一下,為什麼hIm要除上ROTOR_TIME_CONSTANT *SAMPLING_FREQ?
Im的公式是 im(Rk+1) = im(Rk) + T/Tr(id - im)
為什麼一開始還要求im?不是取上一次的值來計算嗎?
懇請指教,謝謝! |