Hey guys...Hopefully you can help me this one I just need to filter and averaging my data of my Drag and Lift force ,maybe due to some noises and vibrations in my project which is wind tunnel.
Example of the data that i gather!!!
(Only the Dragforce)
5
4
6
10
15
8
20
13
3
4
9
11
15
20
5
1
3
7
13
all i need is to filter the number between 3-8
..and averaging them by atleast 10number...
Here is my code..
#include “HX711.h”
// HX711 circuit wiring
const int DF_DOUT = 2; // DOUT for drag
const int DF_SCK = 4; // SCK for Drag
const int LF_DOUT = 11; // DOUT for Lift
const int LF_SCK = 12; // SCK for Lift
//HX711 constructor:
HX711 DFORCE;
HX711 LFORCE;
void setup() {
Serial.begin(38400);
Serial.println();
Serial.println(“Starting Set Up…”);
DFORCE.begin(DF_DOUT, DF_SCK);
DFORCE.set_scale();
DFORCE.tare();
LFORCE.begin(LF_DOUT, LF_SCK);
LFORCE.set_scale();
LFORCE.tare();
}
void loop() {
long DragOrigRead = DFORCE.read ();
long Drag2ndRead;
long Drag1stRead;
long LiftOrigRead = LFORCE.read ();
long Lift2ndRead;
long Lift1stRead;
Serial.println();
Serial.println();
Serial.println(“Start The Fan And Set A Desired Velocity”);
Drag1stRead = (-000.524* LiftOrigRead) -127008.2+14000;
Lift1stRead = (-000.525* DragOrigRead) +37008.2+52000;
Serial.print(“Drag Force Reading Is:”);
Serial.print(Drag1stRead);
Serial.println();
Serial.print(“Lift Force Reading Is:”);
Serial.print(Lift1stRead);
delay(10000);
}
That code shows no filtering and no averaging. What have you tried? Please post your best effort. A typical way to average something is to declare an array of the average size so you can store the values. When a new value arrives, toss the oldest and insert the newest and calculate the average. You can also keep a running total to speed things up. Google will give you lots and lots of hits...