Why does the sample rate slow down when my arduino is connected to external power?

Hi everyone,

I have been working on a test stand for rocket motors to measure their thrust. To do this I use a load cell that measures the thrust at roughly 10 sps. The samples are then saved on a SD card. Because I don't want the laptop to be near the rocket motor (hence the SD card), I need to supply the arduino with external power. However, if I do so the the sample rate slows down significantly after a few seconds. Does anyone know why this could be?

I would really appreciate any help :slight_smile:

Here is the sketch if it helps:

#include <SD.h> 
#include<SPI.h> 
File mySensorData; 

#include "HX711.h"
HX711 scale;
#define calibration_factor 101.0 
#define LOADCELL_DOUT_PIN  3
#define LOADCELL_SCK_PIN  2

int counter = 1; 
int chipSelect = 4;
const int buttonPin = 7;
const int warningPin =  6;
const int buzzPin = 8; 
const int igniterPin = 5; 
int buttonState = 0; 
float thrust;

void setup() {
  Serial.begin(9600);
  SD.begin(4);
  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
  pinMode(buttonPin, INPUT);
  pinMode(warningPin, OUTPUT);
  pinMode(buzzPin, OUTPUT);
  pinMode(igniterPin, OUTPUT);
  pinMode(10, OUTPUT);

  Serial.println("Rocket Motor Test:");
  mySensorData = SD.open("RMD.txt", FILE_WRITE);
  if (mySensorData) { 
    delay(1000);
    Serial.println("SD opened successfully");
    Serial.println("Waiting for activation...");
} else { 
    delay(1000);
    Serial.println("SD failed to open");      
}
}



void loop() {
  if (mySensorData) {
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH) {
    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("Ignition sequence activated!");

  
  for (int i = 0; i <= 3; i++) {  
    digitalWrite(warningPin, HIGH);
    digitalWrite(buzzPin, HIGH);
    delay(500);
    digitalWrite(warningPin, LOW);
    digitalWrite(buzzPin, LOW);
    delay(500);
    }
  for (int i = 0; i <= 7; i++) {  
    digitalWrite(warningPin, HIGH);
    digitalWrite(buzzPin, HIGH);
    delay(250);
    digitalWrite(warningPin, LOW);
    digitalWrite(buzzPin, LOW);
    delay(250);
    }
    digitalWrite(buzzPin, HIGH);
  for (int i = 0; i <= 9; i++) {  
    digitalWrite(warningPin, HIGH);
    delay(100);
    digitalWrite(warningPin, LOW);
    delay(100); 
    }  
    digitalWrite(buzzPin, LOW);
    
    
    digitalWrite(igniterPin, HIGH);
    Serial.println("Ignition!!!");
    Serial.println(" ");
    Serial.print(counter);
    Serial.print(". ");
    Serial.print("Test:");
    Serial.println("");
    mySensorData.print(counter);
    mySensorData.print(". ");
    mySensorData.println("Test:");
    mySensorData.println("");
    
    


    for (int i = 0; i <= 250; i++) {
      thrust = scale.get_units(); 
      mySensorData.print(thrust);
      mySensorData.println();
      Serial.print(thrust); 
      Serial.println(); 
      } 

    
       
      
    digitalWrite (igniterPin, LOW);
    mySensorData.println("");
    mySensorData.println("");
    mySensorData.println("");
    mySensorData.close();
    digitalWrite(buzzPin, HIGH);
    digitalWrite(warningPin, HIGH);
    delay(3000);
    digitalWrite(buzzPin, LOW);
    digitalWrite(warningPin, LOW);
    Serial.println("Test of rocket motor has finished :)");
    Serial.println("");
    Serial.println("");
    Serial.println("");
    mySensorData = SD.open("RMD.txt", FILE_WRITE);
    counter++; 

}   
}
}

What does the external power supply consist of ?

I use a 9v battery.

Not a PP3 by any chance ?

If so, then it cannot supply the required current at the necessary voltage

What is the difference between PP3 and 9v?

You mean like one of these:

That kind of battery is supposed to stop working after a short while because that kind of battery does not have enough power for sustained operations. Your project is running normally for the type of power source you are using.

yes, that's the battery I'm using.

Then your project is properly working and will continue to work that way till a more reliable source or power is added or initiate frequent battery changes, once every 2 hours for starters.

would a 9v lithium battery be better, since it supplies power at 1200 mAh?

Also, the 9v battery I am using currently is new and was part of an Arduino starter kit. If I add up the time, I used it for about 10 min.

What happens when you tried it?

Measure the battery voltage when it is under load. You may be surprised how low it is

This is what happens:

I push a button to activate the count down (10 sec).
During these 10 seconds, a buzzer and a LED are signaling the count down.
After the count down a relay allows current to flow through the igniter, the rocket motor is ignited, and the load cell starts to read the thrust.
For the first 4 seconds of reading the thrust, the sps is at 10 and then slows down to 1 sps for the remainder (6 seconds) of reading the thrust.
After 100 samples (the 10 seconds) the relay blocks the flow and the test has finished.
Since the sps is so slow it takes a very long time to finish.

what if I use two 9v batteries in series?

How much current to they use ?

How much current does the relay use to pull in and to hold in and how is the igniter powered ?

You will have an 18V battery which is too much to power the Arduino without conversion to a lower voltage. If anything you would be better with them connected in parallel but personally I would not use them and would look to using batteries with a higher capacity

Ditch the 9v battery idea all together. Try 4 x "AA" batteries in series.

If I'm correct, doing that would bring the voltage up to 6v (enough since 5v are only required for Arduino Uno) and would supply the Arduino with 2 or 3 Ah. The 9v battery only supplies 1200 mAh (if Lithium Battery). That would work, but isn't there an Amp limitation?

Hey, it's your project, knock yourself out. You appear wedded to the 9V battery idea, so go for it.

Can you provide a link to that?
Are you also using a load cell amplifier like this, which also runs from 5V?

So since the arduino, the laod cell and the amplifier all need 5V why would you use a totally inappropriate battery to power it?

Then..