4
IEEE TRANSACTIONS ON EDUCATION, VOL. E-29, NO. 1, FEBRUARY 1986 27 Short Notes Instructing Industrial Controls Using Ladder PLC's Today Diagrams on an IBM PC In many respects, the PLC has largely remained a sequential controller; however, it has not been used solely to replace relay ROBERT P. PICARD AND GORDON J. SAVAGE panels. Today, the PLC can perform many tasks originally reserved for the computer. For example, some features that PLC's may have are: Abstract-Because of the increased use of programmable controllers in industry, educational institutes should teach the basic principles of 1) high scan speeds, these types of industrial computers. However, the cost of procuring 2) four-function math, hardware for laboratories is usually prohibitive. This paper describes 3) data highways that link mainframes, the simulation of a programmable controller on an IBM PC. Special 4) color graphics displays, software allows the control logic to be described to the computer using 5) servo motor control, and ladder diagram logic. An overview of the software architecture is given 6) robot control features. and use of the simulator in a laboratory environment using real I/O is It is anticipated that PLC's will continue to mature for at least described. two to five years. By this time, language standards may be universal across manufacturers. At present PLC programming is beginning I. INTRODUCTION to cater to a new generation of engineers and technicians that have microcomputer experience, and other programming languages be- The increased use of programmable logic controllers (PLC's) ln sides ladder diagrams are emerging. For example, PLC's such as industry has,beenaccompanied by a serious problem that should be the Maxitron and Gem8O from General Electric can be pro- rectified; that is, engineers are graduating from universities with grammed in Basic, assembly language, and Boolean symbology. The little or no exposure to either PLC's or the concepts that justify Maxitron has taken this concept to the limit and can be pro- their use. grammed in five languages at once. These include Ladder Dia- Engineers today must have at their disposal a wide array of gen- gram, Flow Chart, Boolean, "C," and Basic. eral knowledge that complements their speciality. This fact is es- pecially borne out in the midst of a computer revolution where no III. How PLC's WORK one computer or program is the issue. Rather, the application should From their inception in the late 1960's, the PLC has not changed determine which solution is appropriate. appreciably, and the main components are the CPU, the modular I/ The Department of Systems Design Engineering is presenting to 0 subsystem, and the programming panel as shown in Fig. 1. The their students various methods of interfacing computers to real CPU is responsible for solving the ladder logic and for performing world applications. One of these is the introduction and use of timing, counting, arithmetic, and a variety of special functions such PLC's. To use existing lab facilities to their fullest, a PLC simu- as PID control and other advanced tasks. All this is accomplished lator has been configured around an IBM PC. The simulator is pro- by a scanning technique embedded in the firmware of the PLC. The grammed using LDL language (in a form borrowed from several status of inputs is read continuously and the accumulated infor- manufacturers) and has real input-output through a parallel port. mation is used to solve any internal logic. The outputs are updated based on the results of the logic of the user's ladder program. II. HISTORY OF PROGRAMMABLE CONTROLLERS The I/O subsystem of the PLC is one of its main features. PLC's Since their introduction in 1969, PLC's have steadily gained in are designed to interact directly with industrial equipment and to popularity in industry. They were originally devised as relay repla- be installed directly on the shop floor. Thus, the I/O subsystem cers, and the first PLC's released by Modicon were computers con- must be highly immune to electrical noise and be capable of han- figured for special tasks. The I/O subsystem was accessible by the dling a wide range of signals. The I/O subsystem is usually grouped user through software, and the programming language chosen at in modules that can be tailored for a particular sensor or effector. that time was an adoption of the popular relay ladder logic devel- The plug-in I/O modules can accommodate a wide range of appli- oped in Germany. (This language is easily read by engineers and cations as is indicated by the array of signals given below: electricians in any country, and indeed, the literacy rate of the lan- 1) ac/dc inputs and outputs with voltages in the range 5-220 V, guage is one of the major-driving forces behind the success of the 2) TTL inputs and outputs, PLC.) At the outset, PLC's were slow and susceptible to industrial 3) thermocouple inputs, electrical noise, however, these shortcomings were eventually ironed 4) 4-20 mA output, and out and programmable controllers have become the mainstay of plant 5) RS-232 communication. operation. In the mid-1970's, the cost of relay logic panels increased and The programming of a PLC is usually done using LDL. As an PLC's were seen as an attractive alternative. Later, features such example of LDL, consider the relay JIC drawing in Fig. 2. This as reliability, ruggedness, and the fact that the logic was "soft- particular circuit is used sometimes to start and stop electric mo- wired" boosted the use of the PLC. As industrial awareness grew, tors. The two vertical lines labeled 1 and 2 are defined as rails and manufacturers started to add enhancements. are used to convey power. The horizontal lines are defined as rungs and are made up of JIC symbols that denote either field or internal devices. Manuscript received July 2, 1984; revised June 13, 1985. An equivalent LDL diagram to that in Fig. 2 is displayed in Fig. The authors are with the Department of Systems Design Engineering, 3. This schematic is typical of a PLC program and is usually what University of Waterloo, Waterloo, Ont., Canada N2L 3G1. is displayed on the CRT of the program panel. The similarities be- IEEE Log Number 8404699. tween Figs. 1 and 2 are readily apparent. The PLC solves the "soft- 0018-9359/86/0200-0027$01.00 ©O 1986 IEEE

