How to reduce the sample noise for the code above?
- Sample at a higher rate, or get more samples. I use at least 16Hz
- Use a rolling average of 8 samples.
Add:
dim HX711_AVG1 as long ;Average 1 in binary
dim HX711_AVG2 as long ;Average 2 in binary
dim HX711_AVG3 as long ;Average 3 in binary
dim HX711_AVG4 as long ;Average 3 in binary
dim HX711_AVG5 as long ;Average 3 in binary
dim HX711_AVG6 as long ;Average 3 in binary
dim HX711_AVG7 as long ;Average 3 in binary
dim HX711_AVGOUT as long ;the 4 inputs/4
And for each time you sample the HX711 (CALL HX711_GET), also call HX711_AVG.
Average output of samples is in HX711_AVGOUT
Sub HX711_AVG
HX711_AVGOUT = HX711_AVG0 + HX711_AVG1
HX711_AVGOUT = HX711_AVGOUT + HX711_AVG2
HX711_AVGOUT = HX711_AVGOUT + HX711_AVG3
HX711_AVGOUT = HX711_AVGOUT + HX711_AVG4
HX711_AVGOUT = HX711_AVGOUT + HX711_AVG5
HX711_AVGOUT = HX711_AVGOUT + HX711_AVG6
HX711_AVGOUT = HX711_AVGOUT + HX711_AVG7
HX711_AVGOUT = HX711_AVGOUT/8
;Now shuffle the samples for next time
HX711_AVG7 = HX711_AVG6
HX711_AVG6 = HX711_AVG5
HX711_AVG5 = HX711_AVG4
HX711_AVG4 = HX711_AVG3
HX711_AVG3 = HX711_AVG2
HX711_AVG2 = HX711_AVG1
HX711_AVG1 = HX711_AVG0
end Sub
I have been working on using some strain Gauges, and the HX711 amplifier in the cheaply available board as pictured.
The code could be improved, such as easier to change the HX711 channel and gain, but this does work as is
How to reduce the sample noise for the code above?
- Sample at a higher rate, or get more samples. I use at least 16Hz
- Use a rolling average of 8 samples.
Add:
And for each time you sample the HX711 (CALL HX711_GET), also call HX711_AVG.
Average output of samples is in HX711_AVGOUT
Last edit: James Whyte 2020-04-20