2. plc programmingelectronicsandinstrumentation.weebly.com/uploads/1/... · 2. plc programming...

14
2. PLC PROGRAMMING A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 1 PLC PROGRAMMING: A program consists of one or more instruction that accomplish a task. Programming a PLC is simply constructing a set of instructions. Programming languages can be classified as PROGRAMMING LANGUAGES Graphical language Text based language Ladder diagram Sequential functional chart Instruction list Structured text Functional block diagram LADDER DIAGRAM (ladder language): The ladder language is a symbolic instruction set that is used for programming a programmable logic controller. The ladder instruction symbols can be formatted to obtain the desired control logic. It seems a ladder with two power rails and one or more horizontal lines of elements called rungs. Fig: Ladder diagram Ladder diagram consists of the following three elements mainly: 1. Input contacts input contacts are Normally Open (NO) and Normally Closed (NC) 2. Output The output element is coil or latch 3. Rung Rung represents a condition of the input/output devices. A ladder logic diagram consists of one or more horizontal lines, called rungs. The rungs contain the input and output elements. In a ladder logic diagram, the input element is referred to as the contact and the output element is referred to as the coil.

Upload: others

Post on 05-Oct-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 2. PLC PROGRAMMINGelectronicsandinstrumentation.weebly.com/uploads/1/... · 2. PLC PROGRAMMING A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 2 RULES TO FOLLOW IN DRAWING LADDER

2. PLC PROGRAMMING

A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 1

PLC PROGRAMMING:

A program consists of one or more instruction that accomplish a task. Programming a PLC is simply

constructing a set of instructions. Programming languages can be classified as

PROGRAMMING LANGUAGES

Graphical language Text based language

Ladder diagram Sequential functional chart Instruction list Structured text

Functional block diagram

LADDER DIAGRAM (ladder language):

The ladder language is a symbolic instruction set that is used for programming a

programmable logic controller. The ladder instruction symbols can be formatted to obtain the desired

control logic. It seems a ladder with two power rails and one or more horizontal lines of elements

called rungs.

Fig: Ladder diagram

Ladder diagram consists of the following three elements mainly:

1. Input contacts – input contacts are Normally Open (NO) and Normally Closed (NC)

2. Output – The output element is coil or latch

3. Rung – Rung represents a condition of the input/output devices.

A ladder logic diagram consists of one or more horizontal lines, called rungs. The rungs

contain the input and output elements. In a ladder logic diagram, the input element is referred to as

the contact and the output element is referred to as the coil.

Page 2: 2. PLC PROGRAMMINGelectronicsandinstrumentation.weebly.com/uploads/1/... · 2. PLC PROGRAMMING A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 2 RULES TO FOLLOW IN DRAWING LADDER

2. PLC PROGRAMMING

A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 2

RULES TO FOLLOW IN DRAWING LADDER DIAGRAM:

A PLC programming format’s rules must be observed when programming a PLC ladder diagram.

Otherwise, the PLC CPU will not accept the ladder diagram into its memory.

Here are examples of such limitations for a typical PLC:

1. A contact must always be inserted in slot 1 in the upper left as shown in fig.

2. A coil must be inserted at the end of a rung.

3. All contacts must run horizontally. No vertically orientated contacts are allowed.

4. The number of contacts per matrix is limited. For example, 11 across by 7 down.

5. Only one output may be connected to a group of contacts.

6. Contacts must be “nested” properly.

7. Flow must be from left to right.

8. Contact progression should be straight across.

PLC INSTRUCTION SET:

A programming method that can be considered of entering ladder program using text is called

instruction list or statement list. Each instruction consists of an operator followed by one or more

operands. Mnemonic codes are used for operators, each code corresponding to an operator/ladder

element.

Mnemonic code

(IEC 1131-3)

Operation Similar instruction / task in ladder

diagram

LD Load operand into result register. Start a rung with open contacts.

LDN Load negative operand into result

register

Start a rung with closed contact.

AND Boolean AND Series elements with open contacts

ANDN Boolean AND with negative operand Series elements with closed contacts

OR Boolean OR Parallel element with open contacts

ORN Boolean OR with negative operand Parallel element with closed contacts

ST Store result register into operand AN output.

TIMERS:

All PLCs have timer instructions. Even though each manufacturer may represent timers differently

on the ladder diagram, most timers operate in the same manner.

A timer instruction has three important values associated with it:

1. The time base – The time base is the unit of time used by a timer to time an event

2. The preset value - The preset value of a timer works in conjunction with the time base by

specifying the number of times that the timer must count the time base

3. The accumulated value – The final value associated with a timer is the accumulated value.

Timers – T ON:

