Back to the journal

Analog essentials

Give an analog signal a useful meaning.

A raw number is only the beginning. Scale it, name its units, and test the boundaries.

Fieldnotes / Learning series3 min read

Start with two ranges.

An analog input module supplies a numerical representation of a measurement. Your process logic usually needs engineering units: temperature in degrees, pressure in bar, or tank level in percent. Scaling maps the configured raw input range onto that engineering range.

For a deliberately simple example, assume a raw range of 0 to 1000 represents a tank level of 0 to 100 percent. A raw reading of 250 represents 25 percent. These raw limits are illustrative: use the actual module configuration and sensor calibration for a physical installation.

The linked lab exercise applies the same principle to an input range of 4–20 and an output range of 0–100. Its amplifier uses gain 6.25 and offset −25, so an input of 12 gives an output of 50. Change the input to 4 and 20 to check the endpoints.

engineering = engineeringMin
  + (raw - rawMin)
  * (engineeringMax - engineeringMin)
  / (rawMax - rawMin)

Example: 0 + (250 - 0) * (100 - 0) / (1000 - 0)
Result:  25 %

The boundaries are part of the behavior.

Check the lower endpoint, midpoint, and upper endpoint. Then deliberately go outside the range. A linear scaling expression extrapolates: raw 1100 becomes 110 percent in this example. Clamping the result to 100 percent may make a display neater, but it can conceal an over-range condition unless validity is tracked separately.

A zero-width raw range would divide by zero. Treat it as a configuration error. Also decide how missing, non-finite, or invalid values are represented. A plausible-looking zero is not always a useful substitute for an unavailable measurement.

  • raw = 0 → 0 %
  • raw = 500 → 50 %
  • raw = 1000 → 100 %
  • raw = 1100 → 110 % before any explicit clamp
  • rawMin = rawMax → invalid configuration

Keep measurement and control understandable.

Give the scaled signal a name that includes its meaning, such as TankLevelPercent. Place thresholds after scaling so the threshold values are understandable in the same units. If noisy input makes an output flicker around a threshold, investigate filtering and hysteresis as separate behaviors.

For example, a high-level indicator can turn on at 80 percent and clear below 75 percent. The gap prevents tiny movements around 80 percent from repeatedly changing the indicator. Document what happens exactly at each threshold and test both rising and falling values.

The component library tracks analog blocks alongside their implementation status. Use that status to distinguish the available lab exercises from the planned control tools.