Markel

MSP430FR5969 LP + Sparkfun HX711 0.0 lbs output ?

6 posts in this topic

Hi,
 
   I am evaluating the Sparkfun Load Cell Amplifier HX711 using the MSP430FR5969 Launchpad. I added HX711 library and modified the HX711.cpp and HX711.h according to this post below. 
 
 
 
   I opened the SparkFun_HX711_Example.ino. After build, I get this error at HX711.h.
 
error: ISO C++ forbids in-class initialization of non-const static member 'OFFSET'
 
   I comment out the initialization value of OFFSET and SCALE and it build without errors. I load the program to MSP430FR5969 LP and I get this output,
   "Reading: 0.0 lbs"
 
   HX711.h
 
class HX711
{
	private:
		byte PD_SCK;	// Power Down and Serial Clock Input Pin
		byte DOUT;		// Serial Data Output Pin
		byte GAIN;		// amplification factor
		long OFFSET;    // = 0;	 used for tare weight
		float SCALE;    // = 1;	 used to return weight in grams, kg, ounces, whatever

SparkFun_HX711_Example.ino

 This example demonstrates basic scale output. See the calibration sketch to get the calibration_factor for your
 specific load cell setup.
 
 This example code uses bogde's excellent library: https://github.com/bogde/HX711
 bogde's library is released under a GNU GENERAL PUBLIC LICENSE
 
 The HX711 does one thing well: read load cells. The breakout board is compatible with any wheat-stone bridge
 based load cell which should allow a user to measure everything from a few grams to tens of tons.

 Arduino pin 2 -> HX711 CLK
 3 -> DAT
 5V -> VCC
 GND -> GND
 
 The HX711 board can be powered from 2.7V to 5V so the Arduino 5V power should be fine.
 
*/

#include "HX711.h"

#define calibration_factor -7050.0 //This value is obtained using the SparkFun_HX711_Calibration sketch

#define DOUT  18//3
#define CLK   19//2

HX711 scale(DOUT, CLK);

void setup() {

  Serial.begin(9600);
  Serial.println("HX711 scale demo");

  scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
  scale.tare();	//Assuming there is no weight on the scale at start up, reset the scale to 0

  Serial.println("Readings:");
}

void loop() {
  Serial.print("Reading: ");
  Serial.print(scale.get_units(), 1); //scale.get_units() returns a float
  Serial.print(" lbs"); //You can change this to kg but you'll need to refactor the calibration_factor
  Serial.println();
}
 
After that I connect the Sparkfun Load Cell Amplifier HX711 to MSP430FR5969 Launchpad. Here is the connections pin outs below
 
MSP430FR5969 LP VCC 3.3 V      <--------->      VDD, VCC (shorted)   Sparkfun Load Cell Amplifier HX711
MSP430FR5969 LP VCC GND      <--------->      GND Sparkfun Load Cell Amplifier HX711
MSP430FR5969 LP P1.2 Pin 19    <--------->      CLK  Sparkfun Load Cell Amplifier HX711
MSP430FR5969 LP P3.0 Pin 18    <--------->      DAT  Sparkfun Load Cell Amplifier HX711
 
MSP430FR5969 LP VCC 3.3 V      <--------->     VCC 3.3V Voltage Divider BRD    
MSP430FR5969 LP VCC GND      <--------->     GND 3.3V Voltage Divider BRD    
 
Voltage Divider BRD 15 mV -output <--------->    WHT/A- Sparkfun Load Cell Amplifier HX711
Voltage Divider BRD 15 mV +output<--------->    GRN/A+ Sparkfun Load Cell Amplifier HX711
 
Attached HX711.jpg is my setup. The problem is when I run the code I get output at Tera Term  "Reading: 0.0 lbs". What could be causing this? I am suspecting the cause of this is my pin assignment 19 and 18 are wrong. But, I followed the pin out guide below. Also, maybe I should initialize OFFSET to 0 and SCALE to 1.
 
 
 
Best Regards,
Markel Robregado

post-43534-0-62852900-1488336540_thumb.jpg

Share this post


Link to post
Share on other sites

I modify the HX711 scale(DOUT, CLK); to HX711 scale(DOUT, CLK, 128 ); to set channel A, gain factor 128. I made changes base from HX711.cpp

void HX711::begin(byte dout, byte pd_sck, byte gain) {
	PD_SCK = pd_sck;
	DOUT = dout;

	pinMode(PD_SCK, OUTPUT);
	pinMode(DOUT, INPUT);

	set_gain(gain);
}

I get output at Tera Term "Reading: 0.1 lbs", that is for 20 mV input to Sparkfun Load Cell Amplifier HX711.

 

Best Regards,

Markel Robregado

Share this post


Link to post
Share on other sites

Hi energia,

 

