z_jzhao 发表于 2012-2-21 10:31:59

EQEP计算机械角度

// 计算机械角度: p->theta_mech ~= QPOSCNT/mech_scaler
       // where mech_scaler = 4000 cnts/revolution
       //p->theta_mech ~= QPOSCNT/4000
   tmp = (long)((long)p->theta_raw*(long)p->mech_scaler);        // Q0*Q26 = Q26
   tmp &= 0x03FFF000;                                       
   p->theta_mech = (int)(tmp>>11);                         // Q26 -> Q15
   p->theta_mech &= 0x7FFF;      


按公式不是除法计算吗,为什么先乘法运算,后又相与,再移位,请高手解释一下,多谢!
页: [1]
查看完整版本: EQEP计算机械角度