Overview
All protocol modules support the scaling of item values in order to publish data based on calculated formula instead of raw device data. Any item can be scaled, with the exception of Boolean (bit) and String items. After scaling, the original item data type will be changed to Double.
It is possible to lose data precision due to data type conversion
Linear Scaling
Register{SL,LR,HR,LE,HE}
Validate lows are lower than highs.
Register is the tag or register name in the end device
SL is the linear scale identifier and must appear first after the open bracket.
LR is the low raw value.
HR is the high raw value.
LE is the low engineering value.
HE is the high engineering value.
To calculate scaled data after reading from device:
ScaledValue = (Raw-LoRaw)/(HiRaw-LoRaw)(HiEGU-LoEGU)+LoEGU
Example: 40001{SL,0,4095,0,100}
If the device returns a raw value 1000 the scaled value will be:
ScaledValue = (1000 - 0)/(4095 - 0)(100 - 0) + 0 = 24.42
To calculate raw data before sending to device:
RawValue = (ScaledValue-LoEGU)/(HiEGU-LoEGU)(HiRaw-LoRaw)+LoRaw
Example: 40001{SL,0,4095,0,100}
If a scaled value of 60 was written to the device, the actual value written to the device will be:
RawValue = (60 - 0)/(100 - 0)(4095 - 0) + 0 = 2457
Square Root Scaling
Register{SQ,LR,HR,LE,HE}
Validate lows are lower than highs.
Register is the tag or register name in the end device
SQ is the square root scale identifier and must appear first after the open bracket.
LR is the low raw value.
HR is the high raw value.
LE is the low engineering value.
HE is the high engineering value.
To calculate scaled data after reading from device:
Formula: ScaledValue = SQRT((Raw-LoRaw)/(HiRaw-LoRaw))*(HiEGU-LoEGU)+LoEGU
Example: 40002{SQ,0,4095,0,100}
If device returns a raw value of 1000, the scaled value will be:
ScaledValue = SQRT((1000 - 0)/(4095 - 0))(100 - 0) + 0 = 49.42
To calculate raw data before sending to device:
Formula: Raw = ((Scaled-LoEGU)/(HiEGU–LoEGU))^2(HiRaw-LoRaw)+LoRaw
Example: 40002{SQ,0,4095,0,100}
If a scaled value of 60 was written to the device then the actual value written to the device will be:
Raw = ((60 - 0)/(100 - 0))^2*(4095 - 0) + 0 = 1474.2
Gain/Offset Scaling
Register{SG,Gain:Offset}
Validate Gain is not zero.
Register is the tag or register name in the end device
SG is the gain/offset scale identifier and must appear after the open bracket.
Gain is a multiplier.
Offset is an addition.
To calculate scaled data after reading from device:
Formula: ScaledValue = (RawValue * gain) + offset
Example: 40003{SG,2.5:1}
If the device returns raw value of 1000 the scaled value will be:
ScaledValue = 1000 * 2.5 + 1 = 2501
To calculate raw data before sending to device:
Formula: RawValue = (ScaledValue - offset) / gain
Example: 40003{SG,2.5:1}
If a scaled value of 60 was written to the device then the actual data written to the device will be:
RawValue = (60 - 1)/2.5 = 24.4
Inverse Scaling
Register{SI:Inverse} or Register{SI}
Validate that Item raw value is not zero
Register is the tag or register name in the end device
SI is the inverse scale identifier and must appear after the open bracket.
Inverse is a divider and is optional.
The default inverse for “{SI}” is 1. {SI} is the same as {SI:1}.
To calculate scaled data after reading from device:
Formula: ScaledValue = Inverse/RawValue
Example: 40003{SI:2}
If the device returns a raw value of 1000 the scaled value will be:
ScaledValue = 2/1000 = 0.002
To calculate raw data before sending to device:
Formula: RawValue = (1/ScaledValue) * Inverse
Example: 40003{SI:2}
If a scaled value of 0.5 was written to the device then the actual data written to the device will be:
RawValue = (1/0.5) * 2 = 4