Instructing Industrial Controls Using Ladder Diagrams on an IBM PC

Embed Size (px)

Citation preview

Page 1: Instructing Industrial Controls Using Ladder Diagrams on an IBM PC

IEEE TRANSACTIONS ON EDUCATION, VOL. E-29, NO. 1, FEBRUARY 1986 27

Short Notes

Instructing Industrial Controls Using Ladder PLC's TodayDiagrams on an IBM PC In many respects, the PLC has largely remained a sequential

controller; however, it has not been used solely to replace relayROBERT P. PICARD AND GORDON J. SAVAGE panels. Today, the PLC can perform many tasks originally reserved

for the computer. For example, some features that PLC's may haveare:

Abstract-Because of the increased use of programmable controllersin industry, educational institutes should teach the basic principles of 1) high scan speeds,these types of industrial computers. However, the cost of procuring 2) four-function math,hardware for laboratories is usually prohibitive. This paper describes 3) data highways that link mainframes,the simulation of a programmable controller on an IBM PC. Special 4) color graphics displays,software allows the control logic to be described to the computer using 5) servo motor control, andladder diagram logic. An overview of the software architecture is given 6) robot control features.and use of the simulator in a laboratory environment using real I/O is It is anticipated that PLC's will continue to mature for at leastdescribed. two to five years. By this time, language standards may be universal

across manufacturers. At present PLC programming is beginningI. INTRODUCTION to cater to a new generation of engineers and technicians that have

