Using the Homemade Altimeter

Quick Links
Home
Propellants
Rocket Motors
Rockets
Rocket Electronics
Ground Support
Launch & Static Tests
Software
Links
Motor Class Table
E-Mail Scott
 
 
Don't Click Here!
No doubt this will be a constantly evolving project, so the information here is for the current version (first attempt) of the altimeter.

The current program is scottalt1_4.bs2. The program to download the data after the flight is readalt.bs2.

If you look at the code in scottalt1_4.bs2, the first "DO" "LOOP UNTIL" you will find a line of code that reads: {LOOP UNTIL grndlevel +12 < delaybits: PAUSE 4000}.

What it does is the code constantly reads the current altitude, and does nothing until it senses an altitude increase (decrease of 12 data values or about 100'). You could increase that number if desired, so the computer would not start until 250', or whatever.

Once it reads the decrease in pressure of 12 data values, it comes to the PAUSE 4000. The 4000 is milliseconds, 1000 milliseconds = one second. That shuts things down for 4 seconds, that's the mach delay. You can change that 4000 value to whatever delay you need. 10 seconds would be 10000, 2 seconds 2000 and so on.

After the mach delay pause, it goes to the next "DO" "LOOP", inside this loop are the subroutines the program now follows. ADC_Data sub now reads the current altitude and stores the data in the ram variable adcbits.

The Record sub reads the eeprom data value for maximum altitude, which at the start of the program was recorded as a value of 4095, or 0'. If the current value of adcbits (current altitude) is less (higher altitude), the new maximum altitude is recorded to the eeprom. The pause 100 delays the program so it won't write faster than every 1/10 second. Eeprom memory has a write cycle life of about 10 million writes, so we don't want to wear it out by writing to it every thousandth of a second.

The Display sub simply lets you see data on your screen when running the program connected to your PC.

The Deploy sub is for apogee deployment. If the value of the current altitude is 5 data values more (50' less altitude) than the recorded maximum altitude, then the command HIGH 3 sends +5 volts to pin three, which goes to our deployment transistor to set off the apogee charge. It then also sends the program to the subroutine Main.

The Main subroutine is not in a loop, so once the apogee charge has fired the program will only run through the Main subroutine. The first line of Main, sets a ram variable of grndlevel - 50 = maindeploy. That's the altitude of the main parachute deployment. Again, you could change it to whatever you want. Remember, 1 data value is about 9.6'. So the value of 50 is about 500'. The next two lines display and write the deployment values to eeprom, not really needed but doesn't hurt anything either. The next line checks current altitude, and if it's less than the 50 we programed in, it sends pin 4 high to fire the main charge. Pin 4 is kept high for 2 seconds, then sent low (turned off). The next to last line tells the computer to turn itself off if everything is done. The last line, Return: sends the program back to the start if something went wrong. That should never be the case, and that's an area of code I may change too.

So to actually use the computer, you must load the main program into the computer from your PC. Once the Basic Stamp 2 is programed you can turn the power off, and install the altimeter into the rocket. Once the rocket is loaded on the launch pad and ready to fly, turn on the computer power. The altimeter will re-zero the ground level altitude, and wait until it senses liftoff.

Once the flight is over, you can either leave the power on, and download the data right away using the readalt program, or turn the power off and read the data later. Warning: If you turn the power off to read the data later, you need to run the readalt program within three seconds of turning the power back on or it will rewrite the ground level data/altitude. If you're nervous about getting it loaded in 3 seconds, you could increase the initial pause/warm up time to 10 seconds or whatever you want. The maximum altitude and deployment values will only be rewritten when you reload the scottalt1_4 program.

Using the data from launch test 92:

Ground Level at launch: 3171 data value

Maximum Altitude: 2909 data value

Main Deploy: 3107 data value

This is the data returned when I ran the readalt program. To convert the data values to pressure, use this formula: (ADCvalue) / 4096 + .095 / .009 = kPa

I still haven't found a great program for converting kPa to feet of altitude. What I have been using is the calculator at this page http://hyperphysics.phy-astr.gsu.edu/hbase/kinetic/barfor.html#c1 .

To start with, I enter in my barometric pressure at launch level. You can get it from a local weather station, or I have a home weather station I use. In my case it was 28.59" Hg. The Maximum altitude data related to 89.467 kPa. So now I enter an altitude in the calculator and play a guessing game as altitude vs. pressure, with a little practice you can zero in the pressure quickly. In this case it worked out to exactly 2,269'.