This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

关于光电编码器测转子位置和初始速度



if(DirectionQep ==1) //T2STAT=1,递增计数,代表顺时针;
{
if((RawTheta> RawCnt1) && (OldRawThetaPos<_IQ(1000)))
{
PosCount += TotalCnt; //位置环先不管
}
Place_now= _IQtoF(TotalPulse - RawTheta)+PosCount; //位置环先不管
OldRawThetaPos = RawTheta; //将当前角度计数赋到旧的上面去
}
else if(DirectionQep ==0) //T2STAT=0,递减计数,代表逆时针
{
if((OldRawThetaPos> RawCnt2) && (RawTheta<_IQ(900)))
{
PosCount -= TotalCnt; //位置环先不管
}
Place_now = _IQtoF(TotalPulse - RawTheta)+PosCount; //位置环先不管
OldRawThetaPos = RawTheta; //将当前角度计数赋到旧的上面去
}
MechTheta = _IQmpy(MechScaler,RawTheta); //计算机械角度 见函数分析那一节