Skip to content

Commit

Permalink
1.2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
olkal committed Jan 2, 2021
1 parent 36b4815 commit 4efd4be
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 28 deletions.
6 changes: 2 additions & 4 deletions examples/Calibration/Calibration.ino
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ const int HX711_sck = 5; //mcu > HX711 sck pin
HX711_ADC LoadCell(HX711_dout, HX711_sck);

const int calVal_eepromAdress = 0;
long t;
unsigned long t = 0;

void setup() {
Serial.begin(57600); delay(10);
Serial.println();
Serial.println("Starting...");

LoadCell.begin();
long stabilizingtime = 2000; // preciscion right after power-up can be improved by adding a few seconds of stabilizing time
unsigned long stabilizingtime = 2000; // preciscion right after power-up can be improved by adding a few seconds of stabilizing time
boolean _tare = false; //set this to false if you don't want tare to be performed in the next step
LoadCell.start(stabilizingtime, _tare);
if (LoadCell.getTareTimeoutFlag() || LoadCell.getSignalTimeoutFlag()) {
Expand Down Expand Up @@ -72,7 +72,6 @@ void loop() {

// receive command from serial terminal
if (Serial.available() > 0) {
float i;
char inByte = Serial.read();
if (inByte == 't') LoadCell.tareNoDelay(); //tare
else if (inByte == 'r') calibrate(); //calibrate
Expand All @@ -98,7 +97,6 @@ void calibrate() {
LoadCell.update();
if (Serial.available() > 0) {
if (Serial.available() > 0) {
float i;
char inByte = Serial.read();
if (inByte == 't') LoadCell.tareNoDelay();
}
Expand Down
5 changes: 2 additions & 3 deletions examples/Read_1x_load_cell/Read_1x_load_cell.ino
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const int HX711_sck = 5; //mcu > HX711 sck pin
HX711_ADC LoadCell(HX711_dout, HX711_sck);

const int calVal_eepromAdress = 0;
long t;
unsigned long t = 0;

void setup() {
Serial.begin(57600); delay(10);
Expand All @@ -44,7 +44,7 @@ void setup() {
#endif
//EEPROM.get(calVal_eepromAdress, calibrationValue); // uncomment this if you want to fetch the calibration value from eeprom

long stabilizingtime = 2000; // preciscion right after power-up can be improved by adding a few seconds of stabilizing time
unsigned long stabilizingtime = 2000; // preciscion right after power-up can be improved by adding a few seconds of stabilizing time
boolean _tare = true; //set this to false if you don't want tare to be performed in the next step
LoadCell.start(stabilizingtime, _tare);
if (LoadCell.getTareTimeoutFlag()) {
Expand Down Expand Up @@ -77,7 +77,6 @@ void loop() {

// receive command from serial terminal, send 't' to initiate tare operation:
if (Serial.available() > 0) {
float i;
char inByte = Serial.read();
if (inByte == 't') LoadCell.tareNoDelay();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const int HX711_sck = 5; //mcu > HX711 sck pin
HX711_ADC LoadCell(HX711_dout, HX711_sck);

const int calVal_eepromAdress = 0;
long t;
unsigned long t = 0;
volatile boolean newDataReady;

void setup() {
Expand All @@ -44,7 +44,7 @@ void setup() {
//EEPROM.get(calVal_eepromAdress, calibrationValue); // uncomment this if you want to fetch the value from eeprom

LoadCell.begin();
long stabilizingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilizing time
unsigned long stabilizingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilizing time
boolean _tare = true; //set this to false if you don't want tare to be performed in the next step
LoadCell.start(stabilizingtime, _tare);
if (LoadCell.getTareTimeoutFlag()) {
Expand Down Expand Up @@ -84,7 +84,6 @@ void loop() {

// receive command from serial terminal, send 't' to initiate tare operation:
if (Serial.available() > 0) {
float i;
char inByte = Serial.read();
if (inByte == 't') LoadCell.tareNoDelay();
}
Expand Down
5 changes: 2 additions & 3 deletions examples/Read_2x_load_cell/Read_2x_load_cell.ino
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ HX711_ADC LoadCell_2(HX711_dout_2, HX711_sck_2); //HX711 2

const int calVal_eepromAdress_1 = 0; // eeprom adress for calibration value load cell 1 (4 bytes)
const int calVal_eepromAdress_2 = 4; // eeprom adress for calibration value load cell 2 (4 bytes)
long t;
unsigned long t = 0;

void setup() {
Serial.begin(57600); delay(10);
Expand All @@ -43,7 +43,7 @@ void setup() {

LoadCell_1.begin();
LoadCell_2.begin();
long stabilizingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilizing time
unsigned long stabilizingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilizing time
boolean _tare = true; //set this to false if you don't want tare to be performed in the next step
byte loadcell_1_rdy = 0;
byte loadcell_2_rdy = 0;
Expand Down Expand Up @@ -86,7 +86,6 @@ void loop() {

// receive command from serial terminal, send 't' to initiate tare operation:
if (Serial.available() > 0) {
float i;
char inByte = Serial.read();
if (inByte == 't') {
LoadCell_1.tareNoDelay();
Expand Down
5 changes: 2 additions & 3 deletions examples/Testing/Testing.ino
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const int HX711_sck = 7; //mcu > HX711 sck pin
HX711_ADC LoadCell(HX711_dout, HX711_sck);

const int calVal_calVal_eepromAdress = 0;
long t;
unsigned long t = 0;

void setup() {
Serial.begin(57600); delay(10);
Expand All @@ -44,7 +44,7 @@ void setup() {
//EEPROM.get(calVal_eepromAdress, calibrationValue); // uncomment this if you want to fetch this value from eeprom

LoadCell.begin();
long stabilizingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilizing time
unsigned long stabilizingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilizing time
boolean _tare = true; //set this to false if you don't want tare to be performed in the next step
LoadCell.start(stabilizingtime, _tare);
if (LoadCell.getTareTimeoutFlag()) {
Expand Down Expand Up @@ -92,7 +92,6 @@ void loop() {

// receive command from serial terminal, send 't' to initiate tare operation:
if (Serial.available() > 0) {
float i;
char inByte = Serial.read();
if (inByte == 't') LoadCell.tareNoDelay();
}
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=HX711_ADC
version=1.2.5
version=1.2.6
author=Olav Kallhovd
maintainer=Olav Kallhovd
sentence=Library for the HX711 24-bit ADC for weight scales.
Expand Down
10 changes: 5 additions & 5 deletions src/HX711_ADC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void HX711_ADC::begin(uint8_t gain)
/* start(t):
* will do conversions continuously for 't' +400 milliseconds (400ms is min. settling time at 10SPS).
* Running this for 1-5s in setup() - before tare() seems to improve the tare accuracy */
void HX711_ADC::start(unsigned int t)
void HX711_ADC::start(unsigned long t)
{
t += 400;
lastDoutLowTime = millis();
Expand All @@ -60,7 +60,7 @@ void HX711_ADC::start(unsigned int t)
/* start(t, dotare) with selectable tare:
* will do conversions continuously for 't' +400 milliseconds (400ms is min. settling time at 10SPS).
* Running this for 1-5s in setup() - before tare() seems to improve the tare accuracy. */
void HX711_ADC::start(unsigned int t, bool dotare)
void HX711_ADC::start(unsigned long t, bool dotare)
{
t += 400;
lastDoutLowTime = millis();
Expand All @@ -79,7 +79,7 @@ void HX711_ADC::start(unsigned int t, bool dotare)
/* startMultiple(t): use this if you have more than one load cell and you want to do tare and stabilization simultaneously.
* Will do conversions continuously for 't' +400 milliseconds (400ms is min. settling time at 10SPS).
* Running this for 1-5s in setup() - before tare() seems to improve the tare accuracy */
int HX711_ADC::startMultiple(unsigned int t)
int HX711_ADC::startMultiple(unsigned long t)
{
tareTimeoutFlag = 0;
lastDoutLowTime = millis();
Expand Down Expand Up @@ -128,7 +128,7 @@ int HX711_ADC::startMultiple(unsigned int t)
* use this if you have more than one load cell and you want to (do tare and) stabilization simultaneously.
* Will do conversions continuously for 't' +400 milliseconds (400ms is min. settling time at 10SPS).
* Running this for 1-5s in setup() - before tare() seems to improve the tare accuracy */
int HX711_ADC::startMultiple(unsigned int t, bool dotare)
int HX711_ADC::startMultiple(unsigned long t, bool dotare)
{
tareTimeoutFlag = 0;
lastDoutLowTime = millis();
Expand Down Expand Up @@ -171,6 +171,7 @@ int HX711_ADC::startMultiple(unsigned int t, bool dotare)
}
}
}
else return 1;
}
}
return startStatus;
Expand Down Expand Up @@ -422,7 +423,6 @@ long HX711_ADC::getSettlingTime()
void HX711_ADC::setSamplesInUse(int samples)
{
int old_value = samplesInUse;
int old_divbit = divBit;

if(samples <= SAMPLES)
{
Expand Down
12 changes: 6 additions & 6 deletions src/HX711_ADC.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class HX711_ADC
void setGain(uint8_t gain = 128); //value must be 32, 64 or 128*
void begin(); //set pinMode, HX711 gain and power up the HX711
void begin(uint8_t gain); //set pinMode, HX711 selected gain and power up the HX711
void start(unsigned int t); //start HX711 and do tare
void start(unsigned int t, bool dotare); //start HX711, do tare if selected
int startMultiple(unsigned int t); //start and do tare, multiple HX711 simultaniously
int startMultiple(unsigned int t, bool dotare); //start and do tare if selected, multiple HX711 simultaniously
void start(unsigned long t); //start HX711 and do tare
void start(unsigned long t, bool dotare); //start HX711, do tare if selected
int startMultiple(unsigned long t); //start and do tare, multiple HX711 simultaniously
int startMultiple(unsigned long t, bool dotare); //start and do tare if selected, multiple HX711 simultaniously
void tare(); //zero the scale, wait for tare to finnish (blocking)
void tareNoDelay(); //zero the scale, initiate the tare operation to run in the background (non-blocking)
bool getTareStatus(); //returns 'true' if tareNoDelay() operation is complete
Expand Down Expand Up @@ -102,8 +102,8 @@ class HX711_ADC
const uint8_t divBitCompiled = DIVB;
bool doTare;
bool startStatus;
long startMultipleTimeStamp;
long startMultipleWaitTime;
unsigned long startMultipleTimeStamp;
unsigned long startMultipleWaitTime;
uint8_t convRslt;
bool tareStatus;
unsigned int tareTimeOut = (SAMPLES + IGN_HIGH_SAMPLE + IGN_HIGH_SAMPLE) * 150; // tare timeout time in ms, no of samples * 150ms (10SPS + 50% margin)
Expand Down

0 comments on commit 4efd4be

Please sign in to comment.