bogde / HX711

An Arduino library to interface the Avia Semiconductor HX711 24-Bit Analog-to-Digital Converter (ADC) for Weight Scales.
MIT License
876 stars 535 forks source link

This issue still persists. #216

Open jagannathmurali opened 2 years ago

jagannathmurali commented 2 years ago

This issue still persists. I think that's a fault in the chip design itself.

170.75
170.83
171.22
170.80
170.95
171.04
-143.37
171.36
170.72
170.86
171.10
170.81
170.90
171.05
170.81

EDIT: What I've discovered, however, is that when a spike arises, the next ADC value needs a longer time than usual. This could be used to filter out most of these spikes.

0.03 - 4ms
0.05 - 3ms
0.02 - 3ms
1302.99 - 4ms
0.06 - 10ms
0.05 - 3ms
0.01 - 4ms
...

Originally posted by @Fusseldieb in https://github.com/bogde/HX711/issues/83#issuecomment-844327053

jagannathmurali commented 2 years ago

I also get some spikes

Fusseldieb commented 2 years ago

I do think it's an issue in how Write/Read cycles are handled by the library. It chokes on itself from time to time...

It's pretty unusable imo

Meanwhile I bought another chip on Ali which doesn't have this issue (ads1232ipwr).

X-Ryl669 commented 2 years ago

You can median filter them out easily:

   static inline void swap(float &a, float &b) { float t = a; a = b; b = t; }
   static inline float medianFilter(float value) {
      static float acc[3] = {0, 0, 0};
      static int pos = 0;
      acc[pos % 3] = value;
      if (pos < 2) return value;
      pos++;
      if (acc[0] > acc[1]) swap(acc[0], acc[1]);
      if (acc[1] > acc[2]) swap(acc[1], acc[2]);
      return acc[1];
   }
CossartSim commented 5 months ago

I found a workaround for this issue. You can simply power down the chip between each reading. It removes all the spikes for me but significantly reduces the acquisition frequency.