Programming A Programmable Logic Controller
Programming A Programmable Logic Controller
PROGRAMMING A
PROGRAMMABLE LOGIC CONTROLLER
Note: The source of the technical material in this volume is the Professional
Engineering Development Program (PEDP) of Engineering Services.
Warning: The material contained in this document was developed for Saudi
Aramco and is intended for the exclusive use of Saudi Aramco’s employees.
Any material contained in this document which is not already in the public
domain may not be copied, reproduced, sold, given, or disclosed to third
parties, or otherwise used in whole, or in part, without the written permission
of the Vice President, Engineering Services, Saudi Aramco.
Section Page
PLC-5 Addressing................................................................................................... 39
Logical Addressing ............................................................................................ 39
I/O Addressing................................................................................................... 40
Relay Type Instructions .......................................................................................... 40
Examine If Closed Instruction (XIC)................................................................... 42
Examine If Open Instruction (XIO)..................................................................... 43
Output Energize Instruction (OTE) .................................................................... 43
Output Latch Instruction (OTL) .......................................................................... 44
Output Unlatch Instruction (OTU) ...................................................................... 44
PLC-5 Timer Instructions ........................................................................................ 44
Timer On-delay (TON)....................................................................................... 45
Timer Off-delay (TOF) ....................................................................................... 46
Timer Addressing .............................................................................................. 46
Retentive Timer On-delay (RTO)....................................................................... 47
Counter Instructions................................................................................................ 48
PLC-5 Counter Instructions ............................................................................... 48
Counter Addressing........................................................................................... 50
ENTERING AND TESTING A PLC LADDER LOGIC PROGRAM ............................... 51
Topdoc PLC-5 Programming Software ................................................................... 51
Entering a PLC-5 Program...................................................................................... 52
Testing The Entered Program................................................................................. 53
Program Emulation ................................................................................................. 53
GENERATING PROGRAM DOCUMENTATION.......................................................... 54
Ladder Report ......................................................................................................... 54
Annotated PLC Ladder Printout......................................................................... 55
Element Descriptors .......................................................................................... 56
Rung Comments................................................................................................ 58
Database Report..................................................................................................... 59
Address Report ....................................................................................................... 61
Narrative Describing Operational Sequence ........................................................... 63
Narrative For Simulation Program ..................................................................... 65
WORK AID 1: RESOURCES USED FOR GENERATING BINARY LOGIC
DIAGRAMS .................................................................................................................. 66
WORK AID 2: RESOURCES USED FOR GENERATING RELAY LADDER
DIAGRAMS .................................................................................................................. 67
WORK AID 3: RESOURCES USED TO GENERATE PLC LADDER
PROGRAMS ................................................................................................................ 68
WORK AID 4: RESOURCES USED FOR ENTERING AND TESTING A PLC
LADDER LOGIC PROGRAM ....................................................................................... 69
Work Aid 4A: Procedural Steps To Enter And Test The Program .......................... 69
Work Aid 4B: Addendum - Topdoc Program Development and
Documentation........................................................................................................ 70
LIST OF FIGURES
Hardware
• Personal Computer
• Programming Software
CPU
Communication
Interface Module
Personal
Computer
The personal computer (PC) is the physical device containing
the operating environment that allows the operation of the
programming software. The personal computer also provides
the physical housing for the communication interface module
and ports for connecting the PC to a printer. The printer is used
for printing the PLC program documentation.
• Processor type
• RAM capacity
• Monitor requirements
• Keyboard requirements
• Offline
• Online
• Printing reports.
Binary Concepts
The binary concept refers to the existence of only two states for
devices, ON or OFF, OPEN or CLOSED. For example, the
pushbutton, PB1, shown in Figure 2 has only 2 states; OPEN or
CLOSED.
PB1
Figure 2. Pushbutton
Positive Logic
In digital systems, the two states, 1 and 0, are represented by
distinct voltage levels. Within the PLC, a logic 1 is represented
by a high voltage of +5 Vdc and a logic 0 with a voltage of
0 Vdc. The use of +5 Vdc for a logic 1 and 0 Vdc for a logic 0 is
defined as positive logic. Figure 3 lists the logic states for
various digital devices used in industrial plants.
Negative Logic
The logic state 1 may also be defined as 0 Vdc and logic 0 as
+5 Vdc. This is referred to as negative logic. Both positive and
negative logic are equally valid. Under some conditions
negative logic may be more appropriate for a particular design.
Logic Functions
The binary concept illustrates the two-state relationship
between digital devices and the binary numbers 1 and 0. Digital
devices refer to devices that have only two positions. The
extension of the binary concept is to obtain the True or False
condition (or state) from the combination of two or more binary
variables. The Programmable Logic Controller uses the binary
concept when executing its control program.
• AND
• OR
• NOT
The logic operations combine binary variables to form
statements. Each of the functions, AND, OR, NOT, has a rule
that will determine the True or False state of the statement
output and a unique symbol to represent the operation. The
result of a function is defined as the output Y, and the variables
of the statement are defined as the inputs A, B, C, . . . . . n.
Both the inputs and the outputs are two-state binary variables.
AND Function
Figure 4 shows a series electrical circuit containing a voltage
source, two switches, and a pilot light. For the series circuit
shown, the pilot light will be ON only when both switches SW-A
and SW-B are closed.
+ SW-A SW-B
v Voltage
Source PL1 Pilot Light
_
A
AND Y
B
The inputs to the AND gate, A and B, shown in Figure 5, are the
switches SW-A and SW-B, and the output result is Y, PL-1
shown in Figure 4. For the AND function, the output Y is True
only if inputs A and B are True. Assigning 1 and 0 logic states
to the True and False statements respectively, the relationship
between the output Y and the input variables is stated as:
A B Y
0 0 0
1 0 0
0 1 0
1 1 1
Note that there is only one condition where the output of the
AND gate is True; when both inputs A and B are True.
OR Function
Figure 7 represents an electrical circuit containing a voltage
source, two switches connected in parallel, and a pilot light. For
the parallel switch combination shown, the pilot light will be on
when switch SW-A or SW-B or both are closed.
+ SW-A
v Voltage
Source Pilot Light PL1
_ SW-B
A
OR Y
B
Figure 8. OR Symbol
A B Y
0 0 0
1 0 1
0 1 1
1 1 1
Figure 9. Truth Table for 2-input OR Gate
NOT Function
The NOT function is an inverting function, often called the
compliment. The electrical circuit shown in Figure 10 is used to
illustrate the inverting or NOT function. Relay CR1 and its
normally closed contact CR1-1 are used to invert the action of
SW-A. When SW-A is open, relay CR1 is not energized. The
normally closed contact CR1-1 remains closed and pilot light
PL3 is on. When SW-A is closed, relay CR1 is energized and
the relay contact CR1-1 is now open. The pilot light PL3 is now
off.
+ -
SW-A
CR1
CR1-1
PL3
Pilot Light
Figure 10. Inverting Circuit
The logic symbol for the NOT function is shown in Figure 11.
The NOT function is also called a NOT gate. The output of the
NOT function is True if the input is False and the output is False
if the input is True. The NOT gate, unlike the AND and the OR
gates, has only one input and is often used with the AND gate
and the OR gate. In Figure 10 A represents SW-A. When SW-
A is open, logic input A is False. When input A is False, output
Y is True. Conversely, when input A is True, output Y is False.
A Y
AND or NOT
The truth table for the NOT gate is shown in Figure 12.
A Y
0 1
1 0
The fundamental logic elements are the AND, OR, and NOT
operations. Combinations of the AND, OR, and NOT gates are
interconnected to provide operating functions for control of
components and systems. Example 1 shows the relationship
between an electrical circuit and its corresponding logic
diagram.
Electrical Circuit -
Logic Diagram
Relationship
The electrical circuit shown in Figure 13 is used to provide an
interlock that is part of the controls for a discharge pump. If the
pump discharge pressure is not high, the PSH-1 contact
remains closed. The output, CR1, is energized when PB1 is
pressed. Once energized, relay CR1 is latched and remains
latched by the relay contact CR1-1.
L1 115 Vac L2
CB1
15A PB1
Reset High
PSH-1 Discharge
1 CR1 Pressure
Shutdown
CR1-1
2
For the logic diagram shown in Figure 14, the output, CR1, is
True when PB1 is True and the pressure is not high. When
PB1 is pressed, PB1 is changed from False to True making the
output of the OR gate become True. If the pressure is not high,
the output of the AND gate then becomes True. When the
output of the AND gate is True it provides a feedback path to
the OR gate. This feedback path enables the output of the OR
gate to remain True when PB1 is released.
PB1 OR CR1
Reset (NO) AND High Discharge
Pressure
PSH-1 Shutdown
Discharge
Pressure
High (NC)
Other Functions
NAND Function
The NAND function is a combination of the AND and NOT
function. The NAND, a shortened form of NOT-AND, is an AND
gate followed by an inverter. The NAND function with inputs A
and B will have an output that is the opposite of the
AND function. Figure 15 shows the NAND function. The
corresponding truth table is shown in Figure 16.
A
AND AND Y
B
The truth table for the NAND function is shown in Figure 16.
A B Y
0 0 1
1 0 1
0 1 1
1 1 0
NOR Function
The NOR function is a combination of the OR and NOT
function. The NOR, a shortened version of NOT-OR, is an OR
gate followed by an inverter. The NOR function with inputs A
and B will have an output that is the opposite of the OR
function. Figure 17 shows the NOR function.
A
OR AND Y
B
The truth table for the NOR function is shown in Figure 18.
A B Y
0 0 1
1 0 0
0 1 0
1 1 0
Exclusive OR
Function
The EXCLUSIVE OR function is used to eliminate the
indeterminate condition that exists with the OR circuit when both
inputs are true. The truth table for the OR circuit (Figure 9)
shows that output Y is True when inputs A and B or both A and
B are true. The exclusive OR eliminates this ambiguity. For the
Exclusive OR function the output Y is false when both inputs A
and B are true.
A Y1
B AND
OR Y
AND
Y2
A B Y
0 0 0
1 0 1
0 1 1
1 1 0
Boolean AND
Function
The Boolean equation, for the output Y related to the input
variable A and B, for the AND function shown graphically in
Figure 5 is written as:
Y = A • B or Y = AB
Y = AB.
Boolean OR
Function
The Boolean equation for the OR function shown in Figure 8 is
written:
Y =A+B
The plus sign (+) is used as the symbol for the OR operator.
Boolean NOT
Function
The Boolean equation for the NOT function shown in Figure 11
is written as:
Y=A
The bar written over the letter A is the sign for the invert
function.
The Boolean statement relates the input and the output data
with the use of the logic functions AND (•), OR (+) and INVERT
(__).
Logic Legend
LOGIC LEGEND
A F = 1 IF A = 1 AND B = 1 AND C = 1
B AND F
C F=ABC
A
F = 1 IF A = 1 OR B = 1 OR C = 1
B OR F
C F=A+B+C
F = 1 IF A = 0
A NOT F
F = 0 IF A = 1
MEMORY CIRCUIT
A S F = 1 IF A = 1 AND B = 0 THE OUTPUT
F
REMAINS SET AFTER A =0
B F' F = 0 IF B = 1
R F' = 1 IF F = 0
F' = 0 IF F = 1
S = SET OUTPUT F
R = RESET OUTPUT F
Saudi Aramco
Logic Diagrams
SAES-J-005, Section 5 states that logic diagrams should be
prepared as required. The prepared logic diagrams are then
used by the control equipment vendors to develop the control
system PLC program.
• P&ID
• System drawings
• Boolean equations
System
Description of
Operation
The system description defines the basic operation of a control
system, including interlocks and alarm conditions. Using the
functions defined in the system description the basic logic
functions are developed.
P&ID
Process and instrumentation drawings show how the input and
output devices are wired to the input and output modules. The
input and output drawing also shows the operational states of
the input and output devices and the associated software
memory address.
System Drawings
System drawings, including input and output drawings, show
how the input devices are wired to the input and output
modules. The input and output drawings also shows the
operational state of the input and output devices and the
associated software memory address.
The PLC addresses for the start and stop switches, transfer
pump status, and motor starter output are shown on input and
output drawing #422-I/O, Sheet 09 and the output controls on
drawing #422-I/O, Sheet 06.
Boolean
Equations
A logic diagram can be developed from a Boolean equation.
For example, if the Boolean equation for a specific operation is
given as:
X1
AND
X2
OR Y
X3
AND
X4
Electrical Ladder
Diagrams
The electrical ladder diagram, also referred to as a schematic
diagram or elementary diagram, is used show a circuit in its
simplest form. A ladder diagram shows how a circuit works and
the electrical relationship of the components (not the physical
relationship).
XSH1 XSH2
CR1
XSH3 XSH4
L1 115 Vac L2
CB1
15A PB1
RESET High
1-1 1-2 PSH-1 1-3 Discharge
1 CR1 Pressure
Shutdown
CR1-1
2, 5, 7
2
PB2
RESET
3-2 LSH-1
3-1 3-3 High Level
3 CR2 Shutdown
CR2-1 4, 5, 8
4 Input Devices
PB3
START PB4 CR1-2 CR2-2
5-2 Vacuum
5 M1 Pump
STOP Motor
M1-1 Starter
6
SV1
Output Devices
CR1-3
7-1 7-2 High
7 PL1
Wire Numbers Pressure
Shutdown
CR2-3
8-1 8-2
8 PL2 High Level
Shutdown
Power Rail
Line Numbers
Figure 24. Ladder Logic Diagram
Electrical Symbols
Light Indicating
R R=Red Solenoid Valve
G=Green
A=Amber
W=White
Power Rails
The control circuit receives its power from a 115 Vac source.
The rails are connected to terminals L1 and L2 and are fused
through a 15 Amp circuit breaker. The control circuit is powered
with 115 Vac only when the circuit breaker is closed. The
vertical line on each side of the control circuit represents the
conductors connected to the 115 Vac power source. The
vertical lines are called the power rails since they supply power
to the control circuit.
The numbers within each line, such as 1-1 and 1-2 in line 1,
indicate a wire number. This wire number will be attached to
each end of the wire used to make the electrical connection
shown in the diagram. For example, wire number 1-3 in line 1
identifies the wire that connects PSH-1 to relay output CR1.
The wire numbers help to locate the proper wire when
troubleshooting the system. They are also useful when making
alterations to the system.
Contact Symbology
CR1
CR1-1 CR1-3
CR1-2 CR1-4
Relay Contacts
SYMBOL DEFINITION
X1 Input-NO. Represents an input instruction. Used to represent a switch
or sensor input to the PLC or a contact from a PLC output instruction.
| |
The input-NO instruction is logically TRUE when the address
associated with the instruction (X1) contains a logic “1”.
X2 Input-NC. Represents an input instruction. Used to represent a switch
or sensor input to the PLC or a contact from a PLC output instruction.
|\|
The input-NC instruction is logically TRUE when the address
associated with the instruction (X2)contains a logic “0”.
Y0 Output. Represents an output instruction controlled by input or
combination logic. The output instruction may be an internal logic point
( )
or connected to an external device. The output instruction is set
logically TRUE when all of the preceding input instruction controlling
the output instruction are logically TRUE.
Figure 27. Basic Relay Instructions
The left and right vertical lines, illustrated in Figure 28, are the
left and right power rails. The PLC ladder diagram, although it
looks like an electrical ladder diagram, is actually a logic
diagram. The power rails in the PLC ladder diagram do not
represent power sources, but represent the starting and ending
points for the rungs of logic. The left rail is the starting point for
“logic flow”. That is, when the CPU solves a rung of logic it
starts at the left power rail and tests each instruction for a True
or False state, moving from left to right.
Output Instructions
X1 X2 X3
0 Y0
X4 X5 X6
Y1
1
X7 X8 X9
Y2
Rung Numbers
Figure 28. PLC Rung
Input Instructions
Input instructions form the conditional part of the rung. It is the
True or False state of the input instructions that determines the
True or False state of the output instructions. In rung 0, the
input instructions (labeled rung input conditions in Figure 28)
are X1, X2, and X3. Rung 1 illustrates a set of complex input
instructions, X4 through X9, terminated by two parallel output
instructions Y1 and Y2. Again, the input instructions form the
conditional part of the rung and the output instructions are the
result of the input conditions.
Output
Instructions
Output instructions are the controlled devices in the rung. If the
rung conditions preceding the output instruction are true, the
output instruction is true. All rungs must be terminated with an
output instruction. If input instructions X1, X2, and X3 are True,
then output Y0 is set True.
Summary
| CR1 |
| HIGH |
| DISCHARGE |
| PB1 PRESSURE |
| RESET PSH-1 SHUTDOWN |
| I:000 I:000 B003 |
++-----] [-----+-----]/[-----------------------------------------------( )-----+
|| 00 | 04 00 |
|| | |
|| CR1 | |
|| HIGH | |
|| DISCHARGE | |
|| PRESSURE | |
|| SHUTDOWN | |
|| B003 | |
|+-----] [-----+ |
| 00 |
| |
| CR2 |
| PB2 HIGH LEVEL |
| RESET LSH-1 SHUTDOWN |
| I:000 I:000 B003 |
++-----] [-----+ ----]/[-----------------------------------------------( )-----+
|| 01 | 05 01 |
|| | |
|| | |
|| | |
|| CR2 | |
|| HIGH LEVEL | |
|| SHUTDOWN | |
|| B003 | |
|+-----] [-----+ |
| 01 |
| CR1 |
| HIGH M1 |
| DISCHARGE CR2 VACUUM PUMP |
| PB3 PB4 PRESSURE HIGH LEVEL MOTOR |
| START STOP SHUTDOWN SHUTDOWN STARTER |
| I:000 I:000 B003 B003 O:001 |
++-----] [-----+-----] [-----------] [-----------] [-------------+-----( )-----+
|| 02 | 03 00 01 | 00 |
|| | | |
|| | | |
|| | | |
|| M1-1 | | |
|| VACUUM PUMP | | |
|| RUNNING | | SV1 |
|| I:000 | | O:001 |
|+-----] [-----+ +-----( )-----+
| 06 01 |
| |
| |
| DISCHARGE PL1 |
| PRESSURE HIGH PRESSURE|
| SHUTDOWN SHUTDOWN |
| B003 O:001 |
+-----]/[--------------------------------------------------------------( )-----+
| 00 02 |
| |
| |
| CR2 PL2 |
| HIGH LEVEL HIGH LEVEL |
| SHUTDOWN SHUTDOWN |
| B003 O:001 |
+-----]/[--------------------------------------------------------------( )-----+
| 01 03 |
| |
| |
PLC-5 Addressing
Each instruction has a reference number that is the memory
address location where the 1 or 0 status of the reference
memory address is stored. When the instruction is referenced
to a device wired to the PLC the 1 or 0 located at the memory
address is related to the OPEN or CLOSED state of the field
device. The relation between the input device and the memory
location is defined later in this module.
Logical
Addressing
When entering a logic program a method must be used to
address the different elements in the data files. Equation 1
provides a general format for data file addressing, where:
I/O Addressing
A special case of logical addressing is addressing words or bits
in an input/output file. The general format equation for
addressing I/O is defined in equation 2a and 2b.
where,
I: Input module
O: Output module
r: rack number
g: module group
When dealing with PLC ladder logic the ladder diagram can be
interpreted in the same manner as an electromechanical ladder
diagram. The PLC ladder diagram is, in effect, a logic diagram
that is drawn in a different format. As such, the symbols that
appear in the PLC ladder diagram are software instructions and
are interpreted as True or False rather than Open or Closed.
INSTRUCTION
ADDRESS
I1
OPCODE
Examine If Closed
Instruction (XIC)
The examine if closed instruction is an input instruction that has
a bit level address. The instruction is logically True if there is a
logic 1 at the data table address specified by the instruction.
The logic bit at the data table address has only two states, 0
and 1. The state of the data table bit is determined by the
device that is controlling the address specified by the
instruction. If the address is an input controlled by a device
wired at the PLC, than the status bit represents the open and
closed state of that device. If the device connected to the PLC
is closed, then a logic 1 is placed into the bit location by the
processor during its I/O update. If the switch is open, then a
logic zero is placed into the bit location.
|SS1 |
|AUTO-MANUAL |
|SELECTOR |
|SWITCH |
| |
| I:000 O:001 |
+----| |---------------------------------------------------( )--+
| 00 00 |
| |
| |
Examine If Open
Instruction (XIO)
The examine if open instruction is an input instruction that has a
bit level address. The instruction is logically True if there is a
logic 0 at the data table address specified by the instruction.
|XIO INSTRUCTION |
| |
| I:000 O:000 |
+------|/|------------------------------------------------( )--+
| 01 01 |
| |
| |
Output Energize
Instruction (OTE)
The output energize instruction (OTE) is an output instruction
that is controlled by the logic instructions preceding the Output
instruction.
Output Latch
Instruction (OTL)
When the rung conditions preceding the output latch instruction
are True, the output latch is set and a logic 1 is written into the
data table. The OTL instruction is retentive and remains True
when the rung conditions go False. The output will remain set
until reset by a corresponding output unlatch instruction.
Output Unlatch
Instruction (OTU)
The Output Unlatch instruction is used to reset the Output
Unlatch instruction. When the unlatch instruction is True it
resets the bit in the data table that was set by the latch
instruction.
| I:000 O:001 |
+--] [-------------------------------------------------------(L)--+
| 00 00 |
| I:000 O:001 |
+--] [-------------------------------------------------------(U)--+
| 01 00 |
The time base, TB, is the time period of the internal clock that is
used to increment the timer. For the PLC-5 the time bases
available are 1.0 and 0.01 seconds.
The preset number is the number of timed intervals that are to
be counted.
The accumulated value is the number of timed intervals that
have elapsed after the timer has been enabled. The
accumulated value shows the elapsed time for the timer after
the timer has been enabled.
Timer On-delay
(TON)
| |
| I:000 +- TON ----+ |
+-----] [-------------------------------------| T004:000 +(EN)+
| 04 | Base 1.0 | |
| | PR 10 +(DN)+
| | AC 0 | |
| +----------+ |
| |
| |
| |
| |
| T004:000 O:001 |
+----] [----------------------------------------------( )-----+
| DN 07 |
| |
| |
Timer Off-delay
(TOF)
| |
| I:000 +- TOF ----+ |
+-----] [-------------------------------------| T004:001 +(EN)+
| 05 | Base 1.0 | |
| | PR 10 +(DN)|
| | AC 0 | |
| +----------+ |
| |
| |
| T004:001 O:001 |
+----] [----------------------------------------------( )-----+
| DN 06 |
| |
| |
| |
When the accumulated value equals the preset value, the done
bit (DN) is set False, 0.
Timer Addressing
Timer instructions are addressed in accordance with equation 1.
Timer file T4 is the factory default for timers with timer elements
are 0 to 999 available. In Figure 36 the timer address is T4:000;
timer file 4, element 000.
Retentive Timer
On-delay (RTO)
The Retentive Timer On-delay functions in the same manner as
the Timer On-delay with the exception that the accumulated
value is retained when the command line is False. Each time
that the command line is True, the accumulated value is
incremented at the time base rate. When the command line is
False, the timer stops incrementing and the accumulated value
stays in its last position. When the command line again is True,
the accumulated value starts incrementing from the value that
existed when the command line went False.
The retentive timer On-delay instruction retains its accumulated
value even when rung conditions are False, the loss of AC
power, and the Mode select changed to the PROGRAM
position.
The Retentive timer reset (RES) is used to reset the
accumulated value to 000 and the done bit to 0. The reset
instruction has the same address as the corresponding RTO
instruction.
|I:000 T004:002|
+-] [-------------------------------------------------(RES)--+
| 04 |
|I:000 +- RTO ----+ |
+-] [----------------------------------------| T004:002 +(EN)+
| 05 | Base 1.0 | |
| | PR 15 +(DN)+
| | AC 0 | |
| +----------+ |
|T004:002 O:001|
+--] [---------------------------------------------------( )-+
| DN 05|
| |
For the circuit shown in Figure 37, when input instruction XIC
I:000/05 is True, the RTO timer T4:2 is enabled and the
accumulated value is incremented at 1 second intervals. When
the accumulated value is equal to the preset value (AC = PR)
the done bit, T4:002.DN is set True, enabling output instruction
O:001/05.
To clear the accumulated value and reset the done bit, input
instruction I:000/04 is made True.
Counter Instructions
Industrial processes use counting devices to determine
quantities of parts produced, control sequencing of processing
and procedures such as the clean in place process (CIP) used
in the pharmaceutical industry, or keeping track of the number
of cold starts for large horse power motors.
• Up counter (CTU)
PLC-5 Counter
Instructions
The Allen-Bradley counter instruction includes the UP counter
and the DOWN counter. All counter instructions require three
words for each counter element. The counter element includes
the following functions:
The done bit is a counter flag that is set True (logic 1) when the
accumulated value equals the preset value (AC = PR).
CTU
I:000/02 UP COUNTER
COMMAND LINE
EN
COUNTER: CF:XXX
PRESET: XXX
ACCUM: ddd DN
CF:XXX
I:000/03
RES
Counter
Addressing
Counter instructions are addressed in accordance with equation
1. Counter file C5 is the factory default file for counters. Within
each counter file the counter elements are 0 to 999. An
element is an addressing unit for a counter and contains three
words. A counter program with complete addressing is shown
in Figure 39.
| |
| PB-1 C-1 |
| COUNTER SYSTEM |
| RESET COUNTER |
| I:000 C005:000 |
+-----] [----------------------------------------------(RES)-----+
| 00 |
| |
| PROXSW-23 C-1 |
|COUNTER INPUT SYSTEM |
| COMMAND COUNTER |
| I:000 +- CTU ----+ |
+-----] [----------------------------------------| C005:000 +(CU)+
| 01 | PR 10 | |
| | AC 19 +(DN)|
| +----------+ |
| |
• System Startup
System startup is the procedure used to load the Topdoc
program stored in the personal computer.
• Offline Programming (Edit Mode)
Offline programming is used to enter and document PLC
programs. All editing and documentation is entered from
the offline mode. Configuration of a PLC program is part
of the offline programming process.
• Creating a PLC Ladder Program
After a new file has been created and configured, a PLC
program can be entered by using the program instructions.
• Program Annotation
Program annotation involves adding element descriptors
and rung comments to a ladder program. Rung comments
are used to provide a verbal description of the circuitry
associated with a given rung.
• Program Emulation
• Online Monitoring
• System Start-up
Program Emulation
• Ladder report
• Database report
• Address report
Ladder Report
Annotated PLC
Ladder Printout
Annotation is commentary added to the ladder program to
enhance the readability and understanding of the PLC program.
The PLC programming software has the capability to add
annotation in the form of element descriptions for PLC
instructions. The rung shown in Figure 41 with element
descriptions is shown in Figure 42.
Rung Comment
Element Descriptors
Rung
X
I1 I2 O1
Figure 41. Rung Comment
| |
| |
| CR_3C CR_3O |
| SS_1 PB_18 ZSO_FV3 CLOSE COMMAND OPEN COMMAND |
| MANUAL-AUTO OPEN FLOW FLOW VALVE VALVE FV-3 VALVE FV-3 |
| SELECTION VALVE FV-3 FV3 OPEN (MANUAL) (MANUAL) |
| I:020 I:001 I:001 B003 B003 |
+-----]/[---------] [---------] [----------]/[---------------( )-----+
| 01 | 10 | 11 05 04 |
| | | |
| | | |
| | CR_3O | |
| |OPEN COMMAND| |
| | VALVE FV-3 | |
| | (MANUAL) | |
| | B003 | |
| +-----] [----+ |
| 04 |
| |
Figure 42. Annotated PLC Rung
Element
Descriptors
An element description is a block of text associated with a
specific data table address. The element description, entered
with the programming software, includes a two line-13 character
per line parameter and tag name field, a five line-13 character
per line instruction field, and a 11 character drawing field line.
The programming software entry window is shown in Figures 43
and 44.
ENTRY WINDOW
O:000/00 PARAMETER
MS1 TAG NAME
| CR1 |
| HIGH |
| DISCHARGE |
| PB1 PRESSURE |
| RESET PSH-1 SHUTDOWN |
| I:000 I:000 B003 |
+------] [-----------] [---------------------------------( )-----+
|| 00 | 04 00 |
|| | |
|| CR1 | +------------LABEL INPUT------------+|
|| HIGH | |F9 to accept record ||
|| DISCHARGE | |ESC to abort current changes ||
|| PRESSURE | |-----------------------------------||
|| SHUTDOWN | | I:000/04 PARAMETER ||
|| B003 | | PSH-1 TAGNAME ||
|+-----] [----+ |-----------------------------------||
| 00 | PRESSURE XREF O/R ||
| | SWITCH HIGH <Y/N> <N> ||
| | ||
| | FLD DWG # ||
| | D-123 ||
| PB2 +-----------------------------------+|
| +------------LABEL INPUT------------+|
| |F9 to accept record ||
| |ESC to abort current changes ||
| |-----------------------------------||
| | I:000/04 PARAMETER ||
| | PSH-1 TAGNAME ||
| |-----------------------------------||
| | PRESSURE XREF O/R ||
| | SWITCH HIGH <Y/N> <N> ||
| | ||
| | FLD DWG # ||
| | D-123 ||
| +-----------------------------------+|
Rung Comments
A rung comment is a block of text associated with a specific
rung of ladder logic. Each comment may be several hundred
lines in length with up to 195 characters in each line. When the
ladder diagram is printed the rung comment is printed above the
specific rung associated with the rung comment.
Database Report
The database report lists the tag number, descriptor text, and
field drawing reference for the PLC addresses in the PLC
program. No cross reference information is included in this
report. This report could be considered as an I/O listing.
The procedure for the printing the address, table, usage, and
database reports can be found on page 27 of the Topdoc
Documentation in the Addendum.
A page from the database report for the simulator PLC program
is shown in Figure 46. The report lists input addresses I:001/00
to I:002/14 and the corresponding tag names, element
descriptor text, and the reference I/O drawing showing the field
and terminal block wiring.
Address Report
Four rungs from the PLC simulator program are shown in Figure
48. The narrative explaining the operation of the four rungs
follows Figure 48.
Narrative For
Simulation
Program
The four rungs shown in Figure 48 are used to simulate the
filling of tank TK-214 during the operation of the process. The
accumulated value of counter C5:2 is used to represent tank
TK-214 level, scaled to 0-100 per cent.
The first rung contains the control logic for incrementing the
counter, thus simulating the filling of the tank. When the batch
system is started (B3/48) is set True. Then, when the transfer
pump P-106 is started and input instruction I:020/14 is set True.
The counter is then incremented at the rate determined my
timer t4:0 (not shown). The timer flag, T4:0.DN is set True each
0.3 second so that the counter accumulated value will increment
by 1 each timer interval of 0.3 seconds or 3.33 counts each
second. The counter is incremented to a maximum value of
100 representing a tank level of 100 %.
The second rung contains the control logic for controlling the
tank level when the product loading pump is running. When the
product loading pump is running, the level in the tank is reduced
by one count or 1 per cent every 0.3 seconds.
LOGIC LEGEND
A F = 1 IF A = 1 AND B = 1 AND C = 1
B AND F
C F=ABC
A
B OR F F = 1 IF A = 1 OR B = 1 OR C = 1
C F=A+B+C
F = 1 IF A = 0
A NOT F
F = 0 IF A = 1
MEMORY CIRCUIT
A S F F = 1 IF A = 1 AND B = 0 THE OUTPUT
REMAINS SET AFTER A =0
B F' F = 0 IF B = 1
R F' = 1 IF F = 0
F' = 0 IF F = 1
S = SET OUTPUT F
R = RESET OUTPUT F
Electrical Symbols
Light Indicating
R R=Red Solenoid Valve
G=Green
A=Amber
W=White
Select the appropriate input instruction for each condition and the
appropriate output instruction for each action.
Rung Logic: Arrange input conditions on the left side of the rung.
Work Aid 4A: Procedural Steps To Enter And Test The Program
2. Create a new program file with the name “Lab 4”. Configure the program
for a PLC-2/20, station address 3, and 3 I/O racks.
The Participant will use the Addendum: Topdoc Program Development and
Documentation: Section - Generating Reports (Pages TD-5 to TD-25)
GLOSSARY
bit storage A user defined data table area in which bits can be
set or reset without directly affecting or controlling
output devices. However, any storage bit can be
monitored as necessary in the user program.
Exclusive OR gate A logic device requiring one or the other but not
both of its inputs to be satisfied before activating its
output.
industrial terminal The device used to enter and monitor the program
in a PLC.
truth table A table listing that shows the logic states for an
output device for all possible combinations of logic
states for the input devices.