You are on page 1of 22

INTERFACING MICRCCOMPurERS FOR PROCESS CONI'ROL

John M. Messer
Eastern Illinois Universtiy
To adeqmtely deal with the interfacing of microcanputers and
process control, it is necessary to first establish a minimal level of
understandi ng of both process control and microcomputers.
INl'RODu:::rION 'ill PROCESS CONTROL
Process control usually consists of two parts, 1) a control
circuit, that turn on or off the process, and 2) a feedback circuit,
that monitors the process and 'feedbacks' a signal to inform the control
circui t as to condi tions in the process. This is usually referred to as
a 'closed loop' control circuit. The control circuit can be continmus
or discontinmus. Continuous indicates that the control circuit never
interrupts or discontines the controlled process (e.g. to control the
temperature of an oven using a continmus control circuit, heat would
always be generated in the oven by a resistive material and a variable
voltage/current) . Discontinuous indicates that the control circuit
interrupts or turns on and off the process (e.g. to control the
temperature of an oven using a discontinuous control circuit, the heat
would be generated at maximum until a predetermined temperature is
reached, the heat generating device would be turned off or
Dr. Messer is Associate Professor at Eastern Illinois Uni versi ty ,
Charleston, Illiniois.
INTERFACING MICR()(X)MPurERS FOR PROCESS OJNI'ROL 2
'discontinued' until the temperature dropped to a predetermined level at
which ti.rre the heater would again be turned on).
Since the microcanputer output has basiclly tl,t,Q states, ON & OFF,
the easiest interface to implement is discontim.ous control. Ho.vever,
continuous controls can be accomplished either by using a more canplex
interface or a more complex program.
MICROCDMPurER BASICS
As just mentioned, computers have tl,t,Q basic states; ON & OFF.
These condi tions are also referred to respectively as HIGH & IJ)W, or "1"
& "0". The microcomputer has several sets of conductors or wires
associated with its operation. The conductors are used to carry signals
between the canputer's electronic components, the outside world and the
processor or computer itself.
These conductors are ccmronly referred to as "BUSSES". The busses
are usually grouped into three bus systems, 1) address bus, 2) data
buss, and 3) control buss. A bus refers to a group of conductors
grouped to perform a particular operation or function.
It is important to understand the basic communication process
wi thin the computer to understand the interfacing re:Juirements. It must
be understood, that all comnunications are in the form of ON or OFF
signals. All signal lines in the canputer have tl,t,Q possible condi tions ,
ON or OFF. Arr:i other voltage or condition is not a valid signal and may
be improperly processed. As the number of conductors or lines increase,
the number of possible combinations increase. With two(2) lines,
INl'ERFACING . MICRcx:a1Purrns FOR PROCESS CONTROL 3
four(4) possible combinations exist. Reference will be made to the
lines as A and B; roth can be OFF (A=O & B=O), one can be ON and the
other OFF (A=l & B=O or A=O & B=l), or roth can be ON (A=l & B=l). As
lines are added, addi tinal combinations are available. The mathmatical
relationship between the number of line or conductors and .the possible
number of combinations is 2 ~ n where n is eq:ml to the number of lines
or conductors. Hense, eight(8) lines will yield 2-8 or 256 possible
combinations, and sixteen(16) lines will yield 2-16 or 65536 possible
combinations.
Nuuber of Lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Possible Combinations
2
4
8
16
32
64
128
256
512
1024
2048
4096
8192
16384
32768
65536
Although nolonger absolutely true, rrost microcanputers utilize 16
address lines and 8 cbta lines. This allows the processor to access
65536 (64K) memory locations with each memory location containing an 8
bi t word or cb ta byte.
At first it may be difficult to comprehend the relationship of
INTERFACING MICRcxx)MPurERS FOR PROCESS CONTROL 4
addressing, rrercory . locations , and data bytes. Consider a classroom
setting in which the instructor is assigning lockers. As the instructor
calls a student's name and his locker assignment (e.g. Jack Smith #14),
all student hear the number, but since it is not theirs, they do not
respond or remember the number, Jack may not either but let's assume he
wrote it down were he can find it. In the example, data was written to
a rremory location. The data was #14 and the merrory location was Jack
Smith. Data can be read from a m2m0ry location by addressing the
location and reqoosting that the contents be placed on the data bus.
Back to the classroom, the next day the instructor can not find his list
of locker assignments, so he calls each student's name and the students
respond each in turn, with their locker number. Jack ~ th 's narne is
called, Jack responds with "14". Again, all of the students heard the
reqoost made of Jack, but only Jack responded with his .. number.
Just as students must be told when information is needed from them
and when information is to be given to them, the computer must tell the
memory locations if it is reqoosting information or giving information.
These operations are referred to as 'READ' and 'WRITE' respectively. To
read or write to a memory location, the control bus must be utilized.
The control bus contains all of the lines coming from the microprocessor
or going to the microprocess that 'control' the input/output or other
functions. One of the control lines indicates whether the operation is
to read data from a location or write data to a location. Saretimes
this requires t ~ o or three lines. If single line is used for marory
INl'ERFACING MICRCXDMPurERS FDR PROCESS CDNI'ROL 5
output or input, it is referred to as the Read/Write line. If we wish
to read from the memory location which we are addressing, the line is
"HIGH" or ''In. To write to the rne:rrory location we are addressing, the
line is ' LOW' or "0". Although other lines may be involved in
addressing, and reading or writing data, the a.}:x)ve discussion provides
the ground work for discussing interfacing and control circuits.
INTERFACING
In order to interface or connect to the computer, it is necessary
to tie in or connect to the canputer' s busses. Certain signals are
required. It is necessary to address or talk to the interface at
various tirres (this timing is controlled by the program). The address
lines/bus is used to identify which memory locatiion or interface
circui t that will be input to the processor. Information or data, to be
used for process control, must be passed to the computer and/or receive
from the canputer. To acccrnplish this, connections must be ma.de to the
data lines or bus. And finally, the system must determine if data is to
be input from or output to the data line for process control.
ADDRFSS/roRT DECODING RmUIREMEN1'S
The address bus typically contains sixteen (16) lines, for complete
decoding each line must be deccxled. When developing an interface, it is
often unnecessary to deccxle all sixteen(16) lines of the address bus.
If, as in the VIC-20, only 5K of mernory is used in the basic system,
may select any combination of address lines that will provide a unique
INTERFACING MICRcx::oMPurERS FOR PROCESS CDNI'ROL 6
address for the output. This must be an address that is rot used by the
canputer memory. The binary representation of 5K or 5120 ~ t s of
memory is 0000 1010 0000 0000 with the least significant bit(LSB) on the
right, and the rrost significant bite(MSB) on the left. With this in
mind, any rramry 19Cation above 5120 can be utilized. If only a single
8 bit output, and a single 8 bit input is needed, a VIC-20 user can uti I ize
the BLK 1 address 1 ine. This I ine is active LOW anytime a memory between
8K and 16K is addressed.
The circuit can be set-up so that any time one addresses a memory
location between 8192 and 16383 and the Read!\'Jr i te 1 i ne is LOW
the I/O circuit will use the data as an output. This is referred to as
partial decoding, and is quite acceptable since the computer will not
address this location unless so instructed by the program.
On the VIC-20, the control signal has been combined so that the
VR/W or Vic Read/Wri te is the only control line necessary for reading or
writing to an address. The following digital logic circuit will allow
the address 8192 to be decoded and used as an output enable.
BLK 1
VR!W
Output is Active HIGH
when BLK1 is addressed
and VR/W 1 ine is LOW
INI'ERFACING MICRc.coMPlJrERS FOR PROCESS CONI'ROL 7
The VR/W must be inverted because the write is active low. That is when
the VR/W line -is low or logic 0, the operation performed is a write
function. This logic level must be ANDed with the B l K 1 j n
order to obtain a decoded write or output enable for address 8192.
Actually, this circuit will be enabled for any-address that causes
the BlK' l 1 i ne to be lOW or logic o. This includes addresses 8192
through 16283. But since these are not used for any other function,
this will not create an addressing problem.
DATA/Q)NTROL OlJrPlJr
It is necessary to latch or hold onto the data that is written or
output to this location, because the processor will hold the data on the
data bus valid for only a few microseconds. This can be accomplished by
using an 8 bit iatch. The logic levels of the latch's output lines will
then indicate the logic level of the corresponding data lines of the
canputer when the address 8192 was last addressed. A typical circuit is
diagramned (don't forget Vee and Gnd).
j,OW IoArw
7'1t.SUr.I
-
Enable
07
00
74LS373
QUAO LATCH
---------------------
07
00
INI'ERFACING MICROCOMPUTERS FOR PROCESS CONTROL 8
This circui t will allow the prograrrmer to have the ccmputer output to
the 'real world' any time it is needed to change the control of a
process or operation.
DATA/SENSOR INPUT
A similar circuit is required to input data to the processor from
the real world. Again, rE'ffiErober the canputer can only process a
canbination of ONs and OFFs or logic '1' s and '0' s. The input can be
generated by limit switches, or other devices that will allow for ON/OFF
condi tions. There are as many as eight (8) inputs and each line can
represent a different switch condition. The digital logic circuit
required to enable an input to the processor uses the sarre address and
control lines. The following digital logic circlli t will allow the
address 8192 to be decoded and used as an input el1able.
VR/W
OUTPUT Active HIGH
. when BLKl is addressed
and VR/W is HIGH
The output of the AND gate will be high when BLKl is active LOW and the
VR/w line is Hgh. In order to input to the data bus when the address
INTERFACING MICRCXX)MPurERS FOR PRcx::ESS CONTROL 9
is accessed, and not before or after, it is necessary to utilize an
input buffer . The buffer is a tri-state device, which when disabled,
appears to the data bus as a high impedance or as if it was not
connected to the line. The buffer, diagrarrmed below, requires an active
low enable so the output of the digital logic deco::ling circuit must be
inverted and connected to the buffer enable as cliagranmed.
Enable
VR/iJ 07
00
74LS244
TRI-STATE BUFFER
07
00
This circuit will allow data from outside the ccmputer to be read by the
computer and processed to determine the appropriate data to be output to
the control circuits.
Remember, ccrnputer controlled processes are an advantage only if
very complex control circuits are required or freqU2nt changes in
control pararreters are anticipated.
t
INl'ERFACING MICRCXX)MPUI'ERS FOR PROCESS CONI'ROL 10
I/O SCHEMES
~ l a r circuits can be utilized to interface with other
microcanputers. The only real difference is in the way the control
lines are used. To canplete the interface, it is necessary to
know/understand the active logic levels of the control lines and the
available unused rnerrory locations if you chose to use marory mapped I/O.
Many systems utilize a port for I/O rather than a memory location.
The process is very similar, except only the first eight address lines
are used to identify the port number. The data lines are used to
transfer data to or from the port as discussed earlier. For a processor
to use a port for I/O the manufacture must provide an additional line to
identify if the address of the first eight address lines is for marory
access or port I/O. These systems will often use a control line for the
read function and another control line for the wri te function.
If using the TRS-SO III, an I/O port is already available. This is
the parallel printer port. This port is already decoded and has
eight(S) data output lines and eight(S) data input lines. It can be
used for process I/O ~ installing a 34 conductor riboon cable to the
printer port (the printer must be disconnected). A review of the I/O
section of the manuel identifies the port address is FS hex or 496
decimal.
INl'ERFACING MICRCX:OMPurERS FOR PROCESS cx)NI'ROL 11
BASIC PRcx;RAMMING CXlMMANDS FOR I/O
,
When prograrrming in 'BASIC' and using the output circuits discussed
in this paper, only tv.u ccxmands are necessary to input or output data.
When using menory mapped I/O, as with the Vic-20 or other 6502 or 6800
l::ased microcanputers, the camands are 'roKE' and ' PEEl< ' To output a
value to the output latch, the carrnand is roKE P ,x where P is the {X)rt .
address and X is a , number to be output between 0 and 255. To input the
data located at the input buffer use the ccxmand D=PEElP) where D is
the a variable that will contain the data available at the latch and P
is the address of the location to be input. When using an I/O {X)rt and
the basic language to comnunicate with the {X)rt, the carrrand to output
is our P, X. Where P is the {X)rt address and X is the valLE to be
output. The carrrand to input is D = INP(P). Where D is the data
available at the {X)rt (a number between 0 and 255) and P is the {X)rt to
be read.
QU'rpur BYTE FOR CONTROL
To use the output data byte for control, circuits must be utilized
that will res{X)nd to the ON and OFF conditions of the output signals.
The basic requir6l1ent is that +5VI:x: at a very low current must be
sufficient to energize the control circiut.
SCRs
One {X)ssible circuit utilizes an SCR with the +5VI:x: connected
through a resistor to the gate.
INrERFACING MICRCCOMPUrERS FOR PROCESS OJNI'ROL
DIJ
120 VAC
(High Side)
120 VAC
(Low :' Ide)
12
The resistor is necessary to limit the gate current to a safe value to
prevent darrage to the seR. This circuit was used in the lamp display
during the discussion/presentation. The lamp circuit utilized eight
SCRs, the drain of each SCR was connected to a lamp, LO-L7, as a load;
each SCR gate was controlled by the data bits DO-D7 respectively; and
all source leads were connected to ccmron.
By driving the gate high or to +5VDC, the SCR is activated and will
conduct until the gate is turned OFF and the voltage across the SCR
reverses polarity. (The voltage reverses polarity each half cycle of 60
tirres per second.) In this application, the SCR rray require as much as
1/120th of a second to turn OFF.
BIDIREX:TIONAL OC MYIOR OJNI'ROL
Scree devices require that the control circuit be able to not only
turn ON or OFF the device, but also to reverse the device. The
- -------
...
INI'ERFACING MICRcx::x:1PurERS FOR PROCESS mNrROL 13
reversing of a rrotor is often necessary for given processes. Reversing
a OC rrotor r ~ u i r e s that the current through the motor l:::e reversed. One
solution to this control problem is the use of a canplementary syrrentry
circuit. The circuit utilizes a NPN transistor and a PNP transistor
with sirniliar characteristics. Both a positive power supply voltage and
a negative ~ r supply voltage are r ~ u i r e for circuit operation. A
possible circuit is diagrarrrred.
+ Vee
-Vee
The circuit r ~ u i r e s as an input a positive potential to drive the
NPN transistor, and a negative potential to drive the PNP transistor.
With a positive signal applied to the input(transistor bases), the NPN
transistor will conduct and the motor will run. When a negative signal
is applied to the input, the PNP transistor will conduct while the NPN
transistor is turned off. Current will flow fran the -Vee powersupply
and the rrotor will reverse directions. Since the driving circuit
r ~ u i r e s both a positive and negative voltage to control e1e motor
----- -----
INTERFACING MICRCXX>MPurERS FOR PROCESS (x)Nl'ROL 14
direction, it is necessary to add a seO)nd circuit to O)nvert the
microcomputer outputs of OVDC and +5VDC to a signal capable of
O)ntrolling the drive circuit. If an operational amplifier inputs are
O)nnected to tv.u of the output data bits and the OP amp is configured as
a camparitor, the output will swing positive if one data bit is high and
the other is low(e.g. 00=1,01=0), and negative if the data bit outputs
are reversed (e.g. 00=0,01=1).
+5 VDe
Using tv.u data bi ts, the di recti on of a CC rrotor can be controlled.
If roth data bits are the same (e.g. 00=1, 01=1 or 00=0, 01=0) the CC
rrotor will be turned off.
SOLID STATE RELAYS
Many control operations require that 120VAC or 240VAC be turned on
or off. This can be accomplished using a conventional armature relay.
INI'ERFACING MIc::RCXXX1PlJrERS FOR PROCESS mNl'ROL 15
Hcwever, rrost relays will not activate with +5VDC and require a driver
circuit to activate them . . The solid state relay simplifies these
requiranents. Solid-state relays are available in a variety of packages
and will control currents fran 3 to 20 amps at 120 or 240 VAC. The
beauty of the solid-state relay is that it will activate with as little
as three volts and draws only 10 to 20 milliamps fran the microcanputer.
DARLINGIDNS AND rovER FErS
Solenoid valves for controlling pneumatic or hydraulic cylinders or
. rrotors, unidirectional OC rrotors, drive circuits for sorre stepper motor
applications, conventional relays and solenoids, and other devices
requiring higher OC voltages and currents than are available from the
rnicrocanputer output can be driven with either a Darlington amplifier
circuit or a Power FEr amplifier. The Darlington amplifier utilizes two
transistors configured as diagrammed:
+vcc
D0
..
rnTERFACING MIClKXXlMPurrns FOR PROCESS Q)tn'ROL 16
The Darlington amplifier configuration provides a high imput
impedance and requires a rather law current to activate. Darlington
amplifiers can be constructed using descrete transistors, or can be
purchased as a package which resembles a power transistor.
Field Effect Transistors (PETs) are semiconductor devices s1miliar
in appearance and performance to bipolar transistors. PETs because of
the technology used have a high input impedance and can be driven by the
data bit logic level available from the microcanputer. Th"Ts are
implemented similiar to bipolar transistors.
INPurTING DATA 'IO THE MICRCXXlMPurER
ICGIe SWI'ICHES
The simplest method of inputting data to the microcanputer is with
swi tches which have an output of 0 volts if turned OFF and +5 volts if
turned ON. An input data byte can read the condition or state of up to
eight(S) input switches. The output of the switch in connected directly
the input of the tristate buffer. When the address or port is enabled,
the signal from the switch is fed to the data bus of the microcanputer,
and can then be used by the operator/prograrrmer as needed. Switches to
provide data to the microcanputer are nomally configured in one of tv;o
ways. The ITOst straight forward configuration uses a single pole,
double throw (SPDT) switch. One thraw is connected to +5 VDC and the
other is connected to ground or 0 VDC. The pole is used as the output
and will be either a logic '1' or '0'.
INTERFACING MIOtOCOMPUTERS FOR PROCESS cx)NrROL 17
+5 VDC
0"
_7
The second scheme utilizes a single pole, single throw (SPST)
swi tch and a resistor. The resistor is connected to +5 VDC and to the
pole of the switch. The throw of the switch is connected to the ground
or 0 VOC. When the switch is open, the voltage on the pole is +5 VOC or
l o g ~ '1'. When the switch is closed the +5 VOC is dropp:d across the
resistor, and the voltage on the pole is OVOC or logic '0'.
+5 VDC
Up to eight switches can be ganged or grouped to input to a single
port. Virtually any type of switch can be utilized. These switches can
INTERFACING MICRcx:xx-1PlJrERS FOR PROCESS OJm'ROL 18
be activated manually, ~ a IlDving machine, a door opening or closing,
etc. If a process can activiate a switch, it can be used as an input
for the microcomputer.
A/D CONVERTERS
Most processes produce analog values. Tenperatures between 0 and
100 degrees centigrade, distances between 0 and 3 inches, light
intensity, rroisture content, and liquid level are all analog values.
Tw::> rrethods exist for inputting data of this nature to the micro-
'caTlputer. The most straight forward method is to set a series of limit
switches or thermal activated switches ~ o r various positions or
conditions at selected intervals (e.g. switch 0 ~ u l activate at 0
degrees, switch 1 ~ u l activate at 10 degrees, switch 2 ~ u l activate
at 20 degrees, switch 3 would activate at 30 degrees, etc.) These
switches would be input to the data input port of the microcomputer.
The program could be written to compare the input data to desired values
and control data could then be written to the output port. This
requires a seperate switch for each increment identified and is limited
to eight increments.
The second method utilizes an analog to digital converter (A/D
converter). Several circuit variations exists for producing a binary
number proportional to the analog input. The ADC0804 IC is one of the
simplest AID converters circuits and will produce a binary output
proportional to the analog input. The circuit is a single intergrated
INrERFACING MICRCXMPurERS FOR PROCESS CONI'ROL 19
circuit and requires as few as three(3) discrete components to
implement. The analog input voltage is usually limited to +5 voc. If a
larger voltage is to be input, it must first be reduced using a simple
voltage divider.
ADco804
B
20
Vee
All
11
... th
ClIt R
WJ\ 10k
CLKIN
I1lTJ\
"
017
'"
12
{ .", "'" "'"
ANY
::> Oil
VIN t-,
-
13
AID OVER ANY O($IREO
~ P R O E S S O R
.. 015 OIFF ANALOG INPUT
~
14
VINH
} INPUTS VOLTAGE RANGE
014
SEE SECTION 2.4.1
15
Oil
A eND
1&
OU
VREFf2
17
081
II
080 o GNO
-
SENSORS AND COMPARI'IORS
Sensors are available or can be constructed to sense virtually any
physical condition; heat, light, distance or position, speed, moisture,
hardness, Ph level, etc. In many situations, the actual intensity or
level is unimportant, but when the intensity or level exceeds a
predetermined value a change or control is required. An effective
rrethod of inputing data of this nature to the microcomputer is through a
compari tor. The sensor output is canpared to a known or standard value
and if it exceeds the standard, an output is generated. If the output
is +5 VOC, it can be coupled directly to a data input bit.
INI'ERFACING MICRC:X:n1Purrns FOR PROCESS <X>NI'ROL 20
Comparitors are basicly operational amplifiers configured as
differential amplifiers with an extremely high gain. A typical circuit
is:
+5 vee
Voltage divider Rl and R2 are adjusted such that the voltage at their
junction, when coupled to the OP-arnp is eqU3.l to the voltage at the
j unction of R3 (the sensor) and R4 when the condi tion has been met to
cause an output change. The output of the comparitor will be 0 VDC or
+5 VDC, and can be coupled directly to a data input bit.
PROGRAMMING TIPS
Once the data has been made available at the input data byte, the
microcanputer must be prograrnned to use the data, and generate a
corresponding output for control. Data can be input using the input
-----"-------------------- - --
INl'ERFACING FOR PROCESS ())Nl'ROL 21
statement: A=PEElP), where A= a variable which is to be set equal to
the binary value at me:oc>ry location P, and P= the narory location used
as the input port. If the microcanputer utilizes a port address rather
than a memory address(for TRS-80s, and other Z80 or 8080 base machines)
the correct statement is: A=INP(P). The binary number read into the
microcomputer with the PEEK or INP statement must be utilized in a
program to generate a corresponding control output. The nature of the
variables to be considered dictates the program structure.
Renanber, the input/output data bits correspond to the following
binary numbers:
If ONLY 00 is high or logic
'1 '
the binary input # is 1
If ONLY 01 is high or logic '1 ' the binary input
i is 2
If ONLY 02 is high or logic '1 ' the binary input # is 4
If ONLY 03 is high or logic
'1 '
the binary input
# is 8
If ONLY 04 is high or logic '1' the binary input # is 16
If ONLY 05 is high or logic '1 ' the binary input
# is 32
If ONLY 06 is high or logic '1 ' the binary input # is 64
If ONLY 07 is high or logic '1 ' the binary input # is 128
If 00 and 01 are high or logic '1 ' the binary input # is 3
If 00, 01, and 02 are at logic '1 ' the binary input # is 7
ECl'.
Control data is output from the microcomputor using the following
statenents: fOKE P ,X, where P= the address location used as the output
and X= the binary number to be output. If the microc:omputer utilizes a
port address rather that a memory address, the correct statement is:
our P,X.
INl'ERFACING MIOKXx)MPUI'ERS FUR PROCESS (l)NrROL
Remember, to turn on:
ALL eight ( 8) bits ON
ALL eight ( 8) bi ts OFF
00
01
02
03
04
05
06
07
output
output
output
output
output
output
output
output
output
output
1
2
4
8
16
32
64
128
255
o
Finkel, A., Harris, N., Higginl::ottcrn, P., & Tcm:::zyk. VIC-20
22
PRCX;RAMMER 's REFEREN:E MANUEL. C<lrrOCldore Business Machines Inc &
Heward W. Sarns & Co., 1982.
TRS-80 MJOEL III TOCHNlCAL REFERENCE MANUEL. Radio Shack, Tandy
Corporation, Fort Worth, Texas, 1981.
Zaks, R., & Lesea, A. MICROPROCESSOR INl'ERFACING TOCHNIQUES.
Sybex Inc., Berkeley, Cali fornia

You might also like