QEI - INX CNT can not count, when A / B(SIGMODE =0) stop.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

QEI - INX CNT can not count, when A / B(SIGMODE =0) stop.

3,569 Views
yansinli
Contributor III

中文 :

功能說明 : 設計Z偵測到脈波輸入時,觸發中斷,清除AB向脈波計數值。

問題描述 :

QEI - 當AB相沒有收到任何輸入脈波時,INCNT無法計數。

當AB相有偵測到輸入脈波時,INCNT才會計數。

這現象會導致,編碼器AB 輸入停止時,無法成功清除AB相計數值。

有其他方法可以讓Z 計數獨立計算,不受INGATE(index gating configuration) 影響嗎?

English : 

My Function :   when Z detect pulse , interrtup will clear AB count value.

Problem : 

QEI - when AB encoder  no  input  pulse, INCNT can not  count.

when AB encoder detect input pulse, INCANT can count.

lead  to   " when AB encoder stop,  it can not clear AB count value."

have other way?   let Z  count indepdently.  INGATE ( index gating configuration) can not work.

以下是我QEI 設定

--------------------------------

static void Setup_QEI(void)
{
 /* Enable the clock to the Switch Matrix */
 Chip_Clock_EnablePeriphClock (SYSCTL_CLOCK_QEI);
 Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);
 Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 27, (IOCON_MODE_PULLDOWN | IOCON_FUNC1));
 Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 28, (IOCON_MODE_PULLDOWN | IOCON_FUNC1));
 Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 29, (IOCON_MODE_PULLDOWN | IOCON_FUNC1));
 Chip_SWM_MovablePinAssign(SWM_QEI0_PHA_I, 27); 
 Chip_SWM_MovablePinAssign(SWM_QEI0_PHB_I, 28); 
 Chip_SWM_MovablePinAssign(SWM_QEI0_IDX_I, 29); 
 Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM);
     
/* QEI Control register reset */
LPC_QEI->CON = 15;    
LPC_QEI->CLR = 0xFFFFFFFF;
/* Set QEI signal mode = AB */
LPC_QEI->CONF &= ~(1 << ((uint32_t)1));

 /* Set QEI capture mode  2XAB */
 LPC_QEI->CONF &= ~(1 << ((uint32_t)2));

/* PLCK = 72M, Edges = 2, Load = 72M */
/* 72M = 1000 ms, 1 ms = 72000 */
LPC_QEI->LOAD = (uint32_t) EnCoderPeriod * 72000;
LPC_QEI->MAXPOS = 0xFFFFFFFF;
/* Enable the interrupt for the QEI */
/* SCT/QEI(0) > MRT(6) > Can(7), Priotity 0~7, 0 is the highest */
NVIC_EnableIRQ (QEI_IRQn);
NVIC_SetPriority(QEI_IRQn, 0);

/* QEI Interrupt Enable Clear register, claer all interrupt enable */
LPC_QEI->IEC = 0xFFFFFFFF;

/* QEI Interrupt Enable Set register for INX_EN(BIT0)*/
LPC_QEI->IES = ((uint32_t)(1 << 0));
}
void QEI_IRQHandler(void)
{
    /* Check QEI interrupt status (Bit 0) for INX_EN(Z) */
    if(LPC_QEI->INTSTAT & ((uint32_t)(1 << 0)))
    {
        /* When index pulse(Z) was detedtd, clear Encoder pulse */  
        /* QEI Control register reset */
        LPC_QEI->CON = 15;           
        /* QEI Interrupt Status clear (Bit 15) for INX_EN(Z) */
        LPC_QEI->CLR = ((uint32_t)(1 << 0));    
    }
}
0 Kudos
10 Replies

3,414 Views
yansinli
Contributor III

Any updates?

0 Kudos

3,414 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Yansin,

Can you tell us the part number you are using?

BR

XiangJun Rong

0 Kudos

3,414 Views
yansinli
Contributor III

LPC1519JBD64

0 Kudos

3,414 Views
yansinli
Contributor III

INXGATE.jpgINXGATE lead to  INXCNT can not count independently , when endcoer A / B is stop.  

please try it ......and give me some clear answer. 

YES ->  how  to set ?

NO -> NXP  not suppurt.

0 Kudos

3,414 Views
yansinli
Contributor III

Simplify my question :

INXCNT (RO 0x020 Index count register) .   when endcoer A / B is stop. can INXCNT count independently ?

if  YES . how to setting?

if  NO.........NXP is not suppurt.

0 Kudos

3,414 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Yansin,

I suppose that Index Counter counts only Index signal from the IDX pin even if A/B signals stop. If you connect a low frequency clock signal to IDX pin, then check the Index counter in debugger, does it change or not?

BR

XiangJun Rong

0 Kudos

3,414 Views
yansinli
Contributor III

Frankly speaking, your answer very ambiguous.

I just want to know (yes  or  no).

INXCNT (RO 0x020 Index count register) .   when endcoer A / B is stop. can INXCNT count independently ?

if  YES . how to setting?

if  NO.........NXP is not suppurt.

0 Kudos

3,414 Views
yansinli
Contributor III

Can you tell me what is Z Counter, is it Position counter?

-> my Z is  INXCNT RO 0x020 Index count register.

-> when Z(INXCNT) detect pulse , interrtup will clear AB count value(Position counter).

If it is, how do you clear the counter when the rotor does not spin?

->

My goal : when the rotor does not spin, user can send pulse to Z pin. when Z detect pulse, it clear position couner.

My probolem : when the rotor does not spin, user send pulse to Z pin.  Z  can not detect pulse, so it can not clear position couner. 

0 Kudos

3,414 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Yansin,

Your issue is that you can not generate interrupt when you send pulse to the QEI_IDX pin, if you set the INX_EN bit with your code:LPC_QEI->IES = ((uint32_t)(1 << 0)); I think the interrupt can be triggered.

But as a workaround, I think you can use software interrupt to solve the problem, in other words, you do not need to send pulse to QEI_IDX pin, but the void QEI_IRQHandler(void) can be executed.

After you call NVIC_SetPendingIRQ(QEI_IRQn);, the QEI interrupt will be triggered.

Hope it can help you

BR

Xiangjun Rong

0 Kudos

3,414 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Yanish,

Frankly speaking, I do not know your question very clearly. Yes, if the rotor does not spin, PhA and PhB keep their logic, Position counter stops counting, the Positioin Counter remains it's value. In the case, you can read the Velocity capture register when velocity Timer times out, it should be zero.

Can you tell me what is Z Counter, is it Position counter? If it is, how do you clear the counter when the rotor does not spin?

BR

XiangJun Rong

0 Kudos