A simple loadcell calibration program based on a load cell and HX711 amp. Using HX711 by Bertrand Bouvier. Calibration code comes from SparkFun example at https://learn.sparkfun.com/tutorials/load-cell-amplifier-hx711-breakout-hookup-guide?_ga=1.169212841.987765858.1442369657.
Revision 0:5f789b9ae213, committed 2015-11-28
- Comitter:
- mcragun
- Date:
- Sat Nov 28 19:35:24 2015 +0000
- Commit message:
- A sample loadcell calibration program.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HX711.lib Sat Nov 28 19:35:24 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/laskowsk/code/HX711/#716e1cbdac61
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Nov 28 19:35:24 2015 +0000 @@ -0,0 +1,49 @@ +#include "mbed.h" +#include "HX711.h" + +DigitalOut gpo(D0); +DigitalOut led(LED_BLUE); +HX711 scale(A0, A1); + +AnalogIn scaleRaw(A3); +Serial pc(USBTX, USBRX); // USB Serial Terminal +float calibration_factor = 1000; //-7050 worked for my 440lb max scale setup +int averageSamples = 100; + +int main(void) +{ + pc.printf("Starting Scale"); + pc.printf("HX711 calibration sketch"); + pc.printf("Remove all weight from scale"); + pc.printf("After readings begin, place known weight on scale"); + pc.printf("Press + or a to increase calibration factor"); + pc.printf("Press - or z to decrease calibration factor"); + + + scale.setScale(0); + scale.tare(); //Reset the scale to 0 + + long zero_factor = scale.averageValue(averageSamples); //Get a baseline reading + pc.printf("Zero factor: %.4f\n" , zero_factor); //This can be used to remove the need to tare the scale. Useful in permanent scale projects. + + while (true) { + scale.setScale(calibration_factor); //Adjust to this calibration factor + float weight = scale.getGram(); + //float raw = scaleRaw.read(); + pc.printf("Reading: %.2f\n", weight); + //pc.printf("Raw Value: %.7f\n", raw); + pc.printf(" calibration_factor: %.2f\n", calibration_factor); + + + if(pc.readable()) { + char temp = pc.getc(); + if(temp == '+' || temp == 'a') + calibration_factor += 10; + else if(temp == '-' || temp == 'z') + calibration_factor -= 10; + } + gpo = !gpo; // toggle pin + led = !led; // toggle led + wait(0.2f); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Nov 28 19:35:24 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/165afa46840b \ No newline at end of file