EasyManua.ls Logo

Microchip Technology dsPIC30F - Page 365

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-13
Section 16. Quadrature Encoder Interface (QEI)
Quadrature Encoder
Interface (QEI)
16
16.5.2 Using MAXCNT to Reset the Position Counter
When the QEIM0 bit is ‘1’, the position counter will reset on a match of the position count with
predetermined high and low values. The index pulse reset mechanism is not utilized.
For this mode the position counter reset mechanism operates as follows: (See Figure 16-8 for
related timing details).
- If the encoder is traveling in the forward direction e.g., QEA leads QEB, and the value
in the POSCNT register matches the value in the MAXCNT register, POSCNT will
reset to zero on the next occurring quadrature pulse edge that increments
POSCNT. An interrupt event is generated on this rollover event.
- If the encoder is travelling in the reverse direction e.g., QEB leads QEA, and the value
in the POSCNT register counts down to ‘0’, the POSCNT is loaded with the value in
the MAXCNT register on the next occurring quadrature pulse edge that
decrements POSCNT. An interrupt event is generated on this underflow event.
When using MAXCNT as a position limit, remember the position counter will count at either 2X
or 4X of the encoder counts. For standard rotary encoders, the appropriate value to write to
MAXCNT would be 4N – 1 for 4x position mode and 2N – 1 for 2x position mode, where N is the
number of counts per revolution of the encoder.
For absolute position information where the range of the system exceeds 2
16
, it is also
appropriate to load a value of 0xFFFF into the MAXCNT register. The module will generate an
interrupt on rollover or underflow of the position counter.
Figure 16-8: Rollover/Rollunder Reset-Up/Down Position Counter
0001 0002 0003 0004 0005 0006 0000 0001 0002 0003 0001 0000 0006 0005 0004 0003 0002 0001
0006
POSCNT = MAXCNT
POSCNT set to 0000
POSCNT = 0000
POSCNT set to MAXCNT
Generate QEI Interrupt
Generate QEI Interrupt
0002
QEA
QEB
count_clock
POSCNT
UPDN
MAXCNT

Table of Contents

Other manuals for Microchip Technology dsPIC30F