Академический Документы
Профессиональный Документы
Культура Документы
No part of this book may be reproduced, in any form or by any means, without permission in writing from the publisher.
Notice to the reader The author does not warrant or guarantee any of the products described herein. Also, the author does not warrant or guarantee any of the equipment or programs described herein or accept liability for any damages resulting from their use. The reader is warned that electricity and the construction of electrical equipment are dangerous. It is the responsibility of the reader to use common sense and safe electrical and mechanical practices. MicroLogix, RSLinx, RSLogix, and SLC 500 are trademarks of Allen-Bradley a division of Rockwell Automation.
rogrammable logic controllers are actually a type of industrial computer that was introduced in industry around 1970. The main reason to build and use a programmable logic controller (PLC) was to Substitute very costly and bulky hardwired electromechanical devices (such as timers, relays, sequencers ) and complicated wiring circuits with a machine which could take less space to set up, and be flexible enough to change the original circuit design and add future expansions. Nowadays, the machinery control of many manufacturing companies are done by PLCs. Industries such as packaging, assembling lines, stocking of goods, welding etc are only a few examples to mention. Systems designed using PLCs, are inexpensive and need less space to set up and are very easy to program. A PLC is only an industrial computer that is designed to do mostly controlling tasks rather than running some office application program such as Microsoft Word. Therefore, to program a PLC, one needs some type of especial software. Using any programming language, one needs to know all the instructions that software recognizes to write his program with. Therefore, the purpose of this book is to show how these instructions can be implemented in a software system control program that the software developer has in mind. Many companies have developed software for programming PLCs. For purposes of illustrating and practicing how the software works, I have selected RSLogix 500 software created by ROCKWELL SOFTWARE for programming Micrologix 1500 family of programmable controllers. The software is Windows based and very user friendly. Using software to simulate small programs makes the learning process very interesting and fun!!. I have also included many program exercises in the CD which comes with this manual and therefore, you may load each exercise and run it provided you already had installed RSLogix 500 in your PC. We developer of this educational manual, see our responsibilities in helping the reader to achieve self-confidence. One thing which builds self-confidence is a successful and deep understanding of each lesson explained clearly in the manual. Also, at PLC-DOC we believe our most precious sense is mind-sight the capacity to envision our life in its most satisfying form. Mind-sight is an attitude and a plan of action; it is a dream and the ability to make that dream come true. Hence, anywhere in this manual that we had an unused white page, we used it to mention some emotional support to help you to discover and to put to effective use this powerful sixth sense we all possess. This emotional support is consisted of some wise proverbs, quotes, comments, statements, and short stories from greet thinkers of times. We hope you to like them and thanks for your support and concern!
Preface
-3-
Table of Contents
Chapter 1
Developing our first User Program ..09 SLC 500 and Mircrologix 1000 and 15oo addressing 21 PLCs RUN, REM, and PROG mode ..21 Pictorial view of Allen Bradley Micrologix 1500 ... 25 Inserting Branch Start symbol ..26 CSF and STL format of programming .32
Chapter 2 .39
Ladder Diagrams ..41 Ladder Logic .43 A simple Ladder Logic program ...46 Ladder format of programming 47 Processor Operating Cycle ... 48 Processor Unit .. 49 Operating System Memory (user and storage memory) ...54
Allen Bradley SLC 500 and MicroLogix Counters . 110 UP-Counter (CTU) Instructions format and timing chart ....... 115 Counter Programming Examples 121
Chapter 9 Sequencers.................................................................140
AB PLC-5, SLC 500 & MicroLogix Sequencer Instruction .142 Developing A Sequencer Ladder Program ...144 Definition of SQO Parameters 145 Definition of SQL Parameters ......................................................................147 Definition of SQC Parameters .....................................................................151 Sequencer Programming Examples..............................................................155
APPENDIX A - RSLogix 5/500 & RSLinx Overview..184 APPENDIX B - Binary System & Arithmetic..194 APPENDIX C Pictorial view of MicroLogix 1000 ................... 210
Chapter
1
Running RSLogix 500 to Edit a Ladder Logic Program
Two friends were walking in the desert. During some point of the journey, they had an argument; and one friend slapped the other one in the face. The one who got slapped was hurt, but without saying anything wrote in the sand:
Learn to write your hurts in the sand and to carve your benefits in stone.
Figure 1-9 Note that below 5/05 listing, the are listings for MicroLogix 1500 and 1000 processors series. In the listing, find MicroLogix 1500 the same series you have and click on it. Figure 1-10 shows the listing for our processor.
10
Figure 1-10 Click on OK icon on top right hand side and accept the processor type.
Figure 1-11 RSLogix 500 now knows the MircoLogix 1500 processor is going to be used and will do all the necessary settings and install the drivers needed to process user programs. In figure 1-11, the left side of the screen shows Project Tree while the right side of the screen is called Programming Area where we can develop or edit any user program. In the project tree area, the main folders are Help, Controller, Program Files, Data Files, Force files, Custom Data Monitors, Custom Graphical Monitors,
(c) Copyright PLC-DOC.COM 2004
11
Recipe Monitors and finally Database. Double Clicking on the Controller Folder, opens up the Controller Properties screen shown in figure 1-12
Figure 1-12 Clicking on Compiler, Passwords, or Controller Communications will reveal more information about our processor type or drivers will be used for establishing serial communication between PLC and the PC. Clicking on I/O Configuration symbol, produces screen shown on figure 1-13
Figure 1-13
(c) Copyright PLC-DOC.COM 2004
12
Figure 1-13 shows the Input / Output modules that can be used to configure our PLC system. As it was stated, in this book, we have not added any external I/O modules to our base system and we are using it as a compact form. But figure 1-13 displays all different I/O modules that can be added to the PLC system rack to extend number of I/O terminals. In our case, MicroLogix processor is installed in a 0 slot chassis. And figure 1-13 proves and confirms it. The processor will always be installed in slot 0 whenever using the system with our without and added I/O modules. Software has the ability to indicate the minimum output current capacity of the power supply should be used by the existing. Since in our case, the PLC is being set up and used in its compact form, hence there is no need to select any power supply module. Close I/O Properties screen and under the Data Files folder, double click on Q0 Output and I1- Input files to determine the status of I / O files. See figure 1-14
Figure 1-14 When the processor is ON LINE MODE, the actual status of input and Output devices will be reflected in part of PLCs internal memory. That means any time the input device is activated, the related bit will be set to 1 or High. And any time the input device is in NOT activated, the related bit in the memory will be set to 0 or Low. Since these memory bits are some how linked to files such as Input or Output files, hence in this case the programmer can always check to see if the program is running properly. Visualizing these files can be very handy in instances that programmer is debugging the user program. To check if the flow of program is according to the activations of inputs or output devices.
(c) Copyright PLC-DOC.COM 2004
13
In figure 1-14 notice that status bits I 0 and Q 0 are both set to 0 because non of any input or output devices is activated. Figure 1-15 shows the status bit I0 is set after activation of the input device. Note that after activation of I0, O0 also is set to 1 or HIGH (status bit O0 is set).
Figure 1-15 The Data File folder allows the user to determine the status of I/O files, as well as the status of some other files such as S2 (status file), B3 (binary file), T4 (timer file), C5 (counter file), R6 (control file), N7 (integer), and F8 (floating point) file. Again this brief discussion of the program tree and the information that can be obtained is intended to show the power of the RSLogix software and is not a complete guide to the software. By closing the output data table screen and maximizing the programming side of the display, the screen now looks like figure 1-16 Now, lets assume we would like to have a Ladder Logic diagram consisting of two simple elements. This simple circuit consists of one input open contactor, and one output core (such as a light bulb). In generating a ladder logic diagram, we use symbols to represent field input or output devices.
14
Figure 1- 16 shows the editor window In writing a program in Basic language, we use commands such as IF, GOTO, RUN and such to develop our program. Basic Language Compiler recognizes all these commands and therefore, compiles the user program and if nothing wring is going in the program, the Basic Language Compiler, RUNS it. .In our case, our compiler is a Graphical Language Compiler and it requires us to write our program using symbols. In figure 1-17, you notice on the top tool bar, there are symbols that can be used to develop a user program. Figure 1-17, illustrates the snap shot of the symbols in tool bar menu.
Figure 1-17 illustrates the tool bar menu To place an open contactor (also called Examine On) in the first rung, simply place your mouse pointer on the symbol and click on it. An open contactor will be inserted where the RSLogix prompt is. By doing so, an open contactor will be inserted on the upper left-hand side of the programming screen where four zeros inside the box. The four zeros indicate rung 0000. To start to develop a program, you can also click on New Rung button symbol at the tool bar to create new rungs such as rungs 0000, 0001, 0002 and so forth. New Rung button is the first symbol (from left to right) in the tool bar
(c) Copyright PLC-DOC.COM 2004
15
(shown with arrow in Figure 1-17). Any time you need to insert any symbol in the any rung, move the prompt to that rung and click on any symbol you need. The desired symbol will be inserted in that location. To get ride of any symbol, place the prompt on the symbol and hit Delete Key on the computer keyboard. Figure 1-18 shows that our program is consisted of two rungs and one open contactor as an input device.
Figure 1-18 illustrates the open contactor symbol is placed on the first rung Notice that the few es on the left side the rung 0000 means the rung is being edited. Our circuit supposed to have an output device. To place it, simply go back to tool bar and click on the coil symbol (the fifth symbol from left to right). Figure 1-19 shows the coil element inserted in the first rung. We know that I/O elements connected to a PLC are called Devices that have to be connected to somewhere on the PLCs input / output terminal panel. .This somewhere on a PLCs panel has a name and it is called a Port Terminals So every PLC has some Port terminals that a tech connects the input or output devices to those terminals. In our case, we have two devices, an input switch and a 110 VAC light bulb. Hence, we connect one wire of the input device to input port terminal I:0/0 and the wire to L1 (or HOT). On the other hand, one wire of light bulb connects to output port terminal O: 0/0 and the other wire to L2 (Neutral). You may choose different input terminals to connect your I/O devices such as I 0:/5 or O 0:/8 instead, that is up to you.
16
Figure 1-19 shows the placement of output element in the first rung The PLC does not mind as long as you use correct port terminal assignments in your software to specify which terminal you are using on the PLC under test . Micrologix 1500 Model 1764 24AWA, has 12 AC inputs and 12 relay outputs.
Input terminals are numbered as: I 0, I 1, I 2, I 3, I 4, I 5, I 6, I 7, I 8, I 9, I 10 and I 11 Output terminals are numbered as: O 0,O 1,O 2,O 3,O 4,O 5,O 6,O 7,O 8, O 9, O 10 and O 11
In our case, our input and output devices are tied to I 0:/0 and O 0:/0 accordingly. To assign the port number, click on the device, you see a blank rectangular box appears to the top of the device with a nice looking ? in it (see figure 1-20). We know that the device is an input device. So go a head and type i for input (see figure 1-21). Software is asking you to assign the port number. As soon as you type letter I, the next help appears below the previous box and gives you the clue about port address format. See figure 1-21.We are using address I:0.0/0, go ahead type the address and hit the enter key. As soon as you hit the ENTER KEY, description box appears under the input device asking you to place a label. We go ahead and type input port as a description for the device and click on OK icon, see figure 1-25.
17
Figure 1-20
Figure 1-21 Take the same steps to label the output device and for address type O:0.0/0
18
Figure 1-22
Figure 1-23 Figure 1-25 illustrates the label placed on the upper side of the input device (input port).
19
Figure 1-24 placing label on the upper side of the input device
20
So the format of a typical address would be From left to right each character in the typical address has a special meaning when it comes to the software compiler.
O: 0.0/1
O : 0 . 0 /
indicates the address is for an output device. is called colon and it separates the output designator O, from the rest of the address. is the slot number which holds the actual output (or input) module. The slot number can range from slot 0, adjacent to the power supply to a maximum Number of 30 is called word delimiter and used after the slot number (in our case, slot # is 0). indicates that the output device is connected to slot 0. Hence if we place another module next to the main unit, the device number is going to equal to 1 is called forward slash which is considered as the bit number of the word or the terminal number of the I/O module. For example, in Micrologix 1500, we have 12 I input and 12 output terminals. Hence, in our case, 1 means terminal O 1 which is the one next to terminal O 0.
In figure 1-11, notice that our input device is connected to I:0.0/1 which means terminal number 1 of input terminals on slot 0. Output device has the address O:0.0/0 which means terminal number 0 of output terminals on slot 0. Also, on the left side of the first rung, there are bunch of e (actually seven of them) that is not anything important to be worry about. The software editor thinks something incorrect does exist in the created program. At the compiling time, those e disappear! Ok, at this stage, editing process of the new program is done. Assuming that is a correct program, we wish to test it by running it. Usually to run a program, you must first load the program into the PLCs memory and then issue the RUN command. To down load the program into the PLCs memory, we must first do two things: 1- Connect PLCs communication port to PCs port. To do so, we must use a cable which has two sockets in its two ends. One end connects to PCs serial port (9 pin male socket) and the other socket which is a circular one, connects onto the PLCs serial port (located on the bottom left side of the PLC). 2- Push slide type switch to PROG option. These options are: RUN REM PROG.
(c) Copyright PLC-DOC.COM 2004
21
Hence, when you push the slide, slide switch to PROG option, PLC gets ready to accept the incoming program which is in the form of some electrical signals. Having taken these two last steps, to issue RUN command, on the top left, click on OFFLINE arrow, and choose Go Online option. In a second or so, program will be complied, and loaded into the PLCs memory and figure 1-26 appears on the screen. After the user program being compiled, text Bul. 1764 also will appear under both input and output devices.
Figure 1-26 In figure 1-26, notice that on top left, mode of last operation is shown as: PROGRAM MODE Notice that the ladder symbol is revolving and this means the downloading of program is complete meaning we can RUN the user program now. To command the PLC to start running the program, push the slide switch from right to left to choose RUN option. As soon as this is done, figure 1-26 changes into figure 1-27.
22
Figure 1-27 illustrates software in RUN MODE To make sure if the program is really working correctly, we may activate the input device now. As soon as the input device is activated, PLC energize the output device and we notice that the bulb turns ON. To express this statement in a clearer way, we may say any time we turn ON the Garage switch, (the light bulb is on. In our case), the open contactor symbol in the ladder logic program represents the switch and the light bulb the output symbol. Base on the same logic, if we activate the input, (turn on the switch), the output will be activated. Since physically, in our test circuit, the input port is connected to a hammer switch, to activate, we just need to push it from OFF position to ON position. By doing so, we notice that as soon as the switch is turned on, figure 1-27 change into figure 1-28.
23
In figure 1-28, notice that as soon as the switch is turn on, the side bar of both input and output change into thick green bar. This is the way that RSLogix 500 demonstrates the activation of any input or outputs. No we switch the input into the OFF (position). We see the result on the program accordingly.
Activating the inputs and checking the result on outputs, is the best way to debug a ladder logic program. This is a very valuable feature developed on most PLC programming soft wares nowadays!!.
Figure 1-29 illustrates the physical look of MICROLOGIX 1500 in the lab hard wired Figure 1-29 illustrates different parts of the PLC via numbers from 1 to 7 as following:
Numerical Indicator 1 2 3 4 5 6 7
Description
input port terminals slide switch places PLC in any of RUN, REM or PROG mode output port terminals PLC serial port to be connected to PC to download programs or to establish any other communication between PLC and PC total of 4 modules connected to PLC to provide more input or output terminals AC INPUT indicators (12 LEDS each turns on any time the related input is activated) RELAY OUTPUTS indicators (12 LEDS each turns on any time the related output is activated)
24
Figure 1-30 illustrates the pictorial view of Allen Bradley MicroLogix 1500
Note:
Appendix C, displays how to hardware a MicroLogix 1000 model just in case you have such a hardware and want to use it to download and test your program with!!
(c) Copyright PLC-DOC.COM 2004
25
Figure 1-32 2- Click on BRANCH START symbol (the second symbol on the tool bar). See figure 1-33
Figure 1-33
26
3- Place the mouse pointer at the beginning of the branch box and bring back the
highlighted prompt to location shown in figure 1-34
Figure 1-34
Figure 1-35
27
Figure 1-36
6- Click on Examine ON symbol to palace an Normally Open contact to represent a Holding Contact M. See figure 1-37 7- Place label and port addresses on all input devices as seen on figure 1-38 8- Place the PLC switch on PROG mode, click on OFFLINE Download
Click on OK when Revision Note screen appears And click on Yes on Do You Want to go Online screen. Push back the slide switch back to RUN mode
28
Figure 1-37
Figure 1-38 Figure 1-39, shows the user program developed, is being RUN. Figure 1-40, shows the program when start push button is depressed momentarily.
29
Figure 1-39
Figure 1-40 In figure 1-41, notice that start switch is in its de-activated condition, but the output device connected to output terminal 0 is still on. Figure 1-42 shows the current path to contactor coil via Holding Contact M.
30
Figure 1-41
Figure 1-42 displays the actual current path to output coil In figure 1-12, notice that in Controller properties screen, the memory usage was 0 byte or none. The same screen after loading the last use program is shown in figure 1-43.
31
Notice now that our final program is loaded into the PLCs memory, the data shown on this screen are changed and it shows a Program Checksum of 825f. It also indicates the Number of Program Files, Data Files, used and un-used memory.
Figure 1-43 (CSF) (Control System Flowchart) format of programming CSF (control system flowchart) is a graphical language which uses the logical elements of the Boolean algebra for representing the operation logic. In this method of programming, the main program is prepared from different logical blocks. Figure 1-44 displays AND, OR and Output blocks.
Figure 1-44
32
A program written in STL, consist of different statements grouped to form a list of instructions. RSLogix 500 allows the programmer to develop programs using Mnemonic codes for instructions. As an example, lets assume we like to develop program in figure 1-38 using mnemonic codes, click on prompt assuming you are in editor screen. See figure 1-45 Double click on the prompt to get it changed into figure 1-46
Figure 1-45
33
Figure 1-47 At the end of typing the last instruction, hit the Enter key. Figure 1-47 will change into figure 1-48.
Figure 1-48 To verify to see if the program displayed in figure 1-48 is generated correctly, go to Edit Verify Project And click on Verify Project command. If there is not any error, in the format of the mnemonic instructions typed, user program developed will be compiled and figure 2-49
(c) Copyright PLC-DOC.COM 2004
34
Figure 1-49 Displayed. Meaning the user program is ready to be downloaded and RUN. Table 1-2 displays Commonly used mnemonic instructions.
No.
1 2 3 4 5 6 7 8
Instruction
Examine if close (Examine ON) Examine if open (Examine OFF) Output Energized Branch Start Branch End Next Branch Output Latch Output Unlatch
Mnemonic
XIC XIO OTE BST BND NXB OTL OUT
No.
9 10 11 12 13 14 15
Instruction
One Shot Rising
Mnemonic
OSR
Timer On Delay TON Timer Off Delay Retentive Timer Count Up Count Down Reset TOF RTO CTU CTD RES
B3 File
We mentioned already that The Data File folder allows the user to determine the status of I/O files, as well as the status of some other files such as S2 (status file), B3 (binary file), T4 (timer file), C5 (counter file), R6 (control file), N7 (integer), and F8 (floating point) file. The BIT instructions are an extension of the input and output operations of the PLC. The BIT or B3 operation allows a bit in a 16 bit file to be set or
(c) Copyright PLC-DOC.COM 2004
35
cleared. This file allows for the saving of conditions without involvement of the normal I/O terminals. The B3 or Bit file is listed in the menu at the left of your programming screen (figure1-51). By double clicking the B3 file the contents may be seen at any time. We edit program in figure 1-49 to a one shown in figure 1-50. Notice that we replaced O0 with B3:0.
Figure 1-50
Figure 1-51 Comparing figure 1-50 with figure 1-51, notice that when pushbutton I0 is depressed, B3/0 bit is set. And when I0 is not activated, B3/0 is clear or it is False. Checking B3 bits can be used as a very useful tool in debugging programs.
36
37
Only two things are infinite, The universe and human stupidity. And I am not so sure about the former.
ALBERT EINSTEIN
38
Chapter
2
Introduction to LADDER LOGIC Programming
39
Keeping interested in studying, keeps up your energy and make you able to learn more in a given period of time. And, the more you learn, the more easily you learn.
40
Ladder Diagrams
adder diagrams are specialized schematics commonly used to document industrial control logic systems. They are called ladder diagrams because they resemble a ladder, with two vertical rails (supply power) and as many as rungs (horizontal lines) as there are control circuits to represent. If we wanted to draw a simple ladder diagram showing a lamp that is controlled by a hand switch, it would look like this:
Figure 2.1 displays a simple ladder diagram without power supply shown The L1 and L2 designations refer to the two poles of a 120 VAC supply, unless otherwise noted, L1 is the hot conductor, and L2 is the ground (neutral) conductor. These designations have nothing to do with inductors, just to make things confusing. The actual transformer or generator supplying power to this circuit is omitted for simplicity. In reality, the circuit looks something like this:
Typically in industrial relay logic circuits, but not always, the operating voltage for the switch contacts and relay coils will be 120 volts AC. Lower voltage AC and even DC systems are sometimes built and documented according to Ladder diagrams. Ladder diagrams are used to describe the logic of electrical control systems. There are differences in the way ladder logic was implemented in computerized form as
(c) Copyright PLC-DOC.COM 2004
41
compared to hard wired. The basic component of the control system is the control relay which is a solenoid that operates a number of switches or contacts. The contact come normally open and normally closed, normal being when the relay is not energized. Relays come in various breeds like time delay and latching types. Other components of the control system are the field devices such as push buttons, limits switches, lights, and controlled devices like motor starters and solenoid operated valves. Therefore, Ladder diagrams show the logic of the controls but they are not used to build the system, a wiring diagram is used for that. But the wiring diagram would not be used to trouble shoot with or show functionality, thats where a ladder diagram is most useful.
Figure 2.3 shows a standard motor control circuit (Start /Stop Circuit)
Figure 2.4 displays the actual 3 phase motor circuit plus the controlling circuit
(c) Copyright PLC-DOC.COM 2004
42
Ladder Logic:
Ladder logic is the main programming method used for PLCs. Ladder logic has been developed to mimic relay logic. The decision to use the relay Logic diagrams was a strategic one. By selecting ladder logic as the main programming method, the amount of restraining needed to engineers and trades people was greatly reduced. The reason its called Ladder logic is the program is drawn pictorially and looks like a ladder, unlike a program listing you may be familiar with like Basic or C++ which use alpha numeric characters. Modern control systems still include relays, but these are rarely used for logic. A relay is a simple device that uses a magnetic field to control a switch, pictured in figure 2.5. When a voltage is applied to the input coil, the resulting current creates a magnetic field. The magnetic field pulls a metal switch towards it and the contacts touch, closing the switch. Relays are normally drawn in schematic form using a circle to represent the input coil. The output contacts are shown with two parallel lines. Normally open contacts are shown as two lines, and will be open (non-conducting) when the input is not energized. Normally closed contacts are shown with two lines with a diagonal line through them. When the input coil is not energized the normally closed contacts will be closed (conducting).
Figure 2.5: simple relay layouts and schematics Relays are used to let one power source close a switch for another (often high current) power source, while keeping them isolated. An example of a relay in a simple control application is shown in figure 2.6. In this system the first relay on the left is used as normally closed, and allow current to flow until a voltage is applied to the input A. the
(c) Copyright PLC-DOC.COM 2004
43
second relay is normally open and will not allow current to flow until a voltage is applied to the input B. if current is flowing through the first two relays then current will flow through the coil in the third relay, and close the switch for output C. this circuit would normally be drawn in the ladder logic form. This can be read logically as C will be on if A is off and B is on.
Figure 2.6: a simple Relay Controller The example in figure 2.6 does not show the entire control system, but only the logic. When we consider a PLC there are inputs, outputs and the logic. Figure 2.7 shows a more complete representation of the PLC. Here there are two inputs from push buttons. We can imagine the inputs as activating 24V DC relay coils in the PLC. This in turn drives an output relay that switches 115V AC, that will turn on a light. Note, in actual PLCs inputs are never relays, but outputs are often relays.
44
The ladder logic in the PLC is actually a computer program that the user can enter and change.
Notice that both of the input push buttons are normally open, but the ladder logic inside the PLC has one normally open contact, and one normally closed contact. Do not think that the ladder logic in the PLC needs to match the inputs or outputs. Many beginners will get caught trying to make the ladder logic match the input types. Many relays also have multiple outputs (Throws) and this allows an output relay to also be an input simultaneously. The circuit shown in figure 2.8 is an example of this, it is called a seal in circuit. In this circuit the current can flow through either branch of the circuit, through the contacts labeled A or B. The input B will only be on when the output B is on. If B is off, and A is energized, then B will turn on. If B turns on then the input B will turn on, and keep output B on even if input A goes off. After B is turned on the output B will not turn off.
45
46
output coil
Figure 2.10 You as a programmer should tell the PLC what to do if the switch is inactive or if it is depressed. Programming examples designed in chapter 3 will give you a better understanding of how to develop simple programs to do simple tasks.
47
Figure 2-11
48
Processor Unit
The processor unit houses the microprocessor, memory modules(s), operating software, and necessary electronic circuitry to perform all the control functions. The major difference between a PLC and a regular PC lies in the programming language used and the industrial ruggedness of a PLCs design. A PLC is a special purpose computer utilizing a unique programming language. However, it has also been described as being designed for a harsh industrial environment. PLCs operate without special climate controls in applications as severe as 140F and at humidity levels reaching 95 percent. They generally do no t require special installation considerations above standard good electrical practices found in most industrial applications. Most important, they are designed to withstand moderately rough handling. The PLC affords these major advantages over a PC by its basic architecture. Each component of a PLC system is independently designed for optimum performance under the worst industrial conditions. In this manual, I will not go to detail description of a PLCs hardware. I explain a PLCs hardware in short since it is always good to have a basic idea what is under the hood which causes anything to function. All hardware associated with a PLC falls into one of two functional areas. The actual intelligence of the PLC is derived from electronic computer-based hardware, which comprises the processor, or CPU, portion of the system as represented in figure 212. The processor section of a PLC includes a power supply, a microprocessor or specialpurpose electronic circuitry, as well as a computer-type memory for the storage of programming instructions and system data. All activity of the PLC system is handled by the processor. The processor is responsible for the analysis of incoming as well as previously stored data, and for responding to that information according to a detailed control plan stored within the unit by the user. Most PLC systems offer the standard relay, latch, timing, counting, and simple mathematical functions of addition, subtraction, multiplication, and division as part of their capabilities.
Figure 2-12
(c) Copyright PLC-DOC.COM 2004
49
From figure 2-12 notice that a typical PLC can be divided into four sections:
1-Programming Device 2-Processor Unit (CPU) + Memory Unit 3-Power Supply 3-Input/Output Sections
Programming device is a device used to insert, monitor, edit or troubleshoot the PLC user program or to check the condition of the processor . Programming devices may come in different forms and shapes. Hand-held, dedicated desktop, and personal computer are among the most important types in use today. In this manual, we will use a regular PC as a programming device to edit user programs and such. Processor Unit is the decision-maker section in any PLC system. Using a regular PC, one can use different compilers such as BASIC, C++, PASCAL and such to develop programs in these related languages. A PC computer can also been used to write user programs in Relay Ladder Logic languages. In this case, after the user program is developed and debugged and the programmer is happy with it, the program can be downloaded into a PLCs program memory. Then after the RUN command is issued by the operator, the processor unit in the PLC makes all the decisions necessary to carry out the user program, based on the status of the inputs and outputs for control of a machine or process: which replaces relays, counters, timers, sequencers, and so forth. Power Supply unit supplies the DC power for the CPU and for the I/O section. The voltage is typically +5 volts. The reason this level of voltage is that most Integrated Circuits (IC) such as memory, microprocessor and so forth are designed to function only with +5. And the printed circuit bard (PCB) inside of a PLC has many of these so called ICs. The power supply can be internal with the processor, rack mounted, or externally mounted as a separate unit. AS in the case of MicroLogix 1500, the power supply unit is inside of the PLC hosing. To install it, one only needs to connect related terminals on the PLCs panel to L1 and L2 power line. See figure 1-24 The input /output (I/O) system comprises the interface section of a PLCs architecture. In the majority of PLC systems, the I/O system will usually be the largest single component, with the exception of the process or mechanical hardware being controlled. The I/O structure is the interface between the users field I/O devices and the control logic programmed in the PLC memory. The input module receives signals from the users input devices through wired connections to terminals on the module itself. These signals from the field devices can be of many voltages levels and signal forms. Once received on the modules printed circuit board, they are passed to a conditioning block for the necessary level conversions and signal conditioning required by the processor. The electronics of the signal conversion block of an input module will greatly vary depending on the manufacturer, the system architecture, and the type and class of signal conversion required for the particular module in question.
50
The type of conversion can be classified as either singular or complex. The devices listed in table 1-1 are representative of field devices that are commonly connected to the input modules of a PLC. Any device listed as analog will usually require a complex conversion to be performed by the input module. Those devices listed as discrete generally require a single input point on an input module. Table 1-1 also displays the voltages usually these input devices typically work with. You must as an installer of any PLC related equipment s be very cautious not to impose any different voltage level than from the one the manufacturer of that module or product specifies in the data sheet. Singular or discrete conversion, as it is often called, pertains to one and only one input point per conversion circuit. Discrete input conversions are the simplest since they usually comprise signals of an ON/OFF nature. Complex input conversions, often called analog conversions, require the conversion and scaling of a continuously variable input signal of a continuously variable input signal. Instead of transmitting the ON/OFF status of the input device to the processor, as in the case of a simple conversion, an input module that performs a complex conversion will transmit the input devices status as data to the processor in the form of a group of binary signals.
Discrete
Limit switch Pushbutton Thumbwheel switch Pressure switch Photo cell Relay Contacts Selector switch Keyboard contacts Motor controllers
Analog
Pressure transducer Temperature transducer Load cell Flow sensor Vibration transducer Current transducer Voltage transducer Vacuum transducer Force transducer
AC TYPES
12 volt AC 24-48 volt AC 120 volt AC/DC 220/240 volt AC 120 volt AC isolated
Special TYPES
TTL source TTL sink 5-30 volt selectable 5 volt DC Encoder/Counter 12-24 volt DC Encoder/counter Thermocouple ASCII input Gray Encoder High speed pulse
DC TYPES
12-60 volt DC 12-24 volt DC fast response 24-48 volt DC 12-24 volt DC source Table 1-1
Analog TYPES
1 to 5 volt DC 0 to 10 volt DC -10 to +10 volt DC 4 to 20 mille amperes
51
AS the second type of I/O interface module, the output module is the PLC component that permits processor to communicate with its environment. The output module contains an interface/multiplex block similar in function to that of the input module to receive signals from the processor. These signals are periodic in transmission from the processor and therefore must be remembered in some form of memory or latch block, until the next processor update. The latch block continuously updates the isolation block, which provides full electrical and mechanical isolation between the processor signal and the field device power levels. The output module also contains a status block for monitoring the various operating and signal statuses, as well as terminals for the connection of the actual field output devices to the modules electronics. MicroLogix 1500 has 12 LED indicators to show the status of inputs and 12 LED indicators to display the status of output terminals. Therefore, any time the input or output is in LOW status, the related indicator is OFF otherwise it would be ON. Figure 2-13 displays typical connection of field input and output devices and its very simplified internal electronic circuitry.
Figure 2-13 Figure 2-14 displays typical field input and output devices that are used typically in the industry field.
52
Figure 2-14
Figure 2-15 displays some of I/O symbols used in relay logic circuits
53
Memory Unit
As you have noticed so far, for a programmable controller to function properly it must be able to run the user program repeatedly and accurately. In this respect, a PLC functions much the same as a PC the only big difference is the type of I/O data and configuration. Generally, a PC uses some type of an application program such as spread sheet, word processing, graphic design and so on to input some data and produce some type of output. A PC receives most of its data via keyboard and it generates the output result on either terminal monitor, sends it to printer or saves it on hard drive as a file. Since the processing speed of a PC is very high, it needs lots of memory to use as an intermediate storage area to store application program or input output data. When it comes to compare PC to a PLC, a PLC also uses some type of application program such as RSLogix 500 to process a user program. A PLC receives some input data from field input devices and it produces outputs according to the user program in use. PLC memory can be of various types. Some of the PLC memory is used to hold system memory and some is used to hold user memory. PLC memory consists of hundreds or thousands of locations that are referred to as words. Each word is capable of storing binary data in the form of binary digits. A binary digits can only be a 1 or 0. The number of bits that a word can store will depend on the PLC system. Words can be made up of 64 bits, 32, 18 or 8 bits. The 16-bit word is the most common.
User Memory
The memory of a PLC is broken into blocks that have specific functions. User Memory contains the ladder logic program or User Program which you as programmer develop it. User memory occupies the greater portion of total memory, often 75 percent or more. A PLC with 16 KB of memory will often devote 12 KB or more to the ladder logic program, leaving 4 KB or less of memory for Data Storage Figure 2-16 displays two broad Categories of Memory
54
Storage Memory
Storage Memory stores information needed to carry out the user program: the status of discrete input and output devices, the preset and accumulated values of counters and timers, numerical values, sequencer patterns, internal I/O relay equivalents, and so on. Taking a closer look at the memory map of figure 2-17, we see first that all addresses are given in decimal. Second, we note that each word in memory is 16 bits wide. Concentrating on storage memory, we find the first section, consisting of eight words, is the input image status area (addresses 72-79). It is here that the status of discrete, real world input is stored. The second section, also consisting of eight words, is the output status area (addresses 80-87). This is where binary data (0s or 1s) that will activate real world outputs are stored. Timer status, accumulated values and preset values, is stored in third section of the storage memory, using a total of 24 words, from address 88 to 111. Counter status, accumulated values and preset values, is stored in the forth section, also using total of 24 words. These words are located at addresses 112-135. The fifth section, numerical data, is used for number system conversion. In this section, eight 16-bit words have been reserved, from address 136-143. Other functions can be continued at the bottom of the map as needed. The additional memory size required depends on the total number of different functions included in the CPU.
Figure 2-16
55
Figure 2-17 As we mentioned earlier, some part of storage memory contains the status of inputs and outputs. The real world state of an input is stored as either 1 or a 0 in a particular bit of memory. That means each input or output has one corresponding bit in memory which any time any of these inputs is activated, the same bit in the input image table is going to be set to 1. Also, any time any of these output bits to be activated, the same bit representing that particular bit will be set to a 1. In figure 2-18, switch S, is not activated, therefore the related bit in the Input Image Table is 0. In this case, the output bit also will be set accordingly which is 0 too. In figure 2-19, switch S, is depressed, therefore the related bit in the Input Image Table is set to 1. In this case, the output bit also will be set to 1 in the Input Image Table and therefore the LAMP will be ON.
56
Figure 2-18
Figure 2-19
(c) Copyright PLC-DOC.COM 2004
57
58
Chapter
3
Relay Type Instructions
59
Those who do only the ordinary jobs can expect only moderate returns for their labor. But those who are continually on the alert for new ideas and new uses for their talent, get the greatest profits.
People remember us more for the unusual than for our ability to do ordinary work well.
60
LCs are industrial computers, and as such their input and output signals are typically 120, 24 volts AC or DC, just like the electromechanical control relays they were designed to replace. By connecting different input or output module to a PLC, it can have ability to input or output low-level DC voltage signals of very low in magnitude. In applications such as controlling the temperature of a furnace, we usually have to deal with DC voltages of about 10 MV or even less. Signal magnitude allowable with any PLC or programming language standards vary somewhat between different models of PLCs, but they are similar enough to allow a generic introduction to PLC programming here. Figure 3.1 illustrates a real picture of Allen Bradley MicroLogix 1500
Figure 3.1 illustrates a pictorial view of Allen-Bradley, MicroLogix 1500 Make: Allen-Bradley Controller Platform: MicroLogix 1500 Model: 1764 24AWA Part Number of modules: not mentioned If you are not familiar with all these model numbers or such, do not be worry. I just try to make a picture of the hardware in your mind to help you understand how in real world a PLC should be wired to do control job. As you notice from the specification of the input/output modules, they may function with 12,24, 110, 220 VAC or V DC. That means anytime we depress a push button to activate an input device connection to a PLC, the power supply used must not be more than the said level of voltages. On the other hand, anytime the output bit is activated, to turn on a lamp, relay solenoidetc, the output flow of current is not allowed to be greater than the pre set amount of current per channel. Otherwise, internal circuitry of the PLC might be damaged and smoke may come out of PLCs box!!
61
Figure 3.2 illustrates simplified graphical view of Allen-Bradley, MicroLogix 1500 In figure 3.2, two screw terminals provide connection to 120 volts (L1 and L2) AC for powering the PLCs internal circuitry. 24 other screw terminals on the bottom and top side provide connection to input and output devices, each terminal representing a different input channel with its own identifying label. From now on, for the sake of simplicity, figure 3.3 will be used as a simplified version of a generic PLC to explain the programming and wiring diagrams. Comparing figures 3.2 with 3.3, input/output and power source labels are defined as following:
MicroLogix 1500
L 1 - HOT L2 - Neutral
62
Figure 3.3 generic version of PLC Inside the PLC housing, connected between each input terminal and the M terminal, is an OPTO isolator device (Light-Emitting Diode) that provides an electrically isolated high logic signal to the computers circuitry (a photo-transistor interprets the LEDs light) when there is 24 V DC power applied between the respective input terminal and the M terminal. Two indicating LEDS on the front panel of the I/O modules give visual indication of a depressed input and an energized output device. Output signals are generated by the PLCs computer circuitry activating a switching device (transistor, TRIAC, or even an electromechanical relay), connecting the source terminal, correspondingly, is usually connected to the +24 side of the power source. As with each input, an indicating LED on the front panel of the PLC gives visual indication of an energized output. The actual logic of the control system is established inside the PLC by means of a computer program. This program dictates which output gets energized under which input conditions. Although the program itself appears to be a ladder logic diagram, with switch and relay symbols, there are no actual switch contacts or relay coils operating inside the PLC to create the logical relationships between input and output. There are imaginary contacts and coils, if you will. The program is entered and viewed via a personal computer connected to the PLCs programming port. Figure 3.4 shows the activated input port channel I 1
63
Figure 3.4
An example of how condition and output instruction s are used is shown in the ladder diagrams of figures 3-4 and 3-5. The Examine ON and Examine OFF instructions (conditional) are analogous to relay contacts, while the Output Energize instruction is analogous to a relay coil. However, this diagram must be evaluated in terms of logical continuity rather than electrical continuity. Consider the following circuit and PLC program (figure 3.4). When the pushbutton switch is un-actuated (un-pressed), no power is sent to the I 0.1 input of the PLC. Following the program, which shows a normally-open I 0.1 contact in series with a
(c) Copyright PLC-DOC.COM 2004
64
Q 1.0 coil, no power will be sent to the Q 1.0 coil. Thus, the PLCs Q 1.0 output remains de-energized, and the indicator lamp connected to it remains off. If the pushbutton switch is pressed, however, power will be sent to the PLCs I 0.1 input. Any and all I 0.1 contacts appearing in the program will assume the actuated (non-normal) state, as though they were relay contacts actuated by the energizing of a relay coil named I 0.1 In this case, energizing the I 0.1 input will cause the normally open I 0.1 contact will close, sending power to the Q 1.0 coil. When the Q 1.0 coil of the program energizes, Q 1.0 output will become energized, lighting up the lamp connected to it. It must be understood that I 0.1 contact, Q 1.0 coil, and connecting wires, and power appearing in the personal computers display are all virtual. They do not exist as real electrical components. They exist as commands in a computer program (a piece of software only) that just happens to resemble a real relay schematic diagram. Equally important to understand is that the personal computer used to display and edit the PLC program is not necessary for the PLCs continued operation. Once a program has been loaded to the PLC from the personal computer, it may be unplugged from the PLC, and the PLC will continue to execute the instructions. I include the personal computer display in these illustrations for your sake only, in aiding to understand the relationship between real- life conditions (switch closure and lamp status) and the programs status (power through virtual contacts and virtual coils). The true power and versatility of a PLC is revealed when we want to alter the behavior of a control system. Since the PLC is a programmable device, we can alter its behavior by changing the commands we give it, without having to reconfigure the electrical components connected to it. For example, suppose we wanted to make this switch and lamp circuit function in an inverted fashion: push the button to make the lamp turn off, and release it to make it turn on. The hardware solution would require that a normally-closed switch be substituted for the normally-open switch currently in place. The software solution is much easier. Just alter the program so that contact I 0.1 is Normally closed rather than normally open. In figure 3.5, we have the altered system shown in the state where the pushbutton is un-actuated (not being pressed).
65
On of the advantages of implementing logical control in software rather than in hardware is that input signals can be re-used as many times in the program as is necessary. For example, take the following circuit and program, designed to energize the lamp if at least two of the pushbutton switches are simultaneously actuated. To build an equivalent circuit (see figure 3.6) using electromechanical relays, three relays with two normally-open contacts each would have to be used, to provide two contact per input switch. Using a PLC, however, we can program as many contact as we wish for each input port without adding additional hardware, since each input and each output is nothing more than a single bit in the PLCs digital memory (either 0 or 1), and can be recalled as many times as necessary. Furthermore, since each output in the PLC is nothing more than a bit in its memory as well, we can assign contacts in a PLC program actuated by an output (Q) status. Take for instance this next system, a motor start-stop control circuit.
Figure 3.6 displays the equivalent circuit with three pushbutton switches Figure 3.7 displays the wiring and ladder diagram of motor start circuit. The pushbutton switch connected to input I 1 serves as the start switch, while the switch connected to input I 1 serves as the stop. Another contact in the program, named Q 0, uses the output coil status as a seal-in contact, directly, so that the motor contactor will continue to be energized after the start pushbutton switch is released. You can see the normally-closed contact I 1 showing that it is in a closed (electrically conducting) state.
66
Figure 3.7 a start stop motor circuit If we were to press the start button, input I 1 would energized, thus closing the I 1 contact in the program, sending power to the Q 0 coil, energizing the Q 0 and applying 24 volt DC power to the real motor contactor coil. The parallel Q 0 contact will also close, thus latching the circuit in an energized state. Now, if we release the start pushbutton, the normally-open I 1 contact will return to its open state, but the motor will continue to run because the Q 0 seal-in contact continues to provide continuity to power coil Q 0, thus keeping the Q 0 output energized. Figure 3.8 displays Motor Start circuit, in which the Start button is actuated. When the stop pushbutton is released, input I 1 will de-energize, returning contact I 1 to its normal, closed state. The motor, however, will not start again until the start pushbutton is actuated, because the seal-in of Q 0 has been lost. Figure 3.9 displays start \stop motor circuit in which Motor Stop switch is actuated To stop the motor, we must momentarily press the stop pushbutton, which will energize the I 1 input and open the normally closed contact, breaking continuity to the Q 0 coil see figure 3.10 In addition to input I 1 and output Q 0 program elements, PLCs provide internal coils and contacts with no intrinsic connection to the outside world. These are used much the same as control relays (CR1, CR2, etc.) are used in standard relay circuits to provide logic signal inversion when necessary.
67
Figure 3.8 displays start \stop motor circuit in which Motor Stop switch is actuated
Figure 3.9
(c) Copyright PLC-DOC.COM 2004
68
Figure 3.10
Figure 3.11
69
To understand how one of these internal relays might be used, consider the following example circuit and program, designed to emulate the function of a three-input NAND gate. Since PLC program to elements are typically designed by single letters, I will call the internal relay C1 rather than CR1 as would be customary in a relay control circuit. In this circuit, the coil will remain energized so long as any of the pushbuttons remain un-actuated (un-pressed). Check figure 3.11. To de-energized coil, we will have to actuate (press) all three switches. Switch configuration is displayed on figure 3.12
Figure 3.12 Branch Instructions These are used to create parallel paths of condition instructions, allowing more than one set of conditions (OR logic) to establish continuity in a rung. Figure 3-10 illustrates a branching condition. The rung will be TRUE (H) if either instruction I0.0 or instruction Q 0.0 is TRUE. See figure 3-13. A nested Branch (branch within a branch) can not programmed, but you can program an equivalent branching condition. This is shown in figure 3-14
(c) Copyright PLC-DOC.COM 2004
70
Figure 3-13
Figure 3-14
71
Output Latch These are two Retentive instructions which are usually used as a pair Output Unlatch and at the same address. In figure 3-15, any time input I:0.0/0 is depressed, instruction Output Latch will be True, so does O:0.0/0 and O:0.0/2. This is exactly the case in figure 3-15. If for some reason we lose control power, pushing the stop button I0.0/1 has no effect and the O:0.0/2 remains on, since some type of control power is needed for system to turn-off. That means even if we turn off the power source to PLC, and then turn it back on, the Output O:0.0/0 and O:0.0/2 remain True and thats why we say the instructions are Retentive. To turn O:0.0/0 off, input device I:0.0/0 must be depressed manually. And thats why we say that these two instructions must be used as a pair.
Figure 3-15 You (as a programmer), must be very careful when using these instructions in your user software. Emergency stop switches or pushbuttons which are independent of the PLC on-off circuits, should be included in your control hardware.. Figure 3-16 displays one simple circuit could be used as an emergency stop switches which is independent of PLC control circuit. In figure 3-16 any time if we want to disconnect control power to PLC, manually place the hammer switch on STOP position. In this case anytime should PLC start functioning, the control power is cutoff by CR contactor.
72
Figure 3-16 Internal relays In PLCs there are elements that are used to hold data, i.e. bits, and behave like relays, being able to be switched on or off and switch other devices on or off. Hence the term internal relay do not exist as real-world switching devices but are merely bits in the storage memory that behave in the same way as relays. For programming, they can be treated in the same way as an external relay output and input. This then results in the internal relay contacts being used, in conjunction with other external input switches to give an output, e. g. activate a motor. A variety of other terms are often used to describe these elements such as auxiliary relays, markers, flags, coils, or bit storage. To clarify the application of Internal relays, take a look at figure 3-17, which shows a double pole pressure switch PS-1 is controlling the start and stop of two outputs: motor M1 and M2. To hardwire such a circuit, we need to have a double-pole pressure switch and two contactors. But by programming the same circuit on a PLC, the necessity of purchasing a double circuit pressure switch is eliminated. As figure 3-18 shows, in the user program, one NO and one NC is used instead of the pressure switch but notice that the address of two discrete input devices is chosen the same.
73
Figure 3-17
Figure 3-18
74
Figure 3-19
75
Figure 3-20
Notice:
1-For the sake of simplicity only, we will use I0, I1 or Q0 notation instead of I:0.0/0, I0.0/1 or Q:0.0/0..and such in the Figure EP 3-1. 2- But in any Given User software generated for example programs, the correct notation will be used (otherwise, it would be impossible to check the correctness of the software by the RSLogix 500).
(c) Copyright PLC-DOC.COM 2004
76
Figure 3-21
77
Example 3-3
Consider the Circuit Diagram shown in figure 3-22. In this circuit, to turn on the LAMP, pushbutton S1 must be pressed but pushbutton S2 must be kept un-actuated (or unpressed). Write a program to define the circuit.
Solution: As you see from the circuit diagram, S1 is a NO (Examine ON) switch but S2
is a NC (Examine OFF) one. Therefore, when writing the program, NO and NC symbols must be used for S1 and S2 accordingly.
78
Example 3-4
Circuit diagram for Example 3-23 is given. Develop a user program for it. According to circuit diagram in figure 3-4: Q 0 = 1 if the result of two OR functions equal to 1 Q 0 = 0 if at least the result of any two OR functions equal to 0
Figure 3-23
79
Example 3-5
Circuit diagram for Example 3-25 is given. Develop a user program for it. According to circuit diagram in figure 3-5: Q 0 = 1 if at least one of the following conditions does exist: I0 = 1 or I1=1 or I2=1 or I3 and any of the three top NO contacts.
Figure 3-25
80
Example 3-6
Figure 3-26 Figure 3-26 displays the system hardware. Figure 3-26A displays the user program to fulfill the requirements of the example 3-6.
Notice that:
Some of inputs input instruction such as I:0.0/3, I:0.0/4 and outputs O:0.0/2, O:0.0/3 and O:0.0/4 are used few times in the program. This is due to the fact that these bits are the I/O bits in the image table and could be used as many times as we want anywhere in the program (as internal relays).
81
82
Example 3-7
Figure 3-27
83
84
Chapter
4
Special Contacts
85
Dont look a gift horse in the mouth A bad workman always blames his tools
86
SPECIAL CONTACTS
Every PLC has many special purpose contacts available to the programmer. Some of these special-purpose instructions did not exist years ago when manufactures started building PLC hard wares or software. Hence, sharp programmers were simulating these instructions by using available instructions and therefore adding some more codes into their user programs to simulate these instructions. Nowadays, most manufactures have added these special contacts to their ladder programming languages to meet these needs. Programmers can now accomplish these special tasks with one contact instead of a few lines of logic and lots of head scratching. Master Control Master Control Relays are used to control a zone or an area of a ladder Relays logic program. Two master control relay instructions can control entire sections of a program or the whole program as long as none of the outputs in the zone is retentive outputs. In figure 4-1, if rung # 0 is true, means MCR is true (I0=true), if I1or I2 are true, the outputs O0 and O1 are going to be false If rung # 0 is false, means MCR instruction is false (I0 = false), then even if I1 or I2 Are e, O0 and O1 False. O2 (is outside of MCR loop or area) is independent of MCR instruction effect. It is only controlled by I3.
Figure 4-1
(c) Copyright PLC-DOC.COM 2004
87
Notice that the master control relay should not be confused with the hardwired master control relay that should be used to protect every application. Hardwired master control relay are used to provide for the immediate shutdown of power in the event of an emergency. BIT Instructions The Bit instructions are an extension of the input and output operations of the PLC. The BIT or B3 operation allows a bit in a 16 bit file to be set or cleared. This file allows for the saving of conditions without involvement of the normal I/O terminals. The B3 file values are often referred to as internal output coils. They are used in the same way a regular output coil is used except they only effect the bit value in a file and not an output terminal on the PLC. A PLC may have only a few physical outputs, but may have a large number of B3 files each with 16 bits of storage information. To use the B3 file an output (OTE) would be named as B3:0/3 to set the number 3 bit of the zero numbered B3 file . An input such as an XIO, would take its logic value from the bit defined in the naming, for example B3:1/2 would take its data from bit 2 of the number one B3 file.
88
Chapter
5
Timers
89
Self-confidence is a personal asset which can do big things for you. If you do believe in yourself and you are willing to back up this faith with good hard studying, you can safely leave the final result to itself. With complete confidence, you can look forward to an early success in electronics.
Act as if you could not possibly fail, and you will succeed!
90
Timers
In many control tasks there is a need to control time. For example, a motor or a pump might need to be controlled to operate for a particular interval of time, or be switched on after some time interval. Other example of timer application might be signal lights controlling cars.
1- TIMER ON-DELAY (TON) 2- TIMER OFF-DELAY (TOF) 3- RETENTIVE ON-Delay Timer (RTO) ON-DELAY TIMER (TON)
An on-delay timer will wait for a set amount of time after a line of ladder logic has been true before turning its output on, and it will stay on as long as the line of ladder logic stays at its true status. Figure 5-1, displays an Allen-Bradley ON-DELAY TIMER element, symbol, timing diagram and a simple ladder logic program. Figure 5-1 shows that the timer consists of a timing block containing TIMER address T4:0, TIME BASE which is set to 1.0 second, the PRESET value which is 5 second and finally ACCUM which is = 0.
T4:0 is the timer format in which T Identifies this as a timer file 4 This is timer file 4 (default file) 0 This means timer 0 in file 4 which can be any number from 0 to 255.
In this case, there are 256 timers available in file 4 for the programmer to use SLC 500 and MIcroLogix timers are stored in the timer file, file 4, in the Data file section of the PLCs memory. Timer (file 4) stores information such as preset values, accumulated values, and status bits for timers. Default timer file is file 4. Each timer consists of 3 x 16 bit words (also called timer element). A timer instruction is one element which is made up of three 16 bit words. In timer element, three status bits are: DN (done bit) is set (turned ON) any time accumulated value is equal or greater than to preset value TT (timer-timing) is set to 1 (turned ON) when the timer is timing.
(c) Copyright PLC-DOC.COM 2004
91
EN (enable bit) is set whenever the timer is enabled. Bits 0 to 12 (first 13 bits) is used for PLCs internal use is considered as Reserved Bits. Word 1 is used for Preset value. Since it is a 16 bit word, it can have any number from 0 to 32,767. Hence, if time base of one second is assigned, the timer can be programmed for the maximum time of 32767 / (60 x 60) = 9.1 hours. Word 2 is assigned for ACCUMULATED value hence it can be any number from 0 to 32,767. One timer element is made up three 16 bit words
Figure 5-1
Analyze of circuit figure 5-2 1-As long as I0 = 0, both O0 and O1 are off or 0 (see figure 1 in fig.5-2). 2-At time 1 second, push button I0 is depressed. According to timing diagram, EN= true,
(Rung 0 is true now) and TT become true. Circuit # 2 displays and verifies this visually In this case, the timer is TIMING (that is reason why TT becomes true). And since, the timer has started the timing cycle, hence, Accumulator (ACC) is advancing for one unit per second. That is why ACC line is shown as an inclined line. 3- As soon as ACC value becomes equal to preset one (ACC = Preset =5), according to circuit # 3 and the timing diagram, TT = false, ACC becomes true and EN stays true. Since timer stops the timing cycle, TT = false O1 turns off
(c) Copyright PLC-DOC.COM 2004
92
4- As soon as I0 is released at time=9, Rung 0 becomes false EN, DN and ACC all become false. See figure 5-2 circuit # 4.
93
Figure 5-2
94
Example 5-1
Develop the ladder logic that will turn on an output light O0, 20 seconds after switch I0 (START) has been turned on.
Figure 5-3 shows the user program for Example 5-1 Solution for Example 5-1 is very self explanatory. Bit instruction B3:0/0 is used as an internal output. Pushing start switch, turns B3:0/0 bit on which makes rung 0 true and hence timer T4:0 starts advancing for one pre second since time base is = 1 sec. Eventually, when DN bit is set at the end of timing, it turns O0 on.
95
Example 5-2
Develop a ladder logic that will turn on O0 if two inputs I0 and I1 to be turned on within 1 second of each other.
Solution
The third rung is a AND circuit. Two instructions used in the rung means if both T4:0/TT and T4:0/TT are true, then O0 will be true. Hence pushing to inputs I0 and I1 within 1 second causes the rung to be true and hence output O0 becomes 1.
96
Example 5-3
Develop a program that will turn on a flashing light for 20 second after a PLC is turned on. The light should flash for 1 second on and 1 second off.
Figure 5-5
97
Figure 5-6
98
Figure 5-7
99
100
Figure 5-8
Figure 5-9 Notice the RES instruction is added on rung # 3 with the same address as of T4:0. In figure 5-9, ACCM value 0 if RES rung to be true by depressing input I1.
101
Example 5-4
Develop a program that will turn on when Start button I0 is pushed and can be stopped by I1. when the O0 goes on initially the TON timer is used to sound the horn (O1) for the first 5 seconds to warn that the oven will start, and after that the horn (O1) stops and the heating coil (O2) starts. When the oven is turned of (by pushing I1) fan continues to blow for 10 seconds after, User program is given in figure 5-10
Figure 5-10
(c) Copyright PLC-DOC.COM 2004
102
Example 5-5
Develop a program that will turn on light O0 for 2 second and off for 5 second.
Figure 5-11
103
Example 5-6
The diagram in figure 5-12 is a simple pumping station. The pump transfers liquid from the tank on the left to the tank on the right. Design a program using available inputs and outputs to perform the following requirements. 1- When the start button is actuated, the pump starts. The button can then be released and the pump continues to operate. 2- When the stop button is pushed, the pump stops. 3- Before starting the pump, pressure switch # 1 must be closed. 4- Eight seconds after the pump starts, pressure switch # 2 must close, and sixteen seconds after the pump starts, pressure switch # 3 must close. If these switches do not close then the pump will shut off and will not be able to start again for 50 second.
Figure 5-12
104
Figure 5-12 the user program I3 = PS1 PRESSURE SWITCH # 1 I1 = PS2 PRESSURE SWITHC # 2 I2 = PS3 PRESSURE SWITHC # 3 I8 = MAIN STOP SWITHC I9 = MAIN START SWITCH
105
Example 5-7
A conveyor is run by switching on or off a motor. We are positioning part on the conveyor with an optical detector. When the optical sensor goes on, we want to wait 10 seconds, and then stop the conveyor. After a delay of 4 seconds, the conveyor will start again. We need to use a start and stop button. A light should be on any time the system is active. Figure 5-13 displays the solution ladder logic program
Figure 5-13
106
Chapter
6
Counters
107
Fools tie knots, and wise men loose them Empty vessels makes the most noise
108
Counters
A counter allows a number of occurrences of input signals to be counted. This might be in a situation where items pass along a conveyor belt and a specified number have to be diverted into a box. It might be counting the number of revolutions of a shaft, or perhaps the number of people passing through a door.
C5:3
C identifies the instruction as a counter file 5 the default file number (any unused file number from 10 to 255 can be assigned).
MicroLogix is limited to one counter file, which is default file 5. Hence, it is limited to 40 counters (0 to 39). SLC 500 can use files 0 to 255. :3 : and number 3. Colon separates file number (5) from counter number which is # 3 Number 3 can be any number. There are 256 counters in each file number. In our case, C5:3 is the forth counter from counter file 5.
109
110
Figure 6-3 CTU counting chart Count Up Done Bit (DN) According to figure 6-3, DN bit is set to 1 and stays on when accumulated value is equal or greater than preset value. Count Up Overflow Bit (OV) Hexadecimal number 32,767 is the maximum number that can be accommodated with a sixteen bit binary word. Now any time accumulated count exceeds the upper limit of +32,767, then OV bit sets to 1. Count up Enable Bit (CU) According to figure 6-3, activating input I0, causes a positive edge signal to the counter which (rung 0 becomes true) causes CU status bit to be ON and remains true as long as counter rung is true (rung 0). Clearly, CU is false when the counter rung is false or I1 is activated. In figure 6-3, any time should input device I1 (false to true transition) to be activated, causes ACC to clear and DN to be set to off. Now to investigate CD, DN and UN status bits, we replace C5:39 to a down counter and take a look at its counting chart (CTD). Figure 6-4 displays CTD timer and instructions.
111
112
Count Down Enable Bit (CD) CD 1 as long as counter rung is true. Hence with positive going edge of I0 (false to true transition), notice that CD is also set to 1 and stays ON as long as the counter rung is true. Leading edge of I0 sets CD 0 or false. Also notice that anytime rest instruction is executed by activating input device I1 (0 to 1 transition), ACC 0.
113
Example 6-1
Develop the ladder logic that will turn on a light after switch I0 has been closed 10 times. Switch I1 will be used to reset the counter.
Figure 6-6
114
Example 6-2
Develop a program that will turn on output O0 which is hardwired to a pneumatic cylinder to remove 5 out of every 10 parts from a conveyor carrying the parts. Input I0 is used to detect the parts being carried by the conveyor. The system is using two counters. When the part is detected, both counters will increase their values by 1. When the sixth part arrives the first counter will then be done, thereby allowing the pneumatic cylinder to actuate for any part after the fifth. The second counter will continue until the eleventh part is detected and then both of the counters will be reset.
115
Example 6-3
Design ladder logic that uses normal timers and counters to measure times of 50 days. Figure 6-8 displays the program for example 6-3. Notice that 3600 second = 60 minute Each day is = 24 hours so 50 days = 24 x 50 = 1200 hours. Hence, every time TON counts from 0 to 3600 second, or one hour, counter increments one decimal unit. Therefore, output O0 = 1 anytime CTU counts 1200. I1 can be used to reset CTU.
Figure 6-8
116
Example 6-4
Write a ladder program to perform the following steps using 2 timers and 1 counter. A. Set up a timer to time for 2 hours and then turn on an amber light. B. Then, start counting widgets from 1-50. When 50 is reached, turn on a green light. C. Next, start a second timer timing for 10 hours, and turn on a red light at the end of the timing sequence. D. Finally, use a manual reset to restart the timing sequence.
117
Figure 6-9 Notice that to speed up timers timing, we have chosen T4:1 and T4:2 preset values 10 and 10 second each. Since 1 Hour = 60 minutes = 60 x 60 = 3600 seconds and 5 hours = 5 x 3600 = 18,000 seconds, hence preset values for each of those two timers must be set to 18,000.
118
Example 6-5
Create a program with an interactive Timer and Counter. Requirements: 1. Use a hard-wired Contact (sensor) to Start a 10 second Timer. Include a Start / Stop / Latch station with an Emergency Stop. 2. When the Timer times out (done), increment a Counter one count. Then have the Timer restart again automatically to continue this Cycle until the counter has counted To three (done), the program will stop. 3. Use status indicator lights to show when the Timer is timing and when the circuit has completed its cycle (Counter done).
119
To understand new developments, you must learn the fundamentals in your chosen field and be able to remember them latter. There is only one way to fix ideas in your mind and that is to USE them! Otherwise, you will find facts slipping away from you and your key of knowledge will become rusty and useless.
120
Chapter
7
COMPARISON AND DATA-HANDLING INSTRUCTIONS
121
122
hen PLCs were first introduced, their instruction set was limited to relay latch, timer, and counter functions. As the PLC gained increased acceptance in the industrial marketplace, additional demands and applications began to tax the limited capabilities of the first and second generation units. In order to meet the increasing demands, comparison and data handling functions began to appear as part of the instruction sets for the third and fourth generation PLCs were offered as standard features today. Comparison instructions such as EQU, NEQ, LES, LEQ and GRT allow us to compare or change data for different levels of equality or data formats. On the other hand, Data-Handling instructions such as MOV or COPY allow stored data to be moved or copied from some location in processor memory into a different location or even into the PLC ladder program currently being executed.
COMPARISON INSRUCTIONS
The Equal Instruction (EQU) EQU, greater than or equal instruction, allow the PLC to test if two values as SOURCE A and SOURCE B are equal. When SOURCE A is equal or greater than SOURCE B, then the rung is true. The values tested can be actual values or addresses that contain values. EQU instruction is an INPUT instruction (locates on the left side of an OUTPUT instruction). Source A is the address of the data to test for equality. Source B is can be a constant number or a word address.
Figure 7-1
(c) Copyright PLC-DOC.COM 2004
123
Figure 7-2 In figure 7-1, to place an EQU instruction, according to figure 7-2, click on , (1), to get to Compare icon, and then click on EQU instruction. As usual, Figure 7-1 displays a sample user program in which EQU instruction is used. Notice that in rung 0, EQU instruction is used as an input one. Source A data is located at address N7:3 (10). Source B data is located at address N7:10 (3). Notice that both data to be compared are located in two different addresses. Also notice that Source A data comes from T4:0.ACC () address in rung 2. But Source B data is a constant number 10. Hence, rung 2 means if ACC (value) = or > 10, turn ON output O1 (rung is true).
Figure 7-3
Figure 7-4
(c) Copyright PLC-DOC.COM 2004
124
In figures 7-3 and 7-4 notice that to check the values of N7 INTEGER word bits or the status bits on timer T4:0 you can simply click on the related icon (on the left under DATA FILES). These auxiliary windows are very useful in debugging user programs under develop. The Not Equal Instruction (NEQ) The NEQ instruction is true if data specified as SOURCE A is not equal to data specified as SOURCE B. Source A is the address of any data which contains some value Source B can be either a constant number or a word address The Less Than Instruction (LES) The LES than (LES) instruction is true if data specified as SOURCE A is less than the data specified as SOURCE B. Source A is the address of any data which contains some value Source B can be either a constant number or a word address The Less Than or Equal Instruction (LEQ) The Less than or equal (LEQ) instruction is true if data specified as SOURCE A is less than or equal to the data specified as SOURCE B. Source A is the address of any data which contains some value Source B can be either a constant number or a word address The Greater Than instruction (GRT) The greater than (GRT) instruction is true if data specified as SOURCE A is greater than the data specified as SOURCE B. Source A is the address of any data which contains some value Source B can be either a constant number or a word address The Greater Than or Equal Instruction (GEQ) The greater than or equal (GEQ) instruction is true if data specified as SOURCE A is greater than or equal to the data specified as SOURCE B. Source A is the address of any data which contains some value Source B can be either a constant number or a word address
125
Figure 7-5
126
Figure 7-6 Figure 7-5 displays the Comparison instructions we talked about in this section. And since according to figure 7-6, N7:0 = 28 and N7:5 = 18, you see the result of the conditional instructions when they were executed. In rung 0000, N7:5 = 18 (figure 7-6), and Source B = 18. Rung 0000, means if N7:5 (18) = 18 and I0 = 1 O0 = ON Rung 0001 means if N7:5 (18) = 18 not equal to 30 and I1= 1 O1 = ON Rung 0002 means if N7:5 (18) = 18 less than 64 O2 = ON Rung 0003 means if N7:0 (24) = 24 is greater than 12 O3 = ON Rung 0004 means if N7:0 (24) = 24 is less than or equal 5 OR I2 is true O4 = ON Rung 0005 means if N7:0 (24) = 24 is greater than or equal 11 O5 = ON
127
DATA-HANDLING INSTRUCTIONS
As it was mentioned already, data ( in its binary form ), stored in memory portion of the processor is referred to as data table words. Data-handling instructions are used to move or copy word or words of data from one data file source to a different location in memory. Like the Comparison instructions that we investigated already, any time the data-handling instructions are true, a copy of specified information (data) is moved from Source A to Source B. The Move Instruction (MOV) MOV instruction is used to move data from one word to another word. MOV is an output instruction which means in the rung, it must be placed in the right side of the input filed device such as push button or so. MOV transfers a copy of data from one word (Source address A) to another word (Source address B).
Figure 7-7 In figure 7-7, notice the contents of N7:0 and N7:1 which are hexadecimal numbers 50 and 0 accordingly. Instructions in Rung 0000 means if I1 = true or ON, then a copy of number in N7:0 (50) N7:1. By setting I0 ON, rung 0000 change into a true rung and figure 7-8 displays the result in which hexadecimal 50 is moved from word address N7:0 to word address N7:1.
128
Figure 7-8 Figure 7-9 shows another example of MOV instruction. Notice that if I1 (on Rung 0002), to be depressed (set ON): Content of N7:1 T4:39.PRE And if I2 (on Rung 0003), to be depressed, rung 0003 is set ON: Content of N7:2 T4:39.PRE Hence, by using the MOV instruction you can program your counters or timers for various parameters to suite different processes. The Masked Move Instruction (MVM) MVM instruction is very much the same as MOV instruction except that it has one more requirement to work and that is the mask data. By using mask data in MVM instruction, we can come up with a different form of data which is very important feature of MVM instruction. Lets say we have source a word data of 0110010100100011 = 25891 DEC. And if we mask it with this The destination word after MVM instruction being Executed
129
Figure 7-9 displays the MVM instruction and Data File N7:0 in which binary data 0110010100100011 is typed in. To enter your data (source data) in Data File N7:0 in binary format, just click on the roll down icon where it says Radix. Turn on Binary by clicking it. In the Data File N7:0 filed, type 0 or 1 in the N7:0 word and hit ENTER key. Figure 7-10 displays the same MVM instruction after being executed and source data was masked with 0011001100110011 and the result of mask process which is binary number 0010000100100011.
Figure 7-9
(c) Copyright PLC-DOC.COM 2004
130
Figure 7-10
Figure 7-11
131
Fear about your ability to success leads to failure no matter how hard you try!!
132
Chapter
8
PLC Arithmetic Functions
133
Wishes dont wash dishes Far from eye, far from heart
There is an exceptionally fine quotation I want to pass on to you. I do not recall the name of the author, but the truth in the quotation makes it unforgettable. Here it is:
The one who knows how will always have a job the one who knows why will be the boss.
134
ost PLCs have basic arithmetic functions. These basic functions are addition (+), subtraction (-), multiplication (), and division (). There many times that contacts, coils timers, and counters fall short of what the programmer needs. There are many times applications that require some mathematical computation. For example, imagine a furnace application that requires the temperature to be controlled against the time passed. In another words, the temperature control is a function of time. To make the situation worse, the increase or decrease of temperature which is a function of time, or we may say time versus temperature curve is not a straight line. Figure 8-1 displays the Time VS Temperature Curve.
Figure 8-1 According to figure 8-1, when operator starts the machine for a heating water process: At time = 0 temperature is 0 At time = 40 temperature is 80F At time = 65 temperature is 80F At time = 125 temperature is 165F At time = 245 temperature is 165 F And finally, at time = 275 temperature falls to 80F This simple application required the use of many relational operators (arithmetic comparisons, solving simple line equation, additions, and so forth). The application involved test of equality, less than, or greater than. The application of arithmetic statements makes this a very simple application to write.
135
ALLEN-BRADLEY PLC-5, SLC 500, and MIICROLOGIX MATH INSTRUCTIONS Divide (DIV) Instruction The DIV instruction is used to divide two values. By using this instruction, you can order PLCs processor to divide content of SOURCE A to the content of SOURCE B and write the result of this division in another location defined by address DEST. Figure 8-2 displays a division in which content of SORCE A SORCE B = DEST. In Figure 8-2 the contents of memory locations N7:5 (2000), N7:6 (25). Any time Rung 0000 becomes true by activating I0, the result of this division is written in location defined by address DEST which is N7:7 (80).
OR
N7:5 (2000) N7:6 (25) = N7:7 (80) From now on N7:5 (2000) will mean the content of memory location defined by N7:5 is decimal 2000. Addition (ADD) Instruction The ADD instruction is used to add two values. By using this instruction, you can order PLCs processor to add content of SOURCE A to the content of SOURCE B and write the result of this addition in another location defined by address DEST. Figure 8-2 displays an addition in which content of SORCE A+ SORCE B = DEST. In Figure 8-2 the contents of memory locations N7:0 (2000), N7:1 (2000). Any time Rung 0001 becomes true by activating I1, the result of this addition is written in location defined by address N7:3 (4000).
OR
N7:0 (2000) + N7:1 (2000) = N7:3 (4000) Multiplication (MUL) Instruction The MUL instruction is used to multiply two values. By using this instruction, you can order PLCs processor to multiply content of SOURCE A to the content of SOURCE B and write the result of this multiplication in a location defined by address DEST. Figure 8-2 displays a multiplication in which content of SORCE A SORCE B = DEST. In Figure 8-2 the contents of memory locations are N7:4 (3), N7:5 (2000). Any time Rung 0002 becomes true by activating I2, the result of this multiplication is written in location defined by address N7:6 (6000).
OR
Or N7:4 (3) N7:5 (2000) = N7:6 (4000)
136
Subtract (SUB) Instruction The SUB instruction is used to subtract the value in Source B from the value in Source A. By using this instruction, you can order PLCs processor to subtract content of SOURCE B from the content of SOURCE A and write the result of this subtraction in a location defined by address DEST. Subtraction Equation is: SORCE A SORCE B = DEST. Source A = N7:5 (2000) and Source B = N7:5 (6000). Figure 8-2 displays the contents of two memory locations Source A and B being subtracted any time should I3 to be activated on Rung 0002 and the result (-4000) is placed in destination address word N7:9 (-4000).
OR
N7:5 (2000) N7:5 (6000) = N7:9 (-4000) Square Root Instruction (SQR) In figure 8-2, Rung 0004, any time when I4 is activated, SQR instruction is going to be true and therefore, the square root of Source value is calculated and transferred into the destination word 16 of the N7:6 file. Another words, I4 true, then square root of Source A is calculated and placed in destination N7:6 word.
OR
Square Root of N7:5 (25) N7:6 (5) Negate Instruction (NEG) The negate instruction is used to change the sign of a value. It can be used on a positive number to make it a negative or vise versa. And remember this instruction can be executed every time if the rung is true. In figure 8-2, Rung 0005, any time when I5 is activated, N7:8(12) N7:9 (-12)
137
The From BCD instruction (FRD) is used to convert a BCD number to its binary equivalent (see figure 8-2). According to figure 8-2, the source address of N7:5 contains a BCD number of (0000000110000101). If contact of I7 is true, the instruction executes and converts the BCD number to a Binary number of (0000000010111001) and stores it to the destination address of N7:6.
Figure 8-2
138
139
140
Chapter
9
Sequencers
141
Fools tie knots, and wise men loose them Foxes, when they cannot reach the grapes, say they are not ripe!
142
rior to PLCs development, there were many innovative ways to control machines. Punched cards, for example was one of the earliest control methods to control machines. In a textile manufacturing assembly, you could see many sewing machines producing miles of textile every day based on the patterns prepared by designers and punched on the long sheets of paper. Most manufacturing processes are very sequential, meaning that machines process a series of steps, from one to the next. A bottling line, is another example of a sequential process control. In this case, bottles enter the line are cleaned, filled, capped, inspected, and packed. This is a very sequential process. Many of our home appliances work sequentially. Take a look at a home washer. It works based on a sequential control. Many of these machines are still controlled by a device called a drum controller. A drum controller functions just like an old player piano. The player piano was controlled by a paper roll with holes punched in it. The holes represent the notes to be played. Figure 9-1, displays a drum controller.
Figure 9-1 Drum controller with output switches and conditions for steps
(c) Copyright PLC-DOC.COM 2004
143
The drum controller as you see in figure 9-1, is a cylinder with bunch of pegs around it. There are switches (in figure 9-1 from switch S1 to S6) that the pegs hit as it drum turns with some revolutions per minute. The speed of the drum depends on the motor turning the drum. The duration of the time that each pegs hits the switch and turns the related light on depends on the motor speed. The motor speed can be controlled. Each step must, however, take the same amount of time. If we need any switch to be turned ON for longer time, then consecutive pegs must be installed. Table 9-1 displays the switch condition in each consecutive step. Many of our home appliances are also controlled with this drum technology. Home washer and or dryer are the best example. Now that we see how useful a drum controller can be, lets see how some of these PLC Sequencer Instructions work and used.
ALLEN-BRADLEY PLC-5, SLC-500, and MICROLOGIX SEQUENCER INSTRUCTION Sequencer Output Instruction (SQO)
Instead of using a bulky electromechanical sequencer controller, we can use our PLC to simulate a sequencer instruction. We could use the Allen-Bradley Sequencer Output (SQO) Instruction to step through the sequencer file, usually a bit-file pattern whose bits have been previously set up to control the desired output devices. Allen-Bradley PLCs use function blocks to program sequencers. Three function block instructions are available: Sequencer Output, Sequencer Input, and Sequencer Load. Figure 9-2, displays a sequencer output instruction used in our sample program. In this section, we will develop a sequencer data table in a bit file B3 where each 16-bit word in the data file will represent one step in our sequence. We will use an input I0 to step from one position (or step) in the sequence to the next to control our outputs on or off. Examine figure 9-2. This figure shows a typical sequencer output instruction block. The data that the programmer enters as for the parameters are shown in the figure 9-2.
144
Developing a Sequencer Ladder Program We will develop the ladder rung in figure 9-2 containing an input and the SQO instruction. The application will be programmed to step through a sequence of 6 steps. Each step will control 6 LEDS at a time. Hence, the sequencer will have the same sequence as of our previous example shown on figure 9-1. When the sequence is completed, it will start over. At RSLogix 500 Editor window, click on symbol you will find the sequencer instructions under the File Shift/Sequencer tab of the tabbed Instruction Toolbar or in the Instruction Palette. There are three sequencer instructions, select the SQO instruction. Click on sequencer data table file #B3.0. Start at element 0 Mask 0FFFFh Destination, the output O:0.0. Sequencer control register R6:50 Length of sequencer is 6 steps. Position is 0. After selection input device as I0, Your sequencer has all the elements needed. Now to make sure the instructions are labeled correctly and wipe out all es, in the Edit Mode, click on: Edit verify Project And save the project in order not to loose it for any reason what so ever! File Save Assuming the beloved PLC is already turned ON, push the slide switch to Program Mode (far right). On the Edit window, click on OFFLINE and on and on Download to order PLC to send your Ladder program to the memory (how and where it will be sent is not important for us). Now the next step is to define a word file to store the binary data required for each step of the sequencer. Words B3:1, B3:2, B3:3, B3:4, B3:5 and B3:6 are used for the 6 word file. We can use words from bit file B3 to store our data. To open file B3, on left side of Edit window, click on B3-BINARY (under Data Files directory). You will have Data File B3 BINARY opened. While B3 file opened, set any bit to 0 or 1, by clicking on that particular bit and typing binary information (1s and 0s) are entered into each word of the B3 file. In figure 9-3, notice that the same bit pattern we wished to set for the Drum Controller in figure 9-1, is also created for the PLCs SQO instruction. Now, if you have access to a PLC, go ahead and load or program Ladder program into the PLC and start practicing with it. This helps you to have better idea about the materials covered in next part of this chapter. As you notice in figure 9-2, SQO instruction has some parameters that we needed to define them prior to its usage in the program.
(c) Copyright PLC-DOC.COM 2004
145
Figure 9-3 displays the same bit pattern to program electromechanical Sequencer (Drum Controller) in figure 9-1 As you notice in figure 9-2, SQO instruction has some parameters that we needed to define them prior to its usage in the program.
146
Data File R6, the control file. A control file element contains three words similar to a timer or counter. Word 0 contains status bits such as EN, DN, ER and FD bits. Word 1 contains Length of Sequencer File. As it was mentioned, Length value in the instruction is actually the number of steps in the sequencer file starting with step 1. The instructions length parameter designates how many steps are in the sequence. The total number of words can be used for is: PLC-5 1-1000 SLC 500 1-255 Micrologix 1000 1-104 Step 0 is the start-up position of the sequencer. And the actual data reflecting outputs is stored at step 1. Hence step 0 is not used to have any effect on output bits. So it is some type of no mans land position or neutral one. Word 2 contains the position location or step number where the file sequencer is currently positioned. According to figure 9-2 any time input device I0 makes a transition form false to true or 0 to 1, the position counter will be incremented for one decimal unit. Length: The sequencer length determines how many steps the sequencer has. In our case in figure 9-2, our SQO instruction length is 6. Position: Position address in the instruction indicates the address where the counter is stored.
Figure 9-4 displays three word Elements for an SQO instruction Bit # 11 Sequencer Error bit, ER, set to 1 if any of position or length value is a negative number or length value is 0. Bit # 13 Sequencer done bit, DN, set to 1 any time SQO or SQC executes the last step in the sequencer file. Notice in figure 9-5, DN = 1 because sequencer position is in step 6. Bit # 15 Sequencer enable bit, EN, is set by each 0 to 1 transition of the input device which causes the SQO rung be true.
147
148
position. The position address assigned for a sequencer file is step zero. Sequencer instructions use length plus one word of data for each file referenced in instruction. This applies to the source if addressed as a file. A length value that points past the end of the programmed file causes a major error to occur. Position: Is the word location or step in the sequencer file to which data is moved. A position value that points past the end of the programmed file causes a runtime major error to occur. Control: Is a control file address. The status bits, length value, and position value are stored in this element. Do not use the control file address for any other instruction.
Figure 9-6 Now it is time to test our hardware circuit using SQL instruction on circuit on figure 9-6. We may use hardwired circuit shown on figure 9-7 and start activating input switch I0 to see if status condition of all input switches I0 to I11 is stored on file N7:30 which is located somewhere in the PLCs memory. The meaning of instruction on figure 9-6 is that every 0 to 1 transition of switch I0 will cause the bit status of all input switches I0 to I11 to be stored on the N7:30 file. So go ahead and if you have Ladder Logic on figure 9-6 loaded into your PLC, start turning ON and OFF switch I0 to cause SQL instruction to go through 5 steps one step at a time. And also, click on N7 INTEGER file to observe how and what bits would be stored in the file. After downloading the program, assuming all the switches (I0 to I11) are all turned OFF, start turning ON the switches with the following pattern: At step 1, set switch I11 = ON and then make a 0 to 1 transition with I0 and then turn it to OFF condition (un-energized).
OR 100000000000
At step 2, set switch I10 also to ON and then make a 0 to 1 transition with I0 and then turn it to OFF (un-energized).
OR 110000000000
149
At step 3, set switch I9 also to ON and then make a 0 to 1 transition with I0 and then turn it to OFF (un-energized).
OR 111000000000
At step 4, set switch I8 also to ON and then make a 0 to 1 transition with I0 and then turn it to OFF (un-energized).
OR 111110000000
150
Figure 9-8, the N7:30 file displays the result of our experiment. Notice that, switch I0 = ON in all steps. Every time a 0 to 1 transition done, PLCs processor reads the input switches if any of them is ON, it record the status of that switch as TRUE or ON and places a 1 under the defied bit Number. Hence, I0 is set to 1 in all steps. In step 1, I0 = 1 (it made 0 to 1 transition) the rest of the input switch bits are OFF beside I11 which was set to 1 prior to 0 to 1 transition of I0. Bits I12, I13, I14 and I15 all are set to 0 because Micrologix 1500 has only 12 inputs as a base unit. In step 2, since bits I11 and I10 were already set to 1, then 0 to 1 transition of I0 caused the related input bits in the N7 file also to be set to 1. Notice that the reset of the input bits had been set according in the following steps.
Figure 9-8 Displays N7:30 to N7:35 word elements stored with the status of input switches.
Conclusion:
SQL is very useful and powerful instruction. In industrial process control systems, very often there is a need to have the bit status of all input prior to start the machine. In this case, SQL could be used to check the status of all the input devices and then compare them with a predefined condition to issue MASTER START command.
151
Figure 9-9, displays the SQC instruction with parameters set to some values
152
stepping through the file. At step 1, 3, 4 and 5, FD output would be OFF or false. It would be only in step 2 in which FD = 1 or TRUE. Now while you are continuing to clock the sequencer, change bits I1 to I3 and set them to different combinations of 0 or 1. You notice that in step 2, FD= 1. Now change any of other bit values, any of I4 to I11. Notice that would be FD = 0.
Figure 9-10
Figure 9-11
153
Figure 9-12
Conclusion:
Form figure 9-12 notice that every time sequencer goes through a next step, it scans the input bit status what ever that is, is masked with FFF0H. Bits I12 to I15 are ignored because Micrologix knows that it has only 12 inputs to compare against the B3.0 words. Hence only bits I 0.4 to I0.12 going to be compared with 12 bits in B3:0 file. That is the reason why changing I0 to I3 bits did not have any effect on FDs condition. Because of MASK bits, Word Bits 0 to 3 were always ignored. Thus, in step 2, bit pattern 11001100 is the same as input bit pattern 11001100 and that is the only step that meets the condition of being equal and therefore FD 1 Figure 9-13 displays SQC instruction used in figure 9-9 re-written with status bits DN and FD bits used to control outputs O:0.0 and O:0.1. To use any of these status bits, the address must be given as R6:21/FD or R6:21/DN or you may type R6:21/08 or R6:21/13 in any case, RSLogix 500 changes the bit numbers 08 and 13 into equivalent labels of FD and DN automatically.
154
Figure 9-13
155
Example 9-1
Design and program a PLC ladder logic program which will control the lights on your PLC.
1- The lights will blink one at a time at 1 second intervals from left to right. 2- The lights will blink two at a time at 1 second intervals from left to right. 3- The lights will then blink two at a time at 1 second intervals from right to left. Build a new program that will do the following: 4- Lights 0 and 7 will be ON when switch 1 and 6 are ON and others are OFF. 5- Lights 1,3, and 5 will be on when switch 1 and 4 only are ON. 6- Lights 2 and 4 are ON when switch 7 only is ON. 7- Lights 1, 3, 5, and 7 are ON when switches 0, 1, 2, 3, 4, 6, 7, 8, 10 and 11 are ON. Figure 9-14A displays first portion of B3 file for the output light pattern for the fist portion of the example 9-1. Figure 9-14B displays the user program for the first part.
Figure 9-14A
(c) Copyright PLC-DOC.COM 2004
156
Figure 9-14B
157
Figure 9-15A
158
Figure 9-15B
Figure 9-15C
(c) Copyright PLC-DOC.COM 2004
159
Figure 9-16
160
161
162
163
Figure 9-17
164
Figure 8-18
165
166
Chapter
10
PLC Digital Bit Functions & Application
167
Dont count your chickens before they are hatched Dont cut the bough you are standing on
168
ll digital PLCs are capable of working with digital bits. In chapter 9, you noticed that how just by programming a sequencer, a PLC could set out words of data to output port to control the flow of information to the port. Hence, instead of controlling output devices from individual contacts, the PLCs use register bits in groups. Also in example 9-1 we used EQU instruction to read in a 16 bit of data from input devices (Source A) and compare it with a word of data in Source B to the rung true or false to activate the Sequencer in the same rung. All these activities are only some samples of digital bit manipulation that play a part in process control with digital bits. Hence, the PLC not only uses a fixed pattern of register bits, but can easily set, clear, manipulate or change any individual bit in any register. A shift register is a storage location in PLCs memory. These storage locations can typically hold sixteen bits of data, that is, either 1s or 0s. Shift registers essentially store the status of I/O ports, hold numerical values used to transfer data (MOVE instruction), or to do math functions.
Figure 10-1
(c) Copyright PLC-DOC.COM 2004
169
To experiment with BSL instruction, we hardwire MICROLOGIX TRAINER similar to figure 10-2. Bit pattern 1110 1010 0011 0110 0001 is selected to be feed in by clocking INPUT A and setting input I2 to 0s or 1s according to the bit pattern given. Figure 10-3 displays the words 1 and 2 after making all 0 to 1 transitions of A input and bit setting of input I2.
Figure 10-2 Figure 10-3 in two parts, displays the content of a file which is consisted of two 16 bit words which is called bit array. Figure 10-3 displays the bit array before feeding the bit pattern and after making 4 transitions of 0 to 1 by clocking INPUT A, you notice that bit 1, is shifted to the 4th position from right to left. Since the size of bit array in our example was 20, so two memory words were used. 16 bits of the first word, and 4 more bits of the second word. The reset of bits in word 2 can not be used with by any other programming. Table 10-1 shows the allowable bit-array length for each type of Allen-Bradley PLC.
ALLEN-BRADLEY PLC MAXIMUM BIT ARAY
170
Figures 10-4 and 10-5 display B3 DATA FILE prier and after all bits shifted into word locations and the R6 CONTROL DATA FILE displaying the status bits related to the BSL instruction. In figure 10-6, notice that after 21 bit shifted, the status bit UL is set.
Figure 10-4
Figure 10-5
(c) Copyright PLC-DOC.COM 2004
171
Figure 10-6
CONTROL
Control is the element that stores the status of the BSL or BSR instructions. It consists of three words. Word 0 consists of status bits UL (bit 10), ER (bit 11), DN (bit 13) and EN (bit 15). Word 1 defines the size of bit array which in our case was 20. Word 2 is a reserved word. See figure 10-7.
BIT ADDRESS
Bit address portion of the BSL or BSR instructions is the address of the bit whose data will be shifted into the bit array. In our case, I0/2 was the source of the data whose data was shifted into the bit array with each 0 to 1 transition of input A.
LENGTH
Length partition of the instruction defines the length of the bit array. In our case, the length of bit array was set to 20 bits.
172
Figure 10-7 shows control element which holds status bits for BSL or BSR instructions
BSR Instruction
The definition of BSR instruction is exactly similar to BSL instruction except the fact that the shifting of bits originates from left to right. In figure 10-1 any time input B makes 0 to 1 transition for 38 times, the data starts filling into the bit array the way it is shown in figure 10-8.
Figure 10-8
(c) Copyright PLC-DOC.COM 2004
173
ALLEN-BRADLEY uses these two output instructions to load and unload them in the same order as they were loaded. Figure 10-9 shows these two instructions used in a sample experimental program. The definition of FFL instruction means that 0 to 1 transition of input A, loads the content of Source word at address, N7:10 into the destination address defined address at N7:12 + position off set which is = N7:12 + 9 = N7:21. In our case, the content of Source address of N7:10 is F777 H or 1111 0111 0111 0111 Binary. Hence execution of FFL instruction loads:
Figure 10-9
SEEING IS BELIEVING
Go ahead, download the program in figure 10-9 into your PLC, type in data as N7:10, save the program and RUN it. Figure 10-10 shows the data F777 H we used as Source Data.
174
Figure 10-10
Figure 10-11 After you place the PLC in RUN mode, turn input A (I0) ON and OFF a few times. You may open N7 DATA FILE and check how content of N7:10 is loaded into the N7:21 word. Figure 10-11 shows the loaded DATA in word locations N7:21 to N7:23. Question: What content of N7:21 would be calculated if we change Position value from 9 to 0 ?
Answer: In that case the new location would have be calculated as following:
N7:12 + position off set which is = N7:12 + 0 = N7:12
(c) Copyright PLC-DOC.COM 2004
175
Figure 10-12
Figure 10-13
(c) Copyright PLC-DOC.COM 2004
176
Figure 10-12 shows the content of N7:12 word with offset position equal to 0. Figure 10-13 displays a graphical picture of how the content of Source Word, (N7:10) is loaded into the content of N7:21.
Figure 10-14 After clocking INPUT A, about 34 times and typing 34 different numbers at N7:1 and loading them into the stack, the data can be check if all written correctly just by clicking on N7 DATA FILE. Figure 10-15 shows how all data loaded into the memory location through N7 DATA FILE. Figure 10-16 displays all the data stored in the memory locations by clocking INPUT A. Note that if after filling all data into the memory using FFL instruction, we go ahead and start activating INPUT B few times, we will notice that in each 0 to 1 transition of INPUT B, the data is going to be unloaded for 1 position. After the first activation, our memory table will be updated to the one in which arrow is showing with number 1, and after the second activation, with number 2etc.
(c) Copyright PLC-DOC.COM 2004
177
Figure 10-15
Figure 10-16 Notice that a 0 replaces the memory location at the bottom and in the top of the table, content of N7:3 also is replaced with the next value in the location N7:4.
178
Figure 10-17 Empty Bit (EM) bit 12 of Word 0 is set to true if file is empty. Done Bit (DN) bit 13 of word 0 is set to true if stack is full. Check DN bit in figure 10-18 in which DN = 1 since in figure 10-14 stack is full. FFU/LEU Enable Bit (EU) bit 14 is set to true any time rung becomes true on 0 to 1 transition of INPUT device and false on 1 to 0 transition. FFL/LFL Enable Bit (EN) bit 15 is set to true on a 0 to 1 transition and reset to 0 on a 1 to 0 transition of input device.
Figure 10-18
(c) Copyright PLC-DOC.COM 2004
179
Figure 10-19 Parameters in LFL instruction are set such that N60:1 is assigned as Source location which the data typed in will be stored in word array starting at address #N60:3. The length of data array is 12. To fill the file #N60:3 with data, we may pull out N60 DATA FILE by clicking on N60 icon located on left side of Program Edit window. We can type different decimal numbers in N60:1 word each time and when the program is in run mode, make rung 0000 to go true by activating INPUT A for 12 times. The result is shown in figure 10-20. In figure 10-20 note that 12 words of data is already stored in the file N60:3. In figure 10-21 note that DN = 1 because the Length of N60:3 which was set to 12 words, already is satisfied. Figure 10-22 also displays the content of file N60 in a pictorial form.
180
Figure 10-20
Figure 10-21
181
Figure 10-22 Back to figure 10-19, activating INPUT B, in the first round, causes the content of N60:14 (111) to be written in location N60:2 which is called DESTINATION. Or we simply write: N60:14(111) N60:2 (111) & POSITION = 11 Activating INPUT B one more time causes the next data which is N60:13(110) to be written in location N60:2(110) and again POSITION = 10. Conclusion: In figure 10-19 when INPUT A makes a false to true transition, the LFL/EN = 1, and LFL instruction will load the contents from the source into the WORD FILE and the content of POSITION indicator will be incremented by 1.LFL instruction will continue to load the data until the position value = 12. Any time the last data is loaded, DN= 1 to prevent further loading of data to occur. When LFU rung is true, EU = 1 and LFU instruction will unload the last word in the FILE and store it in the DESTINATION word N60:2. Any time the rung makes one more transition, POSITION indicator will be decremented by 1.
182
Figure 10-23
Figure 10-24 Figure 10-23 displays the N60 DATA FILE after INPUT B is depressed or energized for 12 times and the last data in the Word File is unloaded in the DESTINATION word. Figure 10-24 displays the status bit EM = 1 because the stack or file is empty and the last data is unloaded into the DESTINATION word.
183
184
APPENDIX A
RSLogix 5/500 & RSLinx Overview
185
Few words are best All work and no play makes jack a dull boy Answer one in his own language
186
187
Therefore, we must use some version of RSLinx software to do up and down loading of any written ladder logic software to the PLC under the test!! Installing the RSLogix 500 English version
Installing the software is very straight forward. Just place the main CD ROM in the driver and look for the installing program such as RSLogix 500 English. By clicking on the installer software, InstallShield Wizard program is activated and you see the related screen. Click on Next icon at the bottom of the screen to go to the next window screen which is Rockwell Software Inc. END USER LICENSE AGREEMENT menu. Click on I accept the terms in the license agreement option and then on Next icon. InstallShield Wizard wants to know what type of setup you want to have. Two options are: 1- Complete 2- Custom. You may click on either and then on Next icon to get the software start being installed. Click on X of the up grading installing notes to close it. Installing the RSLogix 500 English version How to connect to an Allen Bradley MicroLogix 1500 to PC via RS-232 For some reason, Allen Bradley requires two software packages to communicate with its family of PLCs. You will need a communication software page which is called RSlinx, and the programming package called RSLogix 500 configured as DF1. Out of the box the Micrologix 1500 is configured as DF1 or RS-232. Of course you can change the protocol if you need to, but first we will connect to the PLC with the default parameters. Most engineers I have talked to leave the programming port as default configured as DF1. If you are ensure, hopefully you have a copy of the latest program that is running in the PLC and then you can check the channel configuration by opening the program in RSLogix 500 and make sure its configured as DF1 before you try and connect. Lets first start by launching RSLinx communication software. RSLinx comes with the RSLogix 500 installation cd-rom. If you did not install RSLinx, please do so now. RSLinx is a free application and does not need to be activated or a master key to be installed to run. Once the software is started, try and not click on any of the + signs. This starts the last configured driver and activates this driver. A diver can not be deleted in the configuration portion once its running. Most generally, you have to close RSLinx and re-start if you want to delete a driver that is active of running already.
188
Figure 1-1 Alright lets assume that you do not have any drivers configured yet. Click on Communications Configured Drivers You will see this popup window. Click on: Add RS232-DF1 devices in the pull down menu, and leave the default driver name as AB_DF1-1.
Figure 1-2 Click OK, then you will see the driver configuration screen.
189
Figure 1-3 The DF1 driver configuration screen is pretty nice because at this point you should have your programming cable connected and you can click on Auto-Configure. RSLinx will run will run through all the baud rate settings and try and auto detect the PLC settings. Most of time this works pretty good. If it did a good job you will see an Auto Configuration Successful message appear in the box to the right of the button you just pressed. If you get an error, try restarting RSLinx at least once and try Auto Configure one more time. Once you have your driver configured, you can go back to the RSWho window and now click on the + sing. This will start the driver. If all is well you should see your computer and the PLC you are trying to communicate with in the menu tree list.
190
Figure 1-4 Once you see that you are communicating with the PLC, all is done in RSLinx. Go ahead and minimize the application. Do not close it, just minimize. Now start up RSLogix 500. Open up your PLC program that should be the same as the PLC program that is stored in the PLC. I always recommend using the Comms, System Comms way of changing and connecting to the PLC. If you do it any other way, the last driver configured in the PLC program might not be the same or have the same or have the same name as the one you just configured. If that is the case, connecting any other way is RSLogix will normally result in a can not connect to driver error etc. So if you do this every time, I promise it will work every time. Ok, so we got RSLinx to communicate first and just minimize RSLinx to the task bar. Now in RSLinx click on Comms System Comms at the top of the program.
Figure 1-5
(c) Copyright PLC-DOC.COM 2004
191
You should next see a little mini window of RSLinx with your running driver. You just configured and the PLC still talking to your computer. If you know that your PLC program on your PC is the same as the PLC, then try and highlight the PLC icon MicroLogix 1500 and click online.
Figure 1-6 If everything is equal or matches in the PLC, RSLogix will display the green power rungs on the left and right. If it is not a match, generally you will probably want to do an upload at this point. Go ahead and click upload and then once the program is uploaded RSLogix should go online.
192
Figure 1-7 If the last diver was the same driver you just used, you might get a warning from RSLogix if it is ok to change the last driver used. Just read the warning prompt and you will start to understand what RSLogix is trying to tell you. I will offer a couple of tips. If you plan on connecting to another PLC or protocol, I always suggest that you close RSLogix and RSLinx. Then restart RSLinx, do not click on the + signs and go to configure drivers. Highlight the DF1 driver and click DELETE. Now you can configure a new driver or different protocol. If the driver is giving you problems, close and restart RSLinx. Sometimes RSLinx will try and take over the computer COM port while it is running. If you notice this has happened, shutting RSLinx down will release the COM port back to the windows system.
193
194
APPENDIX B
BINARY SYSTEM & ARITHMETIC
195
A bad workman always blames his tools Be true and fear not
196
verywhere, except for computer-related operation, the main system of mathematical notation today is the decimal, which is a based -10 system. As in other systems, the position of a symbol in a base-10 number denotes the value of that symbol in terms of exponential values of the base. That is, in the decimal system, the quantity represented by any of the ten symbols used 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 depends on its position in the number.
Unlike the decimal system, only two digits 0, 1 suffice to represent a number in the binary system. The binary system plays a crucial role in computer science and technology. In magnetic storage device (Hard Rigid Disk, Floppy, Zip, Tape, etc.) magnetized areas of the media are used to represent binary numbers: a magnetized area stands for 1, and the absence of magnetization means 0. Flip-flops-electronic devices that can only carry two distinct voltages at their outputs and that can be switched from one state to the other state by an impulse-can also be used to represent binary numbers; the two voltages correspond to the two digits. Optical and magneto-optical storage devices use two distinct levels of light reflectance or polarization to represent 0 or 1. Hence, arithmetic operations in the binary system are extremely simpler than doing it in decimal system as long as computer hardware design is concerned.
Figure A-1
(c) Copyright PLC-DOC.COM 2004
197
The binary numbering system uses a number set that consists of two digits. These digits are zero (0) and one (1). Each digit of the binary numbers system represents a particular power of 2. The decimal equivalent of any binary number can be computed by multiplying the binary digit by its corresponding power of 2 and adding up the results. Figure A-2 illustrates the binary equivalent of the decimal number 25,460.
Figure A-2 The Binary Numbering System is Based on various powers of two. The decimal equivalent of a Binary Number can be computed by multiplying the binary digit by its corresponding power of two, and summing the results. See figure A-2 It is the binary numbers system that is employed by the microprocessor of all PLCs and other computer / microprocessor based equipment. The two digits of the binary system, 1 and 0, easily correspond to the two possible states of a digital signal. Generally the OFF or FALSE state or condition is represented by the binary digit zero (0). The ON or TRUE state or condition is represented by the binary digit one (1).
Figure A-3 00071058 OCTAL NUMBER equals 0 2097152 + 0 262144 + 0 32768 + 7 4096 + 1 512 + 0 64 + 5 8 + 8 1 = 0 + 0 + 0 + 28672 + 512 + 0 + 40 + 8 = 29232
(c) Copyright PLC-DOC.COM 2004
198
The Octal numbering system is based on various powers of eight. The decimal equivalent of an Octal number can be computed by multiplying the Octal digit by its corresponding power of eight, and summing the result.
Figure A-4 AB58 HEXADECIMAL EQUALS 10 4096 + 11 256 + 5 16 + 8 1 = 40960 + 2816 + 80 + 8 = 43864 A (H) = 10 decimal B (H) = 11 decimal C (H) = 12 decimal D (H) = 13 decimal E (H) = 14 decimal F (H) = 15 decimal The HEXADECIMAL numbering system is based on various powers of sixteen. The decimal equivalent of a Hexadecimal number can be computed by multiplying the Hexadecimal digit by its corresponding power of sixteen, summing the results.
199
BCD 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
DEC. 0 1 2 3 4 5 6 7 8 9
Figure A-5
BINARY ADDITION
Lets start by adding two binary bits. Since each bit has only two possible values, 0 or 1, there are only four possible combinations of inputs. These four possibilities, and the resulting sums, are: 12340+0 0+1 1+0 1+1 =0 =1 =1 = 10 (with a carry of 1)
Whoops! That fourth line indicates that we have to account for two output bits when we add two input bits: the sum and a possible carry. Lets set this up as a truth table with two inputs and two outputs, and see where we can go from there. Well, table in figure B-1 looks familiar, doesnt it? The Carry output is a simple AND function, and the Sum is an Exclusive-OR. Thus, we can use two gates to add these two bits together. The resulting circuit is shown in figure B-2.
(c) Copyright PLC-DOC.COM 2004
200
INPUTS A
0 0 1 1
B
0 1 0 1
Figure B-1 the Truth Table Ok, we have got a good start on this circuit. However, we are not done yet. In a computer, we will have to add multi-bit numbers together. If each pair of bits can produce and output carry, it must also be able to recognize and include a carry from the next lower order of magnitude. This is the same requirement as adding decimal numbers if you have a carry from one column to the next, the next column has to include that carry. We have to do the same thing with binary numbers, for the same reason. As a result, the circuit to the left is known as a half adder, because it only does half of the job. We need a circuit that will do the entire job.
Figure B-2 half adder circuit To construct a full adder circuit, we will need three inputs and two outputs. Since we will have both an input carry and an output carry, we will designate them as C (in) and C (out). At the same time, we will use S to designate the final Sum output. The resulting truth table is shown as figure B-2. OK, figure B-2 is looking a bit messy. It looks as if C(out) may be either an AND or an OR function, depending on the value of A, and S is either an XOR or XNOR, again depending on the value of A. looking a little more closely, however, we can note that the S output is actually an XOR between the A input and the half-adder SUM output with B and C(in) inputs. Also, the output carry will be true if any two or all three inputs are logic 1.
201
INPUTS
A 0 0 0 0 1 1 1 1
OUTPUS
S 0 1 1 0 1 0 0 1
B C(in) C(out) 0 0 0 0 1 0 1 0 0 1 1 1 0 0 0 0 1 1 1 0 1 1 1 1
Figure B-2 Full Adder Truth Table What this suggests is also intuitively logical: we can use two half adder circuits. The first will add A and B to produce a partial Sum, while the second will add C (in) to that Sum to produce the final S output. If either half-adder produces a carry, there will be an output carry. Thus, C (out) will be an OR function of the half-adder Carry outputs. The resulting full adder circuit is shown in figure B-3
Figure B-3 displays the circuitry of a Full Adder The circuit above is really too complicated to be used in larger logic diagrams, so a separate symbol, shown in figure B-4, is used to represent a one-bit full adder. In fact, it is common practice in logic diagrams to represent any complex function as a black box with input and output signals designated. It is, after all, the logical function that is important, not the exact method of performing that function. Now we can add two binary bits together, accounting for a possible carry from the next lower order of magnitude, and sending a carry to the next higher order of magnitude. To perform multi-bit addition the way a computer would, a full adder must be allocated for
(c) Copyright PLC-DOC.COM 2004
202
Figure b-4 a Full Adder each bit to be added simultaneously. Thus, to add two 4-bit numbers to produce a 4-bit sum (with a possible carry), you would need four full adders with carry lines cascaded. It is also quite possible to use this circuit for binary subtraction. If a negative number is applied to the B inputs, the resulting sum will actually be the difference between the two numbers. Figure b-5 displays a 4 bit binary Adder / Subtracter
Figure b-5 displays a 4 bit binary Adder / Subtractor Question was asked previously: Why Binary system is the only one used in computer-related operation? The answer is Using Binary system greatly simplifies CPUs internal hardware circuitry and software algorithm design
(c) Copyright PLC-DOC.COM 2004
203
BINARY SUBTRACTION Binary subtraction is performed exactly like decimal subtraction. Therefore, before you attempt binary subtraction, you should reexamine decimal subtraction. You know that in decimal arithmetic, if 5486 is subtracted from 8303, the difference, 2817 is obtained. 7 12 9 13 8 3 0 3 - 5 4 8 6 --------------------Difference 2 8 1 7 Because the digit 6 in the subtrahend is larger than the digit 3 in the minuend, a 1 is borrowed from the next high-order digit in the minuend. If that digit is a 0, as in this example, 1 is borrowed from the next high-order digit that contains a number other than 0. That digit is reduced by 1 (from 3 to 2 in our example) and the digits skipped in the minuend are given the value 9. This is equivalent to removing 1 from 30 with the result of 29, as in our example. In the decimal system, the digit borrowed has the value of 10. Therefore, the minuend digit now has the value 13, and 6 from 13 equals 7. In the second column, 8 form 9 equals 1. Since the subtrahend is larger than the minuend in the third column, 1 is borrowed from the next higher-order digit. This raises the minuend value from 2 to 12, and 4 from 12 equals 8 to 7 because of the previous borrow, and 5 from 7 equals 2. Whenever 1 is borrowed from a higher-order digit, the borrow is equal in value to the radix or base of the number system. As you know, the radix or base of the decimal number system is 10, and the radix or base in the binary system is 2. Therefore, a borrow in the decimal number system equals 10, while a borrow in the binary number system equals 2. When you subtract one binary number from another, you use the same method describe for decimal subtraction. This is summarized by the following for binary subtraction. 123400=0 11=0 10=1 0 1 = 1 with a borrow of 1 Minuend after borrow Minuend Subtrahend
To illustrate the process of binary subtraction, lets subtract 1101 from 11011. Minuend after borrow Minuend Subtrahend Difference 0 10 10 1 1 1 1 0 1 1 - 1 1 01 ----------------------1 1 1 0
(c) Copyright PLC-DOC.COM 2004
204
The minuend after borrow now shows the value of each minuend digit after a borrow occurs. Remember that binary 10 equals decimal 2. In the first column, 1 from 1 equals 0 (rule 2). Then, 0 from 1 in the second column equals 1 (rule 3). In the third column, 1 from 0 requires a borrow from the fourth column. Thus, 1 from 10 equals 1 (rule 4). The minuend in the fourth column is now 0, from the previous borrow. Therefore, a borrow is required from the fifth column, so that 1 from 10 in the forth column equals 1 (rule 4). Because of the previous borrow, the minuend in the fifth column is now 0 and the subtrahend is 0 (nonexistent), so that 0 from 0 equals 0 (rule 1). The 0 in the fifth column is not shown in the difference because it is not a significant bit. Thus, the difference between 1101, and 1101 is 1110. You can verify this by converting the binary number to a decimal number and subtracting. BINARY MULLTIPLICATION Multiplication is a short method of adding a number to itself as many times as it is specified by the multiplier. However, if you were to multiply 324 by 233 you would probably use the following method. Multiplicand Multiplier First partial product Second partial product Third partial product Carry Final product 324 223 ------------927 648 648 -------------0121 -------------72252
You multiply the multiplicand by each digit of the multiplier and then sum the partial products to obtain the final product. Note that, for convenience, the additive carries are set down under the partial products rather than over them as in normal addition. Binary multiplication follows the same general principles as decimal multiplication. However, with only two possible multiplier bits (1 or o), binary multiplication is a much simper process. The example below lists the rules of binary multiplication. These rules will be used to multiply 1111 by 1101. 1- 0 2- 0 3- 1 4- 1 0=0 1=0 0=0 1=1
205
multiplicand Multiplier
1111 1101 -------------First partial product 1111 Second partial product 0000 -------------Carry 0000 --------------Sum of partial products 1111 Third partial products 1111 --------------Carry 111100 Sum of partial product 1001011 Fourth partial product 1111 --------------Carry 1111000 --------------Final product 11000011 As with decimal multiplication, you multiply the multiplicand by each bit in the multiplier and add the partial sums. First you multiply 1111 by the least significant multiplier bit (1) and set down the partial product so the least significant bit (LSB) is under the multiplier bit. Then you multiply the multiplicand by the next multiplier bit (0) and set down the partial product so the LSB is under the multiplier bit. Now that there are two partial products, they should be added. Although it is possible to add more than two binary numbers, keeping track of multiple carries may become confusing.
BINARY DIVISION
Binary division is again similar to its decimal counterpart. _______ 101 11011 from now on statement 101b means 101 base 2 Here, the divisor is 101b or 5 decimal, while the dividend is 11011 b, or 27 decimal. The procedure is the same as that of decimal long division; here, the divisor 101b goes into the first three digits 110b of the dividend one time, so a 1 is written on the top line. This result is multiplied by the divisor, and subtracted from the first three digits of the dividend; the next digit (a 1) is included to obtain a new three-digit sequence. __1_____ 101 11011 - 101 -----011 The procedure is then repeated with the new sequence, continuing until the digits in the dividend have been exhausted:
206
101 ______ 101 11011 - 101 -----011 - 000 -----111 - 101 -----10 Thus, the quotient of 11011b divided by 101b, as shown on the top line, while the remainder, shown on the bottom line, is 10b. In decimal, 27 divided by 5 is 5, with a remainder of 2.
207
Figure C-1 Converting a Decimal Number to a Binary Number. Converting a Decimal Number a Hexadecimal Number To convert a Decimal number into its equivalent HEX, we successively divide by 16 and note the remainders. Thus the decimal number of 156 when divided by 16 gives 9 with remainder 12 and so in hex is 9C. As an example, lets convert decimal number 3380 into its equivalent of Hexadecimal number.
Figure C-2 Converting a Decimal Number to a Hexadecimal Number Converting a Decimal Number an Octal Number To convert a decimal number to Octal, we successively divide by 8 and note the remainders (as usual). Thus the decimal number 15 divided by 8 gives 1 with remainder 7 and thus the decimal number 15 is 17 in the OCTAL system. To convert from octal to decimal we multiply the digits by the power of 8 appropriate to its position in the number. For example, the octal number 365 is 3 8 2 + 6 8 1 + 5 8 0 = 245.
(c) Copyright PLC-DOC.COM 2004
208
Converting a Binary Number Hexadecimal number To convert binary numbers into hexadecimal numbers, we group the binary numbers into fours starting from the least significant number. Thus, for the binary number 001110100110 we have: 0011 1010 0110 Binary number 3 A 6 Hex number Converting Hex Number Binary number For conversion from hex to binary, each hex number is converted to its 4-bit equivalent. Thus, for the hex number 1D we have 0001 for the 1 and 1101 for the D: 1 D Hex number 0001 1101 Binary number
209
APPENDIX C
Figures appendix C-1 and C-2 display hard wiring diagrams of MicroLogix 1000 with Bulletin number 1761-L16BWA. This model consists of 10 Inputs-24 VDC, 6 Outputs-4 Isolated Relays / 2 shared Relays. This particular model comes with a 24-volt DC input interface with maximum of 10 field devices that provide a DC input signal to the PLC. This input signal can range from 0 VDC when the device is OFF to between 15 and 30 VDC when device is ON. A MicroLogix 1000 can have three different types of outputs: 1 Relay 2- Transistor 3 Triac. This particular model, has 6 relay outputs. Relay outputs are used in applications in which the PLCs output devices require a control signal of either 5-265 VAC or 5-125 VDC. The maximum current at each output is 2 A (amps) for both AC and DC devices.
Figure appendix C-1 In figure C-1 notice that all 6 output signal terminals are tied to 6 bulbs which use PLCs internal power supply for sourcing. Although, Allen Bradley recommends to use external DC power supply to source outputs, we did not include such an external power supply just for the sake of simplicity!!
(c) Copyright PLC-DOC.COM 2004
210
Figure appendix C-2 In figure C-2 notice that 4 output signal terminals are tied to four 120 VAC coils (which could represent some external contactors as an example). Notice the other ends of all coils are tied to N. In this way, anytime should any PLCs relay to be energized, the contact of that relay would be closed hence 120 VAC would be applied to the coil and it will be activated. Outputs O/4 and O5 terminals are not touched and still source the 24 VDC bulbs and they share common input terminals. Table C3 is a Job Aid to explain how to interpret the model number in different Micrologix models.
Bulletin NO. Base Unit I/O Count 16 32 Input Type A=120 VAC B = 24 VDC Output Type W = relays B = 24 VDC MOSFET transistor and relays A = 120/240 VAC triacs and relays Power Supply A = 120/240 B = 24 VDC
1761
Table C3
211
Therefore, the example model number shown above (1761-L16BWA) refers to 16 I/O MicroLogix 1000 with a 24 VDC input interface. And an output interface with 6 outputs 4 isolated relays / 2 shared relays with a 120 VAC power supply.
212
Bibliography
Book Name: INTRODUCTION TO PROGRAMMABLE LOGIC CONTROLLERS Written by: Gary Dunning Publisher: Delmar Publishers Inc.1998 ISBN: 0 8273 7866 1 Book Name: FUNDAMENTALS OF PROGAMMABLE LOGIC CONTROLLER, SENSORS, AND COMMUNICATIONS SECOND EDITION Written by: Jon Stenerson Publisher: Prentice Hall - 1993 ISBN: 0 13 746124 - 0 Book Name: Programmable Logic Controllers Principles and Applications -- Fourth Edition Written by: John W. Webb & Ronald A. Reis Publisher: Prentice Hall ISBN: 0 13 679408 4
213
214
DESCRIPTION: Length: 12 feet total Item specifies Control System & PLC Make: Clone adapter Model: S5 6ES5 734 1BD20 Product type: Adapter Condition: Brand New User price: USD $ 77.00 Programming with SIMATIC S7 300/400 Programming Controllers Author: PLC-DOC Binding: PDF (downloadable file) Product Group: Book Printing Date: 2009 Number of pages: 370 User price: USD $ 35.00 ISBN: 978-1-61584-002-1 DESCRIPTION: This E-book does a great job in describing the various tasks necessary to program SIMENS SIMATIC S7 300/400 series of PLC's. It is written for all users of SIMATIC S7 controllers. It describes elements and applications of the graphic oriented programming languages LDA, FBD and STL. There is also an introduction to configuration and parameter setting for the hardware by means
(c) Copyright PLC-DOC.COM 2004
of STEP 7 software enhanced by specific solution examples. The book also provides an introduction to Version 5.3 programming software STEP 7 and especially shows how the simulator which comes with the software can be used to simulate programs. The simulator coming with the STEP 7 package is a great tool for those users who are interested to workout sample programs and test the program coding with any hardware in hand. Programming Siemens S5 PLCs using IBHSoftec simulator software DESCRIPTION: Author: PLC-DOC Binding: PDF (downloadable file) Product Group: Book Printing Date: 2006 Number of pages: 211 User price: USD $ 35.00 ISBN:978-1-60585-730-5 DESCRIPTION: This Self-Teach Manual, features a systematic approach that enables readers with no prior knowledge of programmable logic controllers to gain a comprehensive understanding of what they are, how they work, and how they are programmed. Numerous solved examples are also introduced, making this book a very valuable reference for professional maintenance electricians and plant engineers. Fully updated, this book reflects use of personal computers and detailed programming information on Siemens S5 family of programmable logic controllers. Programming Siemens S5 series of PLCs using PG 2000 compiler software (Circuits and programs for Siemens S5 programmable controllers) Author: PLC-DOC Binding: PDF (downloadable file) Product Group: Book Printing Date: 2007 Number of pages: 211 User price: USD $ 35.00 ISBN: 978-1-60585-731-2
basic, intermediate problems in book1 and rework them out. 24 extra advanced application examples are also added to the book with all solutions. Hence, using the demo version of the software, you can download any problem solution into your PLC's memory and run it and investigate the functionality of the coding Programming Alley Bradley series of PLCs using RSLogix 500 software compiler
(Tutorial Circuits and Programs for Allen-Bradley Family of Programmable controllers)
A concise and thoroughly practical introduction to Programmable Logic Controllers. With many solved sample examples and explanation of the all solutions in full detail. Author: PLC-DOC Binding: PDF (downloadable file) Product Group: Book Printing Date: 2007 Number of pages: 211 User price: USD $ 35.00 ISBN: 978-1-60585-732-9 DESCRIPTION: The book provides both fundamental and cutting-edge coverage on PLCs. It explains most basic and intermediate to advance instructions through many worked-out examples and explanations of the solutions. Since this is a self-tech manual, it is assumed that reader may not have any access to a PLC instructor, to discuss any programming issues with. All the Ladder Logic Instructions are explained very clearly accompanied with very simple programs that actually are generated and RUN using RSLOGIX 500 software and tested on ALLEN BRADLEY MICROLOGIX 1500 PLC. Programming 4 types of PLC in 5 projects Tutorial circuits and programs for Siemens, Mitsubishi, Telemecanique and Sprecher + Schuh PLCs Author: PLC-DOC Binding: PDF (downloadable file) Product Group: Book Printing Date: 2010 Number of pages: 211 User price: USD $ 35.00 ISBN: DESCRIPTION: This book is developed to be an easy-to-understand introduction to the world of programmable logic controllers. Four of the top players in todays PLC market were chosen to be discussed and
(c) Copyright PLC-DOC.COM 2004
used for illustrations. We chose Siemens SIMATIC S5, Mitsubishi, Telemecanique, Mitsubishi and Spreacher + Schuh. The book was developed to be as generic as possible. The hands-on programming projects were developed for all these brands of PLCs. Hands-on programming projects are: Temperature controller system Conveyor Controller to transfer raw materials Designing an elevator controller system Automatic rising parking gate barrier Ceiling mounted hoist crane All these involved projects are completely worked and the user should be able to adapt the solution to any other PLC at hand. In this book, we designed five involved project, defined all phases and issues needed to be taken care of hardware and software wise and finally to come up with ladder logic program to control the PLC do the job. Hence, this book is actually developed for the electrical technician, maintenance person, machine design engineer, and students who need to learn the basics about todays modern PLCs. We Hope you find our product interesting!!
Household wiring circuits, diagrams and projects Author: PLC-DOC Binding: PDF (downloadable file) Product Group: Book Printing Date: 2010 Number of pages:59 User price: USD $ 35 ISBN: DESCRIPTION: If you are a homeowner or just a person who is interested to know how to design a simple electrical circuit or to know more about household wiring, then this book is prepared for you. Or sometimes, you might just need to add a wall socket receptacle or a motion detector to your household wiring system, in cases like this, you should have an idea how to do the wiring if you want to do it yourself. This book is prepared for a person who has basic knowledge about electrical circuits. All household wiring projects are completely worked and the user should be able to adapt the solution to his wiring system easily.