Configure Scaling for Shared Variables
- Updated2025-11-07
- 4 minute(s) read
Scaling is useful for converting a range of values from measured units into a calculated range. You can configure scaling for each data type of shared variables.
You can configure scaling on the Scaling page of the Shared Variable Properties dialog box. You also can use the Scaling SharedVariableIO properties.
Scaling Numeric Shared Variables
You can use linear and square root scaling for numeric shared variables.
Often an application needs the LabVIEW Datalogging and Supervisory Control (DSC) Module to manipulate the raw data used in the device server to put the data in a form, called engineering units, suitable for the users of the application. You can define the raw range and engineering range for a shared variable to perform simple conversions between the two ranges on the Scaling page of the Shared Variable Properties dialog box. The raw range refers to the values used by the device server. The engineering range refers to the values used by the Shared Variable Engine and the Human Machine Interface (HMI) application.
Linear and Square Root Scaling
Linear scaling is defined by the following equation:
m * raw + b
where
- b is the Engineering Zero Scale
- m is the (Engineering Full Scale – Engineering Zero Scale)/(Raw Full Scale – Raw Zero Scale).
Square root scaling is defined by the following equation:
b + m * sqrt(raw – o)
where
- b is the Engineering Zero Scale
- m is the (Engineering Full Scale – Engineering Zero Scale)/sqrt(Raw Full Scale – Raw Zero Scale)
- o is the Raw Zero Scale
The following table shows shared variable values that range from 0 to 100 scaled to engineering units ranging from 0 to 10:
| Raw Units | Linear Scale | Square Root Scale |
|---|---|---|
| 0 | 0 | 0 |
| 4 | .4 | 2 |
| 9 | .9 | 3 |
| 10 | 1 | 3.16 |
| 16 | 1.6 | 4 |
| 20 | 2 | 4.47 |
| 25 | 2.5 | 5 |
| 30 | 3 | 5.48 |
| 36 | 3.6 | 6 |
| 40 | 4 | 6.32 |
| 49 | 4.9 | 7 |
| 50 | 5 | 7.07 |
| 60 | 6 | 7.75 |
| 64 | 6.4 | 8 |
| 70 | 7 | 8.37 |
| 80 | 8 | 8.94 |
| 81 | 8.1 | 9 |
| 90 | 9 | 9.49 |
| 100 | 10 | 10 |
The following table shows shared variable values that range from 0 to 100 scaled to engineering units ranging from 15 to 30:
| Raw Units | Linear Scale | Square Root Scale |
|---|---|---|
| 0 | 15 | 15 |
| 4 | 15.60 | 18 |
| 10 | 16.50 | 19.74 |
| 16 | 17.40 | 21 |
| 20 | 18 | 21.71 |
| 30 | 19.50 | 23.22 |
| 36 | 20.40 | 24 |
| 40 | 21 | 24.49 |
| 50 | 22.50 | 25.61 |
| 60 | 24 | 26.62 |
| 64 | 24.60 | 27 |
| 70 | 25.50 | 27.55 |
| 80 | 27 | 28.42 |
| 90 | 28.5 | 29.23 |
| 100 | 30 | 30 |
Offset scaling delivers more complicated results.
Linear Scaling Example
In this example, a device server returns a voltage from 0 to 5 V. The voltage is related to a position sensor, and the real-world position is measured in centimeters, with 0 V mapped to 50 cm and 5 V mapped to 100 cm.
The following table shows the values of the shared variables after scaling:
| Raw Units (V) | Linear Scale (cm) |
|---|---|
| 0 | 50 |
| 1 | 60 |
| 2 | 70 |
| 3 | 80 |
| 4 | 90 |
| 5 | 100 |
Square Root Scaling Example
In this example, a flow meter measures the flow rate of a liquid using a differential pressure reading. The device server provides 4 to 20 mA readings. The actual flow is measured in Gallons Per Minute (GPM), where 4 mA corresponds to 0 GPM and 20 mA corresponds to 100 GPM.
The following table shows the values of the shared variables after scaling:
| Raw Units (mA) | Square Root Scale (GPM) |
|---|---|
| 4 | 0 |
| 5 | 25 |
| 6 | 35.36 |
| 7 | 43.3 |
| 8 | 50 |
| 10 | 61.24 |
| 13 | 75 |
| 15 | 82.92 |
| 20 | 100 |
Assigning Units to a Double Shared Variable
Use the Scaling.Units SharedVariableIO property to assign units to a shared variable. In the previous example, you could specify gallons per minute as a constant to the Scaling.Units property.
Scaling Boolean Shared Variables
You can use inverted scaling for Boolean shared variables. When you enable inverted scaling, the DSC Module inverts the Boolean value when communicating with the server.
Scaling U32 Bit Field Shared Variables
You can use invert mask and select mask scaling for U32 bit field shared variables.
Mask scaling applies only to U32 bit fields. LabVIEW stores a bit field as a number, translating the number back into a 32-bit field when needed. The bit field holds a collection of 32 values, each value limited to 1 or 0. With mask scaling, you can decide which of these array members to pay attention to. Any bit filtered out by the mask appears as a zero. Bits not filtered out appear as zero or one, reflecting the actual value. A mask of 00000000000000001111111111111111 (0x0000FFFF) where 0 marks a position to filter out and 1 marks a place to report, reads the bit array: 10110011100011001100111000110010
as the following: 00000000000000001100111000110010
The following table shows examples of shared variables configured for U32 bit field scaling:
| Shared Variable Name | Raw Value | Scaling Invert Mask | Scaling Select Mask | Scaled Value |
|---|---|---|---|---|
| Shared Variable 1 | 0x0000000F | 0x00000000 | 0x000000FF | 0x0000000F |
| Shared Variable 2 | 0x0000000F | 0x00000033 | 0x000000FF | 0x0000003C |
| Shared Variable 3 | 0x0000000F | 0x00000033 | 0x0000000F | 0x0000000C |
| Shared Variable 4 | 0x0000000F | 0x00000000 | 0x00000033 | 0x00000003 |
| Shared Variable 5 | 0x0000000F | 0x00000033 | 0x00000033 | 0x00000030 |
| Shared Variable 6 | 0x00000FF0 | 0x0000000F | 0x000000FF | 0x000000FF |