Hi ,


I am trying to use the QEI for reading the encoder data and finding out the position and velocity using the QEI functions QEI_GetPosition & QEI_GetVelocity.

I am not sure if I have configured the device for QEI perfectly. Below is my code:




Encoder data using QEI to get position and velocity



from robovero.LPC17xx import  LPC_QEI

from robovero.lpc17xx_qei import QEI_GetPosition, QEI_Reset, QEI_SetMaxPosition, QEI_CFG_Type, QEI_ConfigStructInit, QEI_DIRINV_NONE, QEI_SIGNALMODE_QUAD, QEI_CAPMODE_2X, QEI_INVINX_NONE, QEI_RESET_POS, QEI_Init,QEI_GetVelocity, QEI_GetTimer

from robovero.extras import roboveroConfig

from robovero.lpc_types import FunctionalState

from time import sleep

import time

from array import *


QEIConfigStruct = QEI_CFG_Type()

QEIConfigStruct.DirectionInvert = QEI_DIRINV_NONE

QEIConfigStruct.SignalMode = QEI_SIGNALMODE_QUAD

QEIConfigStruct.CaptureMode = QEI_CAPMODE_2X

QEIConfigStruct.InvertIndex = QEI_INVINX_NONE




while True:

pos =  QEI_GetPosition(LPC_QEI)

print "pos = ",pos


vel =  QEI_GetVelocity(LPC_QEI)

print "vel = ",vel


time =  QEI_GetTimer(LPC_QEI)

print "timer = ",time




pos =  0
vel =  0
timer =  0
pos =  0
vel =  0
timer =  0


I only get 0s as the output. Can some one tell me what is wrong in my code. OR lend me working example for QEI.