Title: Programming of a PLC to perform

advertisement
Title: Programming of a PLC to perform
basic input / output operations
I. Objectives
(a) Familiarization with the PLC simulator PSIM-2000
(b) Learning of simple input output instructions
(c) Development of ladder logic diagrams for basic programming of a PLC
II Theory
What is a PLC?
A PLC (i.e. Programmable Logic Controller) is a device that was invented to replace the
necessary sequential relay circuits for machine control. The PLC works by looking at its inputs
and depending upon their state, turning on/off its outputs. The user enters a program, usually
via software, that gives the desired results.
PLCs are used in many "real world" applications. Fields of industry such as machining,
packaging, material handling, automated assembly or countless other cases are greatly
benefited because of the PLCs’ presence. Almost any application that needs some type of
electrical control has a need for a plc. For example, let's assume that when a switch turns on,
we want to turn a solenoid on for 5 seconds and then turn it off regardless of how long the
switch is on for. We can do this with a simple external timer. But what if the process included 10
switches and solenoids? We would need 10 external timers. What if the process also needed to
count how many times the switches individually turned on? We need a lot of external counters.
As you can see the bigger the process the more of a need we have for a PLC. We can simply
program the PLC to count its inputs and turn the solenoids on for the specified time.
In the frame of our laboratory sessions you will take enough information to be able to write
programs far more complicated than the simple one above. Initially, we will take a look at what
is considered to be the "top" plc instructions. It can be safely estimated that with a firm
understanding of these instructions one can solve more than 80% of the applications in
1
existence. Of course we'll learn more than just these instructions so as to be able to solve
almost all our potential plc applications.
PLC Operation
A PLC works by continually scanning a program. We can think of this scan cycle as consisting
of 3 important steps (Fig. 1). There are typically more than 3 but we can focus on the important
parts and not worry about the others. Typically the others are checking the system and updating
the current internal counter and timer values.
Figure 1: The three steps of a scan cycle
Step 1-CHECK INPUT STATUS-First the PLC takes a look at each input to determine if it is on
or off. In other words, is the sensor connected to the first input on? How about the second
input? How about the third... It records this data into its memory to be used during the next step.
Step 2-EXECUTE PROGRAM-Next the PLC executes your program one instruction at a time.
Maybe your program said that if the first input was on then it should turn on the first output.
Since it already knows which inputs are on/off from the previous step it will be able to decide
whether the first output should be turned on based on the state of the first input. It will store the
execution results for use later during the next step.
Step 3-UPDATE OUTPUT STATUS-Finally the PLC updates the status of the outputs. It
updates the outputs based on which inputs were on during the first step and the results of
executing your program during the second step. Based on the example in step 2 it would now
turn on the first output because the first input was on and your program said to turn on the first
output when this condition is true.
After the third step the PLC goes back to step one and repeats the steps continuously. One
scan time is defined as the time it takes to execute the 3 steps listed above.
2
Basic Instructions
Now let's examine some of the basic instructions in greater detail to see more about what each
one does.
1.
XIC
The XIC (eXamine the input to see If its physically Closed) instruction is a normally open
contact. Sometimes it is also called load (LD) instruction. The symbol for an XIC instruction is
shown below
Figure 2: An XIC (contact) symbol
This is used when an input signal is needed to be present for the symbol to turn on. When the
physical input is on we can say that the instruction is True. We examine the input for an on
signal. If the input is physically on then the symbol is on. An on condition is also referred to as a
logic 1 state.
2. XIO
The XIO (eXamine the input to see If its physically Opened) instruction is a normally closed
contact. Sometimes it is also called LoaDNot (LDN) instruction. The symbol for an XIO
instruction is shown below
Figure 3: An XIO (normally closed contact) symbol
This is used when an input signal does not need to be present for the symbol to turn on. When
the physical input is off we can say that the instruction is True. We examine the input for an off
signal. If the input is physically off then the symbol is on. An off condition is also referred to as a
logic 0 state.
3. OTE
The OTE (OuTputEnergize) instruction is sometimes also called Out instruction. The output
instruction is like a relay coil. Its symbol looks as shown below.
Figure 4: An OTE (coil) symbol
3
When there is a path of True instructions preceding this on the ladder rung, it will also be True.
When the instruction is True it is physically On. We can think of this instruction as a normally
open output.
Ladder Logic Diagrams
The first PLCs were programmed with a technique known as Ladder Logic Diagrams. This was
based on relay logic wiring schematics which eliminated the need to teach the electricians,
technicians and engineers how to program a computer - but, this method has stuck and it is the
most common technique for programming PLCs today. The method is explained via the
following example:
Let's consider a real world physically connected relay circuit (Fig. 5).
Figure 5: A Simple circuit
A relay is a simple device that uses a magnetic field to control a switch, as pictured in Fig. 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. The
contact that closes when the coil is energized is called normally open. The normally closed
contacts touch when the input coil is not energized. Relays are normally drawn in schematic
form using a circle to represent the input coil.
In the above circuit, the coil will be energized when there is a closed loop between the + and terminals of the battery. We can simulate this same circuit with a ladder diagram. A ladder
diagram consists of individual rungs just like on a real ladder. Each rung must contain one or
more inputs and one or more outputs. The first instruction on a rung must always be an input
instruction and the last instruction on a rung should always be an output (or its equivalent).
4
Figure 6: Circuit converted to ladder diagram
Notice in this simple one rung ladder diagram we have recreated the external circuit above with
a ladder diagram. Here we used the XIC and OTE instructions. Some manufacturers require
that every ladder diagram include an END instruction on the last rung.
Generally, to interpret these diagrams imagine that the power is on the vertical line on the left
hand side which we call the hot rail. On the right hand side is the neutral rail. On each rung, we
may have combinations of inputs (two vertical lines) and outputs (circles). If the inputs are
opened or closed in the right combination the power can flow from the hot rail, through the
inputs, to power the outputs, and finally to the neutral rail. An input can come from a sensor,
switch, or any other type of sensor. An output will be some device outside the PLC that is
switched on or off, such as lights or motors.
III Experimental Work
The PLC simulator PSIM-2000
PSIM is actually three distinct programs combined into a single package. First, PSIM contains a
PLC Ladder Logic editor that allows users to create and edit PLC programs using a series of
PLC instructions. Secondly, PSIM emulates the scanning sequence of a PLC. When placed into
the "RUN" mode, the users program is scanned and the appropriate I/O is updated just as
would occur in an actual PLC. Thirdly, PSIM contains a number of animated simulations which
respond accurately to the inputs, and outputs of the emulated PLC. A conveyor based filling
line, Traffic intersection and Batch mixing simulations present life-like challenges for the student
programmer.
5
Getting Started:
From the Main Menu screen of the PSIM program, select the I/O simulation display. The
I/O (Input/Output) simulation screen shown below (Fig.7) should now be displayed on the
display.
Using The I/O simulator
The I/O simulator allows you to change the state of the switches connected to the Input Card of
our simple PLC. The windows in the centre of the display allow us to monitor the state of the
PLC's Data Table. Although all PLCs store this data as ones and zeros, our simulator
substitutes a period in place of any zero in order to make the display easier to read. In
Figure 7: The Input / Output Simulation screen
addition, we can have the simulator alternatively display this information in both decimal and
hexadecimal format by pressing the [F3] "Toggle Radix" function key.

