Extraction of High Resolution Position Information From Sinusoidal Encoders

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

EXTRACTION OF HIGH RESOLUTION POSITION INFORMATION FROM SINUSOIDAL

ENCODERS
J. Burke, J. F. Moynihan, K. Unterkofler

Abstract - Precision motion control in industrial


automation systems is placing increasing demands on In order to extract reliable position and speed
the position feedback mechanisms used in the information from the sinusoidal encoder signals, a
constituent servo drives of these systems. Traditional certain amount of pre-conditioning of the analog
position transducer solutions based on resolvers or signals must be implemented. As a first stage, the
incremental encoders are increasingly being replaced differential SIN and COS signals (typically 1Vpp
by sinusoidal encoders that offer much higher input signal range) from the sinusoidal encoder must
position and speed resolution. The hardware or be applied to input differential amplifiers. This
software techniques used to interface to the sinusoidal ensures maximum noise immunity and may also be
encoders can have a measurable impact on the used to appropriately amplify and level shift the
achieved position resolution and accuracy. This paper resultant single-ended SIN and COS signals for later
compares the achievable performance levels with input to the Analog to Digital Converter (ADC) stage.
different interface techniques. All techniques are Next, the SIN and COS signals of Figure 1 are
implemented on a common hardware platform. Each applied to comparators that generate square-wave
method is fully described and comparisons and trade- TTL-level signals (EIA & EIB) that are synchronized
offs are made in terms of computational burden, to the SIN and COS signals respectively. The
achievable position bandwidth, the resolution of both relationship between the SIN, COS, EIA and EIB
the speed and position achievable as well as the signals is illustrated in Figure 2.
sensitivity of each method to common transducer
offsets, gain, and phase errors. COS SIN

Fundamental Operation of
Sinusoidal Encoders
EIA
Sinusoidal encoders encode position information by
providing a pair of quadrature sine and cosine signals EIB

as the shaft is rotated. The signals may be generated EIUCNT N N-1 N-2 N-3 N-4 N-5 N-6 N-7
by optical or magnetic means and typically produce
512 or 1024 cycles per mechanical revolution. For

noise immunity the signals are typically transmitted
θelec
differentially from the encoder to the sensor interface
electronics. A typical interface configuration is shown
in Figure 1.

Figure 2: Signals Produced by the Sinusoidal


Differential
ADMC401
Encoder Line Receiver
Comparators
DSP Core
Interface
+
+ EIA
- SIN
-

+
EIU The analog SIN and COS signals are also fed to dual
+
- COS
-
EIB
sample and hold amplifiers (SHA) for subsequent
Midpoint
SaH
conversion to digital and post-processing in the
+ Vsin digital signal processor (DSP). The signals EIA and
-
ADC EIB are typically applied to the internal quadrature
+

-
Vcos counter of a dedicated digital Encoder Interface Unit
(EIU) as illustrated in Figure 1. The resultant parallel
word in the quadrature counter provides the crude
Figure 1: Typical Sinusoidal Encoder Interface position estimate from the sinusoidal encoder. There
are four counts per cycle of the sinusoidal waveforms the final position data is illustrated in Figure 3 for a
(SIN and COS) as seen in Figure 2, so that for a 512 512-line encoder.
line encoder the maximum count value is 2047
(4*512-1) which provides 11 bits of crude position N-1 N N+1 N+2

information. In the case of a 1024 line encoder the


maximum count 4095 which provides 12 bits of
resolution. In the case where the EIB signal leads the COS SIN

EIA signal, the encoder is determined to be rotating


in the reverse direction and the quadrature count
value (EIUCNT) is decremented at each edge of the
EIA and EIB signals, as seen in Figure 2. Naturally, 10
Crude Position Data from EIU
0
when EIA leads EIB, the quadrature count value is
incremented at each event.
Overlap Bits
Fine Position Data from SIN/COS Signals
Fine position resolution is obtained by further 15 0

processing the digitized SIN and COS signals to


