; Exported "Conditional Actions" for Spectrum Lab if( (initialising) ) then ON=1: OFF=0: VERSION="2012-06-09" if( (never) ) then REM Threshold = difference that triggers meteor check if( (initialising) ) then THRESHOLD=20:LOW=1740:HIGH=2600 if( (never) ) then REM DIR = folder to store logs; M_NAM = prefix name for meteor files if( (initialising) ) then DIR="c:\\spectrum\\meteorlog\\":M_NAM="Meteor" if( (never) ) then REM log_WAV = turns .wav file logging on & off; log_PLOTpic turns save of the plotter on & off if( (initialising) ) then log_WAV=OFF:log_PLOTpic=OFF if( (never) ) then REM NOI=noise, SIG=Signal if( (initialising) ) then NOI=0:SIG=0:TOTAL_DUR=0:COUNT_HR=0:FLAG_TIME=0:MAX_DUR=0:T1=0: if( (never) ) then REM RUN = switch, starts turned off and prevents meteors from being measured until timer 4 expires if( (never) ) then REM CHK = switch, if SIG>NOI+THRESHOLD then turn on and check for meteor if( (initialising) ) then RUN=OFF:CHK=OFF:TST=OFF if( (never) ) then REM M_ = possible Meteor ; M_TIM=time ; M_SIG=Signal; M_FRQ=Frequency; M_NOI=noise; M_DUR=duration in cycles if( (never) ) then REM M_YMD= date in YYYYMMDD format; M_HR=hour; M_MS= minutes seconds in MMSS format if( (initialising) ) then M_TIM=0:M_SIG=0:M_FRQ=0:M_NOI=0:M_DUR=0:M_YMD="":M_HR="":M_MS="" if( (never) ) then REM A# = temp noise values used to provide a rolling average for the noise if( (initialising) ) then A0=0:A1=0:A2=0:A3=0:A4=0:A5=0 if( (initialising) ) then timer4.start(10) if( (initialising) ) then FLAG_A=0: FLAG_B=0 :TEST_A=10:TEST_B=0 if( (timer4.expired(1)) ) then RUN=ON:sp.print("Let's find some Meteors! By Simon Dawes Version:"+VERSION):NOI=noise(LOW,HIGH): if( (always) ) then A5=A4:A4=A3:A3=A2:A2=A1:A1=A0:A0=noise(LOW,HIGH) if( (always) ) then NOI=(A0+A1+A2+A3+A4+A5)/6:SIG=peak_a(LOW,HIGH) if( (always) ) then M_YMD=str("YYYYMMDD",now):M_HR=str("hh",now):M_MS=str("mmss",now) if( ((M_DUR=0)&(SIG>(NOI+THRESHOLD))&(RUN=ON)) ) then CHK=ON if( (else) ) then CHK=OFF if( ((CHK=ON)&(SIG>(NOI+THRESHOLD))) ) then M_TIM=M_YMD+" "+M_HR+M_MS:M_NAM="Meteor"+M_YMD+M_HR+M_MS:M_SIG=SIG: M_FRQ=peak_f(LOW,HIGH):M_NOI=NOI if( (CHK=ON) ) then TEST_B=sigma(M_FRQ-10,M_FRQ+10):TEST_A=sqrt((peak_a(M_FRQ-10,M_FRQ-5)-M_SIG)^2) if( (never) ) then REM --------- Next line is for test only --------- if( ((CHK=ON)&(TST=ON)) ) then sp.print("A"+str(TEST_A)+" B"+str(TEST_B)): TST=TST+1 if( (else) ) then TST=OFF if( (never) ) then REM ------- previous line is for test only ------- if( ((CHK=ON)&(TEST_A<6)) ) then FLAG_A=1 if( ((CHK=ON)&(TEST_B<7)) ) then FLAG_B=1 if( ((FLAG_A=1)&(FLAG_B=1)&(RUN=ON)&(SIG>(NOI+THRESHOLD))) ) then M_DUR=M_DUR+1:TOTAL_DUR=TOTAL_DUR+1:timer1.restart(15):timer2.restart(5):timer3.restart(2):timer0.restart(2) if( ((M_DUR=1)&(log_WAV=ON)) ) then rec.filename=DIR+M_NAM+".wav" if( ((M_DUR=1)&(log_WAV=ON)) ) then rec.trigger=1 if( (M_DUR>MAX_DUR) ) then MAX_DUR=M_DUR if( (never) ) then REM ----------- Notify User of Meteor ------------ if( (timer0.expired(1)) ) then COUNT_HR=COUNT_HR+1:fopen2(DIR+"MeteorLog-"+str("YYYYMM",now)+".dat",a):fp2(M_TIM+","+str(M_SIG)+","+str(M_NOI)+","+str(M_FRQ)+","+str(M_DUR)):fclose2 if( (timer3.expired(1)) ) then sp.print(M_TIM,"S=",M_SIG,"dBm N=",M_NOI,"dBm F=",M_FRQ,"Hz t=",M_DUR," S:N=",M_SIG-M_NOI,"Test:",TEST_A,TEST_B):M_DUR=0 if( (timer2.expired(1)) ) then rec.trigger=0 :REM ------------ stop the sound recorder ------------ if( (timer1.expired(1)) ) then capture(DIR+M_NAM+".jpg",100):T1=1 if( ((T1=1)&(log_PLOTpic=ON)) ) then plot.capture(DIR+M_NAM+"Plot.jpg",100):T1=0 if( (val(M_MS,"####")=5955) ) then FLAG_TIME=FLAG_TIME+1 if( (FLAG_TIME=1) ) then fopen3(DIR+"RMOB_Dur-"+str("YYYYMM",now)+".dat",a): fp3(M_YMD+M_HR,",",M_HR,",",COUNT_HR,",",TOTAL_DUR,",",MAX_DUR,",",NOI):fclose3:fopen4(DIR+"RMOB-"+str("YYYYMM",now)+".dat",a):fp4(M_YMD+M_HR,",",M_HR,",",COUNT_HR):fclose4: if( (FLAG_TIME=1) ) then sp.print("Last hour="+str(COUNT_HR)+" Meteor(s) | Total duration "+str(TOTAL_DUR)):M_DUR=0:COUNT_HR=0:MAX_DUR=0:TOTAL_DUR=0 if( ( val(M_MS,"####")=0000 ) ) then FLAG_TIME=0 if( (M_DUR=0) ) then FLAG_A=0:FLAG_B=0:M_SIG=0:M_NOI=0:M_FRQ=0