2-Point Calibration Calculator
Derive slope and offset from two measured reference points.
Reference points
This tool fits the straight line through two reference measurements and hands you the two constants every linear calibration needs: slope (gain) and offset (zero). Enter the raw reading and the true value at two points, and the equation — plus a live apply/invert field — updates instantly.
How it works
A linear channel obeys y = slope·x + offset. Two known points (x₁, y₁) and (x₂, y₂) determine it exactly: slope = (y₂ − y₁)/(x₂ − x₁), then offset = y₁ − slope·x₁. This is the math behind every zero-and-span procedure: the “zero” adjustment moves the offset, the “span” adjustment moves the slope. The same two constants invert cleanly (x = (y − offset)/slope), which is what you need when driving an output to hit a target value.
Accuracy hinges on the reference points: read them with a better instrument than the channel you are calibrating, and spread them wide — slope uncertainty grows as the points move closer together.
Worked example
slope = (200−0)/(20−4) = 12.5 · offset = 0 − 12.5·4 = −50
y = 12.5·x − 50 → at x=12: y = 100
Parameters
| Parameter | Value | Notes |
|---|---|---|
| Model | y = slope·x + offset | linear only |
| Slope | (y₂−y₁)/(x₂−x₁) | gain / span |
| Offset | y₁ − slope·x₁ | zero |
| Inverse | x = (y−offset)/slope | |
| Constraint | x₁ ≠ x₂ |
C implementation
/* Two-point calibration: y = slope*x + offset */
typedef struct { float slope, offset; } cal2_t;
cal2_t cal2_fit(float x1, float y1, float x2, float y2)
{
cal2_t c;
c.slope = (y2 - y1) / (x2 - x1);
c.offset = y1 - c.slope * x1;
return c; /* (4,0)-(20,200): slope 12.5, offset -50 */
}
float cal2_apply(cal2_t c, float x) { return c.slope * x + c.offset; }FAQ
▸When is a two-point calibration enough?
Whenever the sensor or channel is linear over your working range — which covers most industrial transducers, amplified bridges and analog input chains. Two points pin down a straight line exactly; a third point is only needed to check linearity or when the device is known to curve.
▸Which two points should I use?
As far apart as practical, ideally near the ends of the range you care about. Slope error scales with 1/(x₂−x₁), so points close together amplify any reading noise into a large gain error.
▸What do slope and offset mean physically?
Slope is the gain — output units per input unit (12.5 °C/mA in the worked example). Offset is the reading the line predicts at input zero; a nonzero offset is what people informally call the 'zero error'.
▸How do I use the result in my PLC or firmware?
Store the two constants and compute y = slope·x + offset per sample (one multiply, one add). The reverse direction x = (y − offset)/slope converts a desired output back to the raw input — the tool computes both live.
▸Is my data uploaded?
No. The fit runs locally in your browser.