Just be aware of integer overflow. An int can only store up to # 32k. If you wanna make more samples, use a long data type inside the looping for() in data average variable.
You could also have a trend average... take 75% (or something) of the past and 25% (100% - past) of the last reading. Set the initial value to the first reading so you don't start at zero. You can change the percentages to change how much "spike" you want. E.g. static long sensorAverage = analogRead(PIN); sensorAverage = 0.75 * sensorAverage + 0.25 * analogRead(PIN);
Thanks for the video, Kindly assist with arduino code to do this linear regression equation: y=(8*10^-5)x^2+0.1873x+46.131. x is the analog output of the sensor to give an output y, but x is the average of 200 analog samples(x)
is this what I'm trying to code (and failing)? let's say we want 10 readings to avg from. we keep a number 'sum' on which we add the newest readings to, remove the 10th/oldest readings, then 'sum/10' will give a new avg'd value to output. is that it?
Just be aware of integer overflow. An int can only store up to # 32k.
If you wanna make more samples, use a long data type inside the looping for() in data average variable.
Thank you. I was actually looking for a way to smooth out the signal from MPU 6050. Thanks again 🙏
You could also have a trend average... take 75% (or something) of the past and 25% (100% - past) of the last reading. Set the initial value to the first reading so you don't start at zero. You can change the percentages to change how much "spike" you want. E.g.
static long sensorAverage = analogRead(PIN);
sensorAverage = 0.75 * sensorAverage + 0.25 * analogRead(PIN);
Thank you for your video! This was very helpful for my project!
Excellent information. Thank you.
I think this will help me with coding linear acceleration for a stepper motor.
thanks this was simple and helpfull
thank u sooo muchh!!!
Thaaaaaaaankkkkkkk yoooooooouuuuuuu!
thanks!
I only get once every 10 readings a number, and it is not the avg of the reading. have the same code so don't know what is wrong?
Thanks for the video,
Kindly assist with arduino code to do this linear regression equation: y=(8*10^-5)x^2+0.1873x+46.131.
x is the analog output of the sensor to give an output y, but x is the average of 200 analog samples(x)
nice
how to get mean of that signal ?
What to do for digital input??
update( new ) {
static A[ N ] ={ 0 }
static sum = 0
static p = 0
sum = sum - A[ p ] + new
A[ p ] = new
p = (p + 1) % N
return sum / N }
is this what I'm trying to code (and failing)? let's say we want 10 readings to avg from. we keep a number 'sum' on which we add the newest readings to, remove the 10th/oldest readings, then 'sum/10' will give a new avg'd value to output. is that it?
1 April
code please sir