Use Arithmetic Operators And Functions - Allen-Bradley 1756 ControlLogix Instruction Manual

Logix 5000 controllers
Hide thumbs Also See for 1756 ControlLogix:
Table of Contents

Advertisement

Chapter 11
Overview of Structured Text Programming
Use arithmetic operators
and functions
Use this format
value1 operator value2
operator value1
function(numeric_expression)
value1 operator (function((value2+value3)/2)
640
You can combine multiple operators and functions in arithmetic expressions.
Operators calculate new values.
To
Add
Subtract/negate
Multiply
Exponent (x to the power of y)
Divide
Modulo-divide
Functions perform math operations. Specify a constant, a non-Boolean tag, or an
expression for the function.
For
Use this function
Absolute value
ABS (numeric_expression)
Arc cosine
ACOS (numeric_expression)
Arc sine
ASIN (numeric_expression)
Arc tangent
ATAN (numeric_expression)
Cosine
COS (numeric_expression)
Radians to degrees
DEG (numeric_expression)
Natural log
LN (numeric_expression)
Log base 10
LOG (numeric_expression)
Degrees to radians
RAD (numeric_expression)
Sine
SIN (numeric_expression)
Square root
SQRT (numeric_expression)
Tangent
TAN (numeric_expression)
Truncate
TRUNC (numeric_expression)
The table shows some examples.
Example
For this situation
If gain_4 and gain_4_adj are DINT tags and your specification says:
'Add 15 to gain_4 and store the result in gain_4_adj'"
If alarm and high_alarm are DINT tags and your specification says:
'Negate high_alarm and store the result in alarm.'
If overtravel and overtravel_POS are DINT tags and your specification says:
'Calculate the absolute value of overtravel and store the result in
overtravel_POS.'
If adjustment and position are DINT tags and sensor1 and sensor2 are REAL
tags and your specification says: 'Find the absolute value of the average of
sensor1 and sensor2, add the adjustment, and store the result in position.'
Rockwell Automation Publication MOTION-RM002H-EN-P-February 2018
Use this operator
Optimal data type
+
DINT, REAL
-
DINT, REAL
*
DINT, REAL
**
DINT, REAL
/
DINT, REAL
MOD
DINT, REAL
Write
gain_4_adj := gain_4+15;
alarm:= -high_alarm;
overtravel_POS := ABS(overtravel);
position := adjustment + ABS((sensor1
+
sensor2)/2);
Optimal data type
DINT, REAL
REAL
REAL
REAL
REAL
DINT, REAL
REAL
REAL
DINT, REAL
REAL
DINT, REAL
REAL
DINT, REAL

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents