Applying Formulas
This is also called a Formula.
Use it when you want to convert units, zero-adjust, or scale the raw value from the PLC instead of using it as-is.
Common cases:
- A pressure sensor sends an integer
1638but the actual value is163.8 kPa→${VALUE}*0.1 - Celsius → Fahrenheit conversion →
${VALUE}*1.8+32 - mV → V conversion →
${VALUE}/1000
Where to Enter It
Enter the formula in the [Formula] field of the tag registration/modification form. Immediately after registration, the converted value will appear on the screen in the next collection cycle.
- If left blank, the raw value is used as-is.
- Once entered, it is applied automatically on every subsequent collection.
Basic Usage
${VALUE} represents the raw value just read from the PLC.
| What you want to do | Formula | Input → Output |
|---|---|---|
| Use as-is | (leave blank) | 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 |
| Add (Celsius → Kelvin) | ${VALUE}+273.15 | 25 → 298.15 |
| Subtract (zero adjustment) | ${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 Other Tags' Values
You can fetch the latest value of another tag using the ${태그ID} format. This is useful when you manage a zero-offset value in a separate tag or want to keep a calibration factor separate.
| What you want to do | Formula |
|---|---|
| Subtract another tag as a zero reference | ${VALUE}-${TAG_ZERO} |
| Sum of two tags | ${VALUE}+${TAG_OFFSET} |
| Calibration (gain × x + offset) | ${VALUE}*${TAG_GAIN}+${TAG_OFFSET} |
Here, TAG_ZERO, TAG_OFFSET, and TAG_GAIN are the tag IDs of the other tags. They must be registered as separate tags in advance.
If you write ${TAG_ZERO} but that tag has never been collected, the calculation will fail (an error like "No formula variable value" will appear in that tag's status). It will automatically return to normal once the gateway runs one cycle, so please wait a moment.
Available Functions
In addition to arithmetic, you can use frequently used mathematical functions.
| Type | Notation | Example |
|---|---|---|
| Arithmetic | +, -, *, / | ${VALUE}+1 |
| Power | ^ | ${VALUE}^2 (= square) |
| Parentheses | (, ) | (${VALUE}+10)*2 |
| Square root | sqrt(...) | sqrt(${VALUE}) |
| Cube root | cbrt(...) | cbrt(${VALUE}) |
| Natural log | ln(...) | ln(${VALUE}) |
| Common log (base 10) | log(...) | log(${VALUE}) |
| Sine/Cosine/Tangent (radians) | sin, cos, tan | sin(${VALUE}) |
| Inverse trig | asin, acos, atan | atan(${VALUE}) |
| Hyperbolic | sinh, cosh, tanh | tanh(${VALUE}) |
| Constants | pi, e | ${VALUE}*pi/180 (degrees → radians) |
To convert 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 used as-is. - If the corrected result exceeds the integer range, change the data type to
FloatorDouble.
Common Mistakes
| Incorrect pattern | Why it's a problem | Correct pattern |
|---|---|---|
VALUE * 0.1 | Missing ${...} notation | ${VALUE}*0.1 |
${VALUE}*0,1 | Comma used (Korean keyboard mistake) | ${VALUE}*0.1 (use a period) |
if(${VALUE}>0, ...) | No conditional statements | Use a separate system if conditions are needed |
${VALUE} & 0xFF | No bitwise operations | Convert to an arithmetic approach |
Frequently Asked Questions
Q. How do I verify that the formula is applied?
The value shown in the tag's [Current Value] field is the converted value. To see the raw value, register a separate tag at the same address without a formula and compare them.
Q. I want to send two unit conversions (e.g., Celsius and Fahrenheit) simultaneously
Create two tags pointing to the same PLC address: one without a formula, and the other with a conversion formula like ${VALUE}*1.8+32.
Q. The result comes out as NaN / Infinity
- Division by zero →
Infinity - Square root of a negative number →
NaN
The raw value range from the PLC is likely different 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 post-processing stage of the PlantPulse platform or a separate data processing tool (such as Node-RED). See the Node-RED section on the Application Management page.
For a complete function/variable reference, see the Advanced — Formula Reference page.