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.

Quadrature Encoder Interface (QEI) velocity error

Hello

I am using the QEI to read the current position of a rotary dial knob with A/B signals (ALPS EC11B15242AF). To improve the reaction on slow or quick rotation I wanted to use the velocity value provided by the QEI but at low speed the QEI_O_SPEED register sometime counts much more pulses then It can be during the measuring interval.

Here the configuration of QEI:

  // Enable and configure Quadrature Encoder Interface
  HWREG(QEI0_BASE + QEI_O_CTL) |= QEI_CTL_FILTCNT_M;    // Set maximal input filter value
  HWREG(QEI0_BASE + QEI_O_CTL) |= QEI_CTL_FILTEN;       // Enable input filter
  QEIConfigure(QEI0_BASE, QEI_CONFIG_CAPTURE_A_B | QEI_CONFIG_NO_RESET | QEI_CONFIG_QUADRATURE | QEI_CONFIG_SWAP, UINT32_MAX);
  QEIPositionSet(QEI0_BASE, 0);  
  QEIEnable(QEI0_BASE);

  // Enable and configure the velocity counter
  QEIVelocityConfigure(QEI0_BASE, QEI_VELDIV_1, 4E6 - 1);
  QEIVelocityEnable(QEI0_BASE);

Any idea?

Thanks for any help

  • Ludwig Heusser said:
    To improve the reaction on slow or quick rotation I wanted to use the velocity value provided by the QEI but at low speed the QEI_O_SPEED register sometime counts much more pulses then (seems reasonable)... 

    Feel your pain - further detail assists - s'il vous plait.

    • how did this QEI peripheral perform w/out your addition of the "velocity value?"   What were the complaints during that operation?
    • have you tested to insure that your mechanical encoder is producing "clean" pulses - w/proper overlap - in compliance w/quadrature standard?
    • cannot you "model" this set-up by injecting (known clean) GPIO pulses into the QEI inputs - and observing results?   That's a valuable strategy as it will aid in the isolation of issue to, "encoder or MCU's QEI peripheral."   (or your QEI set-up, handling, etc.)

    Now there's a second issue here - your description of, "Measurement Interval."   How sure are you that it (itself) is correct?   When multiple sub-systems operate in concert - all may "not" go well.   (at least upon the first few iterations)

    My small tech firm (always) tests peripherals w/standard (known good) HW resources - so that a performance baseline may be quickly established.

    Now we've used devices similar to your encoder - and (sometimes) especially when rotating slowly - we've observed "illegal" pulses/pulse train.  (and sometimes even "runt" pulses - which may "confound" your QEI inputs.  That may or be not be your issue - oscilloscope monitoring will (usually) reveal.

    Further - the care/handling of the encoder's power & signal terminations are critical.   You may have to "pull-up" or "pull-down" (sometimes filter) the outputs - the device's datasheet should well detail...

    And - in the interest of "completeness" signal leads between encoder & MCU should be short, direct and distant from noise sources and/or high speed digital signals.   It may pay to employ shielded cable and route the cable away from "trouble" sources...