TestBench.tools

PLC Analog Scaling Calculator

Raw counts ↔ engineering units with verified vendor presets.

Engineering value
50
Percent of span
50 %

preset source: spec/vendor-analog-ranges.md

This tool converts raw PLC analog counts into engineering units and back. Pick the verified Siemens S7 preset (0…27648) or enter any custom raw range, set your engineering range, and the conversion — with percent of span — updates live in both directions.

How it works

Analog input modules digitize their electrical input into an integer raw range; your program then maps counts onto physical units with a straight line: eng = engMin + (raw − rawMin) × span ÷ rawSpan. The calculation is symmetric, so the same tool converts a target engineering value back into the raw count to expect — useful when forcing test values or checking a transmitter against a live PLC tag.

Vendor presets in this tool are deliberately conservative: a raw range ships only once its manual reference is recorded in the project's spec gate. Today that is Siemens S7 (0…27648); other vendors are available through the custom range fields.

Worked example

preset: Siemens S7 (0…27648) · engineering range 0…100
raw 13824 → 50.0 (exactly half of 27648)
raw 27648 → 100 · raw 0 → 0

Parameters

ParameterValueNotes
Siemens S70 … 27648verified preset (spec-gated)
Allen-Bradleypending manual verification
Mitsubishipending manual verification
LS ELECTRICpending manual verification
Customany raw rangesame linear formula

C implementation

C
/* Raw PLC counts -> engineering units (linear) */
float plc_scale(long raw, long raw_min, long raw_max,
                float eng_min, float eng_max)
{
    return eng_min + (float)(raw - raw_min)
         * (eng_max - eng_min) / (float)(raw_max - raw_min);
}
/* S7: plc_scale(13824, 0, 27648, 0.0f, 100.0f) -> 50.0f */

FAQ

What is the Siemens S7 raw range?

S7 analog input modules deliver 0 to 27648 counts for a nominal 0–100 % input signal. Raw 13824 — exactly half of 27648 — therefore scales to 50.0 on a 0–100 range. That preset is the only vendor range shipped here, because it is the only one recorded with a source in this project's verification file.

Why are Allen-Bradley and Mitsubishi presets missing?

This site implements vendor constants only after they are recorded with a manual reference in its spec file (a correctness gate). Until then, use the Custom raw range option — the math is identical once you know your module's counts.

What formula does the scaling use?

Plain linear interpolation: eng = engMin + (raw − rawMin) × (engMax − engMin) / (rawMax − rawMin). The reverse direction inverts it and rounds to the nearest integer count.

What happens if my raw value is outside the configured range?

The calculator extrapolates linearly and shows a warning. Real modules clip or signal overflow instead, so an out-of-range result usually means the wrong raw range is configured.

Is my data uploaded?

No. All scaling runs locally in your browser.

Related tools