I am attempting my first build of a 200kg load cell setup to be used as a lower-body isometric strength tester. I am using this load cell: Amazon.com
and have followed the instructions, code and all, from this web page: Building a Load Cell Based Strength Tester - PHYSICAL FUNCTION ASSESSMENT TOOLS
connecting the load cell to an Arduino Mega2560 through the HX711 load cell amp.
Everything is hooked up according to the diagram below, with the exception of the yellow. The load cell I have has loose wires inside the main wire instead of a yellow wire (not sure how to handle the loose wires).
but when I try to collect data within the Arduino IDE or the downloadable labview programs on that web page I am getting spikes following the patterns of what i would expect in tension and compression rather than smooth time series data (i.e. increase force applied, spikes get higher, maintain force applied, spikes stay level). It is registering changes in tension as negative force and compression as positive, increasing for single samples and then returning to zero for several samples, almost like its only reading one of every 4-5 samples.
Code provided below.
/*
QUICK README:
The following code is a modification done by Ross Clark of the code created by Nathan Seidle from Sparkfun Electronics. If you meet him you
must buy him a beer under the rules of the Beerware licence.
This example code also uses bogde's excellent library for the HX711: https://github.com/bogde/HX711
bogde's library is released under a GNU GENERAL PUBLIC LICENSE
If this version does not work you can download the files from the https://www.rehabtools.org website and open in Arduino on your computer.
*/
#include "HX711.h"
// This assumes the following connections have been made
// Amplifier Board DAT = Arduino digital pin 3
// Amplifier Board CLK = Arduino digital pin 2
HX711 scale(3, 2); // parameter "gain" is ommited; the default value 128 is used by the library
float force = 0;
#define calibration_factor -7050.0
// Generally, you should use "unsigned long" for variables that hold time
// The value can quickly become too large for an integer to store - not in this case but its good practice
unsigned long previousMillis = 0; // will store last time the serial output was updated
// constants won't change :
const long interval = 1; // interval at which to check for changes in the load cell data (milliseconds). 1 is fine
void setup() {
Serial.begin(57600);
scale.set_scale(calibration_factor); //Calibration factor (defined above) is very important for the accuracy of your data.
//The number in this code is arbitrary and will not be directly applicable to your load cell, but will likley put you in the ballpark
//You can then experiment with the Sparkfun code or the additional software from my site (rehabtools.org)
scale.tare(); //Zero the load cell - this is important to remove factors such as drift or when starting with something on the load cell
// you don't want to include in the weight.
}
void loop() {
force = scale.get_units()*0.453592; //This multiples the original value by 0.454 to convert from lbs to kg.
//The following section is a very good piece of code to use when collecting data. It waits for a set interval (set above) then runs the subsequent code.
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
Serial.println(force); //This prints the force value from the load cell to the serial port. You can then use this data for your own programs
// or extract it using the examples on my site (rehabtools.org).
}
}
Does anyone have an idea what could be going wrong where I'm registering data intermittently?