请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:TMS320F28379D 你好
在示例项目 eQEP_ex2_pos_speed/eQEP_ex2_calculation.c 中、您计算出机械 θ。 我希望该数字以度为单位。 它采用定点 Q15格式。 当我从 Q15转换为浮点时、它会为我提供非常小的数字。
您能解释一下我如何从0到360度获得角度。
//
//下面的行计算
//
// p->thetaMech ~= QPOSCNT / mechscaler [当前 cnt/(总 cnt 为1 rev)]
//
//其中 mechscal=4000 cnts/rocal
//
temp =(int32_t) p->thetaRaw *(int32_t) p->mechscalp;// Q0 * Q26 = Q26
temp &= 0x03FFF000;
p->thetaMech =(int16_t)(temp >> 11);// Q26 -> Q15
p->thetaMech &= 0x7FFF;