EasyManua.ls Logo

Microchip Technology dsPIC30F - 16-Bit Up;Down Position Counter

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...
dsPIC30F Family Reference Manual
DS70063C-page 16-12 © 2004 Microchip Technology Inc.
16.4.4 Quadrature Rate
The RPM of the position control system will vary. The RPMs along with the quadrature encoder
line count determine the frequency of the QEA and QEB input signals. The quadrature encoder
signals can be decoded such that a count pulse is generated for every quadrature signal edge.
This allows an angular position measurement resolution of up to 4 times the encoder line count.
For example: a 6,000 RPM motor utilizing a 4096 line encoder yields a quadrature count rate of:
((6000/60) * (4096*4)) = 1.6384 MHz. Likewise, a 10,000 RPM motor utilizing a 8,192 line
encoder yields a quadrature count rate of: ((10000/60) * (8192*4)) = 5.46 MHz.
The QEI allows a quadrature frequency of up to F
CY/3. For example, if FCY = 30 MHz, the QEA
and QEB signals may have a maximum frequency of 10 MHz. Refer to the “Electrical
Specifications” section of the device data sheet for further details.
16.5 16-bit Up/Down Position Counter
The 16-bit Up/Down Counter counts up or down on every count pulse which is generated by
the quadrature decoder logic. The counter then acts as an integrator, whose count value is
proportional to position. The direction of the count is determined by the quadrature decoder.
The user software may examine the contents of the count by reading the POSCNT register. The
user software may also write to the POSCNT register to initialize a count.
Changing the QEIM bits does not affect the position counter register contents.
16.5.1 Using the Position Counter
The system may utilize position counter data in one of several methods. In some systems, the
position count is accumulated consistently and taken as an absolute value representing the total
position of the system. For a typical example, assume that a quadrature encoder is affixed to a
motor controlling the print head in a printer. In operation, the system is initialized by moving the
print head to the maximum left position and resetting the POSCNT register. As the print head
moves to the right, the quadrature encoder will begin to accumulate counts in the POSCNT
register. As the print head moves to the left, the accumulated count will decrease. As the print
head reaches the right most position, the maximum position count should be reached. If the
maximum count is less than 2
16
, the QEI module can encode the entire range of motion.
If, however, the maximum count is more than 2
16
, the additional count precision must be
captured by the user software. Generally, to accomplish this, the module is set into a mode where
it resets the counter at match of a maximum count. QEIM0 = 1 enables modes where the
MAXCNT register is used to reset the position counter. When the counter reaches a
pre-determined maximum count while incrementing or reaches zero while decrementing, the
count is reset and an interrupt is generated to allow the user software to increment or decrement
a software counter containing the most significant bits of the position count. The maximum count
can be 0xFFFF, to enable a full range of the QEI counter and software counter or some smaller
value of significance, such as the number of counts for one encoder revolution.
In other systems, the position count may be cyclic. The position count is only used to reference
the position of the wheel within number of rotations determined by the index pulse. For example,
a tool platform moved by a screw rod uses a quadrature encoder attached to the screw rod. In
operation, the screw may require 5.5 rotations to achieve the desired position. The user software
will detect 5 index pulses to count the full rotations and use the position count to measure the
remaining half rotation. In this method, the index pulse resets the position counter to initialize the
counter at each rotation and generates an interrupt for each rotation. QEIM0 = 0 enables these
modes.

Table of Contents

Other manuals for Microchip Technology dsPIC30F