Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Embiq Community

  1. Home
  2. Knowledge Base
  3. Maths & Signal Processing Basics
  4. πŸ“ Sensor math that matters

πŸ“ Sensor math that matters

Scheduled Pinned Locked Moved Maths & Signal Processing Basics
signal-processimathsfirmware
1 Posts 1 Posters 99 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    admin
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better πŸ’—

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    Powered by NodeBB Contributors
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups