EFDA JET R(12)02 K.D. Lawson and JET EFDA contributors Incremental Quadrature Encoder Drift
COPYRIGHT ECSC/EEC/EURATOM, LUXEMBOURG 2012 Enquiries about Copyright and reproduction should be addressed to the Publications Officer, EFDA, Culham Science Centre, Abingdon, Oxon, OX14 3DB, UK.
Incremental Quadrature Encoder Drift K.D. Lawson 1 and JET EFDA contributors* 1 EURATOM/UKAEA Fusion Association, Culham Science Centre, OX14 3DB, UK. * See annex of F. Romanelli et al, Overview of JET Results, (23rd IAEA Fusion Energy Conference, Daejon, Republic of Korea (2010)).
.
Incremental Quadrature Encoder Drift K D Lawson 1 and JET-EFDA Contributors* JET-EFDA, Culham Science Centre, Abingdon, OX14 3DB, UK 1 Euratom/CCFE Fusion Association, Culham Science Centre, Abingdon, OX14 3DB, UK Kerry.Lawson@ccfe.ac.uk Abstract There is widespread use of quadrature encoders to monitor either linear or rotary movements. The encoder indicates movement by detecting light that is transmitted or reflected from a series of slots. By using two outputs, the second shifted by 90 with respect to the first, the so-called 'quadrature encoder' allows the direction of movement to be determined in addition to its magnitude. The direction is obtained by checking the level of the second output at the time of the rising or falling edges of the first signal or alternatively both rising and falling edges can be used. In some cases drift in the monitored position is reported (e.g. 'http://www.plctalk.net/qanda/showthread.php?t=62156'). Although it is generally recognized that the use of only the rising or falling edges of the first signal will give poorer (about half) the spatial resolution compared with the use of both rising and falling edges, it is not always appreciated that the use of only one edge can result in drift of the monitored position (e.g. 'http://abrobotics.tripod.com/ebot/using_encoder.htm'). The reason for this and the need to analyze both the rising and falling edges of the first signal in order to avoid drift are explained. 1. Quadrature encoders Encoders allow either rotary or linear movement to be detected and measured and the information from an encoder can give an absolute or relative position. There are various sensing mechanisms, optical, mechanical or magnetic. The common example of an optical rotary encoder will be discussed and results presented of its use in an incremental measurement of angle. In the simplest arrangement, a series of opaque and transparent or high and low reflectivity slots in a sensing wheel is attached to the axis of movement and the light from a source is detected either in transmission or reflection as a Transistor-Transistor-Logic (TTL) (0-5V dc) square wave as the axis rotates (figure 1). In transmission, an opaque slot will give 0V output and 5V when a transparent slot passes in front of the detector. In reflection, the poorly reflecting surface will produce 0V output and the highly reflecting slot 5V. The number of pulses is counted by detecting the rising or falling edges of the square wave output from the detector and, knowing the number of slots on the sensing wheel, the angle of rotation can be determined. When a single detector is used the only information available is the number of pulses and hence the angle of movement; there is no indication as to the direction of movement. In many applications, it is useful to know the direction in which the axis rotated and this can be provided by a second detector positioned 90 degrees out of phase to the first detector as shown in figure 2. When either the leading or falling edge of the first signal is detected, the second signal will either be at 0V or 5V, 0V indicating movement in one direction, 5V movement in the opposite 1
direction. Figure 2 illustrates clockwise movement or movement to the right, figure 3 anticlockwise or movement to the left. The decoded output stores counts corresponding to movement in one direction in one channel and counts corresponding to movement in the other direction in a second channel. The counts in both channels can then be independently counted and the position of the axis determined allowing for movements in both directions. 2. KT1 oscillating mirror encoders Quadrature encoders were used to determine the position of the oscillating mirrors of the KT1 spectroscopic diagnostic. The movement of the mirrors allows the lines-of-sight of the spectrometers in the JET machine to be varied poloidally, the encoders determining the angles of the lines-of-sight. When the mirror angle was reconstructed from the quadrature decoded signals, drift in the angles was often seen (Lawson et al., 2012). An example is shown for JET pulse 82674 in figure 4. The wider scans before and after the plasma discharge include movement through a reference opto-switch, the narrower scans during the discharge are tailored to match the observation of the plasma with the minimum of travel during which no plasma radiation is observed. The position of the opto-switches will be relocated in the next shutdown so as to fall in the narrower plasma scan. Neither the reference signal nor observations of the radiation emitted from the plasma showed signs that the position of the mirror itself was drifting. It appeared that the mirror positions were repeatable within the limitation of the couplings between the oscillating mirror and stepping motor used to drive the mirror. Although one coupling (the vacuum coupling) was rigid, two of the couplings used were flexible allowing some freedom of movement between the mirror and motor in order to avoid excessive wear on the shaft bearings. The drift was therefore attributed to the quadrature encoder signal and an investigation made as to the reason for the drift (Appelbee, 2012). Consideration was given to the operation of a quadrature encoder in an oscillating system, to the quadrature decoding program or to some other facet of the subsequent recording of the data. It was found that the drift was due to there being an unequal number of counts output from the encoder itself when the mirror rotated in one direction of the oscillating scan compared with the other direction. The reason for the differing number of counts can be understood in terms of the exact position of the end or turning points of the scan relative to the encoder slots when only the leading or falling edge of the square wave is analyzed. 3. The decoded quadrature signals The direction of movement can be determined by analyzing either the rising or falling edges of the square wave output from the first detector of the quadrature encoder or alternatively both the rising and falling edges. The most obvious difference between the use of only the rising or falling edges or both edges is a near doubling of the spatial resolution of the encoder in the second case. However, there is also a more subtle difference relating to drift, which is not always recognized. If only the rising or falling edges are analyzed, the number of counts recorded when moving in one direction of the scan may not be the same as in the other direction. When the counts in the clockwise (right) and anticlockwise (left) channels are summed, the difference in the number of counts will be seen as drift in the position measured by the encoder. 2
The appearance of drift depends only on the position of the ends or turning points of the travel relative to the encoder slots. Figures 5 and 6 show two of the four possible combinations of turning points. The labels given to the encoder slots are defined in figures 1 to 3. Figure 5 illustrates the case in which the turning points fall on a highly reflective encoder slot and at the other end a low reflectivity slot, D and B, respectively. If only rising edges are analyzed, there will be only 3 counts in the red (clockwise or right) direction, but 4 in the blue (anticlockwise or left). Using both rising and falling edges results in 7 counts in both directions and hence no drift. Figure 6 illustrates the case where both turning points lie in highly reflecting slots, D and A. Here there are the same number of counts in both directions, 4 if only rising (or falling) edges are analyzed, 8 with both rising and falling edges. If the turning points fall in the outer halves of the labelled encoder slots, the output from detector 2 will undergo a further change. These are shown as dashed lines in figures 5 and 6. However, the output from detector 1 is unchanged and hence the number of counts will not be affected. Table 1. Examples of the number of decoded counts for all possible cases of a quadrature encoder measuring an oscillating movement. Case 1 2 3 4 Movement between Decoded counts encoder slots Rising edge Falling edge Rising and falling edges D - B 3 4 7 B - D 4 3 7 D - A 4 4 8 A - D 4 4 8 C - B 3 3 6 B - C 3 3 6 C - A 4 3 7 A - C 3 4 7 Table 1 lists the four possible combinations of turning points. Cases 1 and 2 are illustrated in figures 5 and 6, respectively. It can be seen from the table that cases 2 and 3 will show no drift, whereas cases 1 and 4 will show drift if only the rising or falling edges are analyzed. That is, if only the rising or falling edges are analyzed, there is a 1 in 2 chance of drift in the monitored position being observed and a 1 in 4 chance of the drift being clockwise (to the right) or anticlockwise (to the left). In all cases the drift can be removed by analyzing both the rising and falling edges of the square wave output by detector 1. 4. Conclusions Drifts have been observed in the KT1 oscillating mirror positions and have been shown to be due to unequal numbers of encoder counts recorded when the mirror moves in one direction of the scan compared to the other (Appelbee, 2012). The quadrature decoding program being used analyzed only the rising edges of the quadrature signal. It is shown that this leads to a 1 in 2 chance of drift being seen, this depending on the position at which the turning points of the oscillating scan fall relative to the encoder slots. The problem of drift is avoided by analyzing 3
both the rising and falling edges of the quadrature signal, this also leading to a near doubling of the spatial resolution with which the position is monitored. References C W Appelbee, 2012, 'Investigation of KT1 mirror positioning monitoring', CDN/H(12)013 K D Lawson et al., 2012, 'Enhancements to the JET poloidally scanning vacuum ultraviolet / visible spectrometers', Rev. Sci. Instrum., 83, 10D536. Acknowledgments This work, supported by the European Communities under the contract of Association between EURATOM and CCFE, was carried out within the framework of the European Fusion Development Agreement. The views and opinions expressed herein do not necessarily reflect those of the European Commission. This work was also part-funded by the RCUK Energy Programme under Grant No. EP/I501045. * See the Appendix of F. Romanelli et al., Proceedings of the 23rd IAEA Fusion Energy Conference 2010, Daejeon, Korea Figures Figure 1. Schematic diagram and output from an encoder employing a single detector. Figure 2. Schematic diagram and output from a quadrature encoder moving clockwise (to right). Figure 3. Schematic diagram and output from a quadrature encoder moving anticlockwise (to left). Figure 4. Example of drifts in the calculated mirror angle for JET pulse 82674, showing pre- and post-plasma scans, which include a reference signal, and a narrower plasma scan. Figure 5. Outputs from a quadrature encoder moving between high and low reflectivity slots, D and B, respectively. The use of only a rising (or falling) edge results in drift. Figure 6. Outputs from a quadrature encoder moving between highly reflecting slots, D and A. In this case no drift is seen. 4
Figure 1. Figure 2. 5
Figure 3. 30 Mirror angle (degrees) 20 10 0-10 Reference scan Plasma scan Reference scan -20 0 20 40 60 80 100 Time (s) Figure 4. JG12.16-2c 6
Figure 5. Figure 6. 7