# sampling rate with barometer

Hello, I'm working on a flight computer project for a rocket using a BMP 180 barometer and a MPU6050 accelerometer and I was wondering if there was a way to determine the sampling rate of my program. As of right now the program saves the altitude as an integer then reads current altitude, then if the current altitude is less than the previous altitude + a constant, peak altitude is detected and the drogue parachute deploys. However, I need to figure out the sampling rate so I can determine the constant. Right now I'm using 2 meters as the constant because it works well when I simulate increases and decreases in altitude with a small vacuum chamber I made, however if the sampling rate is something like 1 sample per millisecond, the rocket would have to be falling at 2000 m/s, which is obviously not ever going to happen, but I still need some constant to compensate for any noise. Any help/advice would be greatly appreciated, thank you!

I was wondering if there was a way to determine the sampling rate of my program

You could measure how long it takes to gather say, 100 samples, using millis, or micros

Thank you for the response AWOL, could you explain that a little more in depth? I'm pretty new to programming, this is actually my first. I do have all data, including millis, recorded to a SD card, so could I just use, say 100 lines of data on the log file and divide that by the difference in time? Or is the rate at which it writes to an SD card different than the rate it actually samples?

aI do have all data, including millis, recorded to a SD card, so could I just use, say 100 lines of data on the log file and divide that by the difference in time?

Generally during design/coding, I will do domething such as the snippet below:

unsigned long begin_it = 0; unsigned long end_it = 0;

void setup { // other stuff like serial, etc }

void loop{ begin_it = millis(); function_to_measure(); end_it = millis() - begin_it; Serial.print(" Function call took mS: "); Serial.println(end_it); // more stuff }

Ray

That's perfect, thanks!