[F1] Toggle Switch State
You can control the state of the switches connected to Input Card of our simple PLC by
pressing the F1 function key. To select which switch is to be toggled, first use the Up
and Down arrow keys on the keyboard to move the cursor focus to the desired switch.
6

[F2] Toggle Tables
When you first enter the I/O simulation, the upper data window displays the Output
image words of our simple PLC. The lower window displays the Input Image words. The
[F2] key allows you to display other areas of PLC's data table such as those areas used
by timers and counters etc. For this exercise however, we only wish to view the Input
and Output section of the Data Table. Each time you press this key another view of the
PLC's data table will be shown. If you keep pressing this key you will eventually return
to the original Input/Output display.

[F3] Toggle Radix
Pressing the Toggle Radix function key toggles between Binary and Decimal/
Hexadecimal display of Data Table information.

[F5] Rung Edit
Pressing this key takes you to the Ladder Rung Program Editor. We will use this shortly
to enter our first practice program.

[F6] Exit (Esc)
Pressing F6 or the Esc key will return you to the PSIM Main Menu display.
Entering The Rung Editor
From the I/O simulator screen select the Rung Edit function [F5] The Rung Editor Screen shown
below should now be displayed on your Computer.

The Editor is displaying a single rung which marks the end of the program. This rung is
present in every program and is included in the count of the program rungs. Thus an
empty program will still have a rung count of one.

Note the Function Key Menu along the Bottom of the screen. For most operations you
will be required to press the corresponding Function Key on your Keyboard in order to
invoke the specified operation which is described by this and other Function Key
Menus.
7
Entering a Rung
Ensure that you are in the Rung Editor
Enter the above program by following these steps:
Note

All keystrokes that you are required to enter are shown in square brackets [ ].

