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.

TMS320F280049C: EQEP Calculation Doubt

Part Number: TMS320F280049C

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 -

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
// 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;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX