Skip to content
  • 0 Votes
    1 Posts
    99 Views
    A
    Most firmware projects hit a wall that only maths solves β€” a sensor reading too noisy to use, a frequency that must be detected, a filter that needs tuning, a calculation that loses precision on a microcontroller with no FPU. This post is the practical core: no academic DSP, just the techniques that come up with real sensors. Sample fast enough, or lie to yourself Nyquist: to represent bandwidth B you need fs > 2B; anything above fs/2 folds back as a phantom: f_alias = |f - k*fs|. Thermal logger at fs = 10 Hz with 60 Hz mains hum coupled into the wiring β†’ k=6 β†’ |60-60| = 0 Hz. Your "temperature drift" is mains hum pretending to be DC. 100 Hz sampler with 130 Hz motor PWM residue β†’ |130-100| = 30 Hz phantom. You chase a resonance that doesn't exist. The engineering rule (not the textbook 2x): sample at 5–10x the highest frequency you must resolve, so your filter has room to roll off. Averaging after aliasing can't help β€” the fold already happened at the sampling instant. Anti-alias in analog (RC before the ADC) or by oversampling-then-filtering at high fs. Smooth with the right tool Moving average (N): white noise drops by √N, lag β‰ˆ NΒ·T/2. General thermal and ADC cleanup (N = 16–64). Exponential (EMA): y += alpha*(x-y), O(1) RAM. Display smoothing and tight loops. Median (odd N): kills spikes (WiFi bursts, brush clicks), preserves edges. Put it before averaging in spiky environments. Oversample + decimate: 4x oversampling buys roughly 1 extra bit (16x β†’ +2 bits: sample 160 Hz, average 16, output 10 Hz). Needs real noise across 1 LSB to dither. Hysteresis/deadband: act only past Β±band. Stops relay and fan chatter around thresholds. β†’ Sampling and signal conditioning for industrial sensors Convert counts to units β€” with proof Two-point calibration: take two raw/reference pairs, fit T = aΒ·counts + b, then validate with a third point and record references, conditions, date, and stale-data behaviour (hold-last-good, never actuate on unvalidated samples). Sample on a stable timebase (millis() cadence with +=, not delay() drift under WiFi load). Takeaways: match the rate to the physics, filter in analog before digital, median-before-average for spikes, calibrate with numbers and an expiry date. Finish with Sampling, noise and calibration β€” the full treatment this primer is distilled from. Post your sensor, your rate, the filter you tried, and the numbers. Tag with signal-processing.