Formula options
Formulas allow mathematical pre-processing on all numeric, analog, and hex inputs, and post-processing on numeric and hex outputs on Modbus type I/O modules.
The tables below describe the options that are available to create a formula.
Formula reference
Formulas are developed using a stack calculator. The calculator mechanism uses postfix notation, a mathematical notation in which every operator follows all of its operands.
For example, to find the sum of 2 plus 2:
Infix Notation: 2 [+] 2 result 4
Postfix Notation: 2 [Ent] 2 [+] result 4
Controller Formula Screen: [constant value=] 2 [Ent] [constant value=] 2 [Add] result 4
Unless otherwise directed, the result of a formula calculation will be placed on the input or output pin invoking the formula.
Constants formulas
Formula | Description |
---|---|
Current Pin | Allows the use of the current value of the input invoking the formula. |
Input Pin |
Allows the use of the current value of an input pin other than the one invoking the formula. You are required enter the number of the input pin or, if a list box is available, to select the name of a configured and enabled input pin. In-line Parameters
Using the Reference Device field This field is used only if the following conditions are met:
If you selected a device from the Reference Device field, the parameter field is a list box with options are limited to the input pins configured for the selected reference device. You can select an appropriate input pin that works for your formula. If you didn't select a device from the Reference Device field, you must manually enter the an input pin number. |
Output Pin |
Allows the use of the current value of the output pin invoking the formula. You are required enter the number of the output pin or, if a list box is available, to select the name of a configured and enabled output pin. In-line Parameters
Using the Reference Device field This field is used only if the following conditions are met:
If you selected a device from the Reference Device field, the parameter field is a list box with options are limited to the output pins configured for the selected reference device. You can select an appropriate output pin that works for your formula. If you didn't select a device from the Reference Device field, you must manually enter the an output pin number. |
Constant Value |
Allows a user defined numeric value to be used in the formula. You are required to enter a numeric value. In-line Parameters
When a constant value has more than 9 decimal value precision, the full value is stored, but only a maximum of 9 places will be displayed back on return. After a constant value is defined within a formula, it is not updated unless the Update option is checked before clicking Save. |
PI |
The constant pi. |
Constant Hex Value |
Allows a user defined hex value to be used in the formula. You are required to enter the hex value. In-line Parameters
|
Correction |
Allows the use of the correction value that is defined for the input or output pin invoking the formula. |
Min Range | Allows the use of the minimum range value of the analog input invoking the formula. |
Max Range |
Allows the use of the maximum range value of the analog input pin invoking the formula. |
Min Units |
Allows the use of the minumum units value of the input or output pin invoking the formula. |
Max Units |
Allows the use of the maximum units value of the input or output pin invoking the formula. |
Calculate Values formulas
Formula | Description |
---|---|
[Max-Min] Range |
Allows the use of the value of the difference between the Max Range and Min Range of the analog input pin invoking the formula. |
[Max-Min] Units |
Allows the use of the value of the difference between the Max Units and Min Units of the input or output pin invoking the formula. |
Fn Voltage to NTC10K Temperature |
An NTC10K sensor must be configured with an appropriate pull-up resistor to create a 0-5V DC input and temperature in degrees Celcius will be calculated. Suggested pull-up resistor values are 370K for 24VDC power and 140K for 12VDC. Three values must be pushed on the stack. Stack Parameters
In-line Parameters
|
Fn Samples Sum |
Performs a summation on the data coming into the pin and performs a reset to 0 at a set minute of the hour. Before calling this function, the data source and a constant defining a minute value must be specified. The minute value will trigger a change event every hour at the defined minute value and restart the summation from zero. Valid values
|
Fn Samples Difference Sum |
Performs a summation on the difference between the previous sample and the current sample. A maximum expected value for the sample must be specified to account for the rollover of the value. Additionally, before calling this function, the data source and a constant defining a minute value must be specified. The minute value will trigger a change event every hour at the defined minute value and restart the summation from zero. Valid values
In-line Parameters
|
Fn Samples Sum [No Reset] |
Performs exactly as Fn Samples Sum with the exception that the summation will not be reset to 0 at the specified time. |
Fn Samples Difference Sum [No Reset] |
Performs exactly as Fn Samples Difference Sum with the exception that the summation will not be reset to 0 at the specified time. In-line Parameters
|
Fn Average Mem 1 |
Performs averaging on the invoking pin. The function parameter defines the sample size up to a maximum of 2500 samples. Allows for this functionality to be applied to 1 pin only. In-line Parameters
|
Fn Average Mem 2 |
Performs averaging on the invoking pin. The function parameter defines the sample size up to a maximum of 2500 samples. Allows for this functionality to be applied to 1 pin only. In-line Parameters
|
Fn Average Mem 3 |
Performs averaging on the invoking pin. The function parameter defines the sample size up to a maximum of 2500 samples. Allows for this functionality to be applied to 1 pin only. In-line Parameters
|
Fn Average Mem 4 |
Performs averaging on the invoking pin. The function parameter defines the sample size up to a maximum of 2500 samples. Allows for this functionality to be applied to 1 pin only. In-line Parameters
|
Fn Trim Below |
Returns the Trim Below Value when the sample is below that value. You are required to enter a numeric value. In-line Parameters
|
Fn Trim Over |
Return the Trim Above Value when the sample is above that value. You are required to enter a numeric value. In-line Parameters
|
Fn Totalize |
Performs totalizing function over a defined period of time on a numeric input defining a rate. In-line Parameters
|
Fn Volumize |
Takes a pulse input and calculates a rate per defined time interval. In-line Parameters
or
|
Hex Functions
Formula | Description |
---|---|
Fn Swap Words |
Performs a 16 bit swap on 32-bit MODBUS register reads when necessary. Example: ABCD1234 becomes 1234ABCD. [Current Input] [Ent] [Fn Swap Words] |
Fn Swap Bytes |
Performs 8 bit swap on 16 or 32-bit MODBUS register reads when necessary. Example: ABCD1234 becomes CDAB3412. [Current Input] [Ent] [Fn Swap Bytes] |
Fn Signed to REG16 | Performs the conversion of a signed integer value to a 16 bit hex value. The value to be converted is taken from the last value in the calculator’s stack. |
Fn Signed to REG32 | Performs the conversion of a signed integer value to a 32 bit hex value. The value to be converted is taken from the last value in the calculator’s stack. |
Fn Float to REG32 | Performs the conversion of a float value to a 32 bit hex value. The value to be converted is taken from the last value in the calculator’s stack. |
Fn Reg16 to Signed |
Performs the conversion of a 16 bit hex value to a signed integer value. The value to be converted is taken from the last value in the calculator’s stack. Example: Assume the invoking pin is an input of a MODBUS module configured as hex and the source is a 16-bit Holding register. Use the register value as a signed integer. [Current Input] [Ent] [Fn Reg16 to Signed] |
Fn Reg32 to Signed |
Performs the conversion of a 32 bit hex value to a signed integer value. The value to be converted is taken from the last value in the calculator’s stack. Example: Assume the invoking pin is the input of a MODBUS module configured as hex and the source is a 32-bit Holding register. Use the register value as a signed integer. [Current Input] [Ent] [Fn Reg32 to Signed] |
Fn Reg32 to Float |
Performs the conversion of a 32 bit hex value to a float value. The value to be converted is taken from the last value in the calculator’s stack. Example 1: Assume the invoking pin is an input of a MODBUS module configured as hex and the source is a 32-bit Holding register. Use the register value as a float. [Current Input] [Ent] [Fn Reg32 to Float] |
Fn REG32 M10K to Unsigned | Performs the conversion of a 32 bit hex value in Modulo 10000 to an unsigned integer value. The value to be converted is taken from the last value in the calculator’s stack. |
Fn REG32 M10K to Signed | Performs the conversion of a 32 bit hex value in Modulo 10000 to a signed integer value. The value to be converted is taken from the last value in the calculator’s stack. |
Fn Hex Bit State - Position |
Takes a hex value and returns the bit value at the indicated position. In-line Parameters
|
Fn Hex Non-Zero State | Takes a hex value and returns 1 if any bit is set. Returns 0 if no value is set. |
Command Functions
Formula | Description |
---|---|
Fn Save Value |
Takes the value in the stack and stores it into memory at a specified interval. This function requires one parameter that defines an interval time value in seconds at which the value will be saved. A value of zero will save at every change. In-line Parameters
|
Fn Set Input Pin |
Takes the value in the stack and pushes it to the designated input pin at every interval from the top of the hour. This function requires a constant value preceding it that defines an interval time value in minutes. The function call then requires a parameter that defines the number of the input pin to push the value into. In-line Parameters
|
Fn Reset Pin Formula |
Allow the invoking pin to trigger a reset event on another pin. Doing it from the formula rather than as a program function call will keep the even synchronous across multiple, dependent pins. The function takes the pin number that will be reset as the parameter. In-line Parameters
|
Fn [If Not] Reset Event Goto |
Allows the formula to perform certain operations only in the case that a formula reset is triggered from a Reset Pin Formula program function call. The formula function take 1 parameter which tells the formula to skip to the specified line and continue execution in the case or normal operation (not a reset event). In-line Parameters
|
Fn Debounce Low |
When the signal goes low, waits for a period of time before passing the most current value to the system for processing. The time period can be defined in minutes or come from another Input/Ouput in the system. In-line Parameters
Or
|
Fn Debounce High |
When the signal goes high, waits for a period of time before passing the most current value to the system for processing. The time period can be defined in minutes or come from another Input/Ouput in the system. In-line Parameters
Or
|
Fn Trigger Low |
Passes the low signal to the system and waits a period of time before sending the next signal. The time period can be defined in minutes or come from another Input/Ouput in the system. In-line Parameters
Or
|
Fn Trigger High |
Passes the high signal to the system and waits a period of time before sending the next signal. The time period can be defined in minutes or come from another Input/Ouput in the system. In-line Parameters
Or
|
Fn Sample Rate |
Specify a time interval between processing of samples. In-line Parameters
Or
|
Trigonometric Functions
Formula | Description |
---|---|
Radians to Degrees | Performs the conversion of a numeric value in radians to degrees. |
Degrees to Radians | Performs the conversion of a numeric value in degrees to radians. |
Sin - Radians | Performs sin function on numeric value in radians. |
Cos - Radians | Performs cosine function on numeric value in radians. |
Tan - Radians | Performs tangent function on numeric value in radians. |
Asin - Radians | Performs arc sin function on numeric value and returns radians |
Acos - Radians | Performs arc cosine function on numeric value and returns radians |
Atan - Radians | Performs arc tangent function on numeric value and returns radians. |
Mathematical Functions
Formula | Description |
---|---|
Square Root | Performs square root function on numeric value. |