provide much finer granularity between the EIA and
EIB events, as illustrated by the lower
waveform(θelec) of Figure 2. The particular techniques 24 0
used to extract this fine position resolution are the Figure 3: Construction of Total Position
main subject of this paper. Information from Sinusoidal Encoder.
In some applications, it is necessary to know the
initial position of the rotor following power up. There DSP Requirements
are different techniques used to obtain this The minimum requirements for a hardware platform
information depending on the particular encoder to implement the various methods below are:
design. Some encoder designs provide an alternative
pair of sine and cosine signals that provide one cycle 1) A fast, high performance DSP core.
per mechanical revolution, from which it is possible 2) Simultaneous sampling multi-channel Analog to
to derive an initial position estimate. Alternatively, Digital Converter.
some modern sinusoidal encoders now provide a 3) Encoder Interface Unit.
dedicated serial interface that can be used to extract 4) Serial Communication Port.
the initial position following power up [1]. The
particular method used to extract the initial position 26 MIPS DSP Core PM ROM
MEMORY
and the alignment of this value to the computed Data Address
Generators Program
Sequencer
2k x 24

PM RAM DM RAM Watchdog


Power
Interrupt Encoder
Event Digital
DAG1 DAG2 2k x 24 1k x 16 On Capture I/O

position value during normal operation is beyond the EXTERNAL


ADDRESS
Timer
Reset
Controller Interface
Unit Unit

PROGRAM MEMORY ADDRESS

scope of this paper. BUS


DATA MEMORY ADDRESS

PROGRAM MEMORY DATA

EXTERNAL DATA MEMORY DATA

During normal operation, the complete position DATA BUS

2 Channel Precision 16-bit


information must be constructed from both the crude ALU
Arithmetic Units

MAC SHIFTER
SERIAL PORTS
SPORT0 SPORT1
Interval
Timer
Auxiliary
PWM
8 Channel
12-bit ADC
Voltage
Reference
PWM
Generation

and fine position information. The crude information


contains the cycle identification information, which,
depending on the encoder used, can be 11 or 12 bits. Figure 4: Block diagram for the ADMC401
The fine information is the result of the calculation
from the sinusoidal signals. With high resolution The DSP chosen to implement both algorithms is the
analogue to digital conversion of 12 bits on the SIN ADMC401 from Analog Devices, which includes a
and COS, position information to 23/24 bit can be 26 MIPS, 16-bit fixed point DSP core[2]. The DSP
achieved. Since the crude position information is a provides a combination of efficient processing units
quadrature value the 2 least significant bits (LSB) of such as hardware multiply and accumulator (MAC)
the first segment should be the same as the 2 most and arithmetic logic unit (ALU) and shifter. The DSP
significant bits (MSB) of the fine data and so are not core uses a modified Harvard architecture so that
needed and so only the 9 MSBs, in the case of a 512 program and data memory have separate address and
line encoder are used. In the case of a 1024 line data buses permitting highly efficient and parallel
encoder the first 10 bits are used. The construction of memory accesses. A block diagram of the ADMC401
is shown in Figure 4.
The core of the ADC system is a single high- where Vsin and Vcos are the digital representations of
performance 12-bit analog to digital converter that the simultaneously sampled SIN and COS waveforms
uses a pipeline flash conversion technique to achieve from the encoder at the particular sampling instant.
very fast conversions. The ADC system provides 8 The arctangent is approximated in the DSP
analog inputs arranged in two banks of four channels, calculation by a fifth order Taylor series expansion
each of which is provided with a dedicated sample below:
and hold amplifier. This structure permits four pairs
of input signals to be sampled simultaneously. The tan −1 (α ) = 0.318253α + 0.003314α 2 − 0.130908α 3
conversion time for all 8 analog inputs is under 2µs at
+ 0.068542α 4 − 0.009159α 5
a DSP clock rate of 26 MHz and conversion may be
(2)
initiated for either an internal source synchronized to
the PWM generation or from an external source.
Using a Matlab simulation, values for Vsin and Vcos
(quantized at the 12-bit level ) were generated and
The core of the encoder interface unit is a 16-bit
transmitted to the DSP. These values were then used
quadrature up down counter that converts the A and B
as the source to compute the divide and arctangent
quadrature signals from the encoder into a parallel
functions of (1), using standard, 16-bit, fixed-point
word. This word can be read by the DSP as part of
arithmetic. The result of the computation was then fed
the motor control algorithm for motor current
back to Matlab. The difference between the high
commutation, speed estimation and/or position
precision Matlab generated position and the estimate
control. The encoder interface unit of the ADMC401
computed by the ADMC401 using (1) is plotted over
also provides a programmable input filter stage that
1 electrical cycle in Figure 5.
permits encoder pulses less than some minimum
value to be filtered and rejected. With this feature,
spurious noise pulses do not adversely affect the 0.015