microcomputer experience, and other programming languages be-The increased use of programmable logic controllers (PLC's)ln sides ladder diagrams are emerging. For example, PLC's such as

industry has,beenaccompanied by a serious problem that should be the Maxitron and Gem8O from General Electric can be pro-rectified; that is, engineers are graduating from universities with grammed in Basic, assembly language, and Boolean symbology. Thelittle or no exposure to either PLC's or the concepts that justify Maxitron has taken this concept to the limit and can be pro-their use. grammed in five languages at once. These include Ladder Dia-

Engineers today must have at their disposal a wide array of gen- gram, Flow Chart, Boolean, "C," and Basic.eral knowledge that complements their speciality. This fact is es-pecially borne out in the midst of a computer revolution where no III. How PLC's WORKone computer or program is the issue. Rather, the application should From their inception in the late 1960's, the PLC has not changeddetermine which solution is appropriate. appreciably, and the main components are the CPU, the modular I/

The Department of Systems Design Engineering is presenting to 0 subsystem, and the programming panel as shown in Fig. 1. Thetheir students various methods of interfacing computers to real CPU is responsible for solving the ladder logic and for performingworld applications. One of these is the introduction and use of timing, counting, arithmetic, and a variety of special functions suchPLC's. To use existing lab facilities to their fullest, a PLC simu- as PID control and other advanced tasks. All this is accomplishedlator has been configured around an IBM PC. The simulator is pro- by a scanning technique embedded in the firmware of the PLC. Thegrammed using LDL language (in a form borrowed from several status of inputs is read continuously and the accumulated infor-manufacturers) and has real input-output through a parallel port. mation is used to solve any internal logic. The outputs are updated

based on the results of the logic of the user's ladder program.II. HISTORY OF PROGRAMMABLE CONTROLLERS The I/O subsystem of the PLC is one of its main features. PLC's

Since their introduction in 1969, PLC's have steadily gained in are designed to interact directly with industrial equipment and topopularity in industry. They were originally devised as relay repla- be installed directly on the shop floor. Thus, the I/O subsystemcers, and the first PLC's released by Modicon were computers con- must be highly immune to electrical noise and be capable of han-figured for special tasks. The I/O subsystem was accessible by the dling a wide range of signals. The I/O subsystem is usually groupeduser through software, and the programming language chosen at in modules that can be tailored for a particular sensor or effector.that time was an adoption of the popular relay ladder logic devel- The plug-in I/O modules can accommodate a wide range of appli-oped in Germany. (This language is easily read by engineers and cations as is indicated by the array of signals given below:electricians in any country, and indeed, the literacy rate of the lan- 1) ac/dc inputs and outputs with voltages in the range 5-220 V,guage is one of the major-driving forces behind the success of the 2) TTL inputs and outputs,PLC.) At the outset, PLC's were slow and susceptible to industrial 3) thermocouple inputs,electrical noise, however, these shortcomings were eventually ironed 4) 4-20 mA output, andout and programmable controllers have become the mainstay of plant 5) RS-232 communication.operation.

In the mid-1970's, the cost of relay logic panels increased and The programming of a PLC is usually done using LDL. As anPLC's were seen as an attractive alternative. Later, features such example of LDL, consider the relay JIC drawing in Fig. 2. Thisas reliability, ruggedness, and the fact that the logic was "soft- particular circuit is used sometimes to start and stop electric mo-wired" boosted the use of the PLC. As industrial awareness grew, tors. The two vertical lines labeled 1 and 2 are defined as rails andmanufacturers started to add enhancements. are used to convey power. The horizontal lines are defined as rungs

and are made up of JIC symbols that denote either field or internaldevices.

Manuscript received July 2, 1984; revised June 13, 1985. An equivalent LDL diagram to that in Fig. 2 is displayed in Fig.The authors are with the Department of Systems Design Engineering, 3. This schematic is typical of a PLC program and is usually what

University of Waterloo, Waterloo, Ont., Canada N2L 3G1. is displayed on the CRT of the program panel. The similarities be-IEEE Log Number 8404699. tween Figs. 1 and 2 are readily apparent. The PLC solves the "soft-

0018-9359/86/0200-0027$01.00 ©O 1986 IEEE

Page 2: Instructing Industrial Controls Using Ladder Diagrams on an IBM PC

28 IEEE TRANSACTIONS ON EDUCATION, VOL. E-29, NO. 1, FEBRUARY 1986

DotoPROGRAMMER Toble Timer/ Counter Toble

Logic ACCeLislP r L ogiA

2 ~2-3 ~3-

4 ~4-5 ~5-

Linked List Program TableEdit Downn p Prim D.T Addr Attr Row Col

Pointer 2 - _ __ _ -

OU PUT

N PU T 3|_|_

Fig. 1. Block diagram of programmable logic controller. Pointer 5i46 -_

I- Ft =2 F-I 1- *.1/-.. EIi IJLPrimitive Subroutines

Fig. 4. Block diagram of simulator software.

prise up to eight branches and the number of rungs allowed dependsFig. 2. Typical JIC (Joint Industrial Council) electrical drawing with the on the available computer memory. In run mode, the simulator

control relay labeled CR1. "solves" the ladder logic in much the same way as an industrial

PLC, and demonstrates the results.

Software ArchitectureThe simulator software consists mainly of two modules- the ed-

itor module and the run module, and is written mostly in compiled03 Basic. All display routines are written in assembler and accessed

via Basic, making screen alterations quick and sophisticated. Thebulk of the code is dedicated to the "full-screen" editor, and, aswith industrial PLC's, it allows the user to interactively develop aladder program. The editor utilizes the function keys on the PC to

