Rocket MOSFET ejection charge timer

Hey everyone,

I'm trying to get my model rocket assembled and programmed and the final step I need to setup and test is the parachute ejection charge. The engine burns for 8 seconds and the rocket coasts upward for another 11 seconds for an apogee reached at 19 seconds. At this time I want a MOSFET to power my ejection charge. I am not familiar with mosfets and need some help. I have the spark fun MOSFET and have no idea what the code is like. Could anyone give me an example code for a 19 second timer to power the MOSFET?

Thanks,

Sara

It isn't clear exactly what you are looking for - a MOSFET is a type of transistor and does not have any "code". In your type of application, it may be being used as a switch, in which case you need a circuit to turn it on when you want to fire the charge, but that does not involve any programming or are you connecting the MOSFET to some sort of Arduino board that is also doing other things in the rocket?

Hey Sara,

Rocketgirl9:
I'm trying to get my model rocket assembled and programmed and the final step I need to setup and test is the parachute ejection charge. ...

Excellent project.

Could anyone give me an example code for a 19 second timer to power the MOSFET?

Give this a try...

/*
  Pin the MOSFET gate is connected to.  Probably should include a series 
  resistor.  This code assumes LOW is MOSFET not conducting.
*/

const int ParachuteEjectionPin = 9;

/*
  The following constant is the number of milliseconds we wait to fire the 
  parachute ejection.
*/
const uint32_t ParachuteEjectionDelay = 19ul * 1000ul;


void setup() 
{
  /* 
    The following line is not necessary but it makes our intent clear: we want 
    the pin to be LOW when it is changed to an OUTPUT to ensure the parachute 
    does not deploy early.
  */
  digitalWrite( ParachuteEjectionPin, LOW );

  /*
    We need to be able to control the MOSFET so the pin needs to be an OUTPUT.
   */
  pinMode( ParachuteEjectionPin, OUTPUT );
}

/*
  The following two variables define the state of the parachute ejection.
  ParachuteEjectionEnabled must be true for the parachute ejection to fire.  
  ParachuteEjectionStart is when the clock started.  When 
  ParachuteEjectionEnabled is set to true (the parachute ejection is enabled)
  ParachuteEjectionStart is set to the current value of millis.
*/
static bool ParachuteEjectionEnabled;
static uint32_t ParachuteEjectionStart;


static void EnableParachuteEjection( void )
{
  // Only allow the parachute ejection to be enabled once!

  if ( ! ParachuteEjectionEnabled )
  {
    // Start the clock
    ParachuteEjectionStart = millis();

    // Parachute ejection is ready for business
    ParachuteEjectionEnabled = true;
  }
}


void loop() 
{
  /*
    Needing a snapshot of millis is common so we'll always save the value
  */
  uint32_t CurrentMillis;

  CurrentMillis = millis();

  if ( ParachuteEjectionEnabled )
  {
    if ( CurrentMillis - ParachuteEjectionStart >= ParachuteEjectionDelay )
    {
      // GO!
      digitalWrite( ParachuteEjectionPin, HIGH );
    }
  }

  /* 
    At the appropriate time, call EnableParachuteEjection to start the 19 second 
    clock.  Maybe when a digital input goes HIGH indicating the engine has 
    started?
  */
  // EnableParachuteEjection();
}

Gpsmikey, I apologize that I didn't explain it correctly. Yes I am connecting it to an Arduino Nano.

Coding Badly, thank you so much for taking the time to show me the code. I appreciate it a lot! I'm going to give it a go today see how everything works out!

Have you tested the nano in a rocket yet ?

Im told that bits can fall off under acceleration, depending on mounting.

Specifically the crystal.

Gee I didn't know that. Thanks for the info! So far I've just tested the motors and the flight system on the ground. Is there any way to secure the crystal any tighter than it already is?

Since you are using the nano for parachute deployment i would suggest further testing or you could destroy the rocket first launch without a backup system.

Could you just launch a nano first then check it still works.

I know little detail, possibly a blob of epoxy on components with small solder pads would be wise.

Mounting the board with regard to acceleration direction may be wise if the diameter will allow.

