Connect with us

How do I add up analogue inputs to average them?

Discussion in 'Sensors and Actuators' started by Waynelee, Mar 22, 2021.

Scroll to continue with content
  1. Waynelee

    Waynelee

    3
    0
    Mar 22, 2021
    Hey, there
    I would like to read a sensor (acs712) a number of times (20), add them all up, then divide them by the number of reads. So I can get an average to give me a sort of analogue "debounce".
    Am I guessing the sum function?

    I sincerely appreciate any advice you can all give me, I'm incredibly excited about learning all of this!
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    11,713
    2,719
    Nov 17, 2011
    I assume you want to do this using a microcontroller, right? What controller do you use?
    You can do it your way, this will average packets of 20 values each. I.e. you will get one output for every 20 inputs.

    Another approach is a moving average (or rolling average). This will give you an output for every input, also averaged over e.g. 20 values. The advantage is that this method will allow you to react faster to change in input, quickly detect trends etc.
     
  3. Waynelee

    Waynelee

    3
    0
    Mar 22, 2021
    I get an idea, having a A2D converter for the sensor, then 20 digital values that can be averaged by a MCU, CPU or GPU.
     
  4. Harald Kapp

    Harald Kapp Moderator Moderator

    11,713
    2,719
    Nov 17, 2011
    The ACS712 has a built-in filter. You can select the amount of noise suppression by changing the filter capacitor on pin 6. No need to average on the mcu, but possible, of course.
    Which mcu will you use? many of today's mcus have built-in ADCs, so you wouldn't need a separate ADC, unless you want an accuracy much higher than what a built-in ADC of an mcu can offer.
     
  5. Waynelee

    Waynelee

    3
    0
    Mar 22, 2021
    TI MSP430G2452
    ADC channels – 8
    ADC Resolution – 10-Bit SAR
     
  6. Bluejets

    Bluejets

    5,043
    1,053
    Oct 5, 2014
    Arduino have 10 bit resolution on the adc and easy to use into the bargain.
    If you are measuring dc, then then INA219 is a good alternative and on I2c.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-