' Flight5.bs2 ' by John Nordlie, July 15, 1999 ' This program is the flight sequencer and id transmitter for ' the High Altitude Research Group balloon payload #2 ' ** set up variables ** x var byte z var byte i var byte pics var byte t1 var word t2 var word ones var word tens var word hundreds var word thousands var word tenthousands var word ' ** set output ports ** output 0 ' pin 0 is the vertical 35mm camera servo output 1 ' pin 1 keys the transmitter output 2 ' pin 2 is the audio output to the transmitter output 3 ' pin 3 is the audio output to the speaker input 4 ' pin 4 is connected to thermistor #1 input 5 ' pin 5 is connected to thermistor #2 output 6 ' pin 6 is the horizontal 35mm camera servo ' ** initialize variables ** z = 1 ' set 35mm camera countdown pics = 36 ' set number of 35mm pics remaining ' ** park servos for i=1 to 50 ' move the servo to the shutter up position pulsout 0,550 pause 20 next for i=1 to 50 ' move the servo to the shutter up position pulsout 6,200 pause 20 next ' ** start of main program ** start: gosub beep ' beep speaker to let us know the computer is awake gosub temp ' measure temps, send data gosub id ' transmit id for x=1 to 35 ' beep the speaker 35 times gosub beep next if z=0 then takepic ' if its time, take a picture ret3: z = z - 1 ' decrement camera loop count goto start ' do it all again ' ** main program ends, procedures start here ** ' ** procedure takepic causes the 35mm camera to take a picture ** takepic: if pics=0 then skippic ' if no more film left, skip the pic for i=1 to 50 ' move the servos to the shutter down position pulsout 0,140 pause 20 next for i=1 to 50 pulsout 6,500 pause 20 next for i=1 to 50 ' move the servos to the shutter up position pulsout 0,550 pause 20 next for i=1 to 50 pulsout 6,200 pause 20 next pics=pics - 1 ' decrement number of photos left skippic: z = 1 ' reset counter to 1 loops goto ret3 ' ** procedure beep causes the on-board speaker to play some notes ** beep: freqout 3,500,1000 freqout 3,500,2000 freqout 3,500,3000 freqout 3,500,2000 freqout 3,500,1000 return ' ** procedure temp measures the temp from the thermistors and transmits it temp: high 4 ' discharge the cap pause 1 ' for 1 ms rctime 4,1,t1 ' measure RC charge time debug dec ? t1 ' dump result to terminal ones = t1 // 10 ' break number into places if ones = 0 then fixo1 retfixo1: tens = t1 // 100 tens = tens / 10 if tens = 0 then fixtn1 retfixtn1: hundreds = t1 // 1000 hundreds = hundreds / 100 if hundreds = 0 then fixh1 retfixh1: thousands = t1 // 10000 thousands = thousands / 1000 if thousands = 0 then fixth1 retfixth1: tenthousands = tenthousands / 10000 if tenthousands = 0 then fixtt1 retfixtt1: high 1 ' key transmitter pause 500 ' wait for squelch to open freqout 2, 8000, 1250 ' output 8 sec tone for tracking pause 500 for i = 1 to tenthousands ' transmit telemetry freqout 2,300,1500 pause 200 next pause 600 for i = 1 to thousands freqout 2,300,1500 pause 200 next pause 600 for i = 1 to hundreds freqout 2,300,1500 pause 200 next pause 600 for i = 1 to tens freqout 2,300,1500 pause 200 next pause 600 for i = 1 to ones freqout 2,300,1500 pause 200 next pause 600 low 1 ' release transmitter key ' sense and send temp 2 high 5 ' discharge the cap pause 1 ' for 1 ms rctime 5,1,t2 ' measure RC charge time debug dec ? t2 ' dump result to terminal ones = t2 // 10 ' break number into places if ones = 0 then fixo2 retfixo2: tens = t2 // 100 tens = tens / 10 if tens = 0 then fixtn2 retfixtn2: hundreds = t2 // 1000 hundreds = hundreds / 100 if hundreds = 0 then fixh2 retfixh2: thousands = t2 // 10000 thousands = thousands / 1000 if thousands = 0 then fixth2 retfixth2: tenthousands = tenthousands / 10000 if tenthousands = 0 then fixtt2 retfixtt2: high 1 ' key transmitter pause 500 ' wait for squelch to open for i = 1 to tenthousands freqout 2,300,1500 pause 200 next pause 600 for i = 1 to thousands freqout 2,300,1500 pause 200 next pause 600 for i = 1 to hundreds freqout 2,300,1500 pause 200 next pause 600 for i = 1 to tens freqout 2,300,1500 pause 200 next pause 600 for i = 1 to ones freqout 2,300,1500 pause 200 next pause 600 low 1 ' release transmitter key return ' ** procedure id transmits the callsign KC0CRU ** id: high 1 ' key transmitter pause 500 ' wait for squelch on receivers to open freqout 2,900,1000 ' transmit K in morse code pause 200 freqout 2,300,1000 pause 200 freqout 2,900,1000 pause 600 freqout 2,900,1000 ' transmit C pause 200 freqout 2,300,1000 pause 200 freqout 2,900,1000 pause 200 freqout 2,300,1000 pause 600 for i=1 to 5 ' transmit 0 freqout 2,900,1000 pause 200 next pause 600 freqout 2,900,1000 ' transmit C pause 200 freqout 2,300,1000 pause 200 freqout 2,900,1000 pause 200 freqout 2,300,1000 pause 600 freqout 2,300,1000 ' transmit R pause 200 freqout 2,900,1000 pause 200 freqout 2,300,1000 pause 600 freqout 2,300,1000 ' transmit U pause 200 freqout 2,300,1000 pause 200 freqout 2,900,1000 low 1 ' release radio key return ' ** fix tenthousands fixtt1: tenthousands = 10 goto retfixtt1 fixth1: thousands = 10 goto retfixth1 fixh1: hundreds = 10 goto retfixh1 fixtn1: tens = 10 goto retfixtn1 fixo1: ones = 10 goto retfixo1 fixtt2: tenthousands = 10 goto retfixtt2 fixth2: thousands = 10 goto retfixth2 fixh2: hundreds = 10 goto retfixh2 fixtn2: tens = 10 goto retfixtn2 fixo2: ones = 10 goto retfixo2