Calculation Formula Options
- Updated2025-11-19
- 3 minute(s) read
Use standard math operators, functions, and constants to customize hardware channels.
All formulas must adhere to the following rules:
- Every formula must contain a reference to at least one channel.
- Channel references are contained within single quotes ('channel name').
- Element-wise calculation will be done when one of the operands is a channel or the parameter is a channel.
- Decimal separators on literal numbers must be periods. Alternative separators such as commas are not supported.
- Angle measurements must be reported in radians.
Refer to the following table for examples of formula formats that you can use to configure a calculated channel.
| Description | Formula Format | Example |
|---|---|---|
| Element-wise arithmetic addition | 'channel name' + x | 'AI7' + 1 |
| 'channel name x' + 'channel name y' | 'AI7' + 'AI8' | |
| Element-wise arithmetic subtraction | 'channel name' - x | 'AI7' - 1 |
| 'channel name x' - 'channel name y' | 'AI7' - 'AI8' | |
| Element-wise arithmetic multiplication | 'channel name' * x | 'AI7' * 5 |
| 'channel name x' * 'channel name y' | 'AI7' * 'AI8' | |
| Element-wise arithmetic division | 'channel name' / x | 'AI7' / 5 |
| 'channel name x' / 'channel name y' | 'AI7' / 'AI8' | |
| Apply the function to the channel element | function('channel name') | sin('AI7') |
| Arithmetic equation | (x + y) * z / 'channel name' | (2 + 3) * 4 / 'AI7' |
| Number with scientific representation | 'channel name' + 1.23e-5 | 'AI8' + 1.23e-5 |
| Constant usage | function(constant * 'channel name') |
sin(pi * 'AI7') See Supported Functions, Operators, and Constants table. |
| Unary plus (a no-op) | +'channel name' | +'AI7' |
| Power operator | 'channel name'^x | 'AI7'^3 or 'AI7'^0.5 |
| Unary minus | -'channel name' | -'AI7' |
|
Note The data type for all numeric
values is double-precision, floating-point.
|
||
Refer to the following table for examples of formula elements that you can use to configure a calculated channel.
| Formula Element | Signal Type | Definition | |
|---|---|---|---|
| Supported Functions | sin | Analog | Sine |
| cos | Analog | Cosine | |
| tan | Analog | Tangent | |
| arcsin | Analog | Inverse of sine | |
| arccos | Analog | Inverse of cosine | |
| arctan | Analog | Inverse of tangent | |
| abs | Analog | Absolute value of any number | |
| log | Analog | Logarithm | |
| log10 | Analog | Common logarithm (logarithm to base 10) | |
| Supported Operators | + | Analog | Addition |
| - | Analog | Subtraction | |
| * | Analog | Multiplication | |
| / | Analog | Division | |
| ( ) | Analog, digital | Bracket; contents are evaluated first | |
| ^ | Analog | Calculate the base raised to the power of the exponent You can use this operator to take the root of the base. For example, to take the square root, use x^0.5. |
|
| < | Analog | Less than | |
| > | Analog | Greater than | |
| <= | Analog | Less than or equal to | |
| >= | Analog | Greater than or equal to | |
| = | Analog, digital | Equal | |
| != | Analog, digital | Not equal | |
| & | Digital | Logical and | |
| | | Digital | Logical or | |
| ~ | Digital | Negation | |
| ? : | Analog, digital | Ternary operator indicating condition ? valueIfTrue : valueIfFalse. The data type of valueIfTrue and valueIfFalse must be the same. | |
| Supported Constants | pi | Analog | Pi (ฯ) constant |
| e | Analog | Natural logarithm base constant (๐) | |
| true | Digital | Is TRUE | |
| false | Digital | Is FALSE |