Math - Advanced in Advanced Ladder

See also: Project Toolbox for Advanced Ladder

 

Topic Menu

 

Advanced Math in Horner OCS

Energy Monitoring Application: Cscape Example

The Advanced Math functions allow for math operations beyond the basic Multiplication/Division/Addition/Subtraction functions. Many times, these functions will result in an outcome that is a fraction of 1. Therefore, they are all (except the Scale function) only available on variables/registers in REALClosed These numbers use IEEE 754-1985 format to store numbers in following ranges. 32-bit single-precision floating point (REAL) – -3.40282E+38 to +3.40282E+38 64-bit double-precision floating point (LREAL) – -1.79769E+308 to +1.7976E+308 Floating Point refers to both REAL and LREAL data types. or LREALClosed These numbers use IEEE 754-1985 format to store numbers in following ranges. 32-bit single-precision floating point (REAL) – -3.40282E+38 to +3.40282E+38 64-bit double-precision floating point (LREAL) – -1.79769E+308 to +1.7976E+308 Floating Point refers to both REAL and LREAL data types. format.

Home > View > Project Toolbox > Math - Advanced

Power of X (Exponentiate)

This function will raise the first input value to the power of the second input value and place the result in an output variable.

  • IN1/IN2: Variables/registers or static numbers on which the operation will be done.

  • Q: A variable/register that will contain the result of the operation.

  • Type: This function will operate on either REAL or LREAL data types. All parameters must be of the same type.

Power Flow

The Power of X function executes immediately and entirely as soon as it receives power from the incoming rung. The resulting value in the Output (Q) is available for any other use immediately.

The Power of X function will execute on every scan that it has received power from the incoming rung. The Power of X function will always pass power flow to the next function on the rung unless the result overflows or underflows the data type it is configured for.

There is no need for any further functions to exist to the right of the Power of X function on the rung. The function’s result is considered an output.

Return to the Top: Math - Advanced in Advanced Ladder

Power of e

This function determines e (the base of natural logarithms) to the power of the input.

  • IN1: Variable/register or static number to the power of which e should be taken.

  • Q: A variable/register that will contain the result of the operation.

  • Type: This function will operate on either REAL or LREAL data types. All parameters must be of the same type.

Power Flow

The Power of e function executes immediately and entirely as soon as it receives power from the incoming rung. The resulting value in the Output (Q) is available for any other use immediately.

The Power of e function will execute on every scan that it has received power from the incoming rung. The Power of e function will always pass power flow to the next function on the rung unless the result overflows or underflows the data type it is configured for.

There is no need for any further functions to exist to the right of the Power of e function on the rung. The function’s result is considered an output.

Return to the Top: Math - Advanced in Advanced Ladder

Base 10 Logarithm

This function will determine the base 10 logarithm of the input and place the result in the output.

  • IN1: Variable/register or static number on which the operation will be done.

  • Q: A variable/register that will contain the result of the operation.

  • Type: This function will operate on either REAL or LREAL data types. All parameters must be of the same type.

Power Flow

The Log function executes immediately and entirely as soon as it receives power from the incoming rung. The resulting value in the Output (Q) is available for any other use immediately.

The Log function will execute on every scan that it has received power from the incoming rung. The Log function will always pass power flow to the next function on the rung unless the result overflows or underflows the data type it is configured for.

There is no need for any further functions to exist to the right of the Log function on the rung. The function’s result is considered an output.

Return to the Top: Math - Advanced in Advanced Ladder

Natural Logarithm

This function determines the Natural Logarithm of the input.

  • IN1: Variable/register or static number of which the Natural Logarithm is to be taken.

  • Q: A variable/register that will contain the result of the operation.

  • Type: This function will operate on either REAL or LREAL data types. All parameters must be of the same type.

Power Flow

The Natural Logarithm function executes immediately and entirely as soon as it receives power from the incoming rung. The resulting value in the Output (Q) is available for any other use immediately.

The Natural Logarithm function will execute on every scan that it has received power from the incoming rung. The Natural Logarithm function will always pass power flow to the next function on the rung unless the result overflows or underflows the data type it is configured for.

There is no need for any further functions to exist to the right of the Natural Logarithm function on the rung. The function’s result is considered an output.

Return to the Top: Math - Advanced in Advanced Ladder

Sine/Cosine/Tangent

These functions perform the respective trigonometric operation on the input assumed to be in Radians.

  • IN1: Variable/register or static number to which the function will be performed. The input value is assumed to be in Radians [LINK: DEG to RAD].

  • Q: A variable/register that will contain the result of the operation.

  • Type: This function will operate on either REAL or LREAL data types. All parameters must be of the same type.

Power Flow

The Trigonometric functions execute immediately and entirely as soon as they receive power from the incoming rung. The resulting value in the Output (Q) is available for any other use immediately.

The Trigonometric functions will execute on every scan that they have received power from the incoming rung. The Trigonometric functions will always pass power flow to the next function on the rung unless the result overflows or underflows the data type it is configured for.

There is no need for any further functions to exist to the right of the Trigonometric functions on the rung. The functions’ results are considered an output.