Fig. 3. PLC screen display of Fig. 2. II and I2 represent inputs and 03 insert primitives, to form branches on rungs, and to complete rungs.represents an output. The cursor keys are used to move from primitive to primitive in the

ladder program when editing. Once the program is written, the pro-ware circuit" to give the same results as the hard-wired circuit in gram can be run and the results observed using the real I/O capa-Fig. 2. In addition to controlling and monitoring field devices, the bilities of the simulator. The "run" software is designed so that thePLC displays on its CRT all TRUE conditions in a rung and typi- ladder program is executed sequentially, similar to an industrialcally this is done by highlighting the corresponding JIC symbol. PLC. A "save" feature allows the user to save a ladder program on

a diskette and then to recall it at a later time.IV. THE PLC SIMULATOR The simulator software uses three tables: a program table, a data

The simulator described herein simulates the basic operations of table, a timer/counter table, and a linked list as shown in Fig. 4.a PLC using an IBM PC. The programmer module, the power sup- Briefly, the program table stores the LDL program, the linked listply, and the memory for the PLC are those of the IBM PC. The contains the order that primitives are executed, the data table con-inputs and outputs are configured using a Techmar Labmaster ex- tains logic variables, and the timer/counter table contains times,pansion card plugged into one of the PC's peripheral slots. There counts, and logical values. The tables and the linked list are dis-are eight real inputs and eight real outputs that let the user control cussed next in more detail.a variety of devices such as small motors, lights, etc. from a variety The program table stores the LDL program, and its structure andof inputs such as switches. However, the simulator is intended for typical contents are shown in Table I. Each complete row corre-operation in the laboratory only and not on the shop floor. sponds to a primitve and many rows are required to form an entire

The LDL LagaeLDL program. The program table has six columns and these areLanguage ~~~~~~~~~~~discussed in order. The column labeled "#" stores a number that isSpecial software permits rungs to be interactively developed on used as a pointer in a doubly linked list. The list is formed as the

the CRT in LDL language. The language that has been imple- ladder logic is entered and indicates to the program-counter whichmented accommodates the most common PLC symbols (called primitive is to be executed next. The list is also linked using a"primitives"). These primitives are, the EXAMINE ON, the EXAMINE backward reference scheme that is used when editing. The "Prim-OFF, the COUNT UP, the TIMER, and the OUTPUT. Rungs may com- itive" column contains the numerical code for each primitive in the

Page 3: Instructing Industrial Controls Using Ladder Diagrams on an IBM PC

IEEE TRANSACTIONS ON EDUCATION, VOL. E-29, NO. 1, FEBRUARY 1986 29

TABLEI 11 2PROGRAM TABLE

# Primitive Data Table Attribute Row ColumnCode Address (R) (C) 12

0001 I I 1

2 -1/1- 0002 I 1 2

