First page Back Continue Last page Overview Graphics
Scaling and Offsetting
Values used in embedded programs must often be scaled and/or offset to be useful. For example an A/D converter's output may need to be converted to temperature in Fahrenheit.
Values can be scaled by fractional amounts without resorting to using floating point techniques.
e.g. Fahrenheit = Celsius * 9 / 5 + 32
An analog-to-digital converter may output values from 0-255 that correspond to temperatures from 20° to 160°. In this case the A/D converter output would need to be scaled down from 0-255 to 0-140 and then offset by 20.
Using conventional floating point algorithms would provide more flexibility but the algorithms would require more memory and execute more slowly.