Inside the block is information about the timer’s address, time base, preset value, and

accumulated value. A timer ON-delay instruction energizes its done output after the timer block’s in-

Page 3: 2. PLC PROGRAMMINGelectronicsandinstrumentation.weebly.com/uploads/1/... · 2. PLC PROGRAMMING A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 2 RULES TO FOLLOW IN DRAWING LADDER

2. PLC PROGRAMMING

A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 3

put turns ON and a specified delay has occurred. Consequently, this instruction is sometimes called a

timer ON-delay energize instruction.

When the timer block’s input has logic continuity, the block’s enable output will turn on. As a

result, a 1 will be stored in bit 15 of the timer’s control word. Once the timer is enabled, it will start

to time. Thus, a 1 will be stored in bit 14, which is the timer timing bit.

As the timer times, the accumulated value increases until it equals the preset value. At that

point, the timer timing bit will become a 0, and the done bit will become a 1, meaning that the done

output will turn on. This done output is the timer’s delay action contact.

The timer-ON delay instruction’s enable output will remain on as long as the input logic to the

block remains energized. However, the timer will stop timing as soon as the accumulated value

equals the preset value. The timer’s input logic must turn off and then on again before the timer will

start timing again.

Fig. shows the operation of the same ladder diagram, using a timing diagram to keep track of when

the input and outputs turn on and off.

The ladder diagram operates like this:-

When the timer’s input turns on, it will cause the timer’s enable output to turn on.

When this happens, the timer will start timing, but the done output coil will remain off.

The time between the timer being energized and the done output being energized is the four-

second delay implemented by the timer.

Page 4: 2. PLC PROGRAMMINGelectronicsandinstrumentation.weebly.com/uploads/1/... · 2. PLC PROGRAMMING A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 2 RULES TO FOLLOW IN DRAWING LADDER

2. PLC PROGRAMMING

A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 4

TIMER T-OFF:

A timer OFF-delay instruction reenergizes its done output after the timer block’s input turns off and

a specified delay has occurred. Thus, the timer OFF-delay instruction is also called a timer OFF-

delay de-energize instruction.

This circuit works as follows:

• The done output will be OFF when the program is first started and the timer’s input is OFF.

Page 5: 2. PLC PROGRAMMINGelectronicsandinstrumentation.weebly.com/uploads/1/... · 2. PLC PROGRAMMING A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 2 RULES TO FOLLOW IN DRAWING LADDER

2. PLC PROGRAMMING

A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 5

• When the input logic turns ON, both the block’s en-able output and done output will turn ON.

• However, the timer will not start timing because it is waiting for an OFF signal instead of an

ON signal.

• When the block’s input turns OFF, the enable output will turn OFF and the timer will start

timing.

• The done output will stay on because it is waiting for the timer to time out before it will turn

OFF.

• Once the accumulated value equals the preset value, the timer will stop timing and the done

output will turn OFF, implementing the OFF-delay de-energize function.

Retentive Timer Instruction:

A retentive timer, however, can stop timing and then start timing again without its accumulated

value resetting to 0.

Figure 4-11 shows a retentive timer circuit and its timing diagram, which work as follows:

• When the input logic turns on, the enable output will turn on, and the timer will start timing.

• If the input logic turns OFF, the enable output will turn OFF, and the timer will stop timing.

• The accumulated value, however, will not reset to 0.

• When the timer starts timing again, it will pick up where it left OFF.

• When the accumulated value finally reaches the preset value, the done output will turn ON.

• Once a retentive timer has timed out, its done output will remain ON even if its input logic

and enable output turn OFF.

• A reset instruction must be used to turn the done output OFF and reset the timer’s

accumulated value.

Page 6: 2. PLC PROGRAMMINGelectronicsandinstrumentation.weebly.com/uploads/1/... · 2. PLC PROGRAMMING A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 2 RULES TO FOLLOW IN DRAWING LADDER

2. PLC PROGRAMMING

A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 6

COUNTERS:

Counter track the number of events that take place in a process. Common applications of

counters counting the number of finished products the number of defective parts.

Types of counters:

Up counters: UP counters count the number of events that take place and increment the counter

number by one each time the takes place.

An up count increases its accumulated value each time the up count event makes an OFF-to-ON

transition. When the accumulated value reaches, the preset value the counter turns ON the output.

Down counters: DOWN counters count the number of events that take place and decrement the

counted number of each time the event takes place.

A down count decreases its accumulated value each time the down count even makes an OFF-to-

ON transition.

ARITHMETIC and COMPARISION INSTRUCTIONS:

COMPARISION INSTRUCTIONS:

Data instructions are used to compare two values, stored in different words. The following are the

