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.
You can use linear and square root scaling for double shared variables.
Often an application needs the 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 HMI application.
Linear scaling is a straight proportional scale of raw values to engineering unit values.
Square root scaling is a proportional way of scaling raw values to engineering unit values. You can use scaling to the square root of the raw unit after you compensate for offsets.
For example, you might want to scale a raw value that ranges from 0 to 100 to engineering units ranging from 0 to 10. The shared variable returns values as shown in the following table:
| 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 a raw value that ranges from 0 to 100 scaled to engineering units ranging from 15 to 30. Offsets deliver more complicated results.
| 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 |
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.
On the Scaling page of the Shared Variable Properties dialog box, select Linear from the Scale Type pull-down menu. Set the shared variable for the raw range from 0 in the Raw Zero Scale text box to 5 in the Raw Full Scale text box. Set the engineering range from 50 in the Engineering Zero Scale text box to 100 in the Engineering Full Scale text box.
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), and 4 mA corresponds to 0 GPM, where 20 mA corresponds to 100 GPM.
On the Scaling page of the Shared Variable Properties dialog box, select Square Root from the Scale Type pull-down menu. Set the shared variable for the raw range from 4 in the Raw Zero Scale text box to 20 in the Raw Full Scale text box. Set the engineering range from 0 in the Engineering Zero Scale text box to 100 in the Engineering Full Scale text box.
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.
You can use invert scaling for Boolean shared variables. When you enable invert scaling, the DSC Module inverts the Boolean value when communicating with the server.
You can use invert and/or 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
xxxxxxxxxxxxxxxxoooooooooooooooo
where x marks a position to filter out and o marks a place to report, reads the bit array
10110011100011001100111000110010
as the following:
00000000000000001100111000110010
![]() |
Note The invert mask does not invert bits that are masked out. |
The following table shows examples of shared variables configured for U32 bit field scaling.
| Shared Variable Name | Length | Raw Value | Scaling Invert Mask | Scaling Select Mask | Scaled Value |
|---|---|---|---|---|---|
| Shared Variable 1 | 8 | 0x0F | 0x00 | 0xFF | 0x0F |
| Shared Variable 2 | 8 | 0x0F | 0x33 | 0xFF | 0x3C |
| Shared Variable 3 | 8 | 0x0F | 0x33 | 0x0F | 0x0C |
| Shared Variable 4 | 8 | 0x0F | 0x00 | 0x33 | 0x03 |
| Shared Variable 5 | 8 | 0x0F | 0x33 | 0x33 | 0x30 |
| Shared Variable 6 | 16 | 0x0FF0 | 0x000F | 0x00FF | 0x00FF |