How to add up analogue inputs to average them?

  • Thread starter Stonestreecty
  • Start date
  • Tags
    Average
In summary: I sincerely appreciate any advice you can give me, I'm incredibly excited about learning all of this! Many thanks.
  • #1
Stonestreecty
20
3
TL;DR Summary
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
  • #2
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?
 
  • #3
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.
 
  • #4
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 berkeman
  • #6
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 Tom.G

1. How can I add up analogue inputs to average them?

The first step is to connect all of your analogue inputs to a data acquisition system, such as a microcontroller or data logger. This will allow you to read and record the values from each input.

Next, you will need to write a program or script to read the values from each input and add them together. This can be done using a simple mathematical equation, where the sum of all the values is divided by the number of inputs.

Finally, to get the average value, you will need to divide the sum by the total number of inputs. This will give you the average value of all the inputs combined.

2. Can I use a multimeter to add up analogue inputs?

Yes, you can use a multimeter to measure the values of each analogue input. However, you will need to manually record and add up the values, which can be time-consuming and prone to human error. It is recommended to use a data acquisition system for more accurate and efficient results.

3. Do I need to convert the analogue inputs to digital before adding them up?

No, it is not necessary to convert the analogue inputs to digital before adding them up. As long as your data acquisition system can read and record the analogue values, you can use them directly in your calculations for averaging.

4. Can I average different types of analogue inputs?

Yes, you can average different types of analogue inputs, such as voltage, current, or temperature. As long as your data acquisition system can read and record the values, you can add them up and calculate the average value.

5. How can I ensure accuracy when adding up analogue inputs to average them?

To ensure accuracy, it is important to use a high-quality data acquisition system and to regularly calibrate your equipment. You should also minimize any sources of error, such as noise or interference, and take multiple measurements to verify the results. Additionally, using a larger number of inputs can help to increase the accuracy of your average value.

Similar threads

Replies
2
Views
1K
  • Computing and Technology
Replies
4
Views
275
Replies
14
Views
649
  • Introductory Physics Homework Help
Replies
2
Views
981
Replies
4
Views
929
Replies
9
Views
1K
  • Engineering and Comp Sci Homework Help
2
Replies
40
Views
3K
  • Precalculus Mathematics Homework Help
Replies
2
Views
2K
  • Other Physics Topics
Replies
6
Views
2K
  • STEM Academic Advising
Replies
18
Views
2K
Back
Top