Beau Schwabe
Active Member
Ok, So here is an attempt to filter the output of a HX711 ... The Blue line is the raw data from the sensor and the Orange line is the filtered result.
Basically I setup TWO peak detectors in software, one for a HIGH peak detector and another for a LOW peak detector with a decay of ONE for each.
For the HIGH Peak, the decay decreases the HIGH Peak value ... for the LOW Peak, the decay increases the LOW Peak value. 'LOW Peak' and 'HIGH Peak' are two separate variables shown in Red and Green. The 'Peak Avg HIGH' and 'Peak Avg LOW' are also two separate values that take an average each time the corresponding Peak variable is bumped up or bumped down.
PSEUDO CODE:
The 'Peak Avg HIGH' and 'Peak Avg LOW' are then Averaged together in a 5 sample window average to produce the Orange Output
PSEUDO CODE:
Any thoughts or comments are welcome.... The idea here was to try to get good response without having to average the heck out of the original data wich introduces a sluggish, delayed response.
Note: I normalized the data from the HX711 sensor, so that it is NOT 2's complement, but a Centered integer instead.... i.e. -127 to 127 becomes 0 to 255 where the resting value is 127
Basically I setup TWO peak detectors in software, one for a HIGH peak detector and another for a LOW peak detector with a decay of ONE for each.
For the HIGH Peak, the decay decreases the HIGH Peak value ... for the LOW Peak, the decay increases the LOW Peak value. 'LOW Peak' and 'HIGH Peak' are two separate variables shown in Red and Green. The 'Peak Avg HIGH' and 'Peak Avg LOW' are also two separate values that take an average each time the corresponding Peak variable is bumped up or bumped down.
PSEUDO CODE:
Code:
If RAW > PeakHIGH Then
PeakHIGH = RAW
PeakAVGH = Int((PeakAVGH + RAW) / 2)
End If
If RAW < PeakLOW1 Then
PeakLOW = RAW
PeakAVGL = Int((PeakAVGL + RAW) / 2)
End If
PeakHIGH = PeakHIGH - 1
PeakLOW = PeakLOW + 1
The 'Peak Avg HIGH' and 'Peak Avg LOW' are then Averaged together in a 5 sample window average to produce the Orange Output
PSEUDO CODE:
Code:
PeakAVGComposite = Int((PeakAVGH + PeakAVGL) / 2)
DataBase = DataBase + PeakAVGComposite
DataBase = DataBase - DataBase_Avg
DataBase_Avg = Int(DataBase / 5)
Any thoughts or comments are welcome.... The idea here was to try to get good response without having to average the heck out of the original data wich introduces a sluggish, delayed response.
Note: I normalized the data from the HX711 sensor, so that it is NOT 2's complement, but a Centered integer instead.... i.e. -127 to 127 becomes 0 to 255 where the resting value is 127
Attachments
Last edited: