1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices,...

Post on 15-Jan-2016

227 views 0 download

Tags:

Transcript of 1 Chapter 19 Fundamental PLC Programming. 2 PLC Program Execution PLCs monitor input devices,...

1

Chapter 19Fundamental PLC Programming

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

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

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

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)-

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

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

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

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

10

Timer On-Delay Application

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

12

Retentive Timer-On Delay

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

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

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

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

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

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

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

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

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

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

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)

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)

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