Product Specs

Table Of Contents
36 QDEC Quadrature decoder
Page
348
The QDEC decodes the output from the off-chip encoder by sampling the QDEC phase input pins (A and B)
at a fixed rate as specified in the SAMPLEPER register.
If the SAMPLEPER value needs to be changed, the QDEC shall be stopped using the STOP task.
SAMPLEPER can be then changed upon receiving the STOPPED event, and QDEC can be restarted using
the START task. Failing to do so may result in unpredictable behaviour.
It is good practice to change other registers (LEDPOL, REPORTPER, DBFEN and LEDPRE) only when the
QDEC is stopped.
When started, the decoder continuously samples the two input waveforms and decodes these by comparing
the current sample pair (n) with the previous sample pair (n-1).
The decoding of the sample pairs is described in the table below.
Table 83: Sampled value encoding
Previous Current SAMPLE ACC operation ACCDBL Description
sample pair(n samples pair(n) register operation
- 1)
A
B
A
B
0
0
0
0
0
No change
No change
No movement
0
0
0
1
1
Increment
No change
Movement in positive direction
0
0
1
0
-1
Decrement
No change
Movement in negative direction
0
0
1
1
2
No change
Increment
Error: Double transition
0
1
0
0
-1
Decrement
No change
Movement in negative direction
0
1
0
1
0
No change
No change
No movement
0
1
1
0
2
No change
Increment
Error: Double transition
0
1
1
1
1
Increment
No change
Movement in positive direction
1
0
0
0
1
Increment
No change
Movement in positive direction
1
0
0
1
2
No change
Increment
Error: Double transition
1
0
1
0
0
No change
No change
No movement
1
0
1
1
-1
Decrement
No change
Movement in negative direction
1
1
0
0
2
No change
Increment
Error: Double transition
1
1
0
1
-1
Decrement
No change
Movement in negative direction
1
1
1
0
1
Increment
No change
Movement in positive direction
1
1
1
1
0
No change
No change
No movement
36.2 LED output
The LED output follows the sample period, and the LED is switched on a given period before sampling and
switched off immediately after the inputs are sampled. The period the LED is switched on before sampling is
given in the LEDPRE register.
The LED output pin polarity is specified in the LEDPOL register.
For using off-chip mechanical encoders not requiring a LED, the LED output can be disabled by writing
value 'Disconnected' to the CONNECT field of the PSEL.LED register. In this case the QDEC will not acquire
access to a LED output pin and the pin can be used for other purposes by the CPU.
36.3 Debounce filters
Each of the two-phase inputs have digital debounce filters.
When enabled through the DBFEN register, the filter inputs are sampled at a fixed 1 MHz frequency during
the entire sample period (which is specified in the SAMPLEPER register), and the filters require all of the
samples within this sample period to equal before the input signal is accepted and transferred to the output
of the filter.
As a result, only input signal with a steady state longer than twice the period specified in SAMPLEPER are
guaranteed to pass through the filter, and any signal with a steady state shorter than SAMPLEPER will
always be suppressed by the filter. (This is assumed that the frequency during the debounce period never
exceeds 500 kHz (as required by the Nyquist theorem when using a 1 MHz sample frequency).
The LED will always be ON when the debounce filters are enabled, as the inputs in this case will be sampled
continuously.