operation of the quadrature counter. The encoder 0.010


Position Error (deg)

interface unit permits input A and B quadrature 0.005


signals with rates of up to 4.3 MHz corresponding to
0.000
a maximum quadrature rate of 17.2 MHz.
-0.005

The ADMC401 provides two independent serial -0.010

communication ports that can be used to interface -0.015


with sophisticated sinusoidal encoders such as the 0 50 100 150 200 250 300 350
Position (deg)
Stegmann Hiperface[1]. The additional serial port can
be used to transmit the computed position information
to another processor or host. Alternatively the
Figure 5: Quantization Error in Position over
ADMC401 may address shared external memory so
Electrical Cycle.
that data can be accessed by another processor or
host.
As seen from Figure 5, the resultant error in the
computation is always less than or equal to 0.01
Methods for Extracting Fine degrees per electrical revolution. In addition, for an
Position Information encoder that offers 512 electrical cycles per
mechanical revolution, the 9 MSBs of position
information come from the cycle information as
Method 1: Direct Arctangent 29=512, the number of lines in the encoder. This
Computation means that the error occurring in Figure 5 due to the
In the first method the fine position data is computed finite quantization levels and calculation inaccuracies
directly from the digitized SIN and COS signals. The of the DSP is at the 15th bit position of the computed
DSP implements the calculation as: 16-bit fine position value. This implies that the
fundamental limit on the 16-bit fixed point DSP
V 
θ fine = tan −1  sin  calculation used in this method is located at the 24th
 Vcos  bit in position (for a 512-line encoder). In other
(1) words, the maximum achievable resolution from such
a solution is given by 2-24 * 360 * 60 * 60 = 0.077
arc-sec .
This analysis does not take into account position derived using (1). Only the 16 MSB’s of the resultant
accuracy errors due to the expected imperfections in position value are plotted for clarity.
the physical system due to offset or gain errors in the
sine and cosine channels from the encoder or in the Presently, the execution time for this arctangent
analog signal processing circuits prior to the ADC. method is 6.57µs using the ADMC401 DSP. At a
Additional errors are also introduced by phase- motor speed of 6000rpm, a 512-line sinusoidal
imbalance in the encoder such that the sine and cosine encoder will produce sinusoidal outputs at 51.2kHz.
waveforms are no longer in perfect quadrature. At this speed the encoder signals have a period of
19.5µs which allows for just 3 samples per period.
The advantage of the arctangent method is that it The length of time between consecutive samples
allows position information to be requested at any compared to the period of one electrical cycle would
time, as long as the time for consecutive requests is possibly make feedback digital filtering of this
greater than the time taken to run the necessary DSP position information less accurate because aliasing
calculations. This means that if requests are time could occur. It is likely that motor noise could be
stamped, which is possible with the ADMC401, the significant, and this could present a problem with
speed of the motor can than be accurately calculated. using this method. A possible solution is to shield the
motor, which could reduce the noise. Alternatively,
Using a test rig, a Sinusoidal Encoder was mounted finding software solutions that could incorporate
on a very high-resolution turntable. The table was digital filtering as an inherent part of the process of
rotated slowly such that the position change was 1 extracting position information is one reason for
electrical degree (of the sine and cosine waveforms) considering another method.
in 100µs. This corresponds to a shaft speed of
approximately 3.25rpm for a 512-line encoder. The Method 2 – Tracking and Filtering Loop
position was read from both the ADMC401 and the
table counter and the difference is plotted in Figure 6. The second method of extracting precise position
information from the sinusoidal encoder is similar to
Error within one electrical period [°] that used in existing hardware solutions for extracting
position from resolvers using standard Resolver to
0.3
0.2
Digital Converters (RDC) [3]. The solution here
0.1 involves forming a closed loop tracking system that
error [°]

