Chapter 8

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 33

University of Gondar

Institute of technology
Electrical and Computer engineering
Industrial automation (ECEg5233)

By.Getachew. D
Chapter Eight
Math Instructions and Program Control Instructions

Outlines
 Program Control Instructions
 Manipulation Instruction
 Math Instructions
Program Control Instructions
 Several output-type instructions, which are often referred to as override
instructions, provide a means of executing sections of the control logic if certain
conditions are met.
 Program control instructions are used to enable or disable a block of logic
program or to move execution of a program from one place to another place.
 JMP (Jump to Label) —Jump forward/backward to a corresponding label
instruction.
 SBR (Subroutine) —Identifies the subroutine program.
 MCR (Master Control Reset) —Clears all set non retentive output rungs between
the paired MCR instructions.
 LBL (Label), JSR (Jump to Subroutine), RET (Return from Subroutine) and
other instructions
Master Control Reset Instruction
 A Master Control Reset (MCR) instruction is an output coil instruction that
functions like a master control relay.
 MCR coil instructions are used in pairs and can be programmed to control an
entire circuit or to control only selected rungs of a circuit.
 When the MCR instruction is false, or de-energized, all non retentive (non
latched) rungs below the MCR will be de-energized even if the programmed
logic for each rung is true.
Cont.…
Jump and Label Instructions
In PLC programming it is sometimes desirable to be able to jump over certain
program instructions when certain conditions exist.
When the jump instruction is used, the PLC will not execute the instructions of a
rung that is jumped.
LBL (Label): Specifies label location.
Cont.…
The operation of the program can be summarized as follows:
 When the switch is open the jump instruction is not activated.
 With the switch open, closing PB turns on all three pilot lights.
 When the switch is closed the jump (JMP) instruction will activate.
 With the switch closed, pressing PB turns on pilot lights PL1 and PL3 only.
 Rung 3 is skipped over during the PLC program scan so PL2 is not turned on.
Subroutine Functions
In addition to the main ladder logic program, PLC programs may also contain
additional program fi les known as subroutines.
A subroutine is a short program that is used by the main program to perform a
specific function.
Jump to Subroutine (JSR): The JSR instruction is an output instruction that causes
the scan to jump to the program file designated in the instruction.
It is the only parameter entered in the instruction. When rung conditions are true for
this output instruction, it causes the processor to jump to the targeted subroutine fi
le.
Return (RET): The RET instruction is an output instruction that marks the end of
the subroutine file.
It causes the scan to return to the main program at the instruction following the JSR
instruction where it exited the program.
Cont.…
Cont.…
Manipulation Instruction
Data manipulation instructions allow numerical data stored in the controller’s
memory to be operated on within the control program.
There are two basic classes of instructions to accomplish data manipulation:
instructions that operate on word data and those that operate on file, or block, data,
which involve multiple words.
The manipulation of entire words is an important feature of a programmable
controller. This feature enables PLCs to handle inputs and outputs containing
multiple bit configurations such as analog inputs and outputs.
Data Transfer Operations
Data transfer instructions simply involve the transfer of the contents from one word
or register to another.
Data transfer instructions can address almost any location in the memory.
The operation of the program can be summarized as follows:
 When the rung is true, input switch A closed, the value stored at the source
address, N7:30, is copied into the destination address, N7:20.
 When the rung goes false, input switch A opened, the destination address will
retain the value unless it is changed elsewhere in the program.
 The source value remains unchanged and no data conversion occurs.
 The instruction may be programmed with input conditions preceding it, or it may
be programmed unconditionally.
Data Compare Instructions
Data transfer operations are all output instructions, whereas data compare instructions are input
instructions.
Data compare instructions are used to compare numerical values.
These instructions compare the data stored in two or more words (or registers) and make decisions
based on the program instructions.
Data comparison concepts have already been used with the timer and counter instructions.
The compare instructions can be summarized as follows:
EQU (Equal): Tests whether two values are equal.
NEQ (Not Equal): Tests whether one value is not equal to a second value.
LES (Less Than): Tests whether one value is less than a second value.
GRT (Greater Than): Tests whether one value is greater than a second value.
LEQ (Less Than or Equal): Tests whether one value is less than or equal to a second value.
GEQ (Greater Than or Equal): Tests whether one value is greater than or equal to a second value.
All those instructions are input instructions
Cont.…
Cont.…
The operation of the rung can be summarized as follows:
 The instruction is either true or false, depending on the values being compared.
 When the accumulated value of timer T4:10, stored at the address of source A, is
