Go Down

Topic: Need higher sampling frequency than 80hz for load cell (Read 3753 times) previous topic - next topic

koryherber

I am trying to instrument hiking poles with load cells and a data logger (to be semi wireless) for a research project. 

Current setup has arduino uno with adafruit sd data logger interfaced with an hx711 amplifier from sparkfun and my load cell.  I have discovered i can only get like 11hz and up to 80hz sampling frequency if i alter the amp.  However, i need a minimum of 100hz and ideally 1000hz sampling frequency.  I am happy with everything minus the sampling frequency.

Do i need an instrumentation amplifier? which one? two? one for each load cell?

Robin2

Without seeing your code how can we comment?

Also please post links to the datasheets for your load cell and the hx711 amplifier.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

koryherber

https://cdn.sparkfun.com/datasheets/Sensors/ForceFlex/hx711_english.pdf

http://www.forsentek.com/down/tension%20compression%20load%20cell%20FL25.pdf

my question is not about my code or really either of the things i currently have.  it is more so about what instrumentation amplifier can you recommend that will allow me to have a higher sampling rate, and will i need two of them? one for each load cell.

holmes4

I can't see how the amp gas any thing to do with the sampling frequency/ Post your code.

Mark

koryherber

https://www.sparkfun.com/products/13230

The output data rate for this amplifier clearly states 10hz or 80hz output rate.

Magician

Hx711 is slow, but its 24-bits ADC. If you O'K with lower resolution, 16-bits , you may get AD7705 module from aliexpress or ebay, 500 Hz. More expensive is AD7606 , 200 kHz.
It's not clear, why do you need faster sampl. rate, inertial measurements usually slow by definition

DVDdoug

If you only want the peak value, you can use a peak detector circuit in-between your Arduino and instrumentation amplifier.

I use peak detectors for my sound-activated lighting effects and that allows me to take a reading at about 10Hz instead of reading the audio waveform thousands of times per second.

koryherber

@Magician  Thanks for your suggestions, the reduction in resolution to 16 bit vs 24 is not a problem. 

Is it feasible to run two of these AD7705 16 bit modules from an Uno? Also, if I were to use the 7705 ADC board, can I still use my shield wire from my load cell?  and how?

I ran into a problem when trying to read from two hx711's in the same program, not sure if it was a library problem or what?  Will I have the same problem with AD7705 ADC?

Here is my code for those that have asked. It is currently set to run with only one load cell.  I have code in there to set sampling frequency but was rendered useless when using the hx711 amp boards because they output data too slowly.  I need a minimum of 100hz per load cell.

Code: [Select]
#include "HX711.h"
#include <SPI.h>
#include <SD.h>
#include <Wire.h>
#include "RTClib.h"
float calibration_factor = -7050; //  Get cal number from cal sketch //
#define DOUTL  A0
#define CLKL  8
//#define DOUTR  A1
//#define CLKR  11

HX711 leftloadcell(DOUTL, CLKL);
// Call HX711 scale(DO, CK)}   ////  LEFT POLE ////

//HX711 rightloadcell(DOUTR, CLKR);
// Call HX711 scale(DO, CK)}   ////  RIGHT POLE ////

// how many milliseconds between grabbing data and logging it. 1000 ms is once a second
#define LOG_INTERVAL  10 // mills between entries (reduce to take more/faster data)

// how many milliseconds before writing the logged data permanently to disk
// set it to the LOG_INTERVAL to write each time (safest)
// set it to 10*LOG_INTERVAL to write all data every 10 datareads, you could lose up to
// the last 10 reads if power is lost but it uses less power and is much faster!

#define SYNC_INTERVAL  500*LOG_INTERVAL // mills between calls to flush() - to write data to the card
uint32_t syncTime = 0; // time of last sync()

#define ECHO_TO_SERIAL    0 // echo data to serial port (set to 0 to turn off which should increase speed)
#define WAIT_TO_START    0 // Wait for serial input in setup()

// the digital pins that connect to the LEDs
#define redLEDpin 2
#define greenLEDpin 3

//#define BANDGAPREF 14                // special indicator that we want to measure the bandgap

//#define aref_voltage 3.3         // we tie 3.3V to ARef and measure it with a multimeter!
//#define bandgap_voltage 1.1      // this is not super guaranteed but its not -too- off

RTC_DS1307 RTC; // define the Real Time Clock object

// for the data logging shield, we use digital pin 10 for the SD cs line
const int chipSelect = 10;

// the logging file
File logfile;

void error(char *str)
{
  Serial.print("error: ");
  Serial.println(str);

  // red LED indicates error
  digitalWrite(redLEDpin, HIGH);

  while (1);
}

void setup(void)
{

////////// ZERO LOAD CELLS ///////////////////////////////////////////

  leftloadcell.set_scale();
  leftloadcell.tare();  //Reset left load cell to zero
//  rightloadcell.set_scale();
//  rightloadcell.tare();  //Reset left load cell to zero
  ////////////////////////////////////////////////////////////////////
 
  Serial.begin(9600);
  Serial.println();

  // use debugging LEDs
  pinMode(redLEDpin, OUTPUT);
  pinMode(greenLEDpin, OUTPUT);

#if WAIT_TO_START
  Serial.println("Type any character to start");
  while (!Serial.available());
#endif //WAIT_TO_START

  // initialize the SD card
  Serial.print("Initializing SD card...");
  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(10, OUTPUT);

  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    error("Card failed, or not present");
  }
  Serial.println("card initialized.");

  // create a new file
  char filename[] = "LOGGER00.CSV";
  for (uint8_t i = 0; i < 100; i++) {
    filename[6] = i / 10 + '0';
    filename[7] = i % 10 + '0';
    if (! SD.exists(filename)) {
      // only open a new file if it doesn't exist
      logfile = SD.open(filename, FILE_WRITE);
      break;  // leave the loop!
    }
  }

  if (! logfile) {
    error("couldnt create file");
  }

  Serial.print("Logging to: ");
  Serial.println(filename);

  // connect to RTC
  Wire.begin();
  if (!RTC.begin()) {
    logfile.println("RTC failed");
#if ECHO_TO_SERIAL
    Serial.println("RTC failed");
#endif  //ECHO_TO_SERIAL
  }


  logfile.println("millis,leftpoleforce,rightpoleforce");
