# Sensor formulas and variable references :id=top

------

> _Doc Ver:_ 1.1   
_App Ver:_ 2.6.6.53   
_Date:_ 09/13/2026 

------

> Formula tokens for SA1 2.x sensor compute (`sa-di`). Not GTK / RTLinux.
>
> If **Precise wavelength calibration** is enabled, `w` / `#ID` are already the etalon-corrected wavelengths. See [Precise wavelength calibration](precise_wl.md).
>
> **Precise refer** is a different feature: per-sensor lookup of physical value, before formulas. See [Precise reference](precise_refer.md). Do not treat the two pages as one: [contrast](precise_vs.md).

## 1. Constants that can be used in formulas :id=constants

* tc: temperature coefficient
* t0: initial temperature
* wl0: initial wavelength   (not available in virtual sensors)
* a,b,c,d,k: predefined constants
* Other: predefined in global variables

## 2. Variables that can be used in formulas  :id=variables

* w: sensor real-time wavelength (not available in virtual sensors)
* x: wavelength difference, the difference between the real-time wavelength and the initial wavelength, a shorthand for the sensor formula (w-wl0)
* $XX, XX: ID of another sensor; a reference to that sensor's wavelength difference or x value (not applicable to 4.1.1)
* #XX, XX: ID of another sensor; a wavelength reference (not applicable to 4.1.1)
* &XX, XX: ID of another sensor; a physical-value reference (not applicable to 4.1.1)

## 3. Multi-parameter references in formulas  :id=multi

In a sensor configuration formula, no extra setup is required; you can directly reference other sensors' wavelengths, wavelength differences, and physical values.
You can define global variables so that the same settings can be referenced directly across sensors.

  3.1. Wavelength reference

    Format: #XX 
    XX: ID of another sensor   

    Example: in the formula "w-wl0+#1", "#1" references the wavelength of the sensor with ID 1.

  3.2. Wavelength-difference reference

    Format: $XX 
    XX: ID of another sensor

    Example: in the formula "w-wl0+$1", "$1" references the wavelength difference of the sensor with ID 1.

  3.3. Physical-value reference

    Format: &XX 
    XX: ID of another sensor 

    Example: in the formula "w-wl0+(&1+&2)/2", "&1" and "&2" reference the physical values of the sensors with ID 1 and 2.

  3.4. Global-variable reference

    Setting: Menu > 'Setting' > 'Base' > 'Global Variable';
    Formulas can reference a global variable by ID or by name; global variables can be customized, but must not conflict with reserved function names and variable names.

    Example: in the formula "w-wl0+ST", "ST" is a global variable.

## 4. Functions and operation rules in formulas    :id=function

###  4.1. Regular sensors    :id=sensor

  Different "Formula interpreter" types support different functions.

    4.1.1. Type '0: Fast calculation'
      Several fixed formulas for specific applications; enable a specific formula in the "Mode" setting of the second item.

      Mode numbers and the corresponding built-in formulas (cannot be changed):
      0: w                        real-time wavelength
      1: w-wl0 or x               wavelength difference
      2: tc*(w-wl0)+t0            linear formula, for linear sensor formulas, including room-temperature temperature sensors
      3: w-1540000-TC*(w-wl0)     Fan configuration V2;
      4: w-wl0-TC*(w-wl0)         Fan configuration V3;

    4.1.2. Type '1: General four arithmetic operations'
      Addition, subtraction, multiplication, and division +-*/, and parentheses ()

      Example:
        Temperature sensor formula: tc*(w-wl0)+t0 or tc*x+t0
        Strain sensor formula: (w-wl0)/1.2 or x/1.2        (without temperature compensation)

    4.1.3. Type '2: (full-function operation 1)'
      Cross-references are not supported; includes four arithmetic operations and the following functions:   
      abs acos sin tan ceil cos exp floor fmod log max min pi sqrt

    4.1.4. Type '3: (full-function operation 2)'
      Supports cross-references and is compatible with all functions in 'Type 2'.

    Note:
      The larger the type number, the stronger the parsing capability but the lower the parsing efficiency.
      Type 0 and type 1 are not applicable to virtual sensor calculation.

###  4.2. Virtual sensors :id=vss

  Enable "Type 3" in the "Formula interpreter"; this cannot be changed.   
  Statistical functions dedicated to virtual sensors:

    * AVGS&(1,2,3,...): average of sensor physical values, sensor IDs inside '( )';
    * AVGS#(1,2,3,...): average of sensor wavelengths, sensor IDs inside '( )';
    * AVGC&(1,2,3,...): average of physical values of all sensors on specified channels, channel numbers inside '( )';
    * AVGC#(1,2,3,...): average of wavelengths of all sensors on specified channels, channel numbers inside '( )';
    * RELSTD&(1,2,3,...): population std / mean(|physical value|), sensor IDs inside '( )'. Used for three-blade dynamic balance η (`RELSTD&(201,203,205)`). n≥2; denominator floor 1e-9. IDs may be virtual when those virtuals have already been evaluated (ID order). See [Root load](bladeload.md) · [Balance](bladeload-balance.md).   

  > Note: other functions that can be used in formulas are compatible with the functions and reference methods of type 3 in 4.1.

To put virtuals on the dense Modbus map, turn on Include virtual. Sparse MAP IDs are always exported. See [Modbus TCP slave](modbus_tcp_slave.md) · [Virtual sensors](vss.md).

------

### [Top](#top)