0 forces the estimate of the rotor position (ϕ) to


-0.1 0 90 180 270 360
-0.2 converge to the actual position (θ). The error is
-0.3 formed by a heterodyning, cross-multiplication
-0.4
process to form the signal:
angle [°]

error [°]
∆E = sin(θ )cos(ϕ ) − cos(θ )sin(ϕ )
Figure 6: A graph of the error over one electrical = sin(θ − ϕ )
revolution. ≈ θ − ϕ , for small θ − ϕ
(3)

E(s)
ϕ(s)
VSin SHA X 2*d
2
ω0
2 1
ω0 S

VCos SHA X 1
S

Figure 7: Plot of position for an encoder rotated at Encoder


Sin(ϕ)
constant speed. Cos(ϕ)

Figure 7 shows the derived rotor position information


from a 512-line encoder over 1 complete mechanical Hardware Software
revolution. The complete position data is the Figure 8 : Block diagram of the Tracking and
combination of the crude position information (11- Filtering Loop
bits) from the EIU and the fine position information
This process is illustrated graphically in Figure 8. As The following is a summary of some of the results of
with any closed loop system the aim is to force the the tests using the ADMC401 to implement the
error to zero. The benefit of this method is that digital closed loop tracking of (7) and the cross
filtering, which consists of a PI controller in series multiplication of (3). Figure 9 shows the transient
with an integrator, is built into the feedback loop. response in tracking a step change of 45 electrical
This method tracks the position and periodically degrees. As in the previous method Matlab was used
updates a position counter. to generate two values VSin and VCos which were used
as a starting point for the algorithm. The result of the
In the continuous domain, the forward path of the calculation was then sent back to Matlab. [Step] is
system may be expressed as: the step change, [DSP Pos.] is the DSP estimated
position.
G(s) =
ϕ (s)
[
= ω 0
2
]*  1s +
2 * d  1 
 *
ω 0   s 
E(s)  Tracking Responce to a 45 electrical degree step change

(4)
Using the Zero Order Hold (ZOH) approximation to 0.9

translate the transfer function (4) to the discrete


domain, G(z) becomes:

Position(Radians)
0.6

Step

ω * TS   (z + 1)   (2 * d* ω 0 * TS ) 
2 2 DSP Pos.

G(z) ≈  0 * 2
+ 
 2   (z − 1)   (Z− 1)  0.3

(5)
0.0

As can be seen in equation (5) the three main 0 10 20 30 40 50 60 70 80 90

parameters are ω0, d and Ts, where ω0 is the natural


Time (µs)

frequency of the filter, d the Damping Ratio and Ts is


the Sample Time. Due to the ZOH approximation, Figure 9: Plot of DSP and Simulation position
equation (4) becomes: against a step change.

ϕ ( z) The position error is also plotted in Figure 10, so that


G( z) = the tacking error can be seen more clearly.
Z −1 E( z)
(6) Plot of the difference between step change and the DSP estimated position

0.8

Combining equations (5) and (6) results in: 0.7

0.6

ϕ K +1 = A* E K + B * EK −1 + 2 * ϕ K − ϕ K −1 0.5
Error(Radians)

