'************************************************************************************** '* BalloonSat Easy Flight Code * '* if started with Commit pn removed, will download data through PGM pin at 4800 baud * '* otherwise, waits until pin is removed to start mission * '* * '* Must enter maximum ADC channel used: Max_ADC * '* Must enter pause length (in ms) in mission loop: Mission_Delay * '************************************************************************************** symbol record=w0 symbol index=w1 symbol value=b4 symbol geiger_counter = 2 BalloonSat: symbol Max_ADC = 1 ' maximum adc channel used symbol Mission_Delay = 15000 ' length of pause in mission loop Mission_Prep: i2cslave %10100000,i2cfast,i2cword ' set memory speed to 400 kHz and one word records if pin7 = 1 then Download_Data ' download data if comit pin is already pulled Wait_to_Launch: if pin7 = 0 then Wait_to_Launch ' wait until commit pin is pulled Mission: gosub Analog ' collect analog voltages gosub Digital ' do the digital experiments gosub Camera ' operate the camera write 0,record ' store the number of records collected pause Mission_Delay ' pause..... goto Mission ' ....before starting all over Analog: for index = 0 to Max_ADC ' loop for number of analog voltages to record readadc index,value ' get next adc value gosub Record_Data ' go store the value next ' until last voltage is recorded return ' return to main mission loop Digital: count geiger_counter,10000,value ' measure cosmic ray flux for 10 sec gosub Record_Data ' go store the value return ' return to main mission loop Camera: high 5 ' press the camera shutter pause 1500 ' for 1.5 seconds low 5 ' release the camera shutter return ' return to main mission loop Record_Data: if record = 2047 then End_Mission ' check that aren't writing too many records to memory record = record + 1 ' increment record number low 0 ' unwrite protect memory writei2c record,(value) ' write the next record to memory pause 10 ' wait 10 ms for write high 0 ' write protect memory return ' return to the calling calling subroutine Download_Data: read 0,record ' get the number of data records recorded in this flight for index = 1 to record ' until the number of data records readi2c index,(value) ' read the recorded record sertxd (#value,",") ' serial out the data record next ' until last data record read out End_Mission: end ' end of mission