greater than the constant 200 of source B, the output will be on; otherwise the
output will be off.
Math Instructions
 Math instructions, like data manipulation instructions enable the programmable
controller to take on more of the qualities of a conventional computer.
 The PLC’s math functions capability allows it to perform arithmetic functions on
values stored in memory words or registers.
 For example,
Assume you are using a counter to keep track of the number of parts manufactured,
and you would like to display how many more parts must be produced in order to
reach a certain quota. This display would require the data in the accumulated value
of the counter to be subtracted from the quota required.
Cont.…
The basic four mathematical functions performed by PLCs are:
 Addition: The capability to add one piece of data to another.
 Subtraction: The capability to subtract one piece of data from another.
 Multiplication: The capability to multiply one piece of data by another.
 Division: The capability to divide one piece of data by another.
Math instructions use the contents of two words or registers and perform the desired
function.
Addition Instruction
 Most math instructions take two input values, perform the specified arithmetic
function, and output the result to an assigned memory location.
For example,
The ADD instruction performs the addition of two values stored in the referenced memory
locations.
Cont.…
The operation of the logic rung can be summarized as follows:
 When input switch SW is closed the rung will be true.
 The value stored at the source A address, N7:0 (25), is added to the value
stored at the source B address, N7:1 (50).
 The answer (75) is stored at the destination address N7:2.
 Source A and source B can be either values or addresses that contain values,
but A and B cannot both be constants.
Cont.…
Cont.…
The operation of the program can be summarized as follows:
 Source A of the ADD instruction is addressed to store the accumulated value
of counter C5:0.
 Source B of the ADD instruction is addressed to store the accumulated value
of counter C5:1.
 The value at source A is added to the value at source B, and the result
(answer) is stored at destination address N7:1.
 Source A of the GEQ (greater than or equal) instruction is addressed to store
the value of the destination address N7:1.
 Source B of the GEQ instruction contains the constant value of 350.
 The GEQ instruction and PL1 output will be true whenever the accumulated
values in the two counters are equal to or greater than the constant value 350.
 A reset button is provided to reset the accumulated count of both counters to
zero.
Subtraction Instruction
 The SUB (subtract) instruction is an output instruction that subtracts one value
from another and stores the result in the destination address.
 When rung conditions are true, the subtract instruction subtracts source B from
source A and stores the result in the destination.
Cont.…
The operation of the logic rung can be summarized as follows:
 When input switch SW is closed the rung will be true.
 The value stored at the source B address, N7:05 (322), is subtracted from the
value stored at the source A address, N7:10 (520).
 The answer (198) is stored at the destination address, N7:20.
 Source A and source B can be either values or addresses that contain values,
but A and B cannot both be constants.
Vessel overfill alarm program
Cont.…
The operation of the program can be summarized as follows:
 When the start button is pressed, the fill solenoid (rung 1) and filling
indicating light (rung 2) are turned on and raw material is allowed to fl ow
into the vessel.
 The vessel has its weight monitored continuously by the PLC program (rung
3) as it fills.
 When the weight reaches 500lb, the fill solenoid is de-energized and the flow
is cut off.
 At the same time, the filling pilot light indicator is turned off and the full
pilot light indicator (rung 3) is turned on.
 Should the fill solenoid leak 5lb or more of raw material into the vessel, the
alarm (rung 5) will energize and stay energized until the overflow level is
reduced below the 5-lb overflow limit.
Multiplication Instruction
 The multiply (MUL) instruction is an output instruction that multiplies two
values and stores the result in the destination address.
Cont.…
The operation of the logic rung can be summarized as follows:
 When input switch SW is closed the rung will be true.
 The data in source A (constant 20) will be multiplied by the data in source B
(accumulated value of counter C5:10).
 The resultant answer is placed in the destination N7:2.
 Similar to previous math instructions, source A and B in multiplication
instructions can be values (constants) or addresses that contain values, but A and
B cannot both be constants.
Cont.…
Cont.…
The operation of the program can be summarized as follows:
 When input switch SW is closed the MUL instruction is executed.
 The value stored in source A, address N7:1 (123), is then multiplied by the value
stored in source B, address N7:2(61).
 The product (7503) is placed into destination word N7:3.
 As a result, the equal instruction becomes true, turning output PL1 on.
Division Instruction
 The divide (DIV) instruction divides the value in source A by the value in source
B and stores the result in the destination and math register.
Cont.…
The operation of the logic rung can be summarized as follows:
 When input switch SW is closed the rung will be true.
 The data in source A (the accumulated value of counter C5:10) is then divided by
the data in source B (the constant 2).
 The result is placed in the destination N7:3.
Q??
Thank you!!

You might also like