PortableBalanceLab / PBL

Learn how to create your own balance lab using python and a Raspberry Pi
4 stars 1 forks source link

`S3`: Possible fix to the force plate software after getting the hardware modification. #69

Open adamkewley opened 1 year ago

adamkewley commented 1 year ago

The Bug

After having the force plate's load cells modified so that they sample at a higher rate, force plate codes that used to work are now broken.

Possible Solution

Modify hx711.py with a looser (higher) standard deviation:

  1. Open hx711-multi/src/hx711-multi/hx711.py
  2. Find (Ctrl+F) self._max_stdev (line 585 - here is what it should look like)
  3. Change the hard-coded self._max_stdev value from 100 to something much higher (e.g. 1000000)
  4. For sanity, place a temporary print("modified code is running") line below your modification so that, when you test your code, you can be certain that your code uses the modified library code (rather than the hx711 that is installed system-wide).
  5. Modify readings_to_average in your code to a higher value, to reduce noise in your data.
  6. Run your scripts. They should print "modified code is running", so you know for sure that your modifications are being ran.
  7. Remove print("modified code is running") from the script - it was only temporary

Troubleshooting this Solution

Weight Values are Incorrect

Your force plate was calibrated in one hardware mode, but the hardware modification changed that mode. This may affect the raw readings that are produced by the force plate. If you find that the raw values you read are now very different from previous measurements, you may need to recalibrate:

# example of running your modified calibrate.py in a terminal
# don't use /opt/hx711-multi/tests/calibrate.py - that's the unmodified version
cd /home/pbl/Desktop/hx711-multi
python3 tests/calibrate.py

It Still Produces None Values Everywhere

If this Solution Doesn't Work

The issue might be deeper in hx711-multi, or a hardware issue. We are investigating the library but, if in doubt, reverse the hardware change. The electrical engineer can do this. The procedure involves placing a bead of solder back over the connection.

We will try and investigate each issue with this hardware change but some variables are out of out control (specifically, the hardware and the library code). If we cannot fix your sampling rate (e.g. with this hardware change), the measurement will have to be done on the lower sample rate (10Hz). In this case, it is important to note this in the method section of your abstract and how you dealt with this (e.g. right filtering) and to discuss in  the discussion section of your abstract what the effect is of this low sample frequency on your results and conclusions.