3 -+- 0 0 2 1 Fig. 5. LDL of a "three-way" switch.4 ( 0004 0 1 10

12 13

TIMER/COUNTER TABLE

# Accumulated Time (s) Preset Time (s) Logic(ACC) (PRE)

1 00010 00020 FALSE

2 00015 00015 TRUE 3 Tl PR 0S3 00000 00000 FALSE TON

3 TI

ladder program. (In Table 1, the primitive schematic is shown in M OTplace of the code.) For example, the codes for EXAMINE ON andEXAMINE OFF are "1" and "2, " respectively. These codes are used Fig. 6. LDL for motor starter. The "3" represents an internal variable.in "run" mode to identify the primitive. The third column-the"Data Table Address" column-contains an entry that points to thedata table: this table is discussed later. The "Attribute" column ceive a lecture on PLC's, a description of the LDL language, andgives the use of the primitive. Typical attributes are I for input, 0 a user's guide for the operation of the simulator-specifically thefor output, T for timer, C for counter and if no attribute is entered, editor.then 0 is entered to prevent a null entry. The last two columns-the Some introductory exercises are shown in Figs. 5 and 6. Fig. 5R and C columns-give respectively the row and column screen shows the LDL of a "three-way" switch system, whereby twocoordinates for a particular primitve. This information is used to switches at two different locations operate an output. A typical re-display the rungs on the CRT. alistic example is the hallway switches in a house. The Boolean

The data table is really a vector and each entry can be only TRUE expression for the LDL- in Fig. 5 isor FALSE. This table provides an internal logic map in which theladder program and the I/O store both temporary and intermediate [Il . 12] + [11 . 12] = 03.results. Part of the data table is reserved for real I/O and the re- The second example represents a motor starter with separate startmainder is used for storing internal variables. and stop buttons (labeled 12 and I3, respectively). The ladder "cir-

The third table is the timer/counter table and its structure and cuit" also features a timer (TI) that turns the motor off after 5 s oftypical contents are shown in Table II. This table is used to hold operation. The Boolean equations for this circuit cannot be writtenboth accumulated and preset values of the counters and timers. The directly, and a state table must be used to analyze the operation oftwo associated primitives work as follows; when the variable ACC the circuit. This particular example demonstrates to the studentsreaches the parameter PR, then the logic of the primitive becomes the ease with which LDL can be written and debugged without stateTRUE. This logic is automatically entered into the table and may be tables. This is so because the simulator highlights all logical trueused by primitives in other rungs. primitives on the CRT.

Fig. 4 shows the connectivity between the linked list and the Student response to the simulator has been favorable. An esti-three tables. As the LDL program is executed according to the mated 3 h is required to obtain a working knowledge of the simu-linked list, the primitive subroutines are entered in sequence and lator. The majority of this time is taken up in fully understandingthe appropriate logicals are stored in, or retrieved from, either the the meaning of each primitive. This is typical of graphical lan-data table or the timer/counter table. The linked list is traversed guages, since much information is contained in each symbol and acontinuously until the program is stopped. familiarization period is necessary before the symbols are taken for

granted. Beyond this learning curve, the students can concentrateHardware Architecture on designing the appropriate logic using the available primitives.

The simulator comprises in part an IBM PC that must have thefollowing characteristics: VI. FUTURE ENHANCEMENTS

1) at least 128 kbits of RAM, At present, the simulator represents only a subset of the capa-2) one single sided floppy disk drive and bilities of most industrial PLC's. The goal now is to incorporate2) onecsigl siddafop dria. into the simulator as many primitives as is necessary to emulate the

majority of commercial PLC's. This goal should be straightforwardThe simulator software is designed to operate with either a mon- because of the flexible software architecture.

ochrome or color monitor and to access both the B and C parallel Some further improvements remain for the "editor." This isports of the Techmar board. Specifically, the B port is configured partly due to the complexity of displaying a graphical language onas outputs and the C port as inputs. Any unused I/O lines are tied a CRT and partly due to the need to modify the LDL. That is, afterto logical low to prevent erroneous conditions on the Techmar board. edits to the ladder logic have been made, the screen must reflect the

modifications and the software architecture must contain a new in-RESULTS ternal representation of the LDL. Both of these actions fall under

The simulator is used in a third-year laboratory coarse in Analog a different set of rules and are typical of the usual problem in im-and Digital Control. Prior to laboratory exercises, the students re- plementing any graphical language.

Page 4: Instructing Industrial Controls Using Ladder Diagrams on an IBM PC

30 IEEE TRANSACTIONS ON EDUCATION, VOL. E-29, NO. 1, FEBRUARY 1986

At present, execution speed and editing speed are not a problem. 30cmThe compiled Basic software scans the I/O at approximately four !___________times per second, and edit actions occur within a fraction of a sec- c K Iond. Should faster scan rates be required in the future, assemblylanguage subroutines would be incorporated into the scan sectionof the software. Some thought has been given to rewriting the sim- B R Bulator software in the "C" language to provide overall programefficiency. 0 cm

0 4 cm

REFERENCESD

[1] R. E. Morley and A. H. Libbey, "The PC from A to Z," AssemblyEng., May 1982.

[2] R. P. Picard, "Development of an industrial process control simula- ator," Dep. Syst. Design Eng., Univ. Waterloo, Waterloo, Ont., Canada, a 0.8cmWorkshop Rep. SD362, Apr. 1983.

