Other Parts Discussed in Thread: C2000WARE
hi ,
i am using tms320f28379D dsp microcontroller for eQEP (quadrature encoder).
in this Example_279dxEqep_pos_speed.c my qusetions are
tmp = (long)((long)pos16bval*(long)p->mech_scaler); // Q0*Q26 = Q26
tmp &= 0x03FFF000;
tmp = (int)(tmp>>11); // Q26 -> Q15
Ques1. why mech_scalar is taken as 2^26/4000 insted of (1/4000).
Ques2. why the temp is & with 0x03FFF000;
Ques3. why the temp is >>(right shifted) with 11;
Ques4. why the temp is & with 0x7FFF;
Ques5. what is the meaning of newp=_IQ15toIQ(tmp);in that what is _IQ15toIQ(tmp)? if it is equal to tmp/2^9, then why are we dividng tmp by 2^9?
if (p->DirectionQep==0) // POSCNT is counting down
{
if (newp>oldp)
Tmp1 = - (_IQ(1) - newp + oldp); // x2-x1 should be negative
else
Tmp1 = newp -oldp;
}
Ques7. why newp - oldp is subtracted from _IQ(1) =>Tmp1 = - (_IQ(1) - newp + oldp)? why _IQ(1) is used in this statement?
please guide us on above problem as early as possible