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 ![]()
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++;
}
}
}
