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.

CCS/TM4C1294NCPDT: Encoder Module

Part Number: TM4C1294NCPDT

Tool/software: Code Composer Studio

Hi, i am working with QEI Module in Tiva 1294 and when i am using the Direction count mode the counter give me scattered data which have no mean, i checked the register maps and every thing is right in control register, can any one check the configuration i set and help me.



 - Here is pin configuring:

// step 1. CONFIGURE GPIO PINS TO WORK AS ENCODER PIN
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
GPIOPinConfigure(GPIO_PL1_PHA0);
GPIOPinConfigure(GPIO_PL2_PHB0);
GPIOPinConfigure(GPIO_PL3_IDX0);

// step 2. Enable ENCODER PINS
SysCtlPeripheralEnable(SYSCTL_PERIPH_QEI0);
GPIOPinTypeQEI(GPIO_PORTL_BASE,GPIO_PIN_1); // channel A
GPIOPinTypeQEI(GPIO_PORTL_BASE,GPIO_PIN_2); // channel B
GPIOPinTypeQEI(GPIO_PORTL_BASE,GPIO_PIN_3); // channel I

// step 3. Enable ENCODER MODULE
QEIEnable(QEI0);

// step 4. Enable INDEX INTERRUPT
QEIIntEnable(QEI0,QEI_INTINDEX);

// step 5. pad configuration
GPIOPadConfigSet(GPIO_PORTL_BASE, GPIO_PIN_1 | GPIO_PIN_2, GPIO_STRENGTH_8MA_SC, GPIO_PIN_TYPE_STD_WPU);

- Here is module configuring to work in Direction count mode:

QEIConfigure(QEI0,(QEI_CONFIG_CAPTURE_A | QEI_CONFIG_NO_RESET | QEI_CONFIG_CLOCK_DIR | QEI_CONFIG_NO_SWAP),2500); 

- Here is the clock setting i use:

SysCtlClockFreqSet(SYSCTL_OSC_INT,16000000); 

  • Greetings,

    Ali El-Zaghal said:
    when I am using the Direction count mode the counter gives me scattered data

    Your set-up of the QEI Module seems correct.     

    However - there are, "No function calls noted" to (either)  'QEIPositionGet()' or 'QEIDirectionGet().'    Had you issued the (position get) call - yet not presented it for us here?

    Follows a general QEI Encoder Diagnostic Checklist:

    • Is the encoder properly powered?     (i.e. to encoder's spec voltage while 'in operation?')
    • Do the MCU & encoder properly 'share' a common ground?
    • While the motor is at (near) fixed speed - are the 'A, B, & I' encoder outputs reasonably consistent?    (i.e. when viewed on a Scope)
    • Have obvious Noise & Signal sources been 'Turned Off' and/or moved far from the MCU & encoder?
    • Has the cable/wire length between encoder & MCU been minimized - and routed AWAY from noise & power sources?
    • You note scattered data - however unless you call for encoder reset - that data may be 'adding.'   (thus not really 'scattered.'    Presenting that data here enables others to view & comment...)

    Potential encoder difficulties may be confirmed by feeding the QEI pins w/the MCU's 'Timer Output pins' - configured into PWM Output Mode.  Experimentation of this nature 'builds familiarity & mastery of that specific MCU peripheral' - even when - and especially when - the encoder is mis-performing and/or has not yet arrived...

  • Hi Sir,

    My hardware is as follow:
    i connect EQEP A to GPIO PL1  & EQEP B to GPIO PL2 & EQEP I to GPIO PL3 & same  GND for both ECU & EQEP VCC  to 3.3v from ECU, and i ask if the resistors and capacitors which connected to the encoder module input pins like in Delfino as example may affect the operation of [DIRECTION COUNT MODE] as i work Defino with this mode.

    regards.  

  • Ali El-Zaghal said:

    My hardware is as follow:

    i connect EQEP A to GPIO PL1  & EQEP B to GPIO PL2 & EQEP I to GPIO PL3 & same  GND for both ECU & EQEP VCC  to 3.3v from ECU, and i ask if the resistors and capacitors which connected to the encoder module input pins like in Delfino as example may affect the operation of [DIRECTION COUNT MODE] as i work Defino with this mode.

    The usual way of connecting encoders is to have the A and B pins pulled up to the rail with resistors, and the common pin grounded. The RC filtering is helpful, too.

    Check your pins with two channels of your oscilloscope and ensure that they transition as you expect.

  • Did you have a chance to reference the posted code in this link that was mentioned earlier?

    The GPIOPinTypeQEI() will configure the pin for functional use. You don't need to separately call GPIOPadConfigSet in your step 5. 

    Also have you tried to set the clock like below?

    ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
    SYSCTL_OSC_MAIN |
    SYSCTL_USE_PLL |
    SYSCTL_CFG_VCO_480), 120000000);

    or 

    ui32SysClock = SysCtlClockFreqSet(SYSCTL_OSC_INT | SYSCTL_USE_OSC , 16000000);