Skip to content

Variables

A variable is the most fundamental data unit in inSCADA. A temperature measurement, a motor status, an energy meter — each one is a variable.

Variable List

Menu: Runtime → Variables → New Variable

FieldRequiredDescription
NameYesVariable name (unique within the project)
TypeYesData type
UnitNoEngineering unit (°C, kW, V, A, bar…)
DescriptionNoDescription
Connection / Device / FrameYesWhich connection it belongs to
ActiveYesActive/inactive
TypeDescriptionExample
FloatDecimal number25.4, 230.1, 0.95
IntegerWhole number100, -5, 0
BooleanTrue/Falsetrue, false
StringText”Recipe-A”, “Running”
{
"id": 23227,
"name": "ActivePower_kW",
"dsc": "Total active power",
"type": "Float",
"unit": "kW",
"projectId": 153,
"connectionId": 153,
"deviceId": 453,
"frameId": 703,
"isActive": true,
"fractionalDigitCount": 2,
"engZeroScale": 0.0,
"engFullScale": 1000.0,
"logType": "Periodically",
"logPeriod": 10,
"keepLastValues": true,
"valueExpressionType": "CUSTOM",
"valueExpressionCode": "var t = new Date().getTime() / 1000; return (Math.sin(t / 60) * 150 + 450 + Math.random() * 30).toFixed(2) * 1;"
}

The raw value is converted to the engineering value through linear transformation.

ParameterDescription
engZeroScaleEngineering unit lower limit
engFullScaleEngineering unit upper limit
rawZeroScaleRaw value lower limit
rawFullScaleRaw value upper limit
Eng = engZeroScale + (raw - rawZeroScale) ×
(engFullScale - engZeroScale) / (rawFullScale - rawZeroScale)
ParameterValue
rawZeroScale4 (mA)
rawFullScale20 (mA)
engZeroScale0 (°C)
engFullScale100 (°C)
  • Raw: 4mA → Eng: 0°C
  • Raw: 12mA → Eng: 50°C
  • Raw: 20mA → Eng: 100°C
{
"value": 359.91,
"extras": { "raw_value": 606.56 },
"flags": { "scaled": true }
}

value is the scaled engineering value, extras.raw_value is the raw value.


Variable values can be recorded to the time series database.

TypeDescription
PeriodicallyRecords at fixed intervals (logPeriod seconds)
When ChangedRecords only when the value changes
NoneNo recording
ParameterDescription
logPeriodRecording period (seconds). 10 = every 10 seconds
logThresholdMinimum change threshold (optional). Filters out small fluctuations
logMinValue / logMaxValueValid value range. Values outside this range are not logged
keepLastValuesKeep the last values list in memory

fractionalDigitCount determines the number of decimal places to display:

ValueDisplay
0350
1350.5
2350.48
3350.483

A custom JavaScript formula can be assigned to a variable. This formula runs on every read cycle, and its result becomes the variable’s value.

TypeDescription
NONENo expression, raw value is used
CUSTOMInline JavaScript code
REFERENCEShared Expression reference (space level)
// Sine wave (ActivePower_kW)
var t = new Date().getTime() / 1000;
return (Math.sin(t / 60) * 150 + 450 + Math.random() * 30).toFixed(2) * 1;
// Fahrenheit → Celsius
var fahrenheit = value; // raw value
return ((fahrenheit - 32) * 5 / 9).toFixed(1) * 1;
// Calculate efficiency from two variables
var input = ins.getVariableValue("Input_kW").value;
var output = ins.getVariableValue("Output_kW").value;
if (input > 0) {
return ((output / input) * 100).toFixed(1) * 1;
}
return 0;

Pulse mode can be assigned to Boolean variables:

ParameterDescription
isPulseOnON pulse active
pulseOnDurationON pulse duration (ms)
isPulseOffOFF pulse active
pulseOffDurationOFF pulse duration (ms)

Pulse mode is used for momentary command sending (e.g., motor start button — ON when pressed, automatically OFF when released).


ParameterDescription
setMinValueMinimum writable value
setMaxValueMaximum writable value

When these parameters are set, write commands outside the range are rejected. Used to prevent operator errors.


// Read real-time value
var val = ins.getVariableValue("ActivePower_kW");
// → { value: 359.91, extras: { raw_value: 606.56 }, dateInMs: ... }
// Bulk read
var vals = ins.getVariableValues(["ActivePower_kW", "Voltage_V", "Current_A"]);
// Write value
ins.setVariableValue("Temperature_C", {value: 55.0});
// Variable information
var info = ins.getVariable("ActivePower_kW");
// → { name: "ActivePower_kW", unit: "kW", type: "Float", logPeriod: 10 ... }

Detailed API: Variable API → | REST API →