Skip to content

Formula Parameters

A formula parameter is a value calculated from other parameters. You write the formula once, and from then on the value is worked out continuously as the real readings arrive. It appears everywhere a parameter can: the live view, trends, reports, triggers and parameter health.

Typical uses:

  • A physical quantity you cannot measure directly, such as a vapour pressure from a temperature.
  • A calibration curve: turning a raw sensor reading into engineering units with a polynomial.
  • A combination of several readings, such as a flow from a pressure difference, or an efficiency from an input and an output.

Where to find them

Open Digital Twin → Parameters → Formulas. The page lists every formula parameter in your organisation, with its formula, its unit and the hub that calculates it. Use the search box (name or formula) and the hub filter to narrow the list. Click a row to open the parameter's own page.

Engineering access required

Creating, editing and deleting formula parameters needs engineering access, with engineering mode switched on. Anyone who can see parameters can view them.

You can create a formula from two places:

  • The + button on the Formulas page.
  • A device's + menu → Create Formula Parameter. The form then offers that device's hub straight away.

The one-hub rule

Every formula runs on one hub: the edge device that reads its parameters. So all the device parameters in a formula must come from the same hub. As soon as you choose the first device parameter, the form shows which hub the formula will run on and offers only that hub's parameters for the other variables.

Manual parameters (values typed in by people) can be used in any formula, together with the hub's device parameters. A formula needs at least one device parameter, though; manual parameters alone are not enough.

Formula parameters and calculated parameters cannot be used inside a formula.

Creating a formula parameter

  1. Enter a Name, and optionally a Unit and the Machine it belongs to.
  2. Write the Formula (see Writing a formula). Any mistake is explained under the box as you type, and the character at fault is highlighted.
  3. Under Variables, choose the parameter that each variable stands for. The list builds itself from the formula.
  4. Optionally set a Correction factor. The result is multiplied by it; leave it at 1 to keep the result as it is.
  5. Check the result in Try it (see Testing before you save).
  6. Click Create.

The new parameter starts producing values as soon as its hub receives the change and its parameters report.

Writing a formula

A formula uses numbers, variable names, brackets, operators and functions.

  • Variables are short names of your choice, such as x, temp, rh or flow_in. Each one becomes a row in the Variables table, where you link it to a parameter. A formula can use up to 10 parameters.
  • Operators: + - * / and ^ (power). Always write the multiplication: 2*x, not 2x.
  • Constants: pi and e.
  • Decimals use a dot: 0.5. Large and small numbers can be written as 1.5e-3.
Function Meaning
exp(x) e to the power x
ln(x) Natural logarithm
log10(x) Logarithm to base 10
log(x, b) Logarithm of x to base b
sqrt(x) Square root
abs(x) Absolute value
pow(x, y) x to the power y (same as x^y)
min(a, b, …) / max(a, b, …) The smallest / largest value
clamp(x, lo, hi) x kept between lo and hi
round(x) / round(x, n) Rounded, to n decimal places if given
floor(x) / ceil(x) Rounded down / up
sin cos tan asin acos atan Trigonometry, in radians
atan2(y, x) Angle of the point (x, y), in radians

The Functions link next to the formula box shows this list while you type.

Examples

Vapour pressure from a temperature (one variable, x = temperature in °C):

7.267282*exp(9.550426-5723.265/(x+273.15)+3.53068*ln(x+273.15)-0.00728332*(x+273.15))

Calibration polynomial (raw = the sensor reading):

1.5 - 0.2*raw + 0.003*raw^2

You do not have to type a polynomial by hand: click Polynomial, enter the variable name and the coefficients from the constant term up (1.5, -0.2, 0.003), and click Use.

Two parameters with a manual value (p_in, p_out = pressures from the hub, k = a manual parameter holding a constant that engineers update):

k * sqrt(abs(p_in - p_out))

Testing before you save

The Try it panel works the formula out without saving anything.

  • Enter a test value for each variable, and the result appears at once, with the correction factor applied.
  • Use live values fills in the latest readings of the chosen parameters, so you can compare the result with what you expect from the plant right now.
  • If the values lead to an impossible calculation, such as the logarithm of a negative number or a division by zero, the panel says so instead of showing a result.

How values are calculated

  • A new value is calculated whenever one of the device parameters in the formula reports a new reading, at most once per Minimum interval (1 second unless you change it).
  • Each value is stamped with the time of the newest reading it was calculated from.
  • Stale readings are never used. If any device parameter in the formula has sent nothing for longer than the Input max age (120 seconds unless you change it), no value is calculated until it reports again. The formula parameter then shows as stale or offline, like any parameter whose readings have stopped. It never holds a last value that is no longer true.
  • Manual parameters have no age limit: their value counts until someone changes it, and a change is picked up straight away.
  • If the current readings make the formula impossible to work out (for example a negative number under a square root), no value is produced for that moment.

Input max age and Minimum interval are under Advanced in the form.

A formula parameter's own page

The page shows the live value and trend like any parameter, plus a Formula section with the formula, each variable and the parameter it reads (click one to open it), the hub, the correction factor and the timing settings. In engineering mode the Edit button opens the form.

Formula parameters are read-only: their value is calculated, so writing to them is not possible.

Triggers, targets and parameter health can be set up on a formula parameter in the same way as on any other parameter.

Editing and deleting

  • Edit from the row menu on the Formulas page, or from the parameter's own page. Choosing parameters from another hub moves the formula to that hub; the form warns you before you save.
  • Delete from the row menu on the Formulas page.
  • A parameter that a formula uses cannot be deleted while the formula exists. The message names the formula, so you can change or delete the formula first.