A simple way to build a quadrature decoder of general

Transcription

A simple way to build a quadrature decoder of general
A simple way to build
a quadrature decoder of general use
Roberto Zuliani
Picture of an easily assembled Quadrature decoder
A simple way to build a quadrature decoder of general use
Roberto Zuliania*
Department of Molecular Sciences and Nanosystems, Ca’ Foscari, University of Venice,
Dorsoduro 2137, 30123 Venezia, Italy.
*e-mail: [email protected]
a
Received: 2013-03-18
Accepted: 2013-04-26
Abstract: Here a fast and cheap quadrature decoder for rotary encoder is presented. It is possible to decode
a fast transducer to decrease the load of the microprocessor software in a cheap and efficient way using a
single, fast, programmable logic device and the interrupt of microprocessor.
Keywords: Quadrature encoder, Fast quadrature decoder.
DOI: 10.7361/SciCF-454
and down or to other purposes. In this configuration
it is possible to implement the decoder in a single
low price PLD (programmable logic device), available on the market.
The compilation and simulation were done with
WinCupl [1].
1. Introduction
One of the most common approaches to manual
setting an input value in an instrument is the use of a
rotary switch. Such a switch produces a train of pulses,
as a function of the rotation of the knob. The use of
a microprocessor is generally more practical for the
decoding of these pulses and their transformation into
a value, because the speed is low and the software is
lightweight; otherwise to reach a full decode of the
pulses various Small Scale Integration (SSI) devices
are necessary. Another use of the Quadrature Encoder
is to reveal the angular position in equipment movement, but this operation requires a fast decoding,
which causes a greater load for the processor.
On the basis of these considerations, an approach
to solve the problem in a cheap and efficient way
is realized with a single, fast, programmable logic
device by using the interrupt of microprocessor devoted to control the motion.
3. Results, Discussion
The availability on the market of fast microcontrollers certainly allows the reading and decoding
of signals in quadrature during the time available
between one pulse and the next, however the use
of an external decoder such as that proposed decreases the number of instructions required, thus
leaving more resources available for other concurrent operations [2]. This is particularly true when
the processor has inputs of edge-triggered interrupt, being necessary only the operations of context
switching in addition to those of intended use for the
new information.
In the case of reading the angular position of a rotating motor at 3000 rpm using an encoder with 500
pulses per revolution, the processor has 40 microseconds between two pulses to perform the required
operations; the elimination of the time required for
decoding can be important for the specific application, for example the power control of the motor
phases.
2. Schematics and software
The classic scheme (Fig. 1) uses two latches for
any channel in order to synchronize the pulse with
clock and to store the change of state of inputs. Tree
combinatorial outputs decode the quadrature status.
The outputs may be connected to the interrupt
edge triggered of the processor devoted to count up
9
sciences at ca’ foscari
1 | 2013
Figure. 1. Schematics.
Figure. 2. Simulations A and B represent the quadrature input, CW and CCW the pulse out, Out0 the index signal and OE the enable
out respectively. The CLOCK has meaningfully higher speed than quadrature pulse.
The block of equations is made as general as possible in order to eventually integrate the decoder in
more complex devices such as Complex Programmable Logic Device (CPLD) or Field Programmable Gate
Array (FPGA), which are used to count pulse position,
to make comparisons, and other similar purposes.
A simulation of the quadrature decoder is reported in Fig. 2.
4. References
[1] Win-CUPL Design Software, Version 5.30.4, ATMEL.
[2] S. McLaughlin, XGATE Library: Quadrature Decoder
Driver, Freescale Semiconductor A.N. 3752, 2008.
10
sciences at ca’ foscari
1 | 2013
11