Applying Formulas
These are also referred to by the English term Formula.
Use this when you do not want to use the raw value sent by the PLC as-is, but instead need unit conversion / zero-point correction / scale adjustment.
Common cases:
- A pressure sensor sends the integer
1638but the actual value is163.8 kPa→${VALUE}*0.1 - Celsius → Fahrenheit conversion →
${VALUE}*1.8+32 - mV → V conversion →
${VALUE}/1000
Where do I enter it
Write the expression in the [Formula] field of the tag registration / edit form. Once registered, the converted value appears on screen at the next collection cycle.
- If left empty, the raw value is used as-is.
- Once entered, it is applied automatically on every subsequent collection.
Basic usage
${VALUE} refers to the raw value just read from the PLC.
| What you want to do | Formula | Input → Output |
|---|---|---|
| Use as-is | (empty) | 100 → 100 |
| Multiply by 10 | ${VALUE}*10 | 5 → 50 |
| Divide by 10 (integer→decimal) | ${VALUE}*0.1 | 1638 → 163.8 |
| Divide by 1000 (mV → V) | ${VALUE}/1000 | 3300 → 3.3 |
| Addition (Celsius → Kelvin) | ${VALUE}+273.15 | 25 → 298.15 |
| Subtraction (zero-point correction) | ${VALUE}-100 | 1024 → 924 |
| Fahrenheit conversion | ${VALUE}*1.8+32 | 25 → 77.0 |
| Square | ${VALUE}*${VALUE} or ${VALUE}^2 | 5 → 25 |
| Square root | sqrt(${VALUE}) | 144 → 12.0 |
| RPM → Hz | ${VALUE}/60 | 1800 → 30.0 |
Referencing values from other tags
You can pull the last value of another tag using the ${태그ID} form. This is handy for patterns where the zero-point value is managed as a separate tag, or where correction coefficients are kept separately.
| What you want to do | Formula |
|---|---|
| Subtract another tag as the zero point | ${VALUE}-${TAG_ZERO} |
| Sum two tags | ${VALUE}+${TAG_OFFSET} |
| Correction (gain × x + offset) | ${VALUE}*${TAG_GAIN}+${TAG_OFFSET} |
Here, TAG_ZERO, TAG_OFFSET, and TAG_GAIN are the tag IDs of other tags. They must already be registered as tags.
If you enter ${TAG_ZERO} but that tag has never been collected, the calculation fails (an error such as "formula variable value missing" appears in that tag's status). It resolves automatically once the gateway completes one cycle, so just wait a moment.
Available functions
In addition to arithmetic, you can use commonly needed mathematical functions.
| Type | Notation | Example |
|---|---|---|
| Arithmetic operators | +, -, *, / | ${VALUE}+1 |
| Exponentiation | ^ | ${VALUE}^2 (= square) |
| Parentheses | (, ) | (${VALUE}+10)*2 |
| Square root | sqrt(...) | sqrt(${VALUE}) |
| Cube root | cbrt(...) | cbrt(${VALUE}) |
| Natural logarithm | ln(...) | ln(${VALUE}) |
| Common logarithm (base 10) | log(...) | log(${VALUE}) |
| Sine/cosine/tangent (radians) | sin, cos, tan | sin(${VALUE}) |
| Inverse trigonometric | asin, acos, atan | atan(${VALUE}) |
| Hyperbolic | sinh, cosh, tanh | tanh(${VALUE}) |
| Constants | pi, e | ${VALUE}*pi/180 (degrees → radians) |
To convert a degree input to radians, multiply by *pi/180. Example: sin(${VALUE}*pi/180).
Applicable data types
Formulas apply only to numeric (Float, Double, Integer, Long) tags.
- For
StringandBooleantags, the formula is ignored and the raw value is output as-is. - If the corrected result exceeds the integer range, change the data type to
FloatorDouble.
Easy mistakes to make
| Wrong pattern | Why it is a problem | Correct pattern |
|---|---|---|
VALUE * 0.1 | Missing ${...} notation | ${VALUE}*0.1 |
${VALUE}*0,1 | Comma used (Korean keyboard slip) | ${VALUE}*0.1 (use a period) |
if(${VALUE}>0, ...) | Conditionals not supported | If a condition is needed, handle it in a separate system |
${VALUE} & 0xFF | Bitwise operations not supported | Rewrite in a form achievable with arithmetic |
Frequently asked questions
Q. How do I verify that the formula was applied?
The value shown in the tag's [Current Value] field is the converted value. If you want to see the raw value, register the same address as a separate tag without a formula and compare.
Q. I want to send two unit conversions at once (e.g., Celsius and Fahrenheit)
Create two tags pointing to the same PLC address — leave one as-is and enter a conversion expression such as ${VALUE}*1.8+32 in the other.
Q. The result comes out as NaN / Infinity
- Division by zero →
Infinity - Square root of a negative number →
NaN
The PLC's raw value range most likely differs from what you expected. Check the raw value first without a formula.
Q. I need more complex processing (conditional branching / multiple variables / external data)
This is difficult with formulas alone. We recommend using the PlantPulse Platform post-processing stage or a separate data processing tool (such as Node-RED) alongside it. See the Node-RED entry on the Application Management page.
If you need the full function / variable reference, see the Advanced — Formula Reference page.