Download as pdf or txt
Download as pdf or txt
You are on page 1of 38

PLC

Compare Functions
Arithmetic Functions
Data Handling Functions
COMPARE FUNCTIONS

‘Compare Byte’ is used to compare two OPERANDS

 EQUAL
 NOT EQUAL
 GREATER THAN OR EQUAL TO
 LESS THAN
 GREATER THAN
 LESS THAN OR EQUAL TO

Values to be compared are at IN1 & IN2. The O/P is 1 only if the
comparison is true
ARITHMETIC FUNCTIONS

Arithmetic Operations may also be performed using these blocks

 ADD

 SUBTRACT

 DIVIDE

 MULTIPLY

 INCREMENT

 DECREMENT
Here the O/P is on if the inputs A & B are both 1 And if the
comparison is true!
Value at IN1 is added to value at IN2 and the sum is obtained at OUT

Addition is possible only when signal at EN is 1


No errors occur during operation/addition complete  ENO = 1

Even if enable remains on nothing happens!


Same is the case if enable is turned off!
Value at IN2 is subtracted from value at IN1 and the result is obtained at OUT

Subtraction is possible only when signal at EN is 1


No errors occur during operation/subtraction is complete  ENO = 1

Even if enable remains on nothing happens!


Same is the case if enable is turned off!
Value at IN1 is multiplied to the value at IN2 and the product is obtained at OUT

Multiplication is possible only when signal at EN is 1


No errors occur during operation/multiplication is complete  ENO = 1

Even if enable remains on nothing happens!


Same is the case if enable is turned off!
Value at IN2 is divided by the value at IN1 and the result is obtained at OUT

Division is possible only when signal at EN is 1


No errors occur during operation/division is complete  ENO = 1

Even if enable remains on nothing happens!


Same is the case if enable is turned off!
Value at IN/OUT is incremented to the next value (higher value)

Increment is possible only when signal at EN is 1


No overflow errors occur during operation  ENO = 1

When EN=0 ; operation is not executed and ENO is reset


Value at IN/OUT is decremented to the next value (lower value)

Decrement is possible only when signal at EN is 1


No underflow errors occur during operation  ENO = 1

When EN=0 ; operation is not executed and ENO is reset


ADD or SUBTRACT – Do not operate continuously! Operation is performed
only when function is enabled.

Enable remains on / turned off  No change!

A repetitive clock is used!

Coil turns itself on & off at a very fast rate.

This is given as Enable to function blocks for continuous operation


The number whose square root needs to be determined is placed in
‘Source’
The result is placed in ‘Destination’

Source  2 Registers wide; Destination  1 Register wide

When the input is enabled mathematical operation takes place


A number of trigonometric & logarithmic functions may also be
performed

Source – Input is placed


Destination – Result obtained

An enable i/p causes the mathematical operation to be performed!


Average a file (AVE): Obtain the average of a series of numbers!

Negative (NEG): Obtain the negative of a specified input

Standard Deviation (STD): Obtain the Standard deviation for the


specified inputs

X to the power Y (XPY): Equation of this form may be solved!


SKIP – Allows us to SKIP/BYPASS a chosen portion of ladder sequence

The skipped elements remain in the state they were during the
previous scan! ( before skip was enabled)

Effectively branch to a different portion of the program!

Skip is also called ZCL (zone control last state)


This has 7 lines with o/p functions

A skip function is included in third line

When skip is off the seven functions operate


in a normal fashion (on/off)

If Skip is enabled
Lines 1,2,7,8 function normally!
Lines 4,5,6 are frozen / previous state
as long as skip remains enabled!

When skip is on, any change in IN004,


IN005, IN006 will not affect the o/ps of
that line!
Consider a production line system. The production line system has 8 stations
each of which can perform an assembly operation as each product comes
down the line. Depending on the individual part number, all eight operations
may or may not be set up & carried out. The pattern for this (operation
performing) is stored in registers. Each of the 8 stations may or may not be
set up depending on the register status
1 bit – Setup the station;0 bit – Do not set up the station

