PLC Basics
PLC Basics
Basics
Introduction:
This section will consist of information about basic concepts of Programmable
Logic Controllers, advantages of PLCs and their uses in industry. A PLC is a
component of a broader term control system. First we have a look at what is a
control system.
Power
Memory
Memory
There are various types of memory unit. It is the area that holds operating system
and user memory. The operating system is actually a system software that co-
ordinates the PLC. Ladder program, Timer and counter values are stored in the
user memory. Depending on the user’s need, various types of memory are
available for choice:
Scan Time
The process of reading the inputs, executing the program and updating the
outputs is known as scan. The scan time is normally a continuous and sequential
process of reading the status of inputs, evaluating the control logic and updating
outputs. Scan time specification indicates how fast the controller can react to the
field inputs and correctly solve the control logic.
Input devices
Intelligence of an automated system is greatly depending on the ability of a PLC
to read in the signal from various types of automated sensing and manual input
field devices.
Push button, keypad and toggle switches, which form the basic man-machine
interface, are types of manual input devices. On the other hand, for detection of
work piece, monitoring of moving mechanism, check on pressure and or liquid
level and many others, the PLC will have to tap the signal, from the specific
automated sensing devices like proximity switch, limit switch, photoelectric
sensor, and level sensor and so on. Types of input signal to the PLC would be of
ON/OFF logic or analog. These input signals are interfaced to PLC through
various types of PLC input module.
Output Devices
AN automatic system is incomplete and the PLC system is virtually paralyzed
without means of interface to the field output devices. Some of the most
commonly controlled devices are motors, solenoids, relay indicators, buzzers etc.
Through activation of motors and solenoids, the PLC can control from simple
pick and place system to a much complex servo positioning system. These type
of output devices are the mechanism of an auto mated system and so its direct
effect on the system performance.
However, other output devices such as pilot lamp, buzzers and alarms are merely
meant for notifying purpose. Like input signal interfacing, signal from output
devices are interfaced to the PLC through the wide range of PLC output module.
Basic Procedure
There are several basic steps involved in writing a program.
1. Obtain a list of all I/O devices and the I/O points that have been assigned to
them and prepare a table that shows the I/O bit allocated to each I/O device.
2. If you are using LR bits to link two PCs, prepare sheet showing the used of
these bits.
3. Determine what words are available for work bits and prepare a table in
which you can allocate these as you use them.
4. Also prepare tables of TC numbers and jump numbers so that you can allocate
these as you use them. Remember, the function of a TC number can
be defined only once within the program; jump numbers 01 through 99 can
be used only once each.
5. Draw the ladder diagram.
6. Input the program into the CPU Unit. When using the Programming Console,
this will involve converting the program to mnemonic form.
7. Check the program for syntax errors and correct these.
8. Execute the program to check for execution errors and correct these.
9. After the entire Control System has been installed and is ready for use,
execute the program and fine tune it if required.
Instruction Terminology
There are basically two types of instructions used in ladder-diagram
programming instructions that correspond to the conditions on the ladder
diagram and are used in instruction form only when converting a program to
mnemonic code and instructions that are used on the right side of the ladder
diagram and are executed according to the conditions on the instruction lines
leading to them.Most instructions have at least one or more operands associated
with them. Operands indicate or provide the data on which an instruction is to be
performed. These are sometimes input as the actual numeric values, but are
usually the addresses of data area words or bits that contain the data to be used.
For instance, a MOVE instruction that has IR 000 designated as the source
operand will move the contents of IR 000 to some other location. The other
location is also designated as an operand. A bit whose address is designated as
an operand is called an operand bit; a word whose address is designated as an
operand is called an operand word. If the actual value is entered as a constant, it
is preceded by # to indicate that it is not an address.
Basic Ladder Diagrams
A ladder diagram consists of one line running down the left side with lines
branching off to the right. The line on the left is called the bus bar; the branching
lines, instruction lines or rungs. Along the instruction lines are placed conditions
that lead to other instructions on the right side. The logical combinations of these
conditions determine when and how the instructions at the right are executed. A
ladder diagram is shown below.
As shown in the diagram above, instruction lines can branch apart and they can
join back together. The vertical pairs of lines are called conditions. Conditions
without diagonal lines through them are called normally open conditions and
correspond to a LOAD, AND, or OR instruction. The conditions with diagonal
lines through them are called normally closed conditions and correspond to a
LOAD NOT, AND NOT, or OR NOT instruction. The number above each
condition indicates the operand bit for the instruction. It is the status of the bit
associated with each condition that determines the execution condition for
following instructions. The way the operation of each of the instructions
corresponds to a condition is described below. Before we consider these,
however, there are some basic terms that must be explained.
Note When displaying ladder diagrams with the SSS, a second bus bar will be
shown on the right side of the ladder diagram and will be connected to all
instructions on the right side. This does not change the ladder-diagram program
in any functional sense. No conditions can be placed between the instructions on
the right side and the right bus bar, i.e., all instructions on the right must be
connected directly to the right bus bar.
Basic Terms Normally Open and Normally Closed Conditions
Each condition in a ladder diagram is either ON or OFF depending on the status
of the operand bit that has been assigned to it. A normally open condition is ON
if the operand bit is ON; OFF if the operand bit is OFF. A normally closed
condition is ON if the operand bit is OFF; OFF if the operand bit is ON.
Generally speaking, you use a normally open condition when you want
something to happen when a bit is ON, and a normally closed condition when
you want something to happen when a bit is OFF.
Execution Conditions
In ladder diagram programming, the logical combination of ON and OFF
conditions before an instruction determines the compound condition under which
the instruction is executed. This condition, which is either ON or OFF, is called
the execution condition for the instruction. All instructions other than LOAD
instructions have execution conditions.
Operand Bits
The operands designated for any of the ladder instructions can be any bit in the
IR, SR, HR, AR, LR, or TC areas. This means that the conditions in a ladder
diagram can be determined by I/O bits, flags, work bits, timers/counters, etc.
LOAD and OUTPUT instructions can also use TR area bits, but they do so only
in special applications.
Logic Blocks
The way that conditions correspond to what instructions is determined by the
relationship between the conditions within the instruction lines that connect
them. Any group of conditions that go together to create a logic result is called a
logic block. Although ladder diagrams can be written without actually analyzing
individual logic blocks, understanding logic blocks is necessary for efficient
programming and is essential when programs are to be input in mnemonic code.
Instruction Block
An instruction block consists of all the instructions that are interconnected
across the ladder diagram. One instruction block thus consists of all the
instructions between where you can draw a horizontal line across the ladder
diagram without intersecting any vertical lines and the next place where you can
draw the same type of horizontal line.
Mnemonic Code
The ladder diagram cannot be directly input into the PC via a Programming
Console; the SSS is required. To input from a Programming Console, it is
necessary to convert the ladder diagram to mnemonic code. The mnemonic code
provides exactly the same information as the ladder diagram, but in a form that
can be typed directly into the PC. Actually you can program directly in
mnemonic code, although it in not recommended for beginners or for complex
programs. Also, regardless of the Programming Device used, the program is
stored in memory in mnemonic form, making it important to understand
mnemonic code.
Program Memory Structure
The program is input into addresses in Program Memory. Addresses in Program
Memory are slightly different to those in other memory areas because each
address does not necessarily hold the same amount of data. Rather, each address
holds one instruction and all of the definers and operands (described in more
detail later) required for that instruction. Because some instructions require no
operands, while others require up to three operands, Program Memory addresses
can be from one to four words long.
Program Memory addresses start at 00000 and run until the capacity of Program
Memory has been exhausted. The first word at each address defines the
instruction.
Any definers used by the instruction are also contained in the first word.
Also, if an instruction requires only a single bit operand (with no definer), the bit
operand is also programmed on the same line as the instruction. The rest of the
words required by an instruction contain the operands that specify what data is
to be used. When converting to mnemonic code, all but ladder diagram
instructions are written in the same form, one word to a line, just as they appear
in the ladder diagram symbols. An example of mnemonic code is shown below.
The instructions used in it are described later in the manual.
The address and instruction columns of the mnemonic code table are filled in for
the instruction word only. For all other lines, the left two columns are left blank.
If the instruction requires no definer or bit operand, the operand column is left
blank for first line. It is a good idea to cross through any blank data column
spaces (for all instruction words that do not require data) so that the data column
can be quickly scanned to see if any addresses have been left out.
When programming, addresses are automatically displayed and do not have to be
input unless for some reason a different location is desired for the instruction.
When converting to mnemonic code, it is best to start at Program Memory
address 00000 unless there is a specific reason for starting elsewhere.
Ladder Instructions
The ladder instructions are those instructions that correspond to the conditions
on the ladder diagram. Ladder instructions, either independently or in
combination with the logic block instructions described next, form the execution
conditions upon which the execution of all other instructions are based.
When this is the only condition on the instruction line, the execution condition
for the instruction at the right is ON when the condition is ON. For the LOAD
instruction (i.e., a normally open condition), the execution condition would be
ON when IR 00000 was ON; for the LOAD NOT instruction (i.e., a normally
closed condition), it would be ON when 00000 was OFF.
AND and AND NOT
When two or more conditions lie in series on the same instruction line, the first
one corresponds to a LOAD or LOAD NOT instruction; and the rest of the
conditions, to AND or AND NOT instructions. The following example shows
three conditions which correspond in order from the left to a LOAD, an AND
NOT, and an AND instruction. Again, each of these instructions requires one
line of mnemonic code.
Address Instruction Operands
00000 LD 00000
00001 AND NOT 00100
00002 AND LR 0000
00003 Instruction
The instruction would have an ON execution condition only when all three
conditions are ON, i.e., when IR 00000 was ON, IR 00100 was OFF, and LR
0000 was ON.
AND instructions in series can be considered individually, with each taking the
logical AND of the execution condition (i.e., the total of all conditions up to that
point) and the status of the AND instruction’s operand bit. If both of these are
ON,
an ON execution condition will be produced for the next instruction. If either is
OFF, the result will also be OFF. The execution condition for the first AND
instruction in a series is the first condition on the instruction line.
Each AND NOT instruction in a series would take the logical AND between its
execution condition and the inverse of its operand bit.
OR and OR NOT
When two or more conditions lie on separate instruction lines running in parallel
and then joining together, the first condition corresponds to a LOAD or LOAD
NOT instruction; the rest of the conditions correspond to OR or OR NOT
instructions.
The following example shows three conditions which correspond in order
from the top to a LOAD NOT, an OR NOT, and an OR instruction. Again, each
of
these instructions requires one line of mnemonic code.
The instruction would have an ON execution condition when any one of the
three
conditions was ON, i.e., when IR 00000 was OFF, when IR 00100 was OFF, or
when LR 0000 was ON.
OR and OR NOT instructions can be considered individually, each taking the
logical OR between its execution condition and the status of the OR instruction’s
operand bit. If either one of these were ON, an ON execution condition would be
produced for the next instruction.
Here, an AND is taken between the status of IR 00000 and that of IR 00001 to
determine the execution condition for an OR with the status of IR 00200. The
result of this operation determines the execution condition for an AND with the
status of IR 00002, which in turn determines the execution condition for an AND
with the inverse (i.e., and AND NOT) of the status of IR 00003.
In more complicated diagrams, however, it is necessary to consider logic blocks
before an execution condition can be determined for the final instruction, and
that’s where AND LOAD and OR LOAD instructions are used. Before we
consider more complicated diagrams, however, we’ll look at the instructions
required to complete a simple “input-output” program.
If there is no END instruction anywhere in the program, the program will not be
executed at all. Now you have all of the instructions required to write simple
input-output programs. Before we finish with ladder diagram basic and go onto
inputting the program into the PC, let’s look at logic block instruction (AND
LOAD and OR LOAD), which are sometimes necessary even with simple
diagrams.
EXAMPLE#4
Machine for Packaging (For Mangos Packaging)
X =2 S T A R T
N O
I FI =2 O N
Y E S
O =0 O N
O =1 O F F
Y =0 B o x C Mo n) 1 v e y e r (
X = 1B o Sr e n s o r
N O
I FI =1 O N
Y E S Y =1 M a n g o e sM ) C 2 o n v e y e r (
O =0 O N
O =1 O N
I 0= O N
I N PC V
Y =1 M a nS g e o s eo sr
I FP =V S V
X =3 S T O PY E S
I FI =3 O N
N O E N D
Input/Output Address Declaration:
Inputs Outputs
INPUT OUTPUT
Address Description Address Description
I0 Start PB1 O0 Motor (M)
I1 Stop PB2 O1 Valve 1 (V1)
I2 Reset PB3 O2 Valve 2 (V2)
I3 Lower Level Switch (LLS) O3 End Light (L)
I4 Upper Level Switch (ULS) O4 Buzzer
Logic Flowchart:
AFTER FLOW CHART
Follow the procedure as shown in the Example # 1 for loading the Ladder Program & PT Screen.
In this program the CNT counter, LDF rising edge input, LD input & OUT output command are used.
S =V S e t V a l u e
P =V P r e s e n t V a l u e
S T A R T
X =0 S T A R T
I N PC V
I F
I =0 O N N O
I F
Y E S P =V F V
O = 0M
O =3 L I G H T
O = 1V 1 O , O0 1 Y E S
O N
Y E S O 3O N
I =4 U L S I F
I =4 O N
Y E S O 4O N
O = 0M
O = 1V 1 Y =4 B U Z Z E R
O , 0O 1O N
I F T I M E =
0 2V = 2 5 S E C N O
O 2O N
Y E S
I =3 L L S O 4O F F
I F
O 3O N
I =2 V 2 I 1O N
O 2O N X =1 S T O P
O 3O F F
I 3O N
X =2 R E S E T
E N D