Implementation of PID Controllers On Motorola DSP PDF
Implementation of PID Controllers On Motorola DSP PDF
Rev. 1
Implementation
of
PID Controllers
on the
Motorola
DSP56000/SPS/DSP56001
Digital Signal
Processors
M o t o r o l a ’ s H i g h - P e r f o r m a n c e D S P T e c h n o l o g y
Motorola
Digital Signal
Processors
Implementation of PID
Controllers on the Motorola
DSP56000/DSP56001
by
Jay Stokes and Guy R. L. Sohie
Digital Signal Processor Operation
MOTOROLA APR5
Table
of Contents
Section 1 Introduction 1-1
MOTOROLA iii
Table
of Contents
Section 7 7.1 Coefficient Quantization 7-1
Finite-Length 7.2 Overflow 7-5
Register Effects 7.3 Roundoff Noise 7-9
7.4 Implementation of the Gain, g 7-13
REFERENCES References-1
iv MOTOROLA
APR5 LOF Page v Friday, December 15, 1995 11:17 AM
Illustrations
Figure 2-1 General Analog Control System 2-2
MOTOROLA v
APR5 LOF Page vi Friday, December 15, 1995 11:17 AM
Illustrations
Figure 6-3 Sixth-Order Controller Implemented in
Cascaded Direct Form I Biquad Sections 6-4
vi MOTOROLA
APR5 LOF Page vii Friday, December 15, 1995 11:17 AM
Illustrations
Figure 7-2 Roundoff Noise Sources for Direct Form
Implementations 7-11
MOTOROLA vii
APR5 LOF Page viii Friday, December 15, 1995 11:17 AM
Illustrations
Figure 8-9 Measuring the Disk Drive Spindle Velocity Using
IRQA and the SCI Timer 8-13
viii MOTOROLA
APR5Section1 Page 1 Friday, December 15, 1995 11:18 AM
SECTION 1
Introduction
“The DSP56000/ The purpose of this application note is to show how
DSP56001 the Motorola DSP56000/DSP56001 digital signal
offers the processor (DSP) may be used to solve real-time dig-
control designer ital control problems. This application note will
the advantages concentrate on implementing some general control
of digital algorithms including proportional-integral-derivative
electronics in a (PID) controllers and notch filters.
low-cost
package with the
In the past, many real-time control systems have
processing
been restricted to analog electronics; however, ana-
power to handle
log components have several problems. Device
sampling rates
parameters are dependent upon age, temperature,
up to a
power supply voltages, and manufacturing lot. In ad-
megahertz for
dition, analog filters and controllers exhibit low noise
simple
immunity, require periodic tuning, and offer little flexi-
algorithms.”
bility when altering coefficients.
MOTOROLA 1-1
APR5Section1 Page 2 Friday, December 15, 1995 11:18 AM
1-2 MOTOROLA
APR5Section1 Page 3 Friday, December 15, 1995 11:18 AM
MOTOROLA 1-3
APR5Section1 Page 4 Friday, December 15, 1995 11:18 AM
1-4 MOTOROLA
APR5Section2 Page 1 Friday, December 15, 1995 11:19 AM
SECTION 2
Classical Analog
Controls
“For the system A block diagram of a general analog control system
to be stable, the in the Laplace domain is shown in Figure 2-1. The for-
poles of the ward transmission path transfer function is given by
closed-loop G(s); H(s) represents the feedback path transfer func-
transfer function tion. Typically, the feedback element contains a
must lie in the sensor or transducer that measures a physical pa-
left half of the s- rameter, such as velocity or temperature, and
plane.” converts this measurement into a voltage. Therefore,
H(s) represents the gain of the transducer.
C(s)
T ( s ) = ------------ = 1 Eqn. 2-1
R(s)
MOTOROLA 2-1
APR5Section2 Page 2 Friday, December 15, 1995 11:19 AM
( s – z 1 )… ( s – z m )
C(s) G(s)
T ( s ) = ------------ = ----------------------------------- = ----------------------------------------------m < n Eqn. 2-2
R(s) 1 + G ( s )H ( s ) ( s – p 1 )… ( s – p n )
+
R(s) E(s) C(s)
G(s)
r(t) – e(t) c(t)
H(s)
1 + G ( s )H ( s ) = 0 Eqn. 2-3
2-2 MOTOROLA
APR5Section2 Page 3 Friday, December 15, 1995 11:19 AM
ω
S
MOTOROLA 2-3
APR5Section2 Page 4 Friday, December 15, 1995 11:19 AM
c(t) Mp – 1
Percent Overshoot = ----------------
-
100
Mp
1
0.9
ess
0.1
t
tr
ts
2-4 MOTOROLA
SECTION 3
Controllers
“By increasing One way to improve the step response of a control
the gain of the P system is to add a controller to the feedback control
controller, the system in Figure 2-1. The block diagram of a control
rise time of the system, including a controller, Gc(s), is found in Fig-
system can be ure 3-1. In this figure, the controller has been added
decreased, to the forward transmission path although it could
allowing the have been placed in the feedback path. The error sig-
output to follow nal from the summing junction, E(s), is the input to the
the input faster.” controller, and U(s) is the output of the controller as
well as the input to the plant. For this system with uni-
ty feedback gain, H(s)=1, and the transfer function is:
C(s) G c ( s )G p ( s )
------------ = ------------------------------------------ Eqn. 3-1
R(s) 1 + G c ( s )G p ( s )
G c ( s )G p ( s )
T ( s ) = ------------------------------------------ ≈ 1 Eqn. 3-2
1 + G c ( s )G p ( s )
MOTOROLA 3-1
G(s)
H(s)
C ( s ) G c ( s )G p ( s )
------------ ≈ -------------------------------- = 1 Eqn. 3-3
R ( s ) G c ( s )G p ( s )
3-2 MOTOROLA
Likewise, if c(t) is greater than r(t), then a negative
error voltage is applied to the plant, and the output
of the system is reduced. The speed at which the
output can respond to the error signal is dependent
upon the magnitude of the gain of the P controller.
By increasing the gain of the P controller, the rise
time of the system can be decreased, allowing the
output to follow the input faster.
0.9
(c)
0.8 ess
(a)
0.7
0.6 (b)
0.5
0.4
0.3
0.2
0.1
0
0 0.05 0.1 0.15 0.2 0.25 0.3
MOTOROLA 3-3
output. This type of output is illustrated in the (a)
graph of Figure 3-2. If the gain is increased further,
the system will become critically stable at some
point, and the output will oscillate. When this oc-
curs, the poles of the closed-loop transfer function
(see Eqn. 2-2) lie on the jω–axis in the s-plane (see
Figure 2-2). Increasing the gain past the critically
stable point causes the system to become unstable,
and the output increases without bound. In addition,
a constant gain amplifies the high-frequency noise
in addition to the lower frequency bandwidth of the
control system. This high noise amplification can
greatly distort the lower frequency control signals.
3-4 MOTOROLA
the slope of the error signal and provides informa-
tion about how the error signal is changing with
respect to time. For a system with zero overshoot,
the derivative of the error signal should not oscillate
about the x-axis (see Figure 3-3(c)) but should ap-
proach the x-axis asymptotically. A derivative term
has been added to the P controller in the (b) graph
of Figure 3-2. As Figure 3-2 illustrates, the rise time
of the PD controller is as fast as the P controller, but
the output does not exhibit any overshoot. By in-
cluding the derivative term in Gc(s), the controller
can estimate future values of the error signal and
can compensate accordingly.
c(t)
t
(a) c(t) versus Time
e(t)
de(t)
dt
MOTOROLA 3-5
In addition to improving the transient response, a
controller is added to a feedback system to de-
crease the steady-state error. If the steady-state
error is constant, the contribution of the derivative
term is zero since the derivative of a constant is ze-
ro. However, if the steady-state error is time-
varying, the derivative term can be used to reduce
this offset. Again, the derivative of the steady-state
error predicts future values of the error and can be
used to reduce ess. The equation for the steady-
state error is given by:
3-6 MOTOROLA
Another problem associated with the PD controller
is that it functions as a high-pass filter. Therefore,
the PD controller amplifies high-frequency noise,
which reduces the stability of the overall system.
2
Ki Kd s + Kp s + Ki
G c ( s ) = K D s + K p + ----- = ------------------------------------------- Eqn. 3-6
s s
MOTOROLA 3-7
integral term allows zero steady-state error. The ef-
fects of adding an integral term to the P and PD
controllers is shown in graph (c) of Figure 3-2. The
output of the PID reaches unity and has no steady-
state error.
–1 –m
β ( 0 ) + β ( 1 )s + β ( m )s
G c ( s ) = ------------------------------------------------------------------------m < n Eqn. 3-7
–1 –n
1 + α ( 1 )s + … + α ( n )s
3-8 MOTOROLA
SECTION 4
Notch Filters
“...the Notch filters are often added to control systems to
techniques negate the effects of a mechanical resonance at a
used to specific frequency. Suppose a motor has a frequency
implement PID response such as the one illustrated in Figure 4-1(a).
controllers can When the motor reaches a speed corresponding to fr,
also be used to it becomes unstable and begins to vibrate due to the
implement mechanical resonance. These mechanical vibrations
notch filters.” tend to shorten the life of the motor. By filtering the
output with a notch filter as shown in Figure 4-1(b),
the gain of the resonance can be reduced. The
resultant system's frequency response is shown in
Figure 4-1(c). The transfer function of a notch filter,
Gf(s), has a form equal to the transfer function of the
controller shown in Eqn. 3-7. Therefore, the
techniques used to implement PID controllers can
also be used to implement notch filters. ■
MOTOROLA 4-1
Gp
fr
f
(a) Plant with a Resonance at fr
Gf Gp
fr fr
f f
(b) Notch Filter with the Notch at fr (c) Notch Filter and Plant Combined Response
4-2 MOTOROLA
SECTION 5
MOTOROLA 5-1
Another method of transforming an existing analog
design to the z-domain is to use the bilinear trans-
form given by:
–1
2 1 –z
s = --- ------------------ Eqn. 5-1
T
1+z
–1
5-2 MOTOROLA
Disregarding state feedback control, a simple PID
controller, deadbeat controller, or digital filter is de-
scribed by the following equation:
–1 –m
γ ( 0 ) + γ ( 1 )z + … + γ ( n )z
G c ( z ) = --------------------------------------------------------------------------------m < n
–1 –n
1 + δ ( 1 )z + … + δ ( n )z
Eqn. 5-2
■
MOTOROLA 5-3
APR5Section6 Page 1 Friday, December 15, 1995 11:24 AM
SECTION 6
Implementation of
Digital Controllers
“Since the The architecture of the DSP56000/DSP56001 allows
architecture of discrete-time controllers and filters to be implemented
the DSP56000/ efficiently and accurately. To reduce roundoff noise
DSP56001 allows caused by finite-length registers, digital controllers
efficient and filters are often implemented in cascaded or par-
implementation allel first- and second-order sections. Figure 6-1
of digital shows a sixth-order controller implemented in cas-
controllers and cade sections and parallel sections. The parallel
filters, the structure is useful in multiprocessing schemes but can
computational be more sensitive to coefficient quantization noise,
delay which is discussed in 7.1 Coefficient Quantization.
associated with The transfer function for a digital controller implement-
digital signal ed in cascaded biquad sections is:
processing is
minimized.” n b ( 0 ) + b ( 1 )z –1 + b ( 2 )z –2
G c ( z ) = g ∏ ------------------------------------------------------------------------
i i i
Eqn. 6-1
–1 –2
i = 1 1 + a i ( 1 )z + a i ( 2 )z
MOTOROLA 6-1
6-2
–1 –2 –1 –2 –1 –2
b1 ( 0 ) + b1 ( 1 ) z + b1 ( 2 ) z b2 ( 0 ) + b2 ( 1 ) z + b2 ( 2 ) z b3 ( 0 ) + b3 ( 1 ) z + b3 ( 2 ) z
x(k) -------------------------------------------------------------------
- -------------------------------------------------------------------
- -------------------------------------------------------------------
- y(k)
–1 –2 –1 –2 –1 –2
1 + a1 ( 1 ) z + a1 ( 2 ) z 1 + a2 ( 1 ) z + a2 ( 2 ) z 1 + a3 ( 1 ) z + a3 ( 2 ) z
(a) Cascade
–1 –2
b1 ( 0 ) + b1 ( 1 ) z + b1 ( 2 ) z
-------------------------------------------------------------------
-
–1 –2
1 + a1 ( 1 ) z + a1 ( 2 ) z
APR5Section6 Page 2 Friday, December 15, 1995 11:24 AM
+
b2 ( 0 ) + b2 ( 1 ) z–1 + b2 ( 2 ) z–2
x(k) -------------------------------------------------------------------
- + y(k)
–1 –2
1 + a2 ( 1 ) z + a2 ( 2 ) z
+
–1 –2
b3 ( 0 ) + b3 ( 1 ) z + b3 ( 2 ) z
-------------------------------------------------------------------
-
–1 –2
1 + a3 ( 1 ) z + a3 ( 2 ) z
(b) Parallel
Figure 6-1 Cascade and Parallel Implementations of Digital Filters and Controllers
MOTOROLA
APR5Section6 Page 3 Friday, December 15, 1995 11:24 AM
x(k) b0 –1 y(k)
a
0
z-1 z-1
b1 -a1
z-1 z-1
b2 -a2
x(k) –1 b0 y(k)
a
0
z-1 w(k-1)
-a1 b1
z-1 w(k-2)
-a2 b2
MOTOROLA 6-3
6-4
x(k) y(k)
Figure 6-3 Sixth-Order Controller Implemented in Cascaded Direct Form I Biquad Sections
APR5Section6 Page 4 Friday, December 15, 1995 11:24 AM
y(k)
x(k)
Figure 6-4 Figure 6-3 Sixth-Order Controller Transformed into Cascaded Direct Form II Sections
with an All-Zero Section and an All-Pole Section
MOTOROLA
APR5Section6 Page 5 Friday, December 15, 1995 11:24 AM
0.6 + 0.4z – 1 – 0.25z –2 0.8 + 0.6z – 1 + 0.2z –2 0.8 + 0.64z – 1 + 0.9z –2
G c ( z ) = ----------------------------------------------------------- -------------------------------------------------------- ------------------------------------------------------------
1 – 0.8z –1 + 0.6z –2 1 + 0.4z –1 + 0.3z –2 1 + 0.7z –1 + 0.5z –2
Eqn. 6-2
Referring to Figure 6-2 (b), the intermediate values to
be calculated and stored are designated as w(k-1)
and w(k-2). Often, w(k-1) and w(k-2) are called the
MOTOROLA 6-5
APR5Section6 Page 6 Friday, December 15, 1995 11:24 AM
1
w ( k ) = ------ ( x ( k ) – a ( 1 ) *w ( k – 1 ) – a ( 2 )*w ( k – 2 ) ) Eqn. 6-3
a0
6-6 MOTOROLA
APR5Section6 Page 7 Friday, December 15, 1995 11:24 AM
include 'declare.dat'
;******************************************************************************
; X memory locations
;******************************************************************************
org x:$0
data dc 0 ;cascade section 1 w(k-2)
dc 0 ;cascade section 1 w(k-1)
dc 0 ;cascade section 2 w(k-2)
dc 0 ;cascade section 2 w(k-1)
dc 0 ;cascade section 3 w(k-2)
dc 0 ;cascade section 3 w(k-1)
;******************************************************************************
; Y memory locations
;******************************************************************************
org Y:$0
coef
dc .6 ;a(2) — cascade section 1
dc -.8 ;a(1) — cascade section 1
dc -.25 ;b(2) — cascade section 1
dc .4 ;b(1) — cascade section 1
dc .6 ;b(0) — cascade section 1
dc .3 ;a(2) — cascade section 2
dc .4 ;a(1) — cascade section 2
dc .2 ;b(2) — cascade section 2
dc .6 ;b(1) — cascade section 2
dc .4 ;b(0) — cascade section 2
dc .5 ;a(2) — cascade section 3
dc .7 ;a(1) — cascade section 3
dc .9 ;b(2) — cascade section 3
dc .64 ;b(1) — cascade section 3
dc .8 ;b(0) — cascade section 3
;*******************************************************************************
; Fast Interrupt Service Routines
;*******************************************************************************
MOTOROLA 6-7
APR5Section6 Page 8 Friday, December 15, 1995 11:24 AM
;******************************************************************************
; Initialization
;******************************************************************************
org p:main
move #data,r0 ;r0 points to states
move #5,m0 ;r0 is modulo 6
move #coef,r4 ;r4 points to filter coefficients
move #14,m4 ;r4 is modulo 15
movep #$007,x:ipr ;irqa is negative edge triggered, pr 2
movep #2,x:bcr ;2 wait states for A/D and D/A
move x:(r0)+,x0 y:(r4)+,y0 ;init data ALU registers
andi #$FC,mr ;enable all interrupts
;******************************************************************************
; PID Compensator Algorithm
;******************************************************************************
start
wait ;wait for input sample
do #numsec,enddo
mac -x0,y0,a x:(r0)-,x1 y:(r4)+,y0 ;A=x(k)-a2*s2
macr -x1,y0,a X1,x:(r0)+ y:(r4)+,y0 ;A=x(k)-a2*s2-a1*s1
mpy x0,y0,a a,x:(r0) y:(r4)+,y0 ;A=b2*b2
mac x1,y0,a x:(r0)+,x0 y:(r4)+,y0 ;A=b2*b2+b1*s1
macr x0,y0,a x:(r0)+,x0 y:(r4)+,y0 ;A=b2*b2+b1*s1+
; b0(x(k)-a2*s2-a1*s1)
enddo
movep a,y,:D_ ;output result to D/A
jmp start ;repeat
6.2 Initialization
Upon hardware reset, the DSP56000/DSP56001
begins executing instructions at location 0 in pro-
gram memory in all operating modes except normal
expanded, mode 2. In mode 2, the program execu-
tion begins at location $E000 in program memory.
After reset, the DSP56000/DSP56001 immediately
jumps to the beginning of the main routine. The first
eight instructions are responsible for initializing the
digital controller. In this assembly language pro-
6-8 MOTOROLA
APR5Section6 Page 9 Friday, December 15, 1995 11:24 AM
b3(0)
b3(1)
b3(2)
a3(1)
a3(2)
b2(0)
b2(1)
b2(2)
a2(1)
w3(k-1) a2(2)
w3(k-2) b1(0)
w2(k-1) b1(1)
w2(k-2) b1(2)
w1(k-1) a1(1)
w1(k-2) 0 a1(2) r4
r0 0
x
y
MOTOROLA 6-9
APR5Section6 Page 10 Friday, December 15, 1995 11:24 AM
6-10 MOTOROLA
APR5Section6 Page 11 Friday, December 15, 1995 11:24 AM
= 1 – p1 z 1 – p2 z
–1 –2 –1 –1
D ( z ) = 1 + a1 z + a2 z
Eqn. 6-7
MOTOROLA 6-11
APR5Section6 Page 12 Friday, December 15, 1995 11:24 AM
and
2
– a 1 ± a – 4a 2
1
- <1
p 1 ,p 2 = ------------------------------------------ Eqn. 6-9
2
6-12 MOTOROLA
APR5Section6 Page 13 Friday, December 15, 1995 11:24 AM
a2
a2=1
1
-a1=1+a2 a1=1+a2
-1
Figure 6-7 Stability Triangle that Illustrates the Stability Requirements for
a Second-Order System
Figure 6-8 Code Kernel that Implements the Modified Direct Form II Biquad
Section Shown in Figure 6-9
MOTOROLA 6-13
APR5Section6 Page 14 Friday, December 15, 1995 11:24 AM
x(k) 2 b0 y(k)
-1
z
–-------
a1
- b1
2
-1
z
–-------
a2
- b2
2
Figure 6-10 Code Kernel that Implements the Most Efficient Biquad Section
Possible on a DSP56000/DSP56001
6-14 MOTOROLA
APR5Section6 Page 15 Friday, December 15, 1995 11:24 AM
MOTOROLA 6-15
APR5Section7 Page 1 Friday, December 15, 1995 11:25 AM
SECTION 7
Finite-Length
Register Effects
“Therefore, Digital filters and controllers are typically designed
the 24-bit and simulated in high-level computer languages using
DSP56000/ double-precision floating-point arithmetic. However,
DSP56001 once the double-precision coefficients have been de-
may be the rived, a fixed-point simulation of the structure with
only DSP finite-length registers must also be performed to deter-
capable of mine if the filter still meets the design specifications. A
implementing fixed-point design includes three sources of error that
highly precise are negligible in the double-precision floating-point de-
algorithms.” sign: coefficient quantization, overflow, and roundoff
noise.
MOTOROLA 7-1
APR5Section7 Page 2 Friday, December 15, 1995 11:25 AM
–1 –2 –1 –1
1 + a1 z + a2 z = ( 1 + –p z ) ( 1 – p*z ) Eqn. 7-1
7-2 MOTOROLA
APR5Section7 Page 3 Friday, December 15, 1995 11:25 AM
–1 –2 –1 –2
b 1 ( 0 ) + b 1 ( 1 )z + b 1 ( 2 )z b 2 ( 0 ) + b 2 ( 1 )z + b 2 ( 2 )z
G c ( z ) = -------------------------------------------------------------------------
- + -------------------------------------------------------------------------
-
–1 –2 –1 –2
1 + a 1 ( 1 )z + a 1 ( 2 )z 1 + a 2 ( 1 )z + a 2 ( 2 )z
Eqn. 7-4
′ ′ –1 ′ –2 ′ –3 ′ –4
b ( 0 ) + b ( 1 )z + b ( 2 )z + b ( 3 )z + b ( 4 )z
G c ( z ) = ---------------------------------------------------------------------------------------------------------------------------------
′ –1 ′ –2 ′ –3 ′ –4
1 + a ( 1 )z + a ( 2 )z + a ( 3 )z + a ( 4 )z
Eqn. 7-5
MOTOROLA 7-3
APR5Section7 Page 4 Friday, December 15, 1995 11:25 AM
where:
b ′ ( 0 ) = b1 ( 0 ) + b2 ( 0 )
b ′ ( 1 ) = b1 ( 1 ) + b1 ( 0 ) a2 ( 1 ) + b2 ( 1 ) + b2 ( 0 ) a1 ( 1 )
b ′ ( 2 ) = b1 ( 2 ) + b1 ( 1 ) a2 ( 1 ) + b1 ( 0 ) a2 ( 2 ) + b2 ( 2 ) + b2 ( 1 ) a1 ( 1 ) + b2 ( 0 ) a1 ( 2 )
b ′ ( 3 ) = b1 ( 2 ) a2 ( 1 ) + b1 ( 1 ) a2 ( 2 ) + b2 ( 2 ) a1 ( 1 ) + b2 ( 1 ) a1 ( 2 )
b ′ ( 4 ) = b1 ( 2 ) a2 ( 2 ) + b2 ( 2 ) a1 ( 2 )
a ′ ( 1 ) = a1 ( 1 ) + a2 ( 1 )
a ′ ( 2 ) = a1 ( 2 ) + a1 ( 1 ) a2 ( 1 ) a2 ( 2 )
a ′ ( 3 ) = a1 ( 2 ) a2 ( 1 ) + a1 ( 1 ) a2 ( 2 )
a ′ ( 4 ) = a1 ( 2 ) a2 ( 2 )
1.0
Region of Large
Quantization Error
-1.0 1.0
-1.0
Figure 7-1 Location of the Quantized Poles for a 3-Bit Word Length
7-4 MOTOROLA
APR5Section7 Page 5 Friday, December 15, 1995 11:25 AM
7.2 Overflow
In SECTION 6 Implementation of Digital Control-
lers and Filters, the equations for the stability
triangle were derived, which guarantee stable bi-
quad structures. When implementing these
structures in a fixed-point processor such as the
DSP56000/DSP56001, even these stable struc-
tures may become unstable due to overflow. In
classic microprocessor architectures, overflow oc-
curs when the magnitude of an internal node
becomes greater than unity and cannot be accu-
rately stored in memory. For example, in Eqn. 6-3,
w(k)=1/a0(x(k)-a1 w(k-1)-a2w(k-2)). If |w(k)| >1,
then the subsequent outputs of the filter will be
wrong once w(k) is moved to w(k-1), since |w(k-1)|
must be less than unity. Roberts and Mullis present
an excellent analysis of overflow in second-order
structures (see Reference 11). From an architectur-
al standpoint, overflow could be handled in two
ways. First, if overflow is simply ignored and wrap-
MOTOROLA 7-5
APR5Section7 Page 6 Friday, December 15, 1995 11:25 AM
7-6 MOTOROLA
APR5Section7 Page 7 Friday, December 15, 1995 11:25 AM
∞
yj( k ) = ∑ h j ( l )x ( k – 1 ) Eqn. 7-6
l = –∞
∞
yj( k ) ≤ x( k ) ∑ hj( l ) Eqn. 7-7
l = –∞
1
x max < ----------------------------
∞ Eqn. 7-8
∑ hj( l )
l = –∞
MOTOROLA 7-7
APR5Section7 Page 8 Friday, December 15, 1995 11:25 AM
7-8 MOTOROLA
APR5Section7 Page 9 Friday, December 15, 1995 11:25 AM
MOTOROLA 7-9
APR5Section7 Page 10 Friday, December 15, 1995 11:25 AM
– 2B – 2B ∞
2 2 1 –1 –1 2 2
σ f = ------------- -------- ∫ z = 1
12 2πj°
H ( z )H ( z )z dz = -------------
12 ∑ h[n]
n = –∞
Eqn. 7-9
where:
°∫ i is the Cauchy integral
– 2B
2 2 1 + r 2 1
σ f = ------------- --------------- ---------------------------------------------- Eqn. 7-10
12 2 4 2
1 – r r – 2r cos 2θ + 1
7-10 MOTOROLA
APR5Section7 Page 11 Friday, December 15, 1995 11:25 AM
e1
x(k) b0 –1 y(k)
a
0
z-1 z-1
b1 -a1
z-1 z-1
b2 -a2
e1 e2
x(k) –1 b0 y(k)
a
0
z-1
-a1 b1
z-1
-a2 b2
MOTOROLA 7-11
APR5Section7 Page 12 Friday, December 15, 1995 11:25 AM
Figure 7-3 Output Noise Power for a Direct Form I Biquad Section Caused by
Internal Roundoff Noise
7-12 MOTOROLA
APR5Section7 Page 13 Friday, December 15, 1995 11:25 AM
MOTOROLA 7-13
APR5Section8 Page 1 Friday, December 15, 1995 11:27 AM
SECTION 8
System Considerations
“An alternative to A n illustration of the DSP56000/DSP56001 func-
using the HI, SSI, tional signal groups is shown in Figure 8-1. These
and SCI is to different groups allow the DSP56000/DSP56001 to
configure the function well in a digital control system. Three on-chip
ports as general- peripherals are provided: an 8-bit parallel host MPU/
purpose I/O pins.” DMA interface, an SCI, and an SSI. Also, depending
on which of the on-chip peripherals are used, up to 24
general-purpose I/O pins are available.
Vcc Vss
5 7
Address Bus
A0-A15 16
PB0-PB7 8
Host Data Bus
H0-H7 or
Data Bus Port B I/0
D0-D23 24 PB8 HA0
PB9 HA1
PS PB10 HA2
Port A Host Control
DS PB11 HR/W
or Port B I/O
RD PB12 HEN
Bus
WR PB13 HREQ
Control
X/Y PB14 HACK
DSP56000
BR/WT
BG/BS PC0 RXD
PC1 TXD SCI Serial
PC2 SCLK or Port C I/O
Interrupt And MODA/IRQA
Mode Control MODB/IRQB PC3 SC0
RESET PC4 SC1
PC5 SC2 SSI Serial
PC6 SCK or Port C I/O
Clock XTAL PC7 SRD
EXTAL PC8 STD
MOTOROLA 8-1
APR5Section8 Page 2 Friday, December 15, 1995 11:27 AM
MC68000 DSP56000/DSP56001
Interrupt
IPL2-IPL0 Encoder HREQ
Address
A23-A4 Decode
FC2-FC0
HEN
LDS
AS
Interrupt HACK
Vector
Decode
DTACK
DTACK
BERR Timing
Generator
R/W HR/W
A3-A1 HA2-HA0
D7-D0 H7-H0
8-2 MOTOROLA
APR5Section8 Page 3 Friday, December 15, 1995 11:27 AM
MC68HC11 DSP56000/DSP56001
HACK
(HOST Acknowledge)
IRQ HREQ
(HOST Request)
A15-A8 Address
Decode
HEN
E (HOST Enable)
R/W HR/W
(HOST Read/Write)
A7-A3
AS LE A2-A0
Address HA2-HA0
Latch (HOST Address)
H7-H0
A7/D7-A0/D0 (HOST Data)
MOTOROLA 8-3
APR5Section8 Page 4 Friday, December 15, 1995 11:27 AM
8-4 MOTOROLA
APR5Section8 Page 5 Friday, December 15, 1995 11:27 AM
MOTOROLA 8-5
APR5Section8 Page 6 Friday, December 15, 1995 11:27 AM
8-6 MOTOROLA
APR5Section8 Page 7 Friday, December 15, 1995 11:27 AM
MOTOROLA 8-7
APR5Section8 Page 8 Friday, December 15, 1995 11:27 AM
8-8 MOTOROLA
APR5Section8 Page 9 Friday, December 15, 1995 11:27 AM
include 'declare.dat'
;********************************************************************************
;X Memory Declaration
;*************************************************************************
org x:0
b_0 ds 1 ;b(0) coefficient
b_1 ds 1 ;b(1) coefficient
b_2 ds 1 ;b(2) coefficient
b_1 ds 1 ;a(1) coefficient
b_2 ds 1 ;a(2) coefficient
;********************************************************************************
;Fast Interrupt Definitions
;********************************************************************************
;********************************************************************************
;Main Routine
;********************************************************************************
Figure 8-5 Program Language that Alters PID Coefficients in Real Time without
Recompiling the Routine or Halting the DSP56000/DSP56001
MOTOROLA 8-9
APR5Section8 Page 10 Friday, December 15, 1995 11:27 AM
Prescaler Divide
Divide Divide by 1 f osc
by 2 If SCP = 1, then divide by 8 by 2
to 4096 20.5 MHz
If SCP = 0, then divide by 1
Periodic Timer
Divide by 16
Interrupt
Vector
Table
SCI Timer
Interrupt
Service
Routine
P:$001C SCI Timer
8-10 MOTOROLA
APR5Section8 Page 11 Friday, December 15, 1995 11:27 AM
8.4 General-Purpose
I/O Pins
An alternative to using the HI, SSI, and SCI is to con-
figure the ports as general-purpose I/O pins. A port
control register is associated with both ports B and
C, allowing the port pins to be selected as either
general-purpose I/O pins or dedicated peripheral
pins. All 15 pins of port B must function as either I/O
pins or as the HI. However, all individual pins of port
C can be configured separately. For instance, if the
serial transmitter of the SSI is not used, PC8 can be
configured as an I/O pin while PC3-PC7 perform
their assigned SSI functions. A port pin selected as
a general-purpose I/O pin is accessed through the
corresponding port data register. Data written to the
port data register is latched.
MOTOROLA 8-11
APR5Section8 Page 12 Friday, December 15, 1995 11:27 AM
RDNRZ-
Read/Write RDNRZ+
Signals RDCLK-
RDCLK+
Disk Drive Read/Write
SCSI WRCLK-
Controller Electronics
WRCLK+
such as the WRNRZ-
MC68HC99 WRNRZ+
RDGATE
WRTGATE
DS1
Other Signals
ESDI
for Standard Interface AME
(ESDI, ST-506, SMD) HS3 Head
or Custom Interface HS2 Control
Port B I/O Pins
HS1 or Host I/O Port
HS0 DSP56000 Spindle
CMDATA Control
XREQ
XACK
READY
ATTEN Temperature Specs for DSP56000:
-40°C to +85°C
CS DATA
8-12 MOTOROLA
APR5Section8 Page 13 Friday, December 15, 1995 11:27 AM
MOTOROLA 8-13
APR5Section8 Page 14 Friday, December 15, 1995 11:27 AM
Velocity- DSP56001
Feedback
Information IRQA
Event PT PT PT t
t = Resolution of Programmable Timer (PT)
PT
PT
EVENT Interrupt A (Standard Interrupt Service Routine)
PT JSR VEL
PT Process Velocity
VEL RESET R1
RTI
PT
8-14 MOTOROLA
APR5Section8 Page 15 Friday, December 15, 1995 11:27 AM
include 'declare.dat
;****************************************************************************
;Interrupt Service Routine Definitions
;****************************************************************************
;****************************************************************************
;Main Routine
;****************************************************************************
org p:main ;main routine
movep #$C007,x:ipr ;set SCI,IRQA to priority level 2
;IRQA is negative edge triggered
movep #$0,x:bcr ;no wait states
movep #$0,x:sccr ;fastest possible timer rate
movep #$2000,x:scr ;timer interrupt enable
move #0,r1
andi #$FC,mr ;unmask all interrupts
jmp *
velocity
; process velocity information
move #0,r0
rti
Figure 8-9 Measuring the Disk Drive Spindle Velocity Using IRQA and the
SCI Timer
MOTOROLA 8-15
APR5Section8 Page 16 Friday, December 15, 1995 11:27 AM
8-16 MOTOROLA
APR5Section8 Page 17 Friday, December 15, 1995 11:27 AM
MOTOROLA 8-17
APR5Section8 Page 18 Friday, December 15, 1995 11:27 AM
include ‘declare.dat’
org p:reset
jmp main ;upon reset, jmp to main
here
do #10000,end_do ;infinite do loop of nops
nop ;waiting for next timer interrupt
end_do
jmp here
Figure 8-10 Generating Three PWM Signals on the General Purpose I/O pins
Using the SCI Timer and Modulo Addressing
8-18 MOTOROLA
APR5Section8 Page 19 Friday, December 15, 1995 11:27 AM
PC0
PC1
PC2
8-19 MOTOROLA
APR5Section8 Page 20 Friday, December 15, 1995 11:27 AM
V1 T
Digitized
Table of A
Analog
Voltage Demux V2
D/A T
Waveform with
R1 Hold
(Modulo M)
R2 V3 T
Speed
Control R3
8-20 MOTOROLA
APR5Section8 Page 21 Friday, December 15, 1995 11:27 AM
include ‘declare.dat’
jmp *
output
rti
Figure 8-13 Generating Three-Phase Signals for Motor Control Using the
SCI Timer and Sine Wave Table
8-21 MOTOROLA
SECTION 9
Conclusion
“All these The unique architecture of the DSP56000/
features give DPS56001 enables it to function as a powerful mi-
the DSP56000/ crocontroller as well as a DSP. The dual data spaces
DSP56001 the allow a highly parallel implementation of basic con-
power to solve trol algorithms such as PID controllers and notch
many of the filters. The kernel of the biquad section can be exe-
world's difficult cuted in four to six instruction cycles. The increased
embedded throughput allows higher sampling rates and reduc-
control es the amount of negative phase added to the
problems.” overall system due to the computational delay.
MOTOROLA 9-1
Finally, the three on-chip peripherals, the HI, the
SSI, and the SCI, allow the DSP56000/DSP56001
to function with minimal glue logic in an embedded
control system. The two external hardware inter-
rupts in conjunction with the SCI timer can be used
to provide velocity feedback. The modulo arith-
metic available in the address ALU can be used to
efficiently implement PWM and finely tuned, three-
phase output voltages. All these features give the
DSP56000/DSP56001 the power to solve many of
the world's difficult embedded control problems.■
9-2 MOTOROLA
APPENDIX A
Listing of ‘declare.dat’
This appendix contains all of the equates for the lo-
cations of the DSP56000/DSP56001's peripheral
registers and interrupt service routines.
MOTOROLA A-1
reset equ $00 ;reset interrupt service routine
stkerr equ $02 ;stack error interrupt service routine
trace equ $04 ;trace interrupt service routine
swi equ $06 ;software interrupt service routine
irqa equ $08 ;irqa interrupt service routine
irqb equ $0A ;irqb interrupt service routine
ssirx equ $0C ;ssi receive interrupt service routine
ssirxex equ $0E ;ssi receive with exception interrupt service routine
ssitx equ $10 ;ssi transmit interrupt service routine
ssitxex equ $12 ;ssi transmit with exception interrupt service routine
scirx equ $14 ;sci receive interrupt service routine
scirxex equ $16 ;sci receive with exception interrupt service routine
scitx equ $18 ;sci transmit interrupt service routine
sciidle equ $1A ;sci idle interrupt service routine
timer equ $1C ;sci timer interrupt service routine
harddev equ $1E ;hardware development interrupt service routine
hostrx equ $20 ;host receive interrupt service routine
hosttx equ $22 ;host transmit interrupt service routine
hc1 equ $24 ;HC 1 interrupt service routine
hc2 equ $26 ;HC 2 interrupt service routine
hc3 equ $28 ;HC 3 interrupt service routine
hc4 equ $2A ;HC 4 interrupt service routine
hc5 equ $2C ;HC 5 interrupt service routine
hc6 equ $2E ;HC 6 interrupt service routine
hc7 equ $30 ;HC 7 interrupt service routine
hc8 equ $32 ;HC 8 interrupt service routine
hc9 equ $34 ;HC 9 interrupt service routine
hc10 equ $36 ;HC 10 interrupt service routine
hc11 equ $38 ;HC 11 interrupt service routine
hc12 equ $3A ;HC 12 interrupt service routine
hc13 equ $3C ;HC 13 interrupt service routine
main equ $40 ;main routine
A-2 MOTOROLA
REFERENCES
1. Astrom, K. and B. Wittenmark, Computer
Controlled Systems, Englewood Cliffs, NJ:
Prentice-Hall, 1984.
MOTOROLA Reference-1
Motorola reserves the right to make changes without further notice to any products here-
in. Motorola makes no warranty, representation or guarantee regarding the suitability of
its products for any particular purpose, nor does Motorola assume any liability arising out
of the application or use of any product or circuit, and specifically disclaims any and all
liability, including without limitation consequential or incidental damages. “Typical” pa-
rameters can and do vary in different applications. All operating parameters, including
“Typicals” must be validated for each customer application by customer’s technical ex-
perts. Motorola does not convey any license under its patent rights nor the rights of oth-
ers. Motorola products are not designed, intended, or authorized for use as components
in systems intended for surgical implant into the body, or other applications intended to
support or sustain life, or for any other application in which the failure of the Motorola
product could create a situation where personal injury or death may occur. Should Buyer
purchase or use Motorola products for any such unintended or unauthorized application,
Buyer shall indemnify and hold Motorola and its officers, employees, subsidiaries, affili-
ates, and distributors harmless against all claims, costs, damages, and expenses, and
reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury
or death associated with such unintended or unauthorized use, even if such claim alleges
that Motorola was negligent regarding the design or manufacture of the part. Motorola
and are registered trademarks of Motorola, Inc. Motorola, Inc. is an Equal Opportu-
nity/Affirmative Action Employer.