AN-749| Application Note

AN-749 PDF

AN-749| Application Note


Quadrature Signal Interface to a COP400 Microcontroller

Quadrature Signal Interface to a COP400 Microcontroller
INTRODUCTION Switches have always been a popular way of getting information into a microcontroller Two-bit quadrature output devices also known as two-bit gray code output use two switches that are mechanically coupled together thru a shaft so that as the shaft is rotated the switches generate two square waves that are 90 degrees out of phase with each other This is also known as being in quadrature see Figure 1 The reason for doing this is that within the two signals there is the information to detect the direction of rotation i e clockwise (CW) or counterclockwise (CCW) This type of device allows an input variable to be increased or decreased by CW or CCW rotation of the shaft Additionally these devices allow continuous rotation in either direction which lets the span and resolution of the input variable to be a function of the software

National Semiconductor Application Note 749 Walter Bacharowski February 1991

TL DD 11147 1

FIGURE 1

OPERATION Figure 2 shows a hardware connection of a quadrature output device to the COP400 microcontroller Although in this example the G0 and G1 I O pins are used any pin that can be used as an input could be used with the appropriate changes in the software In this example the output of device QD1 is processed to detect a state change in the quadrature signal and which direction the change was in A 3-digit BCD variable which is stored in RAM is then incremented or decremented The variable is defined to have a range of 200 to 350 units The routine allows the variable to saturate at it's upper and lower limits when reached Figure 3 displays the two waveforms that are generated by QD1 as it's shaft is rotated from an arbitrary starting position Each edge represents a change of state By keeping track of the state that was moved from and the state that currently exists it can be determined which direction the rotation was in Referring to Figure 3 there are 4 possible states for a starting position (00 01 11 10)
and they will be referred to as the previous state There are also 4 possible states to move to (00 01 11 10) and they will be referred to as the current state Figure 4 lists the 8 possible combinations of bits that can be formed by starting from each previous state and rotating CW or CCW to the current state If the two bits of the previous state and current state are concatenated into one 4-bit value each value will be unique The routine

AN-749

TL DD 11147 2

FIGURE 2
C1995 National Semiconductor Corporation TL DD11147 RRD-B30M75 Printed in U S A


AN-749 Application Note national Download PDF

Add this permalink to your bookmarks for future download of AN-749 ApplicationNote

Permalink: http://application.emcelettronica.com/national/AN-749

PDF AN-749 APPLICATION NOTE