EasyManua.ls Logo

Microchip Technology dsPIC30F - Page 363

Microchip Technology dsPIC30F
738 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
© 2004 Microchip Technology Inc. DS70063C-page 16-11
Section 16. Quadrature Encoder Interface (QEI)
Quadrature Encoder
Interface (QEI)
16
16.4.1 Explanation of Lead/Lag Test
The lead/lag test is performed by the quadrature decoder logic to determine the phase
relationship of the QEA and QEB signals and hence whether to increment or decrement the
POSCNT register. The Table 16-1 clarifies the lead/lag test.
Table 16-1: Lead/Lag Test Description
16.4.2 Count Direction Status
As mentioned in the previous section, the QEI logic generates an UPDN signal based upon the
Phase A and Phase B time relationship. The UPDN signal may be output on an I/O pin.
Setting the PCDOUT bit (QEICON<6>) and clearing the appropriate TRIS bit associated with
the pin will cause the UPDN signal to drive the output pin.
In addition to the output pin, the state of this internal UPDN signal is supplied to a SFR bit
QEICON<11> as a Read-Only bit, notated as UPDN.
16.4.3 Encoder Count Direction
The direction of quadrature counting is determined by the SWPAB bit (QEICON<7>). If the
SWPAB = 0, the Phase A input is fed to the A input of the quadrature counter and the Phase B
input is fed to the B input of the quadrature counter. Therefore as the Phase A signal leads the
Phase B signal, the quadrature counter is incremented on each edge. This (A signal leads the B
signal) is defined as the forward direction of motion. Setting the SWPAB bit, (QEICON<7>), to a
logic 1 causes the Phase A input to be fed to the B input of the quadrature counter and the
Phase B signal to be fed to the A input of the quadrature counter. Therefore, if the Phase A
signal leads the Phase B signal at the dsPIC30F device pins, the Phase A input to the
quadrature counter will now lag the Phase B input. This is recognized as rotation in the reverse
direction and the counter will be decremented on each quadrature pulse.
Present
Transition
Previous
Transition
Condition Action
QEB QEA leads QEB channel Set UPDN Increment POSCNT
QEA QEB QEA lags QEB channel Clear UPDN Decrement POSCNT
QEA Direction Change Toggle UPDN Increment or Decrement POSCNT
QEB QEA lags QEB channel Clear UPDN Decrement POSCNT
QEA QEB QEA leads QEB channel Set UPDN Increment POSCNT
QEA Direction Change Toggle UPDN Increment or Decrement POSCNT
QEA QEA lags QEB channel Clear UPDN Decrement POSCNT
QEB QEA QEA leads QEB channel Set UPDN Increment POSCNT
QEB Direction Change Toggle UPDN Increment or Decrement POSCNT
QEA QEA leads QEB channel Set UPDN Increment POSCNT
QEB QEA QEA lags QEB channel Clear UPDN Decrement POSCNT
QEB Direction Change Toggle UPDN Increment or Decrement POSCNT

Table of Contents

Other manuals for Microchip Technology dsPIC30F