Return to the Top: Math - Advanced in Advanced Ladder

Inverse Sine/Inverse Cosine/Inverse Tangent

These functions perform the respective trigonometric operation on the input and produce a result in Radians.

Note: The inverse functions may also be notated as follows:


  • IN1: Variable/register or static number to which the function will be performed.

  • Q: A variable/register that will contain the result of the operation in Radians [LINK: RAD to DEG]

  • Type: This function will operate on either REAL or LREAL data types. All parameters must be of the same type.

Power Flow

The Trigonometric functions execute immediately and entirely as soon as they receive power from the incoming rung. The resulting value in the Output (Q) is available for any other use immediately.

The Trigonometric functions will execute on every scan that they have received power from the incoming rung. The Trigonometric functions will always pass power flow to the next function on the rung unless the result overflows or underflows the data type it is configured for.

There is no need for any further functions to exist to the right of the Trigonometric functions on the rung. The functions’ results are considered an output.

Return to the Top: Math - Advanced in Advanced Ladder

Convert to Radians

This function will convert a value assumed to be in Degrees to a value in Radians.

  • IN1: Variable/register or static number to which the function will be performed, assumed to be in Degrees

  • Q: A variable/register that will contain the result of the operation in Radians

  • Type: This function will operate on either REAL or LREAL data types. All parameters must be of the same type.

Power Flow

The Convert to Radians function will execute immediately and entirely as soon as it receives power from the incoming rung. The resulting value in the Output (Q) is available for any other use immediately.

The Convert to Radians function will execute on every scan that it has received power from the incoming rung. The Convert to Radians function will always pass power flow to the next function on the rung.

There is no need for any further functions to exist to the right of the Convert to Radians function on the rung. The function’s result is considered an output.

Return to the Top: Math - Advanced in Advanced Ladder

Convert to Degrees

This function will convert a value assumed to be in Radians to a value in Degrees.

  • IN1: Variable/register or static number to which the function will be performed, assumed to be in Radians

  • Q: A variable/register that will contain the result of the operation in Degrees

  • Type: This function will operate on either REAL or LREAL data types. All parameters must be of the same type.

Power Flow

The Convert to Degrees function will execute immediately and entirely as soon as it receives power from the incoming rung. The resulting value in the Output (Q) is available for any other use immediately.

The Convert to Degrees function will execute on every scan that it has received power from the incoming rung. The Convert to Degrees function will always pass power flow to the next function on the rung.

There is no need for any further functions to exist to the right of the Convert to Degrees function on the rung. The function’s result is considered an output.

Return to the Top: Math - Advanced in Advanced Ladder

Scale

The Scale function translates an input value with a linear range of values into an output value with a different linear range of values. It is useful to convert raw analog input values into readings or to convert settings into raw analog output values. It can be used to convert temperature scales or create setpoint ramping over time. The scale function allows use of INT type, as well as REAL and LREAL types. DINTClosed Double Integer - [Data Type DINT] - A 32-bit signed value. Double Integers are used where the value of the data is expected to be in the range of -2,147,483,648 to +2,147,483,647. is not supported; however, the result of a REAL or LREAL Scale operation may be converted to the DINT type. See also: Conversion in Advanced Ladder

Using the following graph as an example of what the Scale function does, if the Input were set for the Celsius scale and the Output for Fahrenheit; For an Input value of 100 (point 3 on the graph), the corresponding Fahrenheit value at that same point on the X axis would be determined as 212 on the Y axis.

  • IN1: A variable/register or static number to which the function will be performed

  • IN1 min: A value of the Input that will correspond to the Q min value. Static values may be used.

  • IN1 max: A value of the Input that will correspond to the Q max value. Static values may be used.

  • Q: A variable/register that will contain the result of the operation

  • Q min: A value of the Output that will correspond to the Input min value. Static values may be used.

  • Q max: A value of the Output that will correspond to the Input max value. Static values may be used.

  • Type: This function will operate on INT, REAL, or LREAL data types. All parameters must be of the same type.

Note: The min and max values do not limit the Scale function to only work within those ranges.

Note: If min > max on either the Input or the Output, the Output will be inversely linear to the Input.

Power Flow

The Scale function will execute immediately and entirely as soon as it receives power from the incoming rung. The resulting value in the Output (Q) is available for any other use immediately.

The Scale function will execute on every scan that it has received power from the incoming rung. The Scale function will always pass power flow to the next function on the rung unless the result overflows or underflows the data type selected.

There is no need for any further functions to exist to the right of the Scale function on the rung. The function’s result is considered an output.

Scale Examples

  1. Converting a 4-20mA or 0-10V input to a 0-100% reading:

  2. Converting a 4-20mA or 0-10V input to a Floating Point reading (using conversion operation: Conversion in Advanced Ladder).

  3. Converting Celsius to Fahrenheit / Fahrenheit to Celsius:

  4. Make a countdown timer from an incrementing timer accumulatorClosed A register/variable used to gather or accumulate a total of time, counts, items, or events.:

  5. Ramp a setpoint from 50 to 100 over the course of 10,000 seconds:

Return to the Top: Math - Advanced in Advanced Ladder