Skip to main content

# 24 - Calculating Scale and Offset

This article shows how to convert the data from a Mini/Micro input module into a more meaningful format, for example converting a voltage from a throttle or brake pedal into something more useful like a throttle pedal percentage 0-100%.

It should be noted that this calculation only works for linear data where the plot of the data produces a straight line.

For those who don't like maths - please use our 'Scale and Offset Calculator'.

 1: Obtain zero and full scale voltage values For example, say the throttle position sensor gives 0.5 volts on closed throttle, and 5 volts at full throttle. To convert this into a percentage, the equation of the straight line needs to be calculated. The equation describing a straight line is as follows: Y = mX + c Where; Y = The Y values   (% pedal press) X = The X values   (sensor voltage) m = scale               (gradient of the line) c   = offset              (intercept with the Y-axis) 2: Calculate the gradient of the line

The gradient of a line is the change in Y divided by the change in X which gives:

m (gradient) = dY/dX           (change in Y) / (change in X)

dY = 100 – 0 = 100              change in Y = 100% - 0% = 100

dX = 5 – 0.5 = 4.5                change in X = 5 volts – 0.5 volts = 4.5

Therefore the gradient of the line is:

dY/dX = 100 / 4.5

= 22.22                      The Scale is 22.22

3: Calculate the offset

To find the offset value, substitute the known values at zero throttle, back into the equation:

Y = percent = 0, X = Voltage = 0.5 V

Y = mX + c                             Therefore

0 = (22.22 * 0.5) + c               Zero throttle% = gradient x 0.5 volts + Offset

0 = 11.11 + c

C = -11.11                              The Offset is -11.11

4: The full equation for the line

Substituting these values back into the equation again gives us the full equation of the line which passes through our two points.

Y = 22.22X – 11.11

5: Checking the equation

We can double check our equation is correct by calculating a percentage value for a known voltage output.

We know that:

Voltage (x) Percent Pedal Press (y)
0.5 0
5 100

Using the equation we have just derived produces the following results:

Y = 22.22X – 11.11

Y = (22.22 * 0.5) – 11.11 = 0%                        This is correct, as 0.5 volts is equal to a 0% pedal press.

Y = (22.22 * 5.0) – 11.11 = 99.99%                 This is also correct as we know that 5 volts = 100% pedal press.

6: Plotting the full line

The graph below illustrates the calculated scale and offset values. • Was this article helpful?