Hi All,
I was wondering if I could ask for some help, I'm building a parachute actuation system for a high altitude balloon and wanted to include something which would deploy the main parachute if the Arduino battery failed and so could not deploy the parachute when a given set of conditions are met.
In the final version, an Arduino would write the signal line to the MOSFET high when a given set of conditions are reached, this would switch on a separate power circuit running a DC motor, the motor would withdraw a pin from the parachute container and deployment would commence.
I'm alsoo running a temperature sensor and recrding an averaged reading to an SD card - this work well.
I've used a transistor with it's base connected to the 5v rail powered by the Arduino, the collector is connected to the separate battery that is running the DC motor. If the Arduino battery dies, the transistor base becomes 0 and the output become 1, I thought could use this to switch the MOSFET.
In the prototype, the motor is replaced with an LED to demonstrate actuation and the NOT gate has an LED to comfirm that it switches properly when the USB cable from the Arduino is disconnected from the computer. Actuation is simulated by using a momentary button, when it's pressed, the LED in the MOSFET power circuit should light. If the power to the Arduino is cut, the LED connected to the collector should light demonstrating the transistor has switched as a result of 0 on the base.
I've attached two wiring diagrams:
No1: Simply demonstrates that the MOSFET circuit switches when the button is pressed and the NOT gate LED lights when the USB cable is disconnected. This work fine.
No2: Shows a white wire connecting the collecter of the NOT gate to the signal pin of thhe MOSFET - I thought this would switch the MOSFET when the USB cable was withdrawn, seems not.
What the 2nd circuit does/does not do:
LED in the MOSFET circuit doesn't light when the momentary button is pushed
Neither the MOSFET LED or the NOT gate LED light when the USB cable is disconnected.
Code below is not the final version, it's merely to test the above.
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
/*Parachute release failsafe prototype.
* This prototype substitutes an actuator for an LED which is powered by a separate 19650 3.7v battery controlled by the Arduino via a MOSFET.
* A NOT gate has it's signal pin wired to 5v Arduino pin, should the Arduino power fail, the NOT gate supplies a signal to the MOSFET to energise the LED.
*/
/* Micro SD Board pins connnection
Connect the 5V pin to the 5V pin on the Arduino
Connect the GND pin to the GND pin on the Arduino
Connect CLK to pin 52
Connect DO to pin 50
Connect DI to pin 51
Connect CS to pin 53
TMP36 - Temperature sensor
Connect Signal Pin to A5
*/
File myFile; //SD card
const int temperaturePin = A5; //TMP36 Pin Set
int buttonState = 0;
void setup() {
Serial.begin(9600); //Begin serial communication at 9600bps
//SD.begin();
pinMode(53, OUTPUT);
pinMode (9, OUTPUT);
pinMode (8, INPUT); //button to switch MOSFET on
if (!SD.begin(53)) {
Serial.println(F("initialization failed!"));
return;
}
Serial.println(F("SD Card Initialised!")); //Startup Confirmation to Serial Monitor.
delay(2000);
}
void loop() {
buttonState = digitalRead(8); //Button push simulates signal from Arduino to the MOSFET to initite parachute deployment (or switch on LED in testset up).
if (buttonState == HIGH) {
digitalWrite(9, HIGH);
}
else {
digitalWrite(9, LOW);
}
float voltage, degreesC;
voltage = getVoltage(temperaturePin);
degreesC = (voltage - 0.5) * 100.0;
Serial.println(degreesC);
myFile = SD.open("hab.txt", FILE_WRITE); //Write average temp from TMP36 to SD card.
if (myFile) {
Serial.print(F("Writing to test.txt..."));
myFile.println(degreesC);
myFile.close();
Serial.println("done.");
}
else {
// if the file didn't open, print an error:
Serial.println(F("error opening test.txt"));
}
}
float getVoltage(int pin)
{
float volts = 0;
for (int i = 0; i < 1000; ++i) //take average of 1000 readings
{
volts = volts + analogRead(pin);
}
volts = volts / 1000;
return (volts * 0.004882814); //return volts
}
I hope this all makes sense, apologies if I haven't made the request in quite the right way, happy to provide further info if required. Thanks for looking though.
Best wishes
Phil