     From my last post, I can say that it is working but I do not have the correct setup to try out the example program from Sparkfun link below. I should try the example programs using a weighing scale setup connected to the Sparkfun Load Cell Amplifier HX711 board. Also, I am not able to get a calibration value because I am using a voltage divider board that outputs 5 mV, 10 mV, 15 mV, and 20 mV

 

     https://github.com/sparkfun/HX711-Load-Cell-Amplifier

 

     The formula for getting the calibration value, is explained in this link below.

 

      https://github.com/aguegu/ardulibs/tree/master/hx711

 

     I am not an expert with MSP430 Launchpad and Energia, so any helpful inputs would be great.

 

Best Regards,

Markel Robregado

Share this post


Link to post
Share on other sites

Hi,

 

    I set the calibration value to -1.f and now I get value of 3200. So I guess that is more reasonable value. Next I will try the program at load cell or weighing scale setup. Here is my code below.


#include <SPI.h>
#include <OneMsTaskTimer.h>
#include <LCD_SharpBoosterPack_SPI.h>
#include "HX711.h"


/*
 Example using the SparkFun HX711 breakout board with a scale
 By: Nathan Seidle
 SparkFun Electronics
 Date: November 19th, 2014
 License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
 
 This example demonstrates basic scale output. See the calibration sketch to get the calibration_factor for your
 specific load cell setup.
 
 This example code uses bogde's excellent library: https://github.com/bogde/HX711
 bogde's library is released under a GNU GENERAL PUBLIC LICENSE
 
 The HX711 does one thing well: read load cells. The breakout board is compatible with any wheat-stone bridge
 based load cell which should allow a user to measure everything from a few grams to tens of tons.

 Arduino pin 2 -> HX711 CLK
 3 -> DAT
 5V -> VCC
 GND -> GND
 
 The HX711 board can be powered from 2.7V to 5V so the Arduino 5V power should be fine.
 
*/



#define calibration_factor - 1.f//-7050.0 //This value is obtained using the SparkFun_HX711_Calibration sketch
                                 //2280.f

#define DOUT  18//3
#define CLK   19//2

HX711 scale(DOUT, CLK, 128);

// Variables
LCD_SharpBoosterPack_SPI myScreen;
uint8_t myOrientation = 0;
uint16_t myCount = 0;

void setup() {

  Serial.begin(9600);
  myScreen.begin();
  myScreen.clearBuffer();
  Serial.println("HX711 scale demo");

  scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
  scale.tare();	//Assuming there is no weight on the scale at start up, reset the scale to 0

  Serial.println("Readings:");
}

void loop() {
  Serial.print("Reading: ");
  Serial.print(scale.get_units(), 2); //scale.get_units() returns a float
  Serial.print(" grams"); //You can change this to kg but you'll need to refactor the calibration_factor
  myScreen.text(10, 10, String(scale.get_units(), 2));
  myScreen.text(10, 25, "grams");
  myScreen.flush();
  Serial.println();
  
}

Best Regards,

Markel

Share this post


Link to post
Share on other sites

Hi,

 

   Just an update. I tested this at a weighing scale setup. My load weigh is 1 litre of water = 2.2 lbs. I run the SparkFun_HX711_Calibration.ino and got the calibration factor. I set the calibration factor at SparkFun_HX711_Example.ino. I got the correct weight displayed which is 2.2 lbs.

 

Best Regards,

Markel Robregado

bluehash and Fmilburn like this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now