#if ECHO_TO_SERIAL
  Serial.println("millis,leftpoleforce,rightpoleforce");
#endif //ECHO_TO_SERIAL

//  // If you want to set the aref to something other than 5v
//  analogReference(EXTERNAL);
}

///////////////////////////////////////////////////////////////////////////////////////////
// **************************************************************************************//
///////////////////////////////////////////////////////////////////////////////////////////

void loop(void)
{

///////// Set Load Cells to Cal factor determined in setup code ///////////////////

leftloadcell.set_scale(calibration_factor);    //Adjust to this calibration factor
//rightloadcell.set_scale(calibration_factor);    //Adjust to this calibration factor
//  DateTime now;

  // delay for the amount of time we want between readings
delay((LOG_INTERVAL - 1) - (millis() % LOG_INTERVAL));

  digitalWrite(greenLEDpin, HIGH);

  // log milliseconds since starting
  uint32_t m = millis();
  logfile.print(m);           // milliseconds since start
  logfile.print(", ");
#if ECHO_TO_SERIAL
  Serial.print(m);         // milliseconds since start
  Serial.print(", ");
#endif

//  // fetch the time
//  now = RTC.now();
//  // log time
//  logfile.print(now.unixtime()); // seconds since 1/1/1970
//  logfile.print(", ");
//  logfile.print('"');
//  logfile.print(now.year(), DEC);
//  logfile.print("/");
//  logfile.print(now.month(), DEC);
//  logfile.print("/");
//  logfile.print(now.day(), DEC);
//  logfile.print(" ");
//  logfile.print(now.hour(), DEC);
//  logfile.print(":");
//  logfile.print(now.minute(), DEC);
//  logfile.print(":");
//  logfile.print(now.second(), DEC);
//  logfile.print('"');
//#if ECHO_TO_SERIAL
//  Serial.print(now.unixtime()); // seconds since 1/1/1970
//  Serial.print(", ");
//  Serial.print('"');
//  Serial.print(now.year(), DEC);
//  Serial.print("/");
//  Serial.print(now.month(), DEC);
//  Serial.print("/");
//  Serial.print(now.day(), DEC);
//  Serial.print(" ");
//  Serial.print(now.hour(), DEC);
//  Serial.print(":");
//  Serial.print(now.minute(), DEC);
//  Serial.print(":");
//  Serial.print(now.second(), DEC);
//  Serial.print('"');
//#endif //ECHO_TO_SERIAL

  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 

  logfile.print(leftloadcell.get_units(), 1);
  logfile.print(", ");
  logfile.print("right pole load");
  logfile.println();
#if ECHO_TO_SERIAL
 
  Serial.print(leftloadcell.get_units(), 1);
  Serial.print(", ");
  Serial.print("right pole load");
  Serial.println();
#endif //ECHO_TO_SERIAL

  // Log the estimated 'VCC' voltage by measuring the internal 1.1v ref
  //analogRead(BANDGAPREF);
  //delay(10);
  //int refReading = analogRead(BANDGAPREF);
  //float supplyvoltage = (bandgap_voltage * 1024) / refReading;

  //  logfile.print(", ");
  //  logfile.print(supplyvoltage);
#if ECHO_TO_SERIAL
  //  Serial.print(", ");
  //  Serial.print(supplyvoltage);
#endif // ECHO_TO_SERIAL

 // logfile.println();
// #if ECHO_TO_SERIAL
 // Serial.println();
// #endif // ECHO_TO_SERIAL

  digitalWrite(greenLEDpin, LOW);

  // Now we write data to disk! Don't sync too often - requires 2048 bytes of I/O to SD card
  // which uses a bunch of power and takes time
if ((millis() - syncTime) < SYNC_INTERVAL) return;
syncTime = millis();

  // blink LED to show we are syncing data to the card & updating FAT!
  digitalWrite(redLEDpin, HIGH);
  logfile.flush();
  digitalWrite(redLEDpin, LOW);

}



Magician

Quote
Is it feasible to run two of these AD7705 16 bit modules from an Uno?
Probably yes, module is SPI, UNO could theoretically address 14 SPI units via corresponding CS pin.
Quote
Also, if I were to use the 7705 ADC board, can I still use my shield wire from my load cell?  and how?
This may be an issue, I have no idea. Google may know the answers

Newhope

Well if you read hx711 datasheet, you can see hx711 support 10 hz and 80 hz and if you need other frequency, just give external signal to hx711

Boyce

I am trying to instrument hiking poles with load cells and a data logger (to be semi wireless) for a research project. 

Current setup has arduino uno with adafruit sd data logger interfaced with an hx711 amplifier from sparkfun and my load cell.  I have discovered i can only get like 11hz and up to 80hz sampling frequency if i alter the amp.  However, i need a minimum of 100hz and ideally 1000hz sampling frequency.  I am happy with everything minus the sampling frequency.

Do i need an instrumentation amplifier? which one? two? one for each load cell?
Have you solved this? Thanks

Go Up