24
1 Chapter 19 Fundamental PLC Programming

1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

Embed Size (px)

Citation preview

Page 1: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

1

Chapter 19Fundamental PLC Programming

Page 2: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

2

PLC Program Execution• PLCs monitor input devices,

execute instructions, and update output devices sequentially during the processor scan cycle

• The steps of the scan cycle are:– Update the input image

– Reads the CPU for instructions

– Update the output terminals

Page 3: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

3

Ladder Diagram Programming Language

• The programming language most commonly used with programmable logic controllers is the ladder diagram

• Ladder diagram programming is built into the software of most PLCs

Page 4: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

4

Ladder Diagram Programming• Ladder logic language closely resembles hardwired relay

circuits• The symbols represent an instruction set that perform

various logic and on-off functions• There are five categories of instructions

– Relay Logic– Timers– Counters– Data Manipulation– Arithmetic

Page 5: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

5

Relay Logic Instructions• These are the most common instructions found in

PLCs• The relay logic instructions are:

– Examine On -| |-– Energize Output -( )-– Branching - used to implement parallel inputs– Examine Off -|/|-– Latch On Output -(L)-– Unlatch Output -(U)-

Page 6: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

6

Timer Instructions

• Timers are internal instructions to the PLC• Timers are activated by changes in the logic

continuity of the rung• Types of timers found are:

– Timer-On Delay– Timer-Off Delay– Retentive Timer-On Delay

Page 7: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

7

Timer Programming• A separate address file for

timers is provided in PLCs• File addresses begin at

T4:0• Once the address is

entered, the following characteristics are entered:– Time base– Preset value– Accumulated value

Page 8: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

8

Timer Words• Each timer in a PLC uses

three words to store data

• The second and third words store the preset and accumulated values

• The first word contains status bits related to time status

Page 9: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

9

Timer On-Delay• The Timer On-delay

begins timing when rung conditions go true

• When the accumulated value equals the preset value, the timer stops timing and the output is energized as bit 13 is set

Page 10: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

10

Timer On-Delay Application

Page 11: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

11

Timer Off-Delay

• When the condition of the rung goes false, the timer off-delay begins timing

• When the accumulated value equals the preset value, the output is energized

• When the rung goes true, the counter is reset to zero

Page 12: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

12

Retentive Timer-On Delay

• The accumulated value of a retentive time is held until a reset command is given, regardless of rung conditions

Page 13: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

13

Cascading Timers

• If the time valued needed exceeds the maximum value of a single timer, timers may be cascaded using the done bit of previous timers

Page 14: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

14

Counter Instructions

• Counters are output instructions internal to the PLC

• Counters are incremented or decremented by changes in the logic continuity of the rung

• Types of counters found are:– Up Counter– Down Counter

Page 15: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

15

Counter Programming

• A separate file is used for counter functions

• Counter instructions begin with the address C5:0

• The following information must be entered– Counter and address– Preset value– Accumulated value

Page 16: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

16

Counter Words

• Each counter in a PLC uses three words to store data

• The second and third words store the preset and accumulated values

• The first word contains status bits related to count status

Page 17: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

17

Up Counter Application

• The count-up instructions are useful for repeating processes

• The drilling application at the right makes use of an up counter which then activates a robotic arm

Page 18: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

18

The Down-Counter

• The down counter decrements with each false-true transition of the ladder rung

• The down counter is often used to end a cycle

Page 19: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

19

Data Manipulation Instructions• Data manipulation instructions allow words to be

moved within the PLC• Data manipulation instructions permit more complex

operations than relay type instructions• These instructions are divided into three categories:

– Data Transfer– Data Conversion– Data Compare

Page 20: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

20

Data Transfer Instructions

• Data Transfer Instructions are implemented by the move (MOV) instruction

• Contents from one register are moved to another based on rung conditions

Page 21: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

21

Data Conversion• Data conversion is available as:

– Convert to BCD (TOD)– Convert from BCD (FRD)

• Both are output instructions and convert data from or to binary coded decimal

• A typical application would be the implementation of BCD encoded thumbwheel switches to input data into a PLC

Page 22: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

22

Data Compare Instructions• These commands instruct the PLC to compare the numerical contents

of two registers and make decisions based upon their values and the results of the comparison

• Compare instructions:– Compare Equal (EQU)– Compare Not Equal (NEQ)– Compare Less Than LES)– Compare Less Than or Equal (LEQ)– Compare Greater (GRT)– Compare Greater Than or Equal (GEQ)

Page 23: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

23

Arithmetic Functions

• Most PLCs have the capability to carry out arithmetic operations

• The output of an arithmetic instruction is stored in a specified location

• Arithmetic functions available are:– Addition (ADD)– Subtraction (SUB)– Multiplication (MUL)– Division (DIV)

Page 24: 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices, execute instructions, and update output devices sequentially

24

Writing a Program

• Use the following steps when developing a PLC program:– Choose the sequence you want the I/O devices to operate in– Write a description and make a drawing showing the sequence and

conditions for each operation– Use the description to write the ladder diagram– Connect and label the I/O devices– Make a written record of each address used and what the address

represents. Document all counters, timers, data instructions, etc.– Enter the program into the PLC