data comparison instruction are used to compare only.

Equal Instruction (EQU)

The equal instruction is an input instruction used to test whether two values are equal .the EQU

instruction is placed on the ladder rung as an input instruction and the two parameters source A

data and source B data are entered .source A is the address of the data to test for equality and

source B can be either a constant or a word address. When source A and source B are equal, the

instruction is true otherwise the instruction is false.

Page 7: 2. PLC PROGRAMMINGelectronicsandinstrumentation.weebly.com/uploads/1/... · 2. PLC PROGRAMMING A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 2 RULES TO FOLLOW IN DRAWING LADDER

2. PLC PROGRAMMING

A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 7

Not equal instruction (NEQ)

The not equal instruction is an input instruction used to test two values for inequality .the

instruction is true when the data stored in the address specified as source A is not equal to either

data stored in the address specified as source B or a constant entered in source B.

Less than Instruction (LES)

The less than instruction is an input is an input instruction used to test if one value (one source of

data) is less than other. The LES instruction is true when the data stored in the address specified as

source A is less than either the data stored in the address specified as source B or a constant

entered in source B. source A is the address of the data to test to see if it is less than source B .

LESS THAN or EQUAL INSTRUCTION (LEQ)

The LEQ instruction is an input instruction used to test whether source A value is less than or equal

to the value at source B the instruction will be true or else false.

Greater than instruction (GRT)

The greater than instruction is an input instruction used to test if one source of data is greater than

another source of data. The GRT instruction is true, when the data stored in the address specified

Page 8: 2. PLC PROGRAMMINGelectronicsandinstrumentation.weebly.com/uploads/1/... · 2. PLC PROGRAMMING A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 2 RULES TO FOLLOW IN DRAWING LADDER

2. PLC PROGRAMMING

A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 8

as source A is greater than either the data stored in the address specified as source B or a constant

entered in source B.

Greater than or equal to instruction (GEQ)

The GEQ instruction is used to determine or test if one source of data is greater than or equal to

another.

Limit test instruction (LIM)

The limit test instruction is used to test for values whether they are within or outside of the

specified ranges.

ARITHMETIC INSTRUCTIONS: Arithmetic instructions are used to perform a mathematical functions such as addition, subtraction, trigonometry forms etc. ADD INSTRUCTION (ADD):

The addition instructions are used to add the values stored in two referenced memory locations. The processor stores the sum of the values in the specified destination.

Page 9: 2. PLC PROGRAMMINGelectronicsandinstrumentation.weebly.com/uploads/1/... · 2. PLC PROGRAMMING A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 2 RULES TO FOLLOW IN DRAWING LADDER

2. PLC PROGRAMMING

A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 9

SUBTRACT INSTRUCTION (SUB):

The subtract (sub) instruction is used to subtract the values stored in two referenced memory locations as in addition instruction, if the rung is enabled & stores the result in destination memory address.

MULTIPLY INSTRUCTION (MUL):

A multiply instruction multiplies the values from two operands registers. If then uses the

other registers to hold the result of the multiplication.

DIVIDE INSTRUCTION (DIV):

A divide instruction performs the quotient calculation of two numbers, the result of division is

held in two result registers as referenced. The first result register generally holds the integer while

the second result register holds the decimal fraction.

DOL STARTER:

One method of starting electric motors is using direct on line (DOL) or across the line starter.

In this method full line voltage is applied to the motor terminals. This is simplest type of motor starter.

A DOL motor starter contains fuse and over load relay (OLR) for protection purpose. The starter

can be contain momentary contact or maintained contact push buttons. The example considered here

is momentary contact push buttons. For starting purpose normally open (NO) push button is preferred

whereas normally closed (NC) push button is used to stop the motor.

The excessive supply voltage drop causing high inrush current is the criteria to limit the use of

DOL starter. Conveyor motors, water pumps are the applications where DOL starters are used.

Page 10: 2. PLC PROGRAMMINGelectronicsandinstrumentation.weebly.com/uploads/1/... · 2. PLC PROGRAMMING A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 2 RULES TO FOLLOW IN DRAWING LADDER

2. PLC PROGRAMMING

A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 10

Procedure:

Problem Statement: To start a motor using DOL starter.

The simple P&I diagram for this problem is as below.

Listing of Input and Output devices:

Inputs: PB1- To start the motor

PB2- To stop the motor

Output: M1- Motor

Sequence of Events:

1. When Start push button (PB1) is pressed, Motor (M1) has to start.

2. If Start pushbutton (PB1) is released and Stop pushbutton (PB2) is not pressed, Motor (M1)

should remain on.

3. When Stop push button (PB2 is pressed, Motor (M1) has stop.

4. If stop push button is released and start is not pressed (released) motor should remain off.

Fig: Ladder program of DOL starter

STAR – DELTA STARTER:

This is a starting method that reduces the starting current and starting torque. The motor must

be delta connected during a normal run in order to reduce the supply voltage. When the motor speed

picks up, the two way switch is thrown to RUN position i.e.…, Star connection.

Page 11: 2. PLC PROGRAMMINGelectronicsandinstrumentation.weebly.com/uploads/1/... · 2. PLC PROGRAMMING A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 2 RULES TO FOLLOW IN DRAWING LADDER

2. PLC PROGRAMMING

A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 11

Rung 1 Main contactor: The main contactor depends upon the normally open input start push

button (I1), normally closed stop button (I2) and normally closed overload relay. It means that Main

contactor will only be energized if start button is pressed, while stop is not pressed and overload

relay is not activated. A normally open input named (Q1) is added in parallel to the start button

I1. By doing so, a push button is created which means that once motor is started, it will be kept

started even if start button is released

Programing of push button and other requirements for simple motor starter is explained in PLC

Tutorial: Motor starter

Rung 2 Star contactor: Star contactor depends upon main contactor, normally close contacts of

timer (T1), and normally close contacts of output delta contactor (Q3). So star contactor will only be

energized if main contactor is ON, time output is not activated and delta contactor is not energized.

Timer T1: Timer T1 measures the time after which the winding connection of star delta starter is to

be changed. It will start counting time after main contactor is energized.

Rung 3 Delta contactor: Delta contactor will be energized when main contactor (Q1) is energized,

timer T1 is activated and star contactor (Q3) is de-energized.

TRAFFIC LIGHT CONTROLLING:

Traffic light controlling a four way intersection is used below to demonstrate how the

sequencer output command is used in a program. Shown below is the ladder logic used for the

control and how the SQO command is setup. In this example the control of the traffic light will be

done using the SQO command. The Sequencer files will have the four states that the traffic light will

go through. TON timers will be used to initiate the stepping of the sequencer file. The two timers

will be set for 10 seconds and 3 seconds. Once the light goes through an entire cycle the process will

be reset and the SQO command will start back at step 1.

Page 12: 2. PLC PROGRAMMINGelectronicsandinstrumentation.weebly.com/uploads/1/... · 2. PLC PROGRAMMING A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 2 RULES TO FOLLOW IN DRAWING LADDER

2. PLC PROGRAMMING

A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 12

Ladder Logic:

The sequencer files were then set for the four steps of the light cycle as shown above. The first

sequencer file contains the outputs for the red light on the north south street and green light on the

east west street. The second file has the outputs set the north south street to red and the east west to

yellow. The third file sets the north south street to green and the east west to red. And the fourth file

sets the north south street to yellow and the east west street to red. Shown above is the mask in the

Binary file B10:5. This will allow the proper data to pass and block the unnecessary data. The

output diagram above shows an example of what would be happening in step one of the sequencer

output command when true. The sequencer transfers the file B10:1 to the output register O:2.0. The

red light for the North South direction is connected to O: 2/0 and the green light for the East West

direction is connected to O: 2/6.

Page 13: 2. PLC PROGRAMMINGelectronicsandinstrumentation.weebly.com/uploads/1/... · 2. PLC PROGRAMMING A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 2 RULES TO FOLLOW IN DRAWING LADDER

2. PLC PROGRAMMING

A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 13

CONVEYOR CONTROL:

The PLC operates in a synchronous way i.e. inputs does not change under a scan cycle. And

the below figure shows that when a box is placed on the conveyor in front of Photoeye 1, Light 1,

and Motor 1 will turn on, causing the box to move down the conveyor to the left. When the box

passes in front of Photoeye 2, Motor 1 and Light 1 will turn off, stopping the conveyor.

Fig: Conveyor System

The figure shows the program for the conveyor: The first line of code turns on the motor and

the light when a box is detected by photoeye1. Likewise, the motor and light are turned off when

photoeye2 detects the box in the second line of code.

Fig: Ladder Diagram for conveyor belt

The third line begins a timer when the box passes by photoeye1, and if the box does not pass by

photoeye2 in 30 seconds (the timer counts in milliseconds), the motor and light are shut off by line 4.

This is the indication of a jam condition.

Page 14: 2. PLC PROGRAMMINGelectronicsandinstrumentation.weebly.com/uploads/1/... · 2. PLC PROGRAMMING A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 2 RULES TO FOLLOW IN DRAWING LADDER

2. PLC PROGRAMMING

A.A.N.M & V.V.R.S.R POLYTECHNIC, GUDLAVALLERU Page 14