acquisition board shown in Fig. 3. MEK 6800D2 evaluation module built around a
6800 microprocessor is a two- board system with a hex keyboard and display.
Control System Experiment: Use of Microprocessors in Introductory Control laboratory* R. La1 Tummala Department of Electrical Engineering and Systems Science, Michigan State University, East Lansing, MI 48824 ABSTRACT: Microprocessors have been extensively used in the design of real time control systems. To familiarize the students with microprocessors, several experiments are introduced in our introductory control laboratory. The purpose of this paper is ro give a detailed description of rhese experiments.
Introduction Theavailability of lowcostmicroprocessors created a great dealof interest inthedesignofmicroprocessor-based controlsystems.Tofamiliarizethestudents with the microprocessor control, a set of new experiments are added to the introductory control laboratory at MichiganStateUniversity [ I ] . In theseexperiments, the microprocessor is used to acquireanalogdata by interfacingan analog to digitalconverter: to outputa digital data which if used in conjunction withadigitaltoanalogconverter, providestheanalogoutput;tocontrolthe position ofa D.C.Servomotor;andto control the speed of a stepper motor. The purpose of this paper is to give a detailed description of these experiments and the equipment used.
in theseexper-
1) MEK 6800D2 Evaluation Kit available from the Motorola Corporation shown in Fig. 1, 2) An experiment board shown in Fig. 2, and 3) A position servo system with data acquisition board shown in Fig. 3. MEK6800D2evaluationmodule built around a 6800 microprocessor is a twoboardsystem withahexkeyboardand display. It also contains simple a *Received April 14. 1982. Accepted by Associate Editor G . H . Hostetter.
20
Experiments
Fig. 2. Experimentboard used for microprocessor interfacing experiments.
Equipment Theequipmentused iments consists of
Fig. I . Assembled MEK 6800D2 kit
Phillips Controls, Cheshire, Conn., part #K-82701); and driver a SAA1027 (North American Phillips Control Corporation),ananalogtodigitalconverter (part #AD571K, Analog Devices, Inc.), andadigital to analogconverter(part #NE50 18. SigneticsCorporation).The block diagram is shown in Fig. 4. The positionservosystemshown in Fig. 3 is a locally built system with off the shelf components and28V permanent magnetD.C.Servomotormanufactured by Electro-craftCorporation,Hopkins, Minn. [2]. Thesystemwasdesigned in sucha waythatstudentscanperform bothanaloganddigitalcontrolexperiments.Theblockdiagram is shownin Fig. 5.
monitoring system called JBUG, random accessmemory (RAM) andparallelinput/output.TheJBUGmonitor lets the userentermachinelanguageprograms, debugthemandexecutethem.The kit also contains a serial interface which can beusedinconjunctionwithacassette tape recorder for storing programs. The parallel I/O chip,calledaPeripheral InterfaceAdapter(PIA),actuallycontainstwo 8 bit I/O portsfortheuser’s interface. When assembled, the kit providesafullyfunctionalmicrocomputer system and performs an adequate job in the microprocessor control experiments. Theexperimentboardconsistsofa 12Vsteppermontor(NorthAmerican
The students begin these experiments MEK by gainingfamiliaritywiththe 6800D2using thedocumentationprovidedwiththesystem by the manufacturer. They learn the step-by-step procedure to enter machine language programs, debug and execute them using the JBUG monitor [3]. Experimentsdealing withthemicroprocessor interfacing are performed next. In thispart,thestudentsinterfacethe microcomputertotheexternaldevices usingtheperipheralinterfaceadapter (PIA) chip. The PIA, which is housed in a 40 pin package, has two separate eight bidirectional data busses usually known as Port A and Port B for interfacingto the outside world. The 16 bidirectional input/output lines may be programmed to act either as imput or output lines. The datadirectionregister is used for this purpose(seeFig. 6) [4]. Thefollowing experiments are performed by interfacing thevariouscomponentsontheexperiment board and the microprocessor (Fig. 7). a) Initialization of PIA This is animportantpartofallthe experimentswherethe 16 bidirectional
control systems magazine
Fig. 3. PositionServosystem:
lines of PIA are defined as inputs and/or outputs. For example, the program shown in Fig. 8 defines all 8 data lines of “PORT A” as inputs and the 8 data lines of “PORT B” as outputs. b) Display different bit patterm on LED array Usingtheinitializationprocedurein part (a), the 8 data lines, PBO-PB7, that are connected to the LED’s through the buffer on the experiment board (Fig! 4) are set up as output lines. The desired bit patternsareoutputtedusingtheperipheral data register in the PIA. A sample program is shownin Fig. 9. This program outputs0,1,2,. . ., etc.intheconseca utiveorderon PBO-PB7 lineswith delay of specified duration.
( I ) Microcomputer, (2) Controller, ( 3 ) Motorandgears,and
(4) Power supply.
is determined by the following rpm (0) relations: Frequency =
#steps
w
rev
60
-* - Hz
(1)
Since the stepper motor we have chosen has 48 steps per revolution [ 5 ] , we get:
The program is given in Fig. 10. d) Data acquisition This experiment teaches the students to interface A/D andD/Aconverters, an important part of the microprocessor controlsystem.Thestudentswritea
Fig. 4. Block diagram of the experiment board shown in Fig. 2.
c) Speed control of stepper motor In this part, the speed control of stepper motoron the experiment board is controlled by outputtingavariablefrequency square wave. The microcomputer is thus used as variable a frequency square wave generator. Even though one of the PIA data lines can be used for this purpose, it is decided to use one of the control lines such as CB2 (Fig.6 ) in bit 3 followingmode.Thedesiredfrequency of the square wave for a given speed in
Fig. 5 . Block diagram of the position Servo system shown
in Fig. 3 .
8 DATA LINES FROM PERIPHFR~L
program to read an analog voltage using an A/D converter into microprocessor at adesiredsamplingrateandoutputthis value to a D/A converter.The COMeCtions are shown in Fig. 11. In this program, "PORT A" is set up as an 8 bit input port, and "PORT B" is used as an 8 bitoutputport.Use ofinterrupts are introduced.The flow chart ofthisprogram and the listings are shown in Fig. 12 and Fig. 13. The input to the A/D converter is asinewaveofagiven frequency.Thesamplingfrequency,is vaned to observe the aliasing effects.
a
DATA LINES FllOM PERlPHERIl
CONTROI LINES
K":;;"":"T",/"'"
I IVES
rj RSO = 0
fl RS1 = 0 CRA2 = 0
REGISTER A
CONTROL
i
REGISFER E
"0'
"1
'
INPUT
:
OUTPUT
- GRD - PWR l+5!
~
R
REGISTER A
]
INTERRUPT RESET READ A TO hlPU
I
H
S
RSl = 0 I )7
" \/
OR WRITE R E G 8 l SDTA t HT A SELECT FROM LINES TO PAPU MPU
REGISTER B F;
I
R
ENABLE
S
/ - "% -
hlPU FROM ADDRESS LINES
O
RS1 = 1 = 1
INTERRUPT L-"-f E TO hlPU CHIP SELECT FROM hlPU ADDRESS LINES
Fig. 6 . Internal architecture of Peripheral Interface Adapter (PIA). [4]
Experiment using Position Servo system
In this experiment, the microcomputer is introduced in the control loop of the position servo system as shownin Fig. 5. The voltage of the output potentiometer whichrepresentstheoutputposition is an inputted to the microcomputer through analogdigitalconverter(Fig. 14). The desiredpositionisenteredviathekeyboardasadigitalvalue.Themicrocomputer computes the error between the output position and the desired position. Thiserror is thenused to generatea control signal which is converted into an analog form withadigitaltoanalog converter and applied to the inputs of the 15). amplifiersdrivingthemotor(Fig. Thecontrolsignalgeneratedcan bea
Fig. 7. Experimental board andthe microprocessor.
22
control systems magazine
Memory Loc (HEX)Instruction (HEX)
Comments Losd ACCA with zero
0000
86
0002
B7 8005
Enable Data Direction Register A
0005
B7 8007
Enable Direction Data Register B
00
B7 8004
0008
PAO-PA7 lines are inputs
FF
OOOB
86
OOOD
B7 8006
PBO-PB7 lines are, outputs
Memory Loc (HEX) Instruction (HEX) 0000
86
0002
B7 8007
0005
86
0007
B7 8006
Enable DDRB
OOOA Fig. 8. PIA Initialization.
Memory Loc (HEX)Instruction (HEX) 0000
86
0002
B7 8007
0005
86
0007
B7 8007
OOOA
CE HHHH
OOOD
09
OOOE 00 10
.
30
26
Comments
30
FF
Define PBO-PB7 as outputs
04 86
oooc
B7 8007
OOOF
86
0011
B7 8006
0014
CE
0017
09
0018
26
OOlA
4c
00 1B
20
Enable Peripheral data register B
01
Output "1" on the PBO-PB7
CB2 = 0
34
CB2 = 1
T
~
Delay = 2
FD
86
0011
B7 8007
CB2 = 0
0015
CE HHHH
T Delay = 3
0018
09
0019
26
OOlB
7E 0005
Comments
00
HHHH* Delay FD Increment ACCA Branch t o 0011
F4
*H = Hex number Delay = 1 3 Sec. ~ multiplied by the decimal value equivalent of the hex number, HHHH Fig. 9. LED program.
FD Jump to 0005
Fig. 10. Stepper motor control program.
DAC
ANALOG VOLTAGE OUTPUT
JI GND Fig. 11. Interfacing ADC and DAC to the microprocessor.
Memory locations 0000-000F contain the program t o set up PAO-PA7 lines as inputs and PBO-PB7 as outputs (see Figures).
21PFJ0-PB7 as WIPUIS 31CA2 line as Output 41Clea1 ntermpls
B? 86
neby a
sarnpk lime
Fig. 12. Flow chart for data acquisition using ADC and DAC.
2E
Memory Loc (HEX)
Instruction (HEX)
0010
86 04
0012
B7 8005
Enable peripheral - data Register A
0015
87 8007
Enable peripheral data Register B
0018
B6 8004
Clear Interrupts
OOlB
86 34
OOlD
8005
0020
3C
0022
B'7 8005
0025 34
86
0027
B7 8005
002A
B6 8005
002D
1
Comments
Output a convert pulse on the CA2 line
Conversion complete?
FB
002F
B6 8004
Read the output of AID and clear i n t e r rupts
0032
B7 8006
Output the value on PBO-PB7
0035
CE .HHHH
0038
09
0039
26 FD
003B
7E OOlB
Delay
Jump to 00 1B
_____
Fig. 13. Data acquisition program.
simple multiple of the error or the result of complex a controlalgorithmprogrammed microprocessor. into the Studentswriteprogramstocontrolthe position and study the effects of sampling period on the system response. An example is shown in Fig. 15 and Fig. 16. Advanced students program complex such as PID and control algorithms digital equivalents of a n a l o g compensating networks and determine the effects of these on the system response.
Concluding Remarks
I Fig. 14. Data acquisition board associated withthe position Servo.
24
The experiments described in this papercomplement verywellwiththe other experiments in the lab dealing with the analog control systems [I], and form a basis to understand and design real time control systems using a microcomputer. We found that this can be done witha
control systems magazine
ZIPBb-PB7 as outputs 3)Clearinterrupts
(HEX) Instruction Memory Loc (HEX) Comments
-V Outputaconvertpulseona
Memory locations 0000-0031 contain the same program as g i v e n i n F i g u r e 14 Desired position is stored in location 0080. Actual position is stored in l o c a t i o n 0081.
CA2 line
97
0032
Store a c t ut ahle
81
position 96
0036
C90o m p4u1t e
0038
B7
003A
C EH H H H
003DDelay
09
J
003E
26
on P B W B 7 lines
0040
7 E OOlB
&+ Determine the error between the desired position and the actual position
Output the error
80
0034
Loop
8006
the e r r o r Otuhtep u t
error
FD Repeat
Delay (sample time)
Fig. 16. Program
Fig. 15. Flow chart for position control
-
minimal comouter background. Many of the students are motivatedbythis experience and pursue further work in the form of independent study. This usually and construction of involves the design microprocessor based systems. Typical Phillips Controls, Cheshire, student projects in the past included the microprocessor controlled growth chamb e r a n d 3 DOF mechanical manipulator. ~~~
[3] MEK 6800D2 Evaluation Manual.
Motorola Corporation. [4] R. Bishop,“Basicmicroprocessorsand the 6800,” Hayden Book Company, 1979. [SI Data sheets from North American CT.
References R . L. Tummala,1980.“Control Systems Lab Manual.” Departnent of Electrical Engineering and Systems Service, Michigan State University, East Lansing, MI. [2] D . C . Motors, Speed Controls, ServoSystems, AnEngineeringHandbook by Electro-craft Corporation, Hopkins, 1978. MN. Technology. of Institute Madras ing from [I]
February 1983
R. La1 Tummala (S‘66-M‘70) was born in Pamarru. India, on May 22. 1944. He received the B.Sc. degree in mathematics, a pn hd y s i c s , chemistryfromAnd h rUa n i v e r s i t y . N’altair. India. the D.M.I.T.degree in electronicscngineer-
for position control. Madras,India,theM.Tech.degree in industrial electronics from the Indian Institute of Technology,Kharagpur,India,andthe Ph.D.degree in electricalengineering and systems science from Michigan State Unircrsity,EastLansing, in 1961,1964, 1966, and 1970. respectively.Since I966 hehasbeen with Michigan State University, where he has beenResearchAssistant,Human ILearning Research Institute (1966-1967). Kesearch Assistant, Department of Electrical Engineering (1967-1970), and Rcsearch Associate. EnvironmentalSystemsProgram, Division of Engineering Kesearch (1970-1972). He i5 prcsently an Associate Professor in the and Department of ElectricalEngineering Systems Science and the Department of tintomology.Hiscurrentresearchinterestsarc in digital control. robotics and \ystems modeling. He is the author of soera1 papers in theseareas.Dr.Tummala is aSenior Member of the Kobotics intcrnational o l the Society 01 1.Ianufacturiny tingincsrr.
25