1 Publication 1747-RM001G-EN-P - November 2008
Chapter
4
Math Instructions
This chapter contains general information about math instructions and
explains how they function in your logic program. Each of the math
instructions includes information on:
• instruction symbol.
• instruction usage.
Table 4.1 Math Instructions
Instruction Purpose Page
Mnemonic Name
ADD Add Adds source A to source B and stores the result in the destination. 4-5
SUB Subtract Subtracts source B from source A and stores the result in the destination. 4-5
MUL Multiply Multiplies source A by source B and stores the result in the destination. 4-8
DIV Divide Divides source A by source B and stores the result in the destination and the
math register.
4-9
DDV Double Divide Divides the contents of the math register by the source and stores the result in
the destination and the math register.
4-11
CLR Clear Sets all bits of a word to zero. 4-12
SQR Square Root Calculates the square root of the source and places the integer result in the
destination.
4-12
SCP Scale with
Parameters
Produces a scaled output value that has a linear relationship between the input
and scaled values.
4-13
SCL Scale Data Multiplies the source by a specified rate, adds to an offset value, and stores
the result in the destination.
4-15
RMP Ramp Provides the ability to create linear, acceleration, deceleration, and “S” curve
ramp output data wave forms.
4-20
ABS Absolute Calculates the absolute value of the source and places the result in the
destination.
4-24
CPT Compute Evaluates an expression and stores the result in the destination. 4-25
SWP Swap Swaps the low and high bytes of a specified number of words in a bit, integer,
ASCII, or string file.
4-28
ASN Arc Sine Takes the arc sine of a number and stores the result (in radians) in the
destination.
4-29
ACS Arc Cosine Takes the arc cosine of a number and stores the result (in radians) in the
destination.
4-29
ATN Arc Tangent Takes the arc tangent of a number and stores the result (in radians) in the
destination.
4-30
COS Cosine Takes the cosine of a number and stores the result in the destination. 4-30
LN Natural Log Takes the natural log of the value in the source and stores it in the destination. 4-31
LOG Log to the Base 10 Takes the log base 10 of the value in the source and stores the result in the
destination.
4-31
SIN Sine Takes the sine of a number and stores the result in the destination. 4-32
TAN Tangent Takes the tangent of a number and stores the result in the destination. 4-32
XPY X to the Power of Y Raise a value to a power and stores the result in the destination. 4-33