光电编码器位置检测程序
1.位置检测,计算过程中的变量的定义
/*--------------------------------------------------------------------
Define the structure of the QEP (Quadrature Encoder) Driver Object
-----------------------------------------------------------------------------*/
typedef struct {int16 ElecTheta; // Output: Motor Electrical angle (Q15)
//(输出的电角度?)
int16 MechTheta; // Output: Motor Mechanical Angle (Q15)
//(输出的机械角度?)
Uint16 DirecTIonQep; // Output: Motor rotaTIon direcTIon (Q0)
//(电机转向?)
Uint16 QepCounTIndex; // Variable: Encoder counter index (Q0)
//(编码器输出的脉冲数?)
Uint16 RawTheta; // Variable: Raw angle from Timer 2 (Q0)
//(某一时刻转子对于定子A相的绝对角度?)
Uint32 MechScaler; // Parameter: 0.9999/total count (Q30)
//(每个脉冲所转过的机械角度?)
Uint16 LineEncoder; // Parameter: Number of line encoder (Q0)
//(编码器每转输出的脉冲个数?)
Uint16 PolePairs; // Parameter: Number of pole pairs (Q0)
更多编码器知识请访问http://www.elecfans.com/zhuanti/20111111242149.html