How to add up analogue inputs to average them?

  • Thread starter Thread starter Stonestreecty
  • Start date Start date
  • Tags Tags
    Average
Click For Summary

Discussion Overview

The discussion centers on how to read and average multiple analog inputs from a sensor (ACS712) to achieve a more stable output, often referred to as "debouncing." Participants explore various methods for averaging, including both software and hardware considerations, and address potential issues with application circuits.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant suggests reading the ACS712 sensor 20 times, summing the results, and dividing by the number of reads to obtain an average.
  • Another participant proposes that averaging 16 or 32 readings before division could speed up the process and reduce noise, citing a reduction factor of √16 = 4.
  • Concerns are raised about the accuracy of application circuits found in a blog, with a specific example being questioned for correctness.
  • A participant discusses different averaging techniques, such as block averaging and running averages, and suggests using a ring buffer for the latter.
  • There is a suggestion to consider implementing a low pass filter instead of averaging, prompting a discussion on the differences between the two methods.
  • One participant points out a specific application from the Allegro datasheet, questioning the use of an inverting op-amp for a signal that operates between 0V and 5V, and suggests a non-inverting configuration might be more appropriate.

Areas of Agreement / Disagreement

Participants express varying opinions on the best approach to averaging and the validity of certain application circuits. No consensus is reached on the optimal method or the correctness of the schematics discussed.

Contextual Notes

Some participants note limitations in the provided application circuits and express uncertainty about the rationale behind specific design choices, such as the use of inverting versus non-inverting op-amps.

Stonestreecty
Messages
20
Reaction score
3
TL;DR
How read a sensor (acs712) a number of times, add them all up, then divide them by the number of reads?
Hi,
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! Many thanks.
 
Computer science news on Phys.org
Stonestreecty said:
Summary:: How read a sensor (acs712) a number of times, add them all up, then divide them by the number of reads?

I would like to read a sensor (acs712)
Some of the application circuits at your blog seem strange/wrong. Did you do the schematics or did you get them from somewhere. If the latter, where did you get them? Like this one for example looks wrong to me at first glance:

1616168876106.png


Stonestreecty said:
Summary:: How read a sensor (acs712) a number of times, add them all up, then divide them by the number of reads?

a number of times (20), add them all up, then divide them by the number of reads.
It makes it faster if you add up 16 or 32 of them before doing the division. Can you say why?
 
I agree with @berkeman, read it 16 times to make division easier, and to reduce the noise by a factor of √16 = 4.
If the bandwidth is 80 kHz then you must select a slow A-D converter, or wait about 15 μsec between reads. 16 conversions will then take 200 μsec.
 
I presume that you're talking about software, not hardware, to do the average. So coding the different ways of doing it could be instructive.

You could do it as a block average: organize into blocks of 16, take the average of each.

You could do it as a running average: with each new sample, compute the average of the most recent 16. Consider using a ring buffer for the running average.

You could do it not an average, but rather as a stream of samples through a low pass filter. How would you implement a filter as opposed to an average?
 
  • Like
Likes   Reactions: berkeman
Tom.G said:
That happens to be Application 3 on pg. 12 of the Allegro datasheet.
Thanks Tom, that helps. I still don't understand why they would suggest using an inverting opamp to amplify a signal that runs between 0V and 5V...

1616246291174.png

I guess you could just invert the readings from your ADC, but why not just use a non-inverting opamp configuration?
 
  • Like
Likes   Reactions: Tom.G

Similar threads

Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 15 ·
Replies
15
Views
2K
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
858
  • · Replies 2 ·
Replies
2
Views
2K