The point of this document is to explain how to convert to linear ranges using linear algebra. Lets say you need to find the related value from one range of values to another range of values. For this demonstration, we will be using a theoretical industrial temperature sensor for our demonstration. Most industrial analog equipment will return a 4 to 20 milliamp signal output. This standard is an interesting way to perform one way analog communications over just 2 wires. The basics is, at a 4mA current draw, the analog value is equal to the minimum value of the output range. At 20mA current draw, the analog value is equal to the maximum value of the output range. However, to calculate any value in between, we need a linear function.

Doing this in software

Most programming languages, such as Arduino (modified C), have a built in function, for calculating these linear ranges. In software, this is likely the best way to go, since it is simple and built into one. But lets say that there isn't a built in function.. Let's say we need to do this using math!

Mathematical Formulas

We will use the standard \(y=mx+b\), also known as the "slope-intercept form". This equation will be the basis for our linear scale.

\(m = \frac{|in_{min}-in_{max}|}{|out_{min}-out_{max}|}\)

Where \(in_{min}\) is the minimum value for the input range, \(in_{max}\) is the maximum value of the input range. And \(out_{min}\) is the minimum output value, and \(out_{max}\)/ is the maximum value of the output range.

If we simply take our information, and plug it into the formula, we will get our output value that is scale.

Interactive Example