Ensure that the NumLock light is on if using the numeric keypad for numbers.
1. Insert a Rung into your empty program by pressing the F2 function key
2. Select the XIC (Examine-On) instruction by pressing F1.
3. Now enter the address of the first toggle switch by entering [ I 1 0 0 ] followed by
pressing the Return or Enter Key.
Note: The backspace key (the left arrow key above the Enter key) may be used to
delete incorrect entries prior to pressing Enter.
4. Next, press the F8 (Output Instructions) which will display a new menu at the bottom of
the screen.
5. Select the OTE (Output Energize) instruction by pressing the F1 function key.
6. Now enter the address of the first simulator Light. [ O 1 0 0 ] followed by the Enter key.
7. The rung should now be complete and a second rung will have been started. Exit from
the insert mode by pressing the F10 (Exit) key or the Esc key.
8. You can now test your program by exiting the editor (F10 or Esc). When you exit back
to the I/O simulation display the PLC is automatically placed in the RUN mode.
9. Toggle the switch several times and observe the operation of your program. Light 00
should light whenever switch 00 is true (closed).
8
Adding a Rung
From the I/O simulator screen select the Rung Edit function.
Modify your program by adding a second rung as shown above.
10. Append a second Rung to your program by pressing the F1 function key
11. Note: "Insert Rung" adds a rung above the rung the cursor is on.
12. "Append Rung" adds a rung below the rung the cursor is on.
13. Select the XIC instruction and enter the address [ I 1 0 1 ] followed by Enter.
14. Now press F1 again to enter the second XIC instruction and enter its address [ I 1 0 6]
followed by Enter.
15. Press the F8 function key to display the Output Instructions menu.
16. Select the OTE instruction and enter its address. [ O 1 0 1 ]
17. Finally exit the insert mode of the editor and then the editor itself by pressing the F10
twice in a row.
18. Test your program by toggling switch 01 and 06 to different states. Light 01 should light
only when both input 01 and 06 are true (closed).
9
A Branch within a Rung
From the I/O simulator screen select the Rung Edit function
Modify your program by adding the above rung to the Top of your program.
19. Using the arrow keys, move the cursor to the first rung of your program. Insert a Rung
above this first rung by pressing the Insert (above) rung key F2.
20. Press the Branch Start Key F3.
21. Press the XIC key and enter the address [ I 1 0 0 ].
22. Press F1 again to enter the second XIC instruction. Enter its address.[ I 1 0 2 ]
23. Press the F3 (Branch Start) key a second time. The cursor should now be on the
branch below the first XIC instruction.
24. Enter the 3rd XIC instruction and address. [ I 1 0 3 ]
25. Now press F4 (Branch Close) to complete the branch.
26. Select the output menu and enter the OTE instruction and address. [ O 1 0 2 ]
27. Return to the I/O simulator and test the operation of your program.
Saving and Retrieving a Program

From the I/O simulator screen select the Rung Edit function

While in the Rung-Editor we will use the Program Utility function to save and later
retrieve a program to and from the computer's Disk Drive.

Select the Program Utility function by pressing the F7 function key.
10

The Program Utility's function key Menu shown below (Fig.8), should now be displayed
at the bottom of your computer's screen.
Figure 8: The Program Utility's function key Menu
28. Press the [F1] function key to Save your program to Disk.
29. When you press the F1 key, the Disk activity light should illuminate briefly as the
computer writes your program to the disk. When complete the computer will then
replace the Program Utility Function Key Menu with the normal Menu.
30. If you missed seeing the activity light, enter the program utility again and repeat the
program save operation.
31. Press the F8 (Clear Memory) function key to erase your current program.
32. We have now erased the program from the memory of the computer. Our program
however is safe on the computer's Disk and we can retrieve it at will by using the Load
Program utility function.
33. Select the Program Utility function and then retrieve your program by pressing the F2
(Load Program) function key.
Modifying Instructions Within a Rung
Ensure that you are in the Rung Editor and your program is displayed on the computer's screen .
Using the arrow keys, ensure that the cursor is positioned on the first instruction of the
above rung.
11
34. With the cursor on the above rung, press the F3 (Modify Rung) function key.
35. You should now be in the Modify Rung mode and able to place the cursor over any of
the instructions on the selected rung using the left and right arrow keys. A new function
key Menu should be in place and the current instruction and its address as denoted by
the cursor should be displayed on the command line at the bottom of the screen.
36. Using the right arrow key, move the cursor to the XIC I:103 instruction located on the
lower branch of the rung.
37. Press the F1 (Insert Instruction) function key selection.
38. Press the XIC key and enter the address [ I 1 0 0 ].
39. Using the arrow keys, place the cursor over the OTE O:1/02 output instruction.
40. Press the F4 (Modify Instruction) function key.
41. Select the OTE instruction from the Output instructions menu and enter the new
address [ O 1 0 7 ].
Your program should now look like the following:
Now return to the I/O simulator and test the operation of your program.
12
Practice Exercises
Exercise 1:
a. Enter and test out the operation of the following program rung which
emulates the operation of a typical Stop/Start motor control circuit.
b. Toggle the switches by pressing F1 and fill up the table shown in Table 1,
indicating whether the output lamp is ON or OFF.
I: 104
I: 103
I: 100
Open
Open
Open
Open
Open
Closed
Open
Closed
Open
Open
Closed
Closed
Closed
Open
Open
Closed
Open
Closed
Closed
Closed
Open
Closed
Closed
Closed
O: 100
Table 1
c. Comment on the results obtained in Table 1
Exercise 2:
Add a rung which will turn on light O:101 whenever light O:100 is off. When you have
completed testing this new rung, keep a copy of the diagram for your report.
Exercise 3:
Add a rung which will turn on light O:102 whenever light 0:100 is on and switch I:105 is
momentarily pressed. Save your program and keep a copy of the diagram for your report.
13
Exercise 4:
Create, enter and test a program which will emulate the common wiring function of controlling a
single light from two different locations. Light O:100 should change state whenever switch I:100
or switch I:101 change state. List your program.
Exercise 5:
Create, enter and test a program that will turn on output O100, if inputs I100 I101, I106 and
I107 are on or input I102 is on. List your program
14
Download