Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

How capture position once per QA/QB period is done in the void POSSPEED_Calc(POSSPEED *p) ----- pos16bval=(unsigned int)EQep1Regs.QPOSCNT;

$
0
0

hi ,
i am using tms320f28555 dsp microcontroller for eQEP (quadrature encoder).
in this Example_2833xEqep_pos_speed.c my qusetions are

I have used example code of Example_2833xEqep_pos_speed.c present in the control suite and i have configured the eQEP as follows:


***************************************************************************************************************************************************
void POSSPEED_Calc(POSSPEED *p)
void POSSPEED_Init(void)
{
#if (CPU_FRQ_150MHZ)
EQep1Regs.QUPRD=1500000; // Unit Timer for 100Hz at 150 MHz SYSCLKOUT
#endif
#if (CPU_FRQ_100MHZ)
EQep1Regs.QUPRD=1000000; // Unit Timer for 100Hz at 100 MHz SYSCLKOUT
#endif

EQep1Regs.QDECCTL.bit.QSRC=00; // QEP quadrature count mode

EQep1Regs.QEPCTL.bit.FREE_SOFT=2;
EQep1Regs.QEPCTL.bit.PCRM=00; // PCRM=00 mode - QPOSCNT reset on index event
EQep1Regs.QEPCTL.bit.UTE=1; // Unit Timeout Enable
EQep1Regs.QEPCTL.bit.QCLM=1; // Latch on unit time out
EQep1Regs.QPOSMAX=0xffffffff;
EQep1Regs.QEPCTL.bit.QPEN=1; // QEP enable

EQep1Regs.QCAPCTL.bit.UPPS=5; // 1/32 for unit position
EQep1Regs.QCAPCTL.bit.CCPS=7; // 1/128 for CAP clock
EQep1Regs.QCAPCTL.bit.CEN=1; // QEP Capture Enable
}


***************************************************************************************************************************************************
------------------------------------------------------------------------------------------------------------------------------------------------------


In the above POSSPEED_Init(void) function PCRM=00 (Position Counter Reset on Index Event) is selected and when the below POSSPEED_Calc(POSSPEED *p)
is called from the interrupt function __interrupt void prdTick(void); the below statement explains that

pos16bval=(unsigned int)EQep1Regs.QPOSCNT; // capture position once per QA/QB period; in below function

***************************************************************************************************************************************************
void POSSPEED_Calc(POSSPEED *p)
{
long tmp;
unsigned int pos16bval,temp1;
_iq Tmp1,newp,oldp;

//**** Position calculation - mechanical and electrical motor angle ****//
p->DirectionQep = EQep1Regs.QEPSTS.bit.QDF; // Motor direction: 0=CCW/reverse, 1=CW/forward

pos16bval=(unsigned int)EQep1Regs.QPOSCNT; // capture position once per QA/QB period
p->theta_raw = pos16bval+ p->cal_angle; // raw theta = current pos. + ang. offset from QA
***************************************************************************************************************************************************
------------------------------------------------------------------------------------------------------------------------------------------------------


but in the Tms320F28335 - eQep datasheet there is no explanation about the position capture for every QA/QB peiord, instead there is an explanation about the
position latch as mentioned below.

***************************************************************************************************************************************************
Capture Timer (QCTMR) and Capture period register (QCPRD) can be configured to latch on following
events.
· CPU read of QPOSCNT register
· Unit time-out event
If the QEPCTL[QCLM] bit is cleared, then the capture timer and capture period values are latched into the
QCTMRLAT and QCPRDLAT registers, respectively, when the CPU reads the position counter
(QPOSCNT).
If the QEPCTL[QCLM] bit is set, then the position counter, capture timer, and capture period values are
latched into the QPOSLAT, QCTMRLAT and QCPRDLAT registers, respectively, on unit time out.

****************************************************************************************************************************************************
------------------------------------------------------------------------------------------------------------------------------------------------------

So I'm not able to understand how the capture position once per QA/QB period is done thorugh the below statement

****************************************************************************************************************************************************

pos16bval=(unsigned int)EQep1Regs.QPOSCNT; // capture position once per QA/QB period

****************************************************************************************************************************************************
------------------------------------------------------------------------------------------------------------------------------------------------------

Can I read the QPOSCNT at any anytime randomly without latching it because the QPOSCNT will change according to the QCLK and DIR, is there any possibility?

How to capture the QPOSCNT without any Index event, Unit position event, Unit time out event?

Kindly help me out with the problem because the QPOSCNT is basic step to calculate position , speed & this is very essential requirement, due to this I'm not able to move forward.

please guide me as early as possible.
I am waiting for ur reply.


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>