Hi Guys
I am new to the forum but I have searched around and while I did find an answer that was close, I’m not experienced enough to apply it to my situation.
I am developing small rocket motors, the type used to launch model rockets a few hundred/thousand feet into the air. I have a dynamometer that measures rocket thrust over time, which I put together from a project on github. I had to make some changes because I wanted to do more than the original project did.
The original project used a PC/Laptop etc to connect to the USB port. Using Serial Monitor it displayed a list of the dyno readings over a 10 second period. It also listed the start time ( millis()) and end time for the data collection run. The dyno is set to produce 80 readings per second so the 800 reading run should take 10 seconds to complete and before I tried altering the code that was what happened. The idea is that the data from Serial Monitor is copied into Excel to produce a graph of thrust over time.
I wanted to be able to use the dyno in the field without a laptop and cable. For one thing, the cable length makes the laptop rather closer to the rocket motor than I’d like. What I did was include code to write to an SD card. The original section of the code that reads the data is here:
Serial.print("Start time, ms: “);
Serial.print (millis());
Serial.println(” ");
Serial.println();
for (int i=0; i <=800; i++){ //800 samples at 80sa/sec = 10 seconds theoretical
scale.set_scale(calibration_factor); //Adjust to the calibration factor
Serial.println(scale.get_units(), 1);
}
Serial.println();
Serial.print("Stop Time, ms: ");
Serial.print(millis());
My modified code is here :
Serial.print("Start time, ms: “);
Serial.print (millis());
Serial.println(” ");
Serial.println();
for (int i=0; i <=800; i++){ //800 samples at 80sa/sec = 10 seconds theoretical
scale.set_scale(calibration_factor); //Adjust to the calibration factor
File dataFile = SD.open(“datalog.txt”, FILE_WRITE);
dataFile.println(scale.get_units(), 1);
dataFile.close();
Serial.println(scale.get_units(), 1);
}
Serial.println();
Serial.print("Stop Time, ms: ");
Serial.print(millis());
So the addition of the lines that write to the SD card increase the collection to about 18 seconds. There are still 800 samples but the resolution is lower because there’s a delay between each reading.
I can still use the system as it is but as most rocket motors only run for a couple of seconds I’d rather have a shorter run-time. I’d be really grateful if someone could suggest a way to record to the SD more quickly, but in a way that a novice programmer can understand.
Thanks in advance.
Thermocline