It's soldered down, isn't? I don't know why it'd be any more susceptible than the other parts on the board.
Maybe mount it so the crystal is being pressed flat down as the rocket takes off.

CrossRoads:
It's soldered down, isn't? I don't know why it'd be any more susceptible than the other parts on the board.
Maybe mount it so the crystal is being pressed flat down as the rocket takes off.

I think the issue was that the crystal had particularly small pads.
As said i know little about it though.

Hi Sara,

First of all, good luck with your project.

I'm wondering whether you need a better way of determining when you reach apogee.

Instead of just using a timer, it might be better to use either an accelerometer or barometric pressure sensor, or some combination of the three.

I say this, because if your rocket motor misfires, and doesn't give you the acceleration you were expecting, then the rocket may have already hit the ground before the parachute is deployed.

Please keep us updated on your progress. Any photos or videos would be appreciated.

regards
John

If you are worried about the crystal becoming dislodged during launch, then you can bond it to the PCB using an RTV silicon rubber. Choose one that doesn't give off acetic acid during the curing process, as this can erode the PCB tracks.

I think that in practice the most likely failure mode of the crystal is the breaking of the internal bond wires, rather than becoming detached from the PCB.

Rocketgirl9:
Coding Badly, thank you so much for taking the time to show me the code. I appreciate it a lot!

You are welcome.

I'm going to give it a go today see how everything works out!

Excellent. Please let us know what happens.

Boardburner2:
Have you tested the nano in a rocket yet? Im told that bits can fall off under acceleration, depending on mounting. Specifically the crystal.

The crystal is welded to the metal foil. Unless the vendor is incompetent / corrupt, those two are not separating.

The risk has to be the metal foil peeling away from the substrate.

Rocketgirl9:
Is there any way to secure the crystal any tighter than it already is?

Mounting the board so it is horizontal with the parts on top when the rocket is in the ready-to-launch position makes it impossible for any parts to come off. The acceleration would "push" the substrate against the parts holding them in place.

In the long run, because of the repeated forces and vibration exerted on the board, "potting" the board would reduce / eliminate any potential problems. Potting would also protect the board in case of a crash.

However, I have seen PCBs (printed circuit boards) exposed to very extreme conditions for very long periods of time and continued to work flawlessly. In one ridiculous case, nearly all the foil had separated from the substrate. Obviously, the board needed to be replaced but it did still work correctly.

Hello again Sara.

I have been following your project since September.

The example i gave was something specific i knew about.

Months of work plus 8 s burn time implies a substantial rocket.

I would be crying in my boots if i lost that first go.
Even with ground testing , unexpected code or hardware problems can suddenly appear in flight, even the big boys have that problem.

I would suggest for the initial flights that you have a secondary recovery system so if it goes pear shaped you get another try.

Also bear in mind that 'quality' ematches have approx 1% failure rate.
Chinese can be worse.

Here's hoping you get a flawless maiden.

…and, if you find evidence (I cannot find any) that the crystal itself is a problem (breaking of the internal bond wires) the board can be reconfigured to use an oscillator that is inside the processor.

I think that realistically there will be no problem with the crystal due to the acceleration levels that you are likely to achieve.

I have experience of using PCBs at accelerations/decelerations into the 10s of thousands of g.

You are likely to be several orders of magnitude below that.

No. it fell off the board.

I'll try to get a copy of the pic from someone.

EDIT

Thinking back to the autopsy, it was pin mounted transversely so crystal must have been up.

Maybe it came off in the crash and its a red herring.

Yes, the maximum instantaneous G force from dropping the board on a cement floor probably greatly exceeds the maximum instantaneous G at this rocket launch.

Boardburner2 - The only time I've actually tested the durability of the Nano was by inserting it into the electronics bay and physically throwing it up into the air and catching it when it came down...and it did survive that g-force. The actual point of the exercise was to test a Memsic accelerometer which I was going to use for parachute deployment. However, the accelerometer did not register "0" when in free fall and I couldn't figure out how to reset it (if it's even possible). And last but not least, thank you so much for following my project and offering your help along the way :slight_smile:

CrossRoads - Yes the crystal is soldered onto the board.

JohnLincoln - I will definitely take some photos of the setup and I also have an onboard video recorder for the flight!