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.
Hi,
I am working on the EQEP project, more specifically eqep_ex2_pos_speed.c to obtain motor speed and angle.
Could you please explain the reason why they are doing this? p->thetaMech &= 0x7FFF
I have given the code snippet below -
// The following lines calculate // // p->thetaMech ~= QPOSCNT / mechScaler [current cnt/(total cnt in 1 rev)] // // where mechScaler = 4000 cnts/revolution // temp = (int32_t)p->thetaRaw * (int32_t)p->mechScaler; // Q0 * Q26 = Q26 temp &= 0x03FFF000; p->thetaMech = (int16_t)(temp >> 11); // Q26 -> Q15 p->thetaMech &= 0x7FFF;
Like the comment, the "thetaMech" is _IQ15 format and its maximum value is _IQ(1.0).
_IQ(1.0) = 0x7FFF