Arduino Altimeter/Tracker Advice

The Rocketry Forum

Help Support The Rocketry Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
I too am working on a flight computer. I am using the Adafruit Feather M0 Adalogger (https://www.adafruit.com/products/2796). I need some help in programing the computer. Mainly when I disconnect the USB cable the computer stops working. I am also open minded on how to detect launch.

Any help would greatly welcomed:)

Rocket Nut
 
I too am working on a flight computer. I am using the Adafruit Feather M0 Adalogger (https://www.adafruit.com/products/2796). I need some help in programing the computer. Mainly when I disconnect the USB cable the computer stops working. I am also open minded on how to detect launch.

Any help would greatly welcomed:)

Rocket Nut


To fix your issue with the program stopping when you disconnect the USB cable, try checking your code for a line that is like "while ( ! Serial);" and if you see it comment it out.


When I was sensing altitude using a BMP-180 baro sensor, I kept a moving/rolling average of the current altitude and identified a launch when it jumped over about 200 feet within two seconds.
 
Here is the main loop sketch code:


//==========================================
void loop()
{
ResetPyro(); // Check pyro pins to be turned off
UserSketch(); // Do user code

// Generate the out put string
DataStringGen();

// If in Logging mode then save Data String to the SD Card
if(Logging)
{
digitalWrite(SIM_LED, HIGH);
delay(10);
logfile.println(Data_String);
digitalWrite(SIM_LED, LOW);
}

// If USB is connect then check for a command
while(Serial.available()&& digitalRead(USB_Status))
{
char c = Serial.read();
if ( c == '\n')
{
ParseCommand(command);
command = "";
break;
}
else
{
command += c;
}
}

// If USB is connected the send data to ground computer.
if(digitalRead(USB_Status))
{
for(int x = 0; (x<= Data_String.length()&& digitalRead(USB_Status)); x++)
{
if(!digitalRead(USB_Status))
{
Serial.print(Data_String.charAt(x));
}
else
{
break;
}
}
if(digitalRead(USB_Status))
{
Serial.println("");
}
}


digitalWrite(BoardLED, LOW);

// Flash some leds to see it sketch is working
for(int thisPin = 0; thisPin < 6; thisPin++)
{
digitalWrite(PyroPin[thisPin],HIGH);
delay(250);
digitalWrite(PyroPin[thisPin],LOW);
}




digitalWrite(BoardLED, HIGH);
delay(250);
Sample ++;
}
 
Here is the main loop sketch code:


//==========================================
void loop()
{
ResetPyro(); // Check pyro pins to be turned off
UserSketch(); // Do user code

// Generate the out put string
DataStringGen();

// If in Logging mode then save Data String to the SD Card
if(Logging)
{
digitalWrite(SIM_LED, HIGH);
delay(10);
logfile.println(Data_String);
digitalWrite(SIM_LED, LOW);
}

// If USB is connect then check for a command
while(Serial.available()&& digitalRead(USB_Status))
{
char c = Serial.read();
if ( c == '\n')
{
ParseCommand(command);
command = "";
break;
}
else
{
command += c;
}
}

// If USB is connected the send data to ground computer.
if(digitalRead(USB_Status))
{
for(int x = 0; (x<= Data_String.length()&& digitalRead(USB_Status)); x++)
{
if(!digitalRead(USB_Status))
{
Serial.print(Data_String.charAt(x));
}
else
{
break;
}
}
if(digitalRead(USB_Status))
{
Serial.println("");
}
}


digitalWrite(BoardLED, LOW);

// Flash some leds to see it sketch is working
for(int thisPin = 0; thisPin < 6; thisPin++)
{
digitalWrite(PyroPin[thisPin],HIGH);
delay(250);
digitalWrite(PyroPin[thisPin],LOW);
}




digitalWrite(BoardLED, HIGH);
delay(250);
Sample ++;
}

I'm not sure why that would stop running when USB is disconnected. You may want to try just running a basic blinking program first, then slowly add in the other stuff until it stops working.
 
Back
Top