Servo trigger on certain altitude (high altitude balloon)

Post Reply
User avatar
alduxvm
Posts: 40
Joined: Thu Apr 25, 2013 2:25 pm
Contact:

Servo trigger on certain altitude (high altitude balloon)

Post by alduxvm »

Hi guys!

What would it be the easiest way to open a servo payload tray at a certain altitude?

I'm using a multiwii board (HK AOI) with a openlog to log GPS, Altitude and Attitude of a system that is going to go inside a high altitude balloon... and at certain altitude (25,000 meters) I want to open a payload bay and then close it at 30,000 meters, and everything will be parachuted to safe at 33,000 meters...

My first idea was to make the openlog monitor the altitude and if is it between the range 25k-30k send RC serial command to aux 1 at 2000, to activate the camera trigger... but the camera trigger function moves the servo 90 degrees and then returns it to original position after 1 second... so, maybe not good...

The next idea is perhpas to modify the output.cpp in the part of the camera trigger servo...

And my next idea is to create a function that will go inside multiwii.cpp which will monitor the altitude and if in range, move servo, if not don't move...

Am I in the right path? has anyone done something similar?

Another question... would the actual value of the altitude be able to reach 30,000?? I guess it can, because in the MSP is a uint32, unless I stand corrected by an expert??

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: Servo trigger on certain altitude (high altitude balloon

Post by PatrikE »

The Altitude in Mwii is 32-bit and have a range of -2,147,483,648 to 2,147,483,647 cm.

Easiest should be to make a new model in MWii.
And a new mixer in output to handle the servo.
Maybe you want to control more servos or functions too?

It should be easy to make a release function that controls balloonDrop,Camera and parachute.

User avatar
alduxvm
Posts: 40
Joined: Thu Apr 25, 2013 2:25 pm
Contact:

Re: Servo trigger on certain altitude (high altitude balloon

Post by alduxvm »

We actually just need a servo to move to 90 deg and then close when the altitude is appropriate...

This is the one I want to modify:

Code: Select all

  #if defined(CAMTRIG)
    // setup MIDDLE for using as camtrig interval (in msec) or RC channel pointer for interval control
    #define CAM_TIME_LOW  conf.servoConf[2].middle
    static uint8_t camCycle = 0;
    static uint8_t camState = 0;
    static uint32_t camTime = 0;
    static uint32_t ctLow;
    if (camCycle==1) {
      if (camState == 0) {
        camState = 1;
        camTime = millis();
      } else if (camState == 1) {
        if ( (millis() - camTime) > CAM_TIME_HIGH ) {
          camState = 2;
          camTime = millis();
          if(CAM_TIME_LOW < RC_CHANS) {
            ctLow = constrain((rcData[CAM_TIME_LOW]-1000)/4, 30, 250);
            ctLow *= ctLow;
          } else ctLow = CAM_TIME_LOW;
        }
      } else { //camState ==2
        if (((millis() - camTime) > ctLow) || !rcOptions[BOXCAMTRIG] ) {
          camState = 0;
          camCycle = 0;
        }
      }
    }
    if (rcOptions[BOXCAMTRIG]) camCycle=1;
    servo[2] =(camState==1) ? conf.servoConf[2].max : conf.servoConf[2].min;
    servo[2] = (servo[2]-1500)*SERVODIR(2,1)+1500;
  #endif


I'm not brave enough at the moment to do a new multiwii model :P

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: Servo trigger on certain altitude (high altitude balloon

Post by PatrikE »

This should work

Code: Select all

#if defined(CAMTRIG)
  #define OPEND_HATCH  1000  // µs
  #define CLOSED_HATCH 2000
 
  #define OPEN_AT_ALT 250000// cm
  #define CLOSE_AT_ALT 300000

  static boolean lock = false;
  if(est.EstAlt > CLOSE_AT_ALT)
    servo[2] = CLOSED_HATCH;
   lock = true;
  else if( est.EstAlt > OPEN_AT_ALT && !lock  )
    servo[2] = OPEND_HATCH;

#endif

User avatar
alduxvm
Posts: 40
Joined: Thu Apr 25, 2013 2:25 pm
Contact:

Re: Servo trigger on certain altitude (high altitude balloon

Post by alduxvm »

Thanks a lot Patrik! that worked very easily!

After some tests, I end up using this one instead, based on your structure:

Code: Select all

#if defined(CAMTRIG)
  #define OPEN_HATCH  2000  // µs
  #define CLOSE_HATCH 1000
  //Small altitudes just for testing
  #define OPEN_AT_ALT 50 // cm
  #define CLOSE_AT_ALT 150 // cm
 
  // If altitude is between the two values, open the hatch
  if(alt.EstAlt > OPEN_AT_ALT && alt.EstAlt < CLOSE_AT_ALT){
    servo[2] = OPEN_HATCH;
  }
  // Keep servo close in any other case
  else
    servo[2] = CLOSE_HATCH;
#endif


I'm still testing it, because I don't want to fail with the experiments that are going to be exposed using this code, hehe

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: Servo trigger on certain altitude (high altitude balloon

Post by PatrikE »

You might consider to use Lock after closing.
Or when descending xx m/sec if something happens on the way up ex a Balloon burst
Otherwise it will open again on the way down!
Your code keeps it open regardless if it's ascending or descending between the altitudes.
And freefall speed can be around Mach 1 at these altitudes!
And i guess you don't want a open hatch then?

Code: Select all

static boolean Descendlock = false;
// If altitude is between the two values, open the hatch
  if(alt.EstAlt > OPEN_AT_ALT && alt.EstAlt < CLOSE_AT_ALT && !Descendlock){
    servo[2] = OPEN_HATCH;
  }
  // Keep servo close in any other case
  else
    servo[2] = CLOSE_HATCH;
   if(alt.EstAlt > CLOSE_AT_ALT) Descendlock=true;
#endif


A sidenote..
Non military GPS stops working at an altitude higher than 60,000 feet (18,000 m)
http://en.wikipedia.org/wiki/CoCom#Legacy

User avatar
alduxvm
Posts: 40
Joined: Thu Apr 25, 2013 2:25 pm
Contact:

Re: Servo trigger on certain altitude (high altitude balloon

Post by alduxvm »

totally true!

thanks a lot!

I knew about the GPS... I'll post the logs to see if 18000 is actually true haha

Post Reply