Part Number:TMS320F28069
p->DirectionQep = EQep1Regs.QEPSTS.bit.QDF; //电机旋转方向 Motor direction: 0=CCW/reverse, 1=CW/forward
pos16bval=(unsigned int)EQep1Regs.QPOSCNT; // capture position once per QA/QB period 每个QA周期计数值
p->theta_raw = pos16bval+ p->cal_angle; // raw theta = current pos. + ang. offset from QA角度=计数值+原始偏差
// The following lines calculate p->theta_mech ~= QPOSCNT/mech_scaler [current cnt/(total cnt in 1 rev.)]
// where mech_scaler = 4000 cnts/revolution
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;
这段什么意思呀 特别是那些左移右移程序
Green Deng:
你好,具体是来自哪个例程的?
这些右移主要是Q格式的转换,你可以单独了解一下Q格式的转换规则。