[3] , "Instructing industrial controls using ladder diagrams on an IBM S /H VoKtmeterPC," Dep. Syst. Design Eng., Univ. Waterloo, Waterloo, Ont., Can-ada, Workshop Rep. SD462, Apr. 1984.

[4] J. Scrimgeour, "Industrial computing and automatic control: A per- E - 1spective, past, present and future," in Proc. 1982 CICS Conf., J. D. S s SWright, Ed., Hamilton, Ont., Canada, May 3-5, 1982.

Fig. 1. Apparatus schematic.

A Novel Apparatus to Study Faraday's Laws of 2

Electromagnetic InductionlQ Coil ( 1000 Tu rn s )

ANWAR A. KHAN R

_ _ r r b ~~C2 JSD

Abstract-A simple and inexpensive apparatus to study Faraday's laws N OTEE: 1 1of electromagnetic induction is described. The method of measurement A, A2,A; =>)UA741is straightforward, illustrative, and does not require the use of expen- Power Supply to op amps =>+ 12 V

sive instruments. Diodes = 1N34Cl =>'10,u F/25VC2 => 10OO,uF/50V

I. INTRODUCTION R, = > 1 K QThis note describes an apparatus embodying a simple and direct R2 => 10 KQ2 linear Pot

approach to study Faraday's laws of electromagnetic induction. The Fig. 2. Circuit schematic of S/H voltmeter.method is straightforward, illustrative, and does not require the useof expensive instruments. (S/H) type voltmeter with low acquisition time and large hold on

11. APPARATUS DESCRIPTION time. The circuit schematic of such a voltmeter, as shown in Fig.2, comprises two positive peak detectors built around op amps Al

The apparatus as sketched in Fig. 1 comprises a doughnut shaped and A2 and a noninverting voltage amplifier using A3. The capacitorpermanent magnet M with a 0.5 cm central hole, through which a C, charges to the positive peak value of the EMF induced in the0.4 cm diameter brass rod R of length 120 cm passes. The magnet velocity pickup coil D because of low charging time constant. Theis polarized to have one polarity at its upper surface and the other capacitor C2 then picks up this voltage and gives a stationary displayat its lower surface. The rod R is held vertical with the help of two in the voltmeter connected at the output of A3. A two-pole ON/OFFclamping aluminum rods BB and two supporting frames C and E. switch SW resets the circuit. Note that the detector A1 has low ac-The frame C is made up of aluminum and E is a massive wooden quisition time while A2 offers large hold on time.block with three leveling screws S, which are used for vertical align- The apparatus is required to be adjusted for maximum sensitiv-ment of the rod R. A 0.8 cm width velocity pickup coil D, having ity. To do this, coil D is held at about 20 cm above the base E andabout 1000 turns of fine wire wound over a wooden -cylinder frame the charges on C1 and C2 are cleared. The magnet is then releasedwith a 3.0 cm diameter central hole, is clamped with the rod BB from a height of about 100 cm above D and the corresponding out-such that the magnet M with 2.6 cm outer diameter freely passes put voltage is observed. This voltage corresponds to the peak valuethrough the coil. The height of the coil D from the base E can be of induced EMF in D, if the acquisition time of the S/H voltmeteradjusted. The magnet rests on the foam pad F attached to the base is small compared to the rise time of the induced EMF. However,of the rod R. if this condition is not met in practice, the procedure is to be re-

The magnet, while passing through the coil D, induces an EMF peated several times until no appreciable change in output voltagewhose peak amplitude is measured with the help of a sample/hold is obtained. The gain of A3 is then adjusted by means of R2 to give

full scale deflection in the dc output voltmeter.

Manuscript received December 4, 1984; revised June 13, 1985. III. PRINCIPLE OF OPERATIONThe author was with the University of Ranchi, Ranchi 834008, India.

He is now with the Department of Electrical Engineering, College of En- Suppose the magnet is released from a height h above the coilgineering, Kind Saud University, Riyadh 11421, Saudi Arabia. D. The magnitude of the velocity v of the magnet as it leaves the

IEEE Log Number 8405308. coil D may be computed from

0018-9359/86/0200-0030$01.00 ©B 1986 IEEE