Hi all,
Can you please show me how to compute a rolling average? The playground page isn't too helpful.
Hi all,
Can you please show me how to compute a rolling average? The playground page isn't too helpful.
chessy:
Hi all,Can you please show me how to compute a rolling average? The playground page isn't too helpful.
Why isn't it helpful? What are you not understanding?
There actually is no page for Rolling Averages.
And with the Running Average page, I copied and pasted the code to a .cpp and .h file, then combined them into a RunningAverage folder and put it in libraries. However, I get the error message that 'a subfolder of your sketchbook is not a valid library.'
chessy:
There actually is no page for Rolling Averages.
You wrote that there was.
Have you tried Googling 'rolling averages'? The concept is the same which ever language you use. Do you even know how to program?
(deleted)
http://playground.arduino.cc/Main/RunningAverage
first off there is a page.
second, it is confusing as any I have ever seen.
Alas, it boils down to the simple "FORUM LAW"
the answers are only as good as the question.
a corollary is that you have to know the technology in order to ask the right question.
and that implies that if you knew the technology, you would not be asking the question......
the other corollary is that a person responding has to grasp that the OP does not know the technology or would not be asking. posting answers that assume the OP has a comprehensive and working knowledge of the technology lead to more answers and confusion.
I tried to read the running averages page and left more confused that when I started.
doing it the hard way
sensor = analogRead(SensorInput) ; // this was posted incorrectly.
reading = analogRead(SensorInput ; // this is more better.
reading9 = reading8 ;
reading8 = reading7 ;
reading7 = reading6 ;
reading6 = reading5 ;
reading5 = reading4 ;
reading4 = reading3 ;
reading3 = reading2 ;
reading2 = reading1 ;
reading1 = reading0 ;
reading0 = reading ;
running_average = (reading0 + reading1 + reading2 + reading3 + reading4 + reding5 + reading6 + reading7 + reading8 + reading9) / 10;
dave-in-nj:
sensor = analogRead(SensorInput) ;
Should be
reading = analogRead(SensorInput) ;
i guess.
lg, couka
. . . but the compiler woud've told you that, wouldn't it?
If all the used variables were declared before... I doubt that.
lg, couka
dave-in-nj:
a corollary is that you have to know the technology in order to ask the right question.
and that implies that if you knew the technology, you would not be asking the question......the other corollary is that a person responding has to grasp that the OP does not know the technology or would not be asking. posting answers that assume the OP has a comprehensive and working knowledge of the technology lead to more answers and confusion.
I tried to read the running averages page and left more confused that when I started.
When I am asking a question and expecting help, I try do all the work, so that the person answering with have a clickable lik in order to help answer what I do not know.
First, there is a page. then there isn't a page. What? ? ?
I am not going to waste my time to hunt for something that you need help with.
I am grasping that the OP does not know. But I have no idea what is it that is confusing. Explain yourself better if you expect a better answer. I am not a mind reader.
How much programming has the OP done? Can he translate code from one language to another.
Rolling averages is hardly rocket science.
Google is always a great resource. I use it constantly.
I am kind of a newbie at code.
dave-in-nj:
doing it the hard waysensor = analogRead(SensorInput) ;
reading9 = reading8 ;
reading8 = reading7 ;
reading7 = reading6 ;
reading6 = reading5 ;
reading5 = reading4 ;
reading4 = reading3 ;
reading3 = reading2 ;
reading2 = reading1 ;
reading1 = reading0 ;
reading0 = reading ;
running_average = (reading0 + reading1 + reading2 + reading3 + reading4 + reding5 + reading6 + reading7 + reading8 + reading9) / 10;
The only problem is that the sensor calculates values in the loop function and I do not know how to make the value generated by one loop be different from the next.
chessy:
I am kind of a newbie at code.
The only problem is that the sensor calculates values in the loop function and I do not know how to make the value generated by one loop be different from the next.
first off, fix my total F-up and instead of using
sensor = analogRead(SensorInput) ;
use
reading = analogRead(SensorInput) ;
now, you have to do some work.
you have to figure out what your variables will be.
assuming, you are using the ADC, we can know that 10 variables, will be less than 6,000 and will work well in this simple sketch.
before setup, do the leg work,
int reading ;
int reading1;
and so on.
let's take it from the top.
since you are asking, that means you have a sketch ? right ?
go to the top of any forum, read the post that say how to use this forum,
scroll down to #7 and read about code tags.
then, copy your code and post it.
so far, we have nothing to work with.
dave-in-nj:
doing it the hard waysensor = analogRead(SensorInput) ; // this was posted incorrectly.
reading = analogRead(SensorInput ; // this is more better.
reading9 = reading8 ;
reading8 = reading7 ;
reading7 = reading6 ;
reading6 = reading5 ;
reading5 = reading4 ;
reading4 = reading3 ;
reading3 = reading2 ;
reading2 = reading1 ;
reading1 = reading0 ;
reading0 = reading ;
running_average = (reading0 + reading1 + reading2 + reading3 + reading4 + reding5 + reading6 + reading7 + reading8 + reading9) / 10;
That really is serious head-banging.
To perform a rolling average, you use a (circular) array to hold the values. A pointer steps through the array, cycling back from last to first to make it circular.
A value called "tally" is kept; at each step, the value pointed to is subtracted from the tally, the new value is added to the tally and also stored according to the pointer, which is then incremented.
The average is determined by dividing the tally by the number of entries in the array. If that number is a power of two, the division is performed by a simple shift operation, similarly for arrays of ten or 100 decimal floats.
You seem to start a lot of threads about rolling averages. How about just sticking to one, so everyone can see the answers that have already been given?
http://forum.arduino.cc/index.php?topic=403804.0
http://forum.arduino.cc/index.php?topic=403565.0
... and the first one has already been merged!
Paul__B:
That really is serious head-banging.
it is at the OP's level.
some times the head-banging is getting the concept.
that was like long division compared to the shorthand of your array.
@chessy: Please think long and hard before starting any new threads.
Thread locked.