0.4
(7)
0.3
where
0.2

ω 2 *T2 0.1

A= 0 + 2 * d * ω * TS 0.0

2 0 -0.1
0 10 20 30 40 50 60 70 80 90

ω 2 * TS 2
-0.2

B= 0 − 2 * d * ω * TS Time (µs)

2 0
(8) Figure 10: Plot of the tracking error for a 45° step
change.
To improve the resolution and speed of convergence
Figure 11 illustrates the transient response of the
the algorithm was implemented in 32-bit arithmetic.
position error, E, when the speed of rotation is 1000
These 32 bits of fine position information combined
rpm. In this case the rotor position is ramping linearly
with the 9 bits of cycles information from a 512 line
and Figure 11 shows the initial error in the rotor
encoder results in 41 bits of position information over
position estimate due to the finite tracking
one complete mechanical cycle of which only the 32
performance of the proposed method. It can also be
MSB’s are stored for use by subsequent algorithms.
seen that the tracking loop reduces the steady state Sensitivity to System Offsets and Signal Gains
estimation error to zero in about 70µs.
Test were also carried out in regards to the effects of
Plot of the difference between Real Positon and Estimated Position
system offsets and mismatched gains on the final
0.30
result. Due to the cross multiplication approach the
effect of mismatched gains and offsets is greatly
0.25
reduced. The final algorithm will incorporate
amplitude scaling and offset compensation to fully
0.20 eliminate these effects.
Error(Radians)

0.15

Conclusions
0.10
At a speed of 120rpm, a 512-line encoder will have
0.05
swept out an angle of 1.65888 electrical degrees in
the 4.5µs computation time, making the 32 bits of
0.00 position information relatively useless for position
0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0

Time (µs)
estimation for an outside controller. Thus, it makes
sense to say that such high resolution is really only
required at low speeds, and for the most part the
Figure 11: Error in tracking a ramp at 1000 rpm. encoder will be at rest in order to determine exact
position information. Given this, both methods have
The maximum number of DSP cycles executed in their advantages. The tracking loop requires less DSP
implementing this tracking is 111. This is equivalent cycles and results in higher resolution than the
to 4.269µs and so Ts was chosen to be 4.5µs. Using arctangent method. However the arctangent method
the sampling theorem as a starting point, ω0Max is has zero settling time. The greatest considerations in
approximately 700krad/s. For a 512-line encoder, this choosing a method would be the maximum speed the
gives a theoretical limit of the mechanical speed of encoder is allowed to travel at and the required
approximately 12000rpm. For the test showed above, resolution of the position estimation.
the bandwidth ω0 of the filter was set to 100krad/s.
The Damping Ratio (d) was set to 0.9. With these
values, there is no need of scaling of the coefficients
of equation (8).
References:
[1] SRS50, Motor Feedback System for Servomotors
This method can produce very high position SinCos SRS 50 with HIPERFACE by
resolutions once the motor speed is kept inside the STEGMANN.
bandwidth of the filter. As with all such closed-loop
tracking systems, it is possible to trade-off the [2] ADMC401, Single-Chip, DSP-Based, High
mutually exclusive characteristics of resolution and Performance, Motor Controller, Analog Devices
position bandwidth by adjusting the filter coefficients Inc., 1999.
in the feedback loop. Using the above parameters the
motor could be tracked to a speed of 11000rpm, [3] AD2S81A/AD2S82A, Variable Resolution
which is in accordance with the theoretical limit Monolithic Resolver to Digital Converter,
stated above. Analog Devices Inc., 1998.

Unlike the arctangent method, this method requires a


settling time, during which the position estimation Acknowledgements:
may not be exact and incur some error as in Figure
11. However the obvious benefit for a second order The authors of this paper would like to thank Ulrich
tracking loop is zero steady state error (at least to Armbruster, Andrew Monnin and Bernd Appel of
Stegmann Inc. for all their input.
within the quantization noise levels in the DSP
implementation).

You might also like