Lab PLC 1
Lab PLC 1
Lab PLC 1
LAB1
LAB 1
Writing and Simulating a Basic Ladder Diagram & OR Logic, Latching and
Unlatching Output, One Shot Rising.
OBJECTIVES:
In this activity you will accomplish the following:
• Write and run a PLC program.
• Program with the input instruction XIC (eXamine If Closed).
• Program with the output instruction OTE (OutpuT Energize).
• Program with the input instruction XIO (eXamine If Open).
• Implement NOT logic in a ladder diagram.
• Implement AND logic in a ladder diagram.
• Load and modify an existing PLC program.
• Program a ladder diagram to control a Conveyor.
• Implement OR logic in a ladder diagram.
• Program with output instruction OTL (OutpuT Latch).
• Program with output instruction OTU (OutpuT Unlatch).
• Program with the OSR (One Shot Rising) input instruction.
• Program a ladder diagram to control a Gate.
• Program a ladder diagram to control a Ice Cream.
SKILLS
In this activity you will develop the following skills:
• Systems: understand systems.
• Resources: manage time.
• Information: acquire/evaluate information; uses computer to process information;
interprets/communicates information.
• Basic: reading.
• Thinking: knows how to learn.
• Personal: responsibility and self-management.
PLC Scan
A PLC can be programmed using a variety of methods and programming
techniques. You will use the ladder diagram programming language to program
your PLC. This programming technique is so named since the instructions in
the program are presented as rungs of a ladder. The instruction in each rung
presents the logic condition for activating certain outputs.
The format described by each rung is: IF. (condition), THEN (result). In ladder
1
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
diagrams, the conditions (inputs) are placed at the left side of the ladder, and
the results (outputs) at the right side. This enables you to read the instructions
as you would read any other text - from left to right.
The PLC's function is to continuously update inputs and outputs, apply that
update to the ladder diagram and then apply the effects of the inputs. This is
known as the PLC scan.
The PLC applies the effects of the inputs, or "solves" the ladder diagram, from
top to bottom, rung to rung. Only once it has read the entire ladder diagram
will it then return to the beginning. As inputs' states change, so will their output
coils. It is important to note, however that the effects of internal coils whose
contacts are located on a rung higher than the coil's location will not be read
until the next scan.
Next to the XIC instruction, the programmer must indicate a memory address.
The XIC instruction output will be true if the value of the address is true, and it
will be false if the value of the address is false.
When referring to an input device, the instruction will be true when the switch
in this device is closed and false when the switch is open.
Next to this instruction, the programmer must indicate a memory address. The
OTE instruction can be placed only on the right side of the ladder rungs and it
serves as the rung output.
The OTE instruction will be true if the conditions described on the rung are
met. The OTE instruction will be false if the conditions described on the rung
are not met. If the OTE instruction refers to an output address when the OTE is
true, the device will be activated.
Next to the XIO instruction, the programmer must indicate a memory address.
The XIO instruction will be true if the value of the address is false, and it will
be false if the value of the address is true.
When referring to an input device, the instruction will be true when the switch
2
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
AND Logic
Let say you need to control an elevator that automatically stop the motor when
the elevator is fully raised or lowered. The demands for the elevator control can
be summarized using the following logic variables.
In logic terminology, this is known as AND logic. This AND function has two
inputs and a single output. The output will be true only if both inputs are true.
If one input (or both) are false, the output will be false.
Figure 1-1
3
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
In Figure 1-1, the lamp will turn on only when there is a continuity of
electrical conductors from one pole of electric power supply through the lamp
to the other pole. As shown in Figure 1-1, the continuity is disturbed in switch
1 and in switch 2.
You will need a ladder diagram with two rungs to control the elevator system
(Figure 1-2). The first rung will control the raising of the elevator, the second
the lowering.
Figure 1-2
Here, you will program an XIC instruction (referred to as the down switch
address) in a series connection with an XIO instruction (referred to as the left
sensor address). The rung output will be an OTE that starts the motor, moving
the nut to the left.
4
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
Figure 1-3
PROCEDURES
In this task, you will run the PLC Editor module for the first time.
If a PLCMotion programs group has already been created on your desktop, click on
the PLC Editor icon.
You will use this module to program your first ladder diagram. You will then
simulate it using the PLC Simulator and HMI PLC Line modules.
5
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
Figure 1-4
The rung activation button is the small button at the left side of the rung. While
the Add Rung icon is active, clicking on any rung activation button will insert a
new and empty rung before the selected rung. Since the ladder diagram in this
activity will include only one rung, no additional empty rungs are needed and you
are ready to start placing instructions on the rung.
In the program you are writing, you will stipulate the logic value of the upper
6
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
switch with the logic condition of the solenoid. Both the switch and the solenoid
are logic variables whose values are kept in the PLC memory at a designated
address.
Figure 1-5
Click on the XIC (eXamine If Closed) instruction.
The XIC instruction is a normally open (NO) contact. An NO contact is open when
the input associated with it is off and closed when the input associated with it is on.
Figure 1-6
The XIC instruction appears, and the Object Properties dialog box opens
(Figure 1-7).
Figure 1-7
7
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
5. Using the Object Properties dialog box, set a variable address and comment for this
input contact:
• In the Address field, click on the I:0/0 keys from the on-screen keypad or type it
from your keyboard.
• In the Comment field, type SW_1.
The comment is not stored in the PLC memory and has no effect on the program.
The comment is used only as a reminder to the programmer for future use. The
PLC regards the variable only as I:0/0.
Figure 1-8
Figure 1-9
7. Then click on the OTE (OutpuT Energize) instruction.
An output coil, the OTE must be placed on the right side of the ladder diagram.
8. Click on the right side of rung 00 (note the cursor location in Figure 1-10).
8
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
Figure 1-10
The Object Properties dialog box opens again. Do the following from the
dialog box:
• In the Address field, click on the 0:0/0 keys from the on-screen keypad or type it
from the keyboard.
• In the Comment field, type Red_Lamp.
• Click OK to close the dialog box.
An OTE (output energize) instruction linked with the address O:0/0 is added to
the ladder diagram.
Your ladder diagram should look like Figure 1-11.
Figure 1-11
Prior to running the program you have just completed, the ladder diagram must be
saved, and then compiled and debugged (if necessary).
9
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
Figure 1-12
2. Save the file as LAB1, (where LAB1 is replaced by characters that identify either the
individual student or team; e.g., JFOX2, BLUE2).
Do not use a file name extension. PLCMotion adds the extension LAD
automatically to the file.
The Compile option checks for syntax errors in the ladder diagram.
The compiling action checks only whether you have made a syntax
error. If your ladder diagram is wrong but the ISM syntax is correct, an
error will not be detected until simulation or running of the program.
"X" appears, read the explanatory message at the bottom of the screen.
The erroneous position on the ladder diagram will be marked with a red
circle.
10
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
4. Exit PLC Editor by selecting File | Exit or by clicking on the Exit button in the upper-
right hand corner of the screen.
A dialog box opens asking whether you are sure you want to exit the application.
Click Yes.
Note: Skip this task if you did not find errors when compiling your program in
Task 4-4.
1. To remove an object:
11
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
• Click on the rung containing the erroneous instruction and click on the
instruction.
• In the open dialog box, add the instruction address and comment.
You will now open PLC Simulator and the HMI PLC Line to run and
simulate the program. Theoretically, you can keep PLC Editor open as
well, but it will put a great strain on your computer's memory.
Figure 1-13
1. From your desktop or Start menu, select HMI PLC Line to run PLC Simulator and the
HMI PLC Line modules.
2. Open the file LAB2, which you just wrote and saved in PLC Editor.
Maximize the ladder diagram window.
3. Make sure all three switches on the panel are off.
12
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
easier.
4. Click on the Add Rung icon and then click on the end rung's rung activation
button to add an empty rung to the ladder diagram.
An empty rung is inserted above the selected rung.
5. To program rung 01, do the following:
• Click on the Contact icon and then click on the XIO instruction.
This list is found at the lower right-hand side of the dialog box. Selecting an
item from this list will cause the address and the attached comment to appear
automatically in the fields.
Figure 1-14
The I/O List contains all variables defined during programming thus far. The
I/O List enables you to program faster and to reduce incidents of human error.
Click OK to close the dialog box.
13
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
Figure 1-15
6. Save the file as LAB1-2, (where LAB1-2 is replaced by characters that identify either
the individual student or team; e.g., JFOX2, BLUE2).
Do not use a file name extension. PLCMotion adds the extension LAD
automatically to the file.
14
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
• In rung 00, the object background is white. In this case, the XIC
(examine if closed) instruction examines whether the switch is closed.
The switch is open; therefore the rung output is false.
• In rung 01, the object background is green. Here, the XIO
(examine if open) instruction checks whether the switch is open.
It is; thus the rung output is true.
5. Click on the I:0/0 contact on rung 00.
You can activate HMI switches by clicking on their corresponding
memory address in the ladder diagram.
6. Click repeatedly on the I:0/0 contact.
Note: Changes in the background of O:0/1 and O:0/1 the state of the
HMI Red and Green Lamp.
7. Switch ON/OFF Switch 1.
8. Switch ON/OFF Switch 2.
Figure 1-16
Set its address to I:0/3 and the comment to SW_3.
• Click on the Coil icon and then click on the OTE instruction.
• Place the contact on the right-hand side of rung 00.
15
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
Continue creating your Ladder Diagram until your screen look like Figure
1-17 below.
Figure 1-17
16
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
EXERCISE A:
1. Write a PLC program for the HMI Conveyor below. Print the Ladder Diagram and
attach it together with Lab Report. (5 marks)
Figure 1-18
Hints:
1. The conveyor system above has 2 inputs.
a) I:0/0 is a switch to activate the conveyor motor O:0/0.
b) I:0/1 is a sensor that detects a reject product on the conveyor.
3. The solenoid cylinder will energize when sensor I:0/1 detect a reject product.
17
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
QUESTIONS:
1. Name 4 PLC brand available in the market world wide. (4 marks)
a) __________________________
b) __________________________
c) __________________________
d) __________________________
2. List down 2 (two) advantages and 2 (two) disadvantages of using PLC in controlling
a machine? (4 marks)
Advantage
a) __________________________________________________________________
__________________________________________________________________
b) __________________________________________________________________
__________________________________________________________________
Disadvantage
a) __________________________________________________________________
__________________________________________________________________
b) __________________________________________________________________
__________________________________________________________________
18
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
OR Logic
You will use HMI PLC LINE to conduct this activity. In this activity you will turn
ON the Green Lamp using either Switch 1 OR Switch 2.
In other words "IF either of the switches is on, then the Green Lamp is activated. This
is known as OR logic.
The logic function OR is achieved by connecting the contacts representing the logic
variables in a, Parallel connection. The Green Lamp will illuminate only if there is a
continuity of electric conductors from one pole of the electric power supply through
the lamp to the other pole. In Figure 1, continuity is achieved by closing either switch
1 or switch 2 (or closing both).
19
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
PROCEDURES:
20
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
8. Click on the Horizontal Line at the Rung 000 and another Relay of (I:0/1) at the
bottom of Relay (I:0/0) (Figure 2-4).
21
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
Note:
• Replace the OR Relay (previously I:0/1) with the Output Address (O:0/2).
• Add Normally Close (I:0/1) at Rung 00. It will act as STOP Switch.
22
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
The Output Latch (OTL) instruction appears in the ladder diagram as:
Next to this instruction the programmer must indicate a memory address.
When the logic conditions that precede the OTL instruction are true, the memory
address is latched. The output address will stay true even if the logic conditions that
precede the OTL instruction are false.
The Output Latch (OTL) instruction appears in the ladder diagram as:
Next to this instruction the programmer must indicate a memory address.
When the logic conditions that precede the OTU instruction are true, the memory
address is unlatched (it turns, false). The address will stay false even if the logic
condition that precedes the OTU instruction turn false.
The OTL and OTU instructions always come in pairs as both refer to the same address
in the PLC memory. The address controlled by the OTL and OTU instructions is
called the retentive address since it retains the last instruction issued to it.
When this pair of instructions is used in an industrial controller (that is usually backed
up by a long-life battery), the address value will be retained even in the case of a
power failure or prolonged stoppages.
Analogy
Consider an Automatic Gate (Figure 2-6)
gate is opened and closed by an electric motor that drives one of the gate's wheels.
The electric motor is controlled by two push button (PB) switches installed in the
gatekeeper's booth: Open and Close
23
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
The input/output relationship in this system differs from previous systems in two ways:
1. The output is activated when a defining logic condition is met, but it stays energized
even if this condition ceases to exist.
2. The output is activated when another logic condition is met.
To implement this control demand you will obviously need a new type of instruction.
The instruction should latch the motor address in energized position when the PB is
activated. This will guarantee that the output (motor) will stay on (latched) even when
the input (PB) is no longer activated. The latched address should then be unlatched by
the activation of the sensor.
24
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
PROCEDURES
25
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
The One Shot Rising (OSR) input instruction appears in the ladder diagram as:
Next to the OSR instruction, the programmer must indicate an internal memory address.
The OSR instruction cannot be the first (furthest to the left) instruction in a ladder
diagram.
• When the logic conditions that precede the OSR instruction turn from false to
true, the OSR output becomes true for a single PLC scan.
• In following scans, the OSR output turns false (even if the logic conditions that
precede it are still true).
• The OSR output will be true again (for a single PLC scan) only if the logic
conditions that precede it turn from false to true (thus it must first turn back from
true to false).
To understand the OSR instruction, you must first review the PLC working method.
When a PLC is running a program, the PLC scans successively (starting from rung 00)
the logic condition of every rung. After checking all the rungs, the PLC updates (if
necessary) the address indicated by the rung output. When the scanning and updating
process is completed, another cycle of scanning and updating is started. As you may
remember, this is known as the PLC scan.
The duration of each scanning and updating process is very short (a few
milliseconds). Cycle duration is dependent on the program size and controller type.
To better understand the function of the OSR instruction, you will first program the
ladder diagram without the OSR instruction. You will then add an OSR to clearly see
how it affects the stapling operation.
Analogy
26
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
To ensure quality stapling, the stapler and solenoid must retract immediately upon
the bending of the staple. If the solenoid retracts too early, the staple edges will
not be fully bent and the papers will not be securely attached to one another. If the
solenoid retracts too late, the staple edges will be crooked making the holes in the
paper to be less aesthetic.
The output in this control system is energized when a defined logic condition is
met. It stays energized until another logic condition is met, even if the initial
activating condition is still true.
To meet this requirement, the upper switch will latch the solenoid using an OTL
instruction; the limit switch sensor will unlatch it. You must still define how to
ensure that the logic condition that preceded the OTL instruction will turn false
before the limit switch is activated.
The problem will be solved using a new instruction named OSR - One Shot
Rising. OSR generates a short pulse upon activation of the instruction.
PROCEDURES
27
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
28
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
1. The OSR instruction requires an internal coil address. B3:0/0, which is an internal
memory bit, will serve as a "dummy" address. It won't play any role in the current
program.
2. Save this program under Lab2_5.LAD.
3. Compile the program.
29
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
EXERCISE B:
1. Write a PLC program for the HMI Gate below. Print the Ladder Diagram and attach it
together with this Lab Report. (5 marks)
The Gate HMI enables users to simulate ladder diagrams that control an entrance gate,
which is opened and closed by an electric motor that drives one of the gate's wheels.
The electric motor is controlled by two push button (PB) switches installed in the
gatekeeper's booth: OPEN PB and CLOSE PB.
30
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
2. Write a PLC program for the HMI Ice Cream below. Print the Ladder Diagram and
attach it together with this Lab Report. (5 marks)
The Ice Cream Filling Station HMI simulates the control of an ice cream filling
process.
31
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
DISCUSSION:
2. Why you must add a STOP switch in the Holding Relay Rung? (1 mark)
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
3. What is the advantage using the Latch and Unlatch command instead of Holding
Relay command? (1 mark)
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
4. Why the Latch and Unlatch must be in Pairs? Can the Unlatch command be several
Rungs below the Latch Rung? (2 marks)
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
5. What happen to the PLC programming if the Latch command does not has it pairs?
(1 mark)
_____________________________________________________________________
_____________________________________________________________________
____________________________________________________________________
7. Give one example of application that utilizing the OSR command? (1 marks)
_____________________________________________________________________
_____________________________________________________________________
____________________________________________________________________
32
EPT 352 - INSTRUMENTATION & CONTROL SYSTEM
LAB1
33