Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN =...

50
1 Indra Nisja

Transcript of Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN =...

Page 1: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

1

Indra Nisja

Page 2: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

2

Page 3: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

3

Page 4: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

4

Page 5: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

5

Page 6: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

6

Page 7: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

7

Page 8: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

8

Page 9: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

9

Page 10: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

10

EN = Enable bit

TT = Timing bit

DN = Done bit

Page 11: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

11

Page 12: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

12

Page 13: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

13

Page 14: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

14

Page 15: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

15

Page 16: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram
Page 17: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

Nonretentive Timer

A single input timer called a non-retentive timer is used in some PLCs.

Energizing IN001 caused the timer to run for 4 seconds.

At the end of 4 seconds the output goes on.

When the input is de-energized, the output goes off and

the timer resets to 0

If the input IN001 is turned off during the timing interval (for

example. After 2.7 seconds), the timer resets to 0.

Def. Nonretentive timer is timer that reset when de-energized

Page 18: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

The block format below includes the Enable/Reset line which allows

the timer to run when energized. When de-energized, the timer is kept

at 0 or reset to 0.

Page 19: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

• The upper line causes the timer to run when the timer is enabled.

• When enabled, the timer runs as long as the run input is

energized.

• If Run is de-energized while the timer is running, the timing stops

where it is and does not reset to 0

• If both IN001 (Run) and IN002, (Enable/Reset) open and close at

the same time, the timer function is the same manner as the

non-retentive timer.

For format (a), suppose that IN002 is closed and IN001 is turned

on. After 6 seconds, IN001 is opened. The timer retains a count

of 6. Timing has not reached preset value 0f 14 seconds, and

the timer output still off. The timer does not reset unless IN002 is

opened.

Suppose that sometime later IN001 is reclosed. After 8 more

seconds of IN001 being closed, the timer coil will energize, since

6 + 8 = 14.

Page 20: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

Format (b) is an alternate.

IN7 is for timing RT31 = RN.

IN8 enables RT31 = RS.

When the timer goes on, its output 31(internal) turns output 78 on.

A special case when the enable and reset are two separate input

rather than a common single input.

Page 21: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

Example 1:When the circuit is turned on, one action take place. A specified

time later, another action occurs.

Page 22: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

Example 2:A motor and its lubrication pump motor are both running.

Lubrication for main motor bearings is required during motor

coast-down. After the main motor is shut off, the lubricating pump

remains on for a time corresponding to coast-down. In this

example, a lubricating pump remains on for 20 seconds after the

main system is shut down.

Page 23: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

Example 3:Two inputs go on at the same time. Then, one of them is go to

off after the preset period of time. One output A stays on; the

other output B turns off at the end of the timing interval.

Resetting is accomplished by turning IN001 and IN002 off.

Single time

interval

Page 24: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

Example 4:A multiple application timing system. Three outputs turn on at

the same time. One stays on. Another, M shuts off after 8

seconds. The third output N, shuts off after 14 second.

Page 25: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

Example 5:A short voltage pulse is produced every 12 seconds. The timer is

initially turned on by its “time” input. After the timing interval, the

timer turns the output on. When the output goes on, one of its

contacts, TT013, immediately opens and resets the timer to 0.

When the timer is reset to

0, the output is turned off.

Then, since the timer is

also off, TT013 recloses,

restarting the cycle. The

pulsed on time is very

short, one can-scan cycle

time. The process repeats

itself continuously.

Page 26: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

Example 7:This example is for a timed interval of a number of seconds after

the start of a process operation. This type of time interval is

some time called an embedded time interval.

This operation uses the

special operation of a

fan. The fan is to come

on 8.7 seconds after a

system is turned on. It is

then to run until 16

seconds after the system

is turned on, which is a

net time of 7.3 second.

Page 27: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

27

Page 28: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

28

Page 29: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

29

Page 30: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

30

Page 31: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

31

Page 32: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram
Page 33: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

For the UC, the count starts at 0 and increments by 1

each time IN001 is pulsed on. When the preset value is

reached the output, CR17 goes on.

At the count goes

on beyond the

preset value, the

output stay on.

Opening IN002 at

any time resets the

counter to 0.

The DC operate in

the similar manner

Page 34: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

There are three input :

Page 35: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram
Page 36: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

May wish to stop the count for a time without it resetting to 0

and start counting again later where the count left on.

This is accomplished with the Enable and Reset inputs are

separate.

Page 37: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

Example 1: Straight Counting in Process.

The counter output goes on after the set count

is received by repetitive pulses to the counter

input.

Either counter will function if its Enable line

is energized. After the count input receives

18 pulses, the CR output will energize.

Page 38: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

Example 2: Two counters used with a common register to give

the sum of two counts

Suppose that we

wanted an output

indicator to go on

when 6 of part C

and 8 of part D

are on conveyor.

IN002 and IN003

are proximity

devices that

pulse on when a

part goes by

them.

Page 39: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram
Page 40: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram
Page 41: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

Example 4: A process where a timed interval is started when

a count reaches a preset value.

Page 42: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram
Page 43: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram
Page 44: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

44

Page 45: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

45

Page 46: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

46

Page 47: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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)

47

Page 48: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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)

48

Page 49: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

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

49

Page 50: Chapter 18 Fundamental PLC Programmingportal.unimap.edu.my/portal/page/portal30/Lecture... · EN = Enable bit TT = Timing bit ... Convert to BCD (TOD) ... Create the ladder diagram

Larger-Process Ladder Diagram Construction

Some of the steps in planning a program for a large process are:

1. Define the process to be controlled

2. Make a sketch of the process operation

3. Create a written step sequence listing for the process

4. Add sensors on the sketch as needed to carry out the control sequence

5. Add manual control as needed for process setup or operational checking

6. Consider the safety of the operating personnel and make addition and

adjustments as needed

7. Add master stop switches as required for safe shutdown

8. Create the ladder diagram that will be used as a basis for the PLC program

9. Consider the “what if’s” where the process sequence may go astray.