[go: up one dir, main page]

0% found this document useful (0 votes)
133 views5 pages

PLC Arithmetic Operations

Uploaded by

usewaste69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
133 views5 pages

PLC Arithmetic Operations

Uploaded by

usewaste69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

ARITHMETIC OPERATIONS 2023-2024

PLC Arithmetic operations


 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. Other applications include combining parts
counted, subtracting detected defects, and calculating run rates.
 Depending on what type of processor is used, various math instructions can be
programmed. The basic four mathematical functions performed by PLCs are:
i. Addition: The capability to add one piece of data to another.
ii. Subtraction: The capability to subtract one piece of data from another.
iii. Multiplication: The capability to multiply one piece of data by another.
iv. Division: The capability to divide one piece of data by another.

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. The ADD
instruction used with the SLC 500 controllers. 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.

SLC 500 ADD instruction


 The program illustrates how the ADD instruction can be used to add the
accumulated counts of two up-counters.
 This application requires a pilot light to come on when the sum of the counts
from the two counters is equal to or greater than 350. The operation of the
program can be summarized as follows:
 Source A of the ADD instruction is addressed to the accumulated value of
counter C5:0.

ROBOTICS & ARTIFICIAL INTELLIGENCE BTI COLLEGE


ARITHMETIC OPERATIONS 2023-2024
 Source B of the ADD instruction is addressed to 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 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
sum of the values in the two counters is equal to or greater than the constant
value 350.
 A reset button is provided to reset the accumulated count of both counters to
zero.
 When performing math functions, care must be taken to ensure that values
remain in the range that the data table or file can store; otherwise, the overflow
bit will be set.
 The arithmetic status bits for the SLC 500 controller are found in word 0, bits 0
to 3 of the processor status file S2.
 After an instruction is executed, the arithmetic status bits in the status file are
updated.

Counter program that uses the ADD instruction

ROBOTICS & ARTIFICIAL INTELLIGENCE BTI COLLEGE


ARITHMETIC OPERATIONS 2023-2024
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.

 SUB instruction used with the SLC 500 controllers. 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


 The program shows how the SUB function can be used to indicate a vessel
overfills condition.
ROBOTICS & ARTIFICIAL INTELLIGENCE BTI COLLEGE
ARITHMETIC OPERATIONS 2023-2024
 This application requires an alarm to sound when a supply system leaks 5 lb
or more of raw material into the vessel after a preset weight of 500 lb has
been reached.
 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 flow into
the vessel.
 The vessel has its weight monitored continuously by the PLC program (rung
3) as it fills.
 When the weight reaches 500 lb, 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 5 lb 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.
 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.

 Source A and B in multiplication instructions can be values (constants) or


addresses that contain values, but A and B cannot both be constants.

MUL instruction used to calculate the product of two sources

ROBOTICS & ARTIFICIAL INTELLIGENCE BTI COLLEGE


ARITHMETIC OPERATIONS 2023-2024

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.
 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.
 If the remainder is 0.5 or greater, a roundup occurs in the integer destination.
 The value stored in the math register consists of the unrounded quotient and
the remainder.
 Some PLCs support the use of floating point numbers as well as integer
values. As an example, 10 divided by 3 may be expressed as 3.333333 or 3
with a remainder of 1.
 A minor fault bit is set upon detection of a division by zero.

DIV instruction used to calculate the value that results from dividing source A by
source B

ROBOTICS & ARTIFICIAL INTELLIGENCE BTI COLLEGE

You might also like