When a part arrives at the beginning of the conveyor a sensor detects the
presence of parts
At the third station an inspection takes place. If the part is good then it
continues down the operating line; if it is bad it is shunted to a side conveyor
& repaired. After repair the part re enters at the beginning of the conveyor.
As a part proceeds down the counter an
operation is performed (if set up) when
the part is detected by sensors at each
station

Sensors: IN0021-IN0028 ; Operations:


CR0061-CR0068

If a part is rejected at station 3, it is


shunted to repair.

When the repaired part re enters the


conveyor, setups of station 1-3 do not
have to be reset again. (prevented by
Skip)

Skip is enabled by a sensor at repair re


entry point & may be disabled ahead.
MCR – Master Control Relay / Master Control Reset

When enabled the ladder logic works normally!

If not enabled  Certain elements remain in the off


position/inactive position!

Even if individual enable lines are turned on the elements in the


frozen section remain off!
This has 7 lines with o/p functions

A MCR function is included in third line

When MCR is turned on the seven functions


operate in a normal fashion (on/off)

If MCR is disabled
Lines 1,2,7,8 function normally!
Lines 4,5,6 are turned off as long as
Master Control Relay remains disabled!

When MCR is off, any change in IN004,


IN005, IN006 will not affect the o/ps of
that line!
A production line similar to the previous problem (Skip function) is
considered

Operation of each station depends on the setup as specified by a


certain register

Each station’s operation is initiated by a proximity switch


IN0081 – IN0088

Production Line Layout & Product Flow are as shown


 Station 5 is an inspection station

 Rejected parts are shunted on to a conveyor & repaired

 After repair the parts re enter the conveyor.

When it re enters it turns on an input which turns on & seals an relay that
turns off MCR

The first five operations are now prevented by MCR

When the part gets to station relay is unsealed & MCR is turned on!
Part continues through stations 6,7 and 8
SKIP MCR

 Next specified section (frozen area)  Next specified section (frozen area)
stays in the previous scan state remains off!
(on/off)

 Skip is active when enabled!  MCR is active when disabled! i.e. when
enabled program occurs normally!

 Fail Safe!
Jump with Return
Jump with No - Return
A command that causes a sequence to go on / branch to a specified point
other than the next line in a program

Jump with non-return: Similar to skip – Leaps over a certain portion of the
main program when called upon to do so

Jump with return: Leaps to a subroutine when activated & on completing


the subroutine returns to the main program!

Advantages of Jump: Reduce scan time, programming effort, memory


space!
Allows to skip/branch to a different portion of the program (usually further
down)

The inputs of the skipped portion are never scanned & hence the outputs
remain frozen

Jump Operation: Program scan takes place from top – bottom. On


encountering ‘jump’ instruction scan leaps to jump destination & continues!

For a jump to take place, there must be


 A place to jump from (JMP)
 A place to jump to (LBL)

Note: Both JMP & LBL must have the same address!
 If i/p 121 is true (line 17), program jumps to LBL (line 22)
Lines 18-21 are not scanned hence O/Ps remain in their last state!
 If i/p is false, program continues to line 18!
It is possible to jump to the same location (LBL) from different locations
(JMP)

Program scan will jump from


either locations (when enabled)
by whichever JMP location
that is encountered first!
Often a process goes through repetitive sub processes

E.g. 10 identical time delays required in a certain program


Instead of writing the code 10 times it is better to write the code once & call
it as many times needed – Subroutine!

A group of instructions written separately from the main program to


perform a function that occurs repeatedly in the main program!
A Jump to Subroutine (JSR) consists of a call operation and a return
operation

If the rung containing JSR is true, a subroutine is called. Program scan


moves to subroutine (LBL)
The subroutine is located away from the main program
JSR & LBL have the same address

When subroutine is completed, an unconditional return to the main


program must take place! Return is always to rung following the JSR
When i/p 121 is true (line 22),
a jump to subroutine takes
place at LBL (line 107)

Lines 107 – 110  Not part of


the main program!

When RET is encountered,


subroutine returns to line 23!
Subroutines are also often nested!
Subroutine within a subroutine  Faster program operation!

You might also like