Analog to Digital Module Integration and Data Processing in Embedded Systems

Amazeng Technical Team
4 min read
Embedded SystemsADC IntegrationSignal ProcessingFirmwareData AnalysisCalibration

In an embedded system, the value coming from an ADC is not a physical quantity but just an integer (one of 16,777,216 possible values for 24 bits). To turn that number into a meaningful measurement, firmware has to apply four steps in order: interpret the raw data correctly, filter it, convert it to a physical unit with calibration coefficients, and process it in real time. This article explains the approach Amazeng follows in the ZMA and GDT series, with formulas and a numeric calibration example.

How is raw ADC data interpreted?

The output of a 24-bit ADC can come in two formats:

FormatRangeTypical use
Unipolar0 … 16,777,215Positive-only signals
Bipolar, two's complement−8,388,608 … +8,388,607Differential signals such as load cells (tension and compression)

With bipolar data, the sign bit must be preserved when the 24-bit value is widened to a 32-bit integer. If this step is skipped, negative loads appear as very large positive numbers:

int32_t sign_extend_24(uint32_t raw)
{
    if (raw & 0x800000u) {          /* bit 23 is the sign bit */
        raw |= 0xFF000000u;         /* fill the upper 8 bits with 1s */
    }
    return (int32_t)raw;
}

Another practical note: the mantissa of a 32-bit float is 24 bits, so 24-bit raw values fit into a float without loss. The sum of many samples (for averaging), however, exceeds that limit; keeping sums in int64_t avoids losing precision.

How is raw data filtered?

Before calibration, digital filters are applied to reduce hardware noise. The most common options:

FilterAdvantageDrawback
Moving average (N samples)Simple, reduces white noise by √NResponds to sudden changes with an N-sample delay
Exponential average (IIR, coefficient α)Little memory, adjustable strengthSettling time depends on α, smooths peaks
Median filterRemoves isolated spikesHigher computational load

Worked example: 16-sample moving average at 1 kHz

Noise reduction    = √16 = 4× (≈ 2 bits of effective resolution gained)
−3 dB bandwidth    ≈ 0.443 × fs / N = 0.443 × 1000 / 16 ≈ 27.7 Hz
Delay (group)      ≈ (N − 1) / 2 samples = 7.5 ms

This setting suits slowly changing measurements such as weighing; but if you want to capture the peak in a fracture test, you must account for the filter clipping that peak. Peak tracking is therefore usually done separately on unfiltered or lightly filtered data.

How are calibration coefficients applied?

Firmware converts raw data into physical units using pre-recorded Zero and Span values:

k = Span_load / (Span_raw − Zero_raw)
Measured value = (Raw − Zero_raw) × k

Worked example: two-point calibration

StepLoadRaw value
Zero calibration (empty)0 kg125,000
Span calibration (reference weight)50.000 kg1,802,000
k = 50.000 / (1,802,000 − 125,000) = 50 / 1,677,000 ≈ 2.98 × 10⁻⁵ kg/count (≈ 0.03 g/count)
For Raw = 900,000: (900,000 − 125,000) × k ≈ 23.107 kg

Here "0.03 g/count" is a calculation step; the real resolution of the measurement is set by noise. For traceability of calibration references, see the calibration and metrology glossary entry. In the field, Tare shifts the zero point instantly without disturbing the calibration, while Zero sets a new zero reference.

For nonlinear sensors two points may not be enough; a multi-point piecewise-linear table or polynomial correction is then used.

What is real-time signal processing?

Especially in devices such as ZMA Data Acquisition, which sample at up to 1 kHz, "Peak" and "Valley" values are updated as each sample arrives. See the peak-valley glossary entry for details. When this is done in firmware, the highest value is not lost no matter how slow the display or communication is.

What does Zephyr RTOS add to ADC integration?

At Amazeng we use Zephyr RTOS in the firmware layer. This modern operating system offers the following advantages for ADC integration:

  • Multi-threading: Data acquisition runs in a high-priority thread, while Modbus communication or display updates run in other threads. Communication load therefore does not delay sampling, and the risk of data loss is reduced.
  • Standard ADC API: Our signal processing algorithms in the upper layer stay the same even when we use different ADC chips.

What does the firmware layer of GDT and ZMA do?

Our devices are not just "converters" but small computers:

  • GDT Digital Transmitter: Works with 24-bit resolution and 1000 Hz sampling; its adaptive filter algorithms can analyze the vibration characteristic in the field and set the filter strength themselves. It communicates over Modbus RTU/TCP and RS232.
  • Synchronization: In the ZMA series, data from multiple channels is synchronized with timestamps, so the relationship between, for example, force and displacement can be analyzed clearly.

Summary: checklist for the ADC data processing chain

  • Verify the raw data format (unipolar / two's complement) and test sign extension.
  • Choose the filter type and N according to the bandwidth the measurement needs; calculate the delay.
  • Calibrate with references that represent the measuring range and store coefficients in non-volatile memory.
  • Track peaks at a point where the filter will not clip them.
  • Keep sampling separate from, and higher priority than, communication and UI tasks.

Talk to our engineering team about our embedded system solutions and custom firmware needs.