Blog

HX711 Analysis for SlackCellv2

I'm currently working on the second version of SlackCell. I switched from Arduino to a Raspberry Pi Zero WH to open up the possibilities. It's running a webservice which makes the SlackCell platform independent (as long as the platform has a modern browser). Furthermore it's less buggy than the old Bluetooth connection and will support more LEDs for the LeuchteLine. Recording works much better and so I looked a bit deeper into the data which are generated by the 24bit ADC HX711.

First Filter

While creating the front end I noticed that I get huge force spikes from the HX711. So I implemented the rudimentary filter of SlackCellv1 that the force must deviate less than 1kN from the previous value. This actually made it harder to see, what is actually going on. So after the first tests without load I plotted the forces. Big random spikes still appeared which seemed to have the same value. I recorded a sample without the filter and started to analyze with Python.

Second Filter

Unfiltered Forces from HX711
Looking at the peak values I got the idea that they could be 2^n values. So I tried to convert them back from the force values to raw values. I'm loosing some accuracy while converting to int in the Python script so they were not perfect but close to 2^n. Next I recorded raw data from the HX711. And the peaks are actually at (2^n - 1) for n = [15, 24]. Which means they are a stream of ones in binary. I found two more peaks for 20479 (binary: 100111111111111) and 24575 (binary: 101111111111111) which are also mostly ones. n = 24 is the limit because the HX711 is a 24bit ADC. Apparently the HX711 likes to write a lot of ones from time to time. I don't know the reason for that but for this project I don't need to do further research.
Filtered Forces from HX711
After applying the filter for these discrete values I get better results. There are still some smallish spikes but they are not repeating their value. Depending on the sample I'm dropping a bit less than 0.5% of the data. As the HX711 is recording in 80Hz mode (12.5ms) this is no problem. Furthermore the standard deviation gets reduced by a factor of 1e3 and is around 1. Let's see if I have to filter more when I'm recording dynamic loads.

Sample Rate

The sample rate fluctuates a bit but more than 99% are in the range of 10 - 14 ms. The mean is 13 ms (goal 12.5 ms), max is roughly 6 times that which probably occurs while polling Pi stats. Often a long timedelta is followed by a really short one which could be caused by some interruption of the data aquiring thread and the timestamp is not taken right after reading the force. That's the problem when you're switching from near realtime C++ to Python.