Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

4-Wire Strain Gauge Wiring Help

Status
Not open for further replies.
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:
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

  • HX711 filtering.JPG
    HX711 filtering.JPG
    149.1 KB · Views: 132
Last edited:
The possible problem I see with that is that you are specifically using the peaks, so if it's a noisy signal it's picking up on the noise rather than removing it - but on the other side, it will respond quickly to changes.

I usually use a slightly different method for noise removal, though both sample rate and required response time will affect the suitability of any particular approach.

In principle, pseudo C style:

Code:
long av_acc; // Storage
int sample; // Raw data
int output; // filtered data

// Sample process routine

if(!av_acc) {
    // Initialise for fast start up & settling
    // You can use a bit set to show initialisation complete instead for speed, or if the samples are zero based.
    output = sample;
    av_acc = (long)(sample << 4);
}
else {
    // Accumulator = 16x sample value, if the shift is 4.
    // Output = accumulator / 16
    // Subtract that = 15 samples old, add new sample.
  
    output = (int)(av_acc >> 4);
    av_acc -= (long)output;
    av_acc += (long) sample;
}

You can change the shift value in both places to change the old/new ratio, a lower shift gives less filtering and a higher one more.

You can also cascade two or more filter stages for higher noise removal with reasonable response time.
 
you are specifically using the peaks, so if it's a noisy signal it's picking up on the noise rather than removing it
--- That's exactly why I am using a traditional High Peak and a not so traditional Low Peak. True noise should be random in both directions and for the most part cancel out. Even with noise present, the true signal derived from the Peaks should bias the direction up or down
 
Hi Pommie/RJ,

I am not sure how to add the HX711 library onto the BBB as it is not possible to access the file system without knowing linux intimately.

Can you explain a little bit more on the bit shifting? This might be why my output is not reading correctly now. I did purchase the AD623 as suggested by RJ and set REF and -Vs to ground. When i do this, i get a reading of 10.9 mV on Vout when sensor is not loaded at all. If i load the sensor up i can get it to go up to 12 mV. Should -Vs be -5v, 0v or is this correct and i just need to shift? I also am using the regular caps, not the electrolytic ones. Sorry, im struggling a little.
 
I did purchase the AD623 as suggested by RJ and set REF and -Vs to ground.
Try adding a 10K resistor from the amp output to ground; that may reduce or eliminate the stray voltage. The amp cannot pull down to exactly its negative supply, just very close.

Though I'd expect that if you have a decent gain set on the amp, you should be able to easily get a volt or more out?

Failing that, if you want to try a negative supply, get something like a MAX660 or ICL7660 - they can convert a +5V input to a -5V output at a few tens of milliamps, suitable for supplying low power circuits such as the opamp.
 
I am not sure how to add the HX711 library onto the BBB as it is not possible to access the file system without knowing linux intimately.
How are you writing any code for this? No library is needed, the C code above simply reads the chip and returns a 24 bit value.

Mike.
 
Status
Not open for further replies.

Latest threads

Back
Top