Scale Codes

Because the raw byte value can
range from 0 to 255 it may not be a suitable representation of the units of
measure. A simple example of this is the engine coolant temperature: the real
world temperature may range from -40 degrees Celsius up to 150 degrees Celsius. However the value is processed by the computer as an 8 bit byte with
values from 0 to 255.
How can we display the
temperature byte that has values from 0 to 255 as a temperature with values
from -40 to 150 degrees Celsius? The answer is to apply a scaling formula; in
this case we first multiply the raw byte value by 0.75 (the factor) and then
subtract 40 (the offset). This actually converts the range: 0 to 255 into the
range: -40..151.25 degrees Celsius.
Nearly all scaling formulas
consist of a factor and an offset, in fact most don't even require an offset.
To determine the values of the
factor and offset, you must first know the maximum and minimum values that are
to be displayed. Then calculate the Factor and Offset using the formulas
below.
For 8 bit bytes:
- Offset = minimum
- Factor = (maximum-minimum)/255
For 16 bit words:
- Offset = minimum
- Factor =
(maximum-minimum)/65,535
Some very rare measurements
require more complex scaling formulas, involving the inverse of the raw byte
value, while others require the whole range to be reversed from (0..255) to
(255..0).
Units
The real world units that this
scale code represents. (Descriptive only).
Factor
The multiplication factor that
is applied.
Offset
The offset is added to the product of the factor and the raw byte (after
and inverting or reversing has been applied).
Display
These two fields define the upper and lower chart axis values. They also
define the gauge display range for the virtual dashboard.
If the display minimum is the same
value as the display maximum then these fields are ignored.
Alarm
The alarm minimum and maximum determine the acceptable operating range of
the attribute. The "Aldl (F7)" tab page uses these two values to
calculate the %Low and %High values for the attribute. The dashboard also
displays gauges in alternative colors when their attributes exceed alarm
values.
Minimum/maximum
Click on the
button to automatically calculate the minimum and maximum values based on the
number of bits, factor and offset.
Reverse
If this box is checked then prior to multiplying it with the factor, the
raw value is subtracted from its theoretical maximum. Its theoretical maximum
is (2^bits)-1 where bits is the raw value's number of bits.
Raw
Byte |
Reversed |
0
|
255
|
1
|
254
|
2
|
253
|
3
|
252
|
...
|
...
|
252
|
3
|
253
|
2
|
254
|
1
|
255
|
0
|
|
Raw
Word |
Reversed |
0
|
65,535
|
1
|
65,534
|
2
|
65,533
|
3
|
65,532
|
...
|
...
|
65,532
|
3
|
65,533
|
2
|
65,534
|
1
|
65,535
|
0
|
|
Invert
If this box is checked then prior to multiplying it with the factor, the
raw value is converted into its reciprocal. The reciprocal is calculated by
dividing 1 by the raw byte value+1.
Raw
Byte |
Inverted |
0
|
1.000000
|
1
|
0.500000
|
2
|
0.333333
|
3
|
0.250000
|
...
|
...
|
252
|
0.003953
|
253
|
0.003937
|
254
|
0.003922
|
255
|
0.003906
|
|
Raw
Word |
Inverted |
0
|
1.000000
|
1
|
0.500000
|
2
|
0.333333
|
3
|
0.250000
|
...
|
...
|
65,532
|
0.000015
|
65,533
|
0.000015
|
65,534
|
0.000015
|
65,535
|
0.000015
|
|
The "Show as Output" button will
display a table of raw byte values converted to their real world values. Scaling
formulas that you intend to use to convert data that is received from the
vehicle should be tested using this button. This usually means data that is
returned from a mode $01 request.
The first and last 256 values in the range 0..65535 will be displayed.
The "Show as Input" button will
display a table of real world values converted to raw byte values. Scaling
formulas that you intend to use to convert data that will be sent to the vehicle
should be tested using this button. This usually means data that is required for
input to mode $04 commands.
Only the first 256 values will be displayed.
|