UKHAS Wiki

UK High Altitude Society

User Tools

Site Tools


projects:mihab:ultracode

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
projects:mihab:ultracode [2007/06/25 21:42] laurencebprojects:mihab:ultracode [2008/07/19 23:33] (current) – external edit 127.0.0.1
Line 26: Line 26:
 Declare Sub Updatepredict() Declare Sub Updatepredict()
 Declare Sub Cutdown() Declare Sub Cutdown()
 +Declare Sub Landingvideo()
  
 Dim Temp1 As Byte , Temp2 As Byte , Dim Temp1 As Byte , Temp2 As Byte ,
Line 32: Line 33:
 Dim Jordancurveypoints(18) As Single Dim Jordancurveypoints(18) As Single
 Dim Numberofpoints As Byte Dim Numberofpoints As Byte
 +Dim Videookay As Byte
  
  Dim G As Byte , De As Byte , Cutdown As Byte  Dim G As Byte , De As Byte , Cutdown As Byte
Line 67: Line 69:
  Dim Deltae As Single , Deltan As Single , Deltaa As Single , Deltat As Single  Dim Deltae As Single , Deltan As Single , Deltaa As Single , Deltat As Single
  Dim Averagealt As Single  Dim Averagealt As Single
 + Dim Cuttingdown As Eram Byte
  
- + Open "COM2:" For Binary As #1 
- Open "COM2:" For Binary As #1                                                         'debug terminal + Open "coma.0:9600,8,n,1,inverted" For Output As #3 
- Open "coma.0:9600,8,n,1,inverted" For Output As #3                                    'phone + Open "comd.0:4800,8,n,1" For Input As #2 
- Open "comd.0:4800,8,n,1" For Input As #2                                              'gps + Open "comd.1:4800,8,n,1" For Output As #4
- Open "comd.1:4800,8,n,1" For Output As #4                                             'radio+
  
  Numberofpoints = 17  Numberofpoints = 17
Line 114: Line 116:
  Iterations = 0  Iterations = 0
  Cutdown = 0  Cutdown = 0
 + Videookay = 0
  
 '---------------------------------------------------------------------- '----------------------------------------------------------------------
Line 128: Line 131:
 Config Clock = Soft Config Clock = Soft
 Config Portd.0 = Input Config Portd.0 = Input
 +Config Watchdog = 2048
  
 I2cinit                                                     ' we need to set the pins in the proper state I2cinit                                                     ' we need to set the pins in the proper state
Line 147: Line 151:
  
 '------------------------------------------------------------------start of main program '------------------------------------------------------------------start of main program
 + Stop Watchdog
 + Cutdownpin = 0
  Print #1 , "Hello from ULTRAHAB"  Print #1 , "Hello from ULTRAHAB"
  Wait 1  Wait 1
  
-$include "Config_MMC.BAS"                                       'code off the avr-dos site+$include "Config_MMC.BAS"                                   'code off the avr-dos site
 $include "CONFIG_AVR-DOS.BAS" $include "CONFIG_AVR-DOS.BAS"
  
Line 163: Line 169:
  Print #1 , "Card setup okay"  Print #1 , "Card setup okay"
 End If End If
- Print #1 , "camera on" 
- Cam_power = 1 
- Waitms 500 
- Cam_power = 0 
  Print #1 , "sms time"  Print #1 , "sms time"
  S = "hello test"  S = "hello test"
Line 191: Line 193:
 Call Updatepredict() Call Updatepredict()
 Temp1 = Checkposition(predictede , Predictedn) Temp1 = Checkposition(predictede , Predictedn)
-Print #1 , "ckeck says:" ; Temp1+Print #1 , "check says:" ; Temp1
 Print #1 , "press the button you fool!!!!" Print #1 , "press the button you fool!!!!"
 For Temp1 = 1 To 10                                         ' dead man button For Temp1 = 1 To 10                                         ' dead man button
Line 201: Line 203:
 Iterations = 241 Iterations = 241
 Print #4 , "ULTRAHAB bad news: forced reeboot, cutting down" Print #4 , "ULTRAHAB bad news: forced reeboot, cutting down"
-Print #11 , "bad news: forced reeboot, cutting down"+Print #, "bad news: forced reeboot, cutting down" 
 +Wait 4 
 +If Cuttingdown = 15 Then 
 + Print #4 , "ULTRAHAB insufficient power to cutdown" 
 + Print #1 , "not enought power!!!" 
 + Cutdown = 1 
 +End If
 Goto Theflightloop: Goto Theflightloop:
 Userpresent: Userpresent:
 +If Cuttingdown <> 0 Then
 + Cuttingdown = 0
 +End If
 Print #1 , "Filesystem: " ; Gbfilesystem Print #1 , "Filesystem: " ; Gbfilesystem
 Print #1 , "FAT Start Sector: " ; Glfatfirstsector Print #1 , "FAT Start Sector: " ; Glfatfirstsector
Line 222: Line 233:
   Wend   Wend
  
-Open "verbos.txt" For Input As #14+Open "VERB.TXT" For Input As #14
 Do Do
  Do  Do
Line 231: Line 242:
  Input #1 , B  Input #1 , B
 Loop Until B = "Y" Loop Until B = "Y"
-Kill "verbos.txt" 
 Close #14 Close #14
-Open "gps.txt" For Input As #14+Kill "VERB.TXT" 
 + 
 + 
 +Open "LOG.TXT" For Input As #14
 Do Do
  Do  Do
Line 242: Line 255:
 Input #1 , B Input #1 , B
 Loop Until B = "Y" Loop Until B = "Y"
-Kill "gps.txt" 
-Close #14 
-Open "tlog.txt" For Input As #14 
-Do 
- Do 
-   Line Input #14 , S                                       ' read a line 
-   Print #1 , S                                             ' print on terminal 
- Loop Until Eof(#14) <> 0 
-Print #1 , "deleting, okay? (Y/N)" 
-Input #1 , B 
-Loop Until B = "Y" 
-Kill "tlog.txt" 
 Close #14 Close #14
 +Kill "LOG.TXT"
 +Print #1 , "camera on"
 + Cam_power = 1
 + Waitms 500
 + Cam_power = 0
  
  
Line 260: Line 266:
 Theflightloop: Theflightloop:
 Do Do
- Open "verbos.txt" For Append As #11                        'these are all our files + Open "VERB.TXT" For Append As #11                          'these are all our files 
- Open "gps.txt" For Append As #12 + Open "LOG.TXT" For Append As #12                           'main flight loop
- Open "tlog.txt" For Append As #10                                                          'main flight loop+
  Incr Iterations  Incr Iterations
  Print #1 , "Main loop iteration number:" ; Iterations  Print #1 , "Main loop iteration number:" ; Iterations
Line 269: Line 274:
  Cam_shutter = 0  Cam_shutter = 0
  Call Onewiretemperature()  Call Onewiretemperature()
- Print #10 , Seconds ; "   " ; Storage+ Print #12 , Seconds ; "," ; Storage ; ",";
  Print #11 , "temperature is:" ; Storage  Print #11 , "temperature is:" ; Storage
  Wait 30  Wait 30
Line 276: Line 281:
   B = Mid(s , 2 , 6)                                        'check stuff and update   B = Mid(s , 2 , 6)                                        'check stuff and update
  Loop Until B = "$GPGGA"  Loop Until B = "$GPGGA"
 + S = Mid(s , 2 , 90)
  Print #11 , S  Print #11 , S
  Print #12 , S  Print #12 , S
  Call Processgps()  Call Processgps()
  Call Updatepredict()  Call Updatepredict()
 + If Deltaa < 0 And Videookay = 1 And Altitude < 300 Then
 +  Call Landingvideo()
 + End If
  Print #11 , "Predicted at " ; Seconds ; "was" ; Predictede ; " " ; Predictedn  Print #11 , "Predicted at " ; Seconds ; "was" ; Predictede ; " " ; Predictedn
  Call Sendsms()  Call Sendsms()
Line 295: Line 304:
    Print #4 , "geofence cutdown"    Print #4 , "geofence cutdown"
   End If   End If
-  If Iterations > 240 Then+  If Iterations > 180 Then                                  ' 3 hour cutdown approx
    Print #1 , "Time limit cutdown"    Print #1 , "Time limit cutdown"
    Print #11 , "Time limit cutdown"    Print #11 , "Time limit cutdown"
Line 306: Line 315:
  Cam_shutter = 0  Cam_shutter = 0
  Call Onewiretemperature()  Call Onewiretemperature()
 + Print #12 , Seconds ; "," ; Storage ; ",";
 + Print #11 , "temperature is:" ; Storage
  Wait 10                                                    'video  Wait 10                                                    'video
- Call Video(6)+ Call Video(8)
  Wait 10  Wait 10
  Do  Do
Line 313: Line 324:
   B = Mid(s , 2 , 6)   B = Mid(s , 2 , 6)
  Loop Until B = "$GPGGA"  Loop Until B = "$GPGGA"
 + S = Mid(s , 2 , 90)
  Print #11 , S  Print #11 , S
  Print #12 , S  Print #12 , S
  Call Processgps()  Call Processgps()
  Call Updatepredict()  Call Updatepredict()
 + If Deltaa < 0 And Videookay = 1 And Altitude < 300 Then
 +  Call Landingvideo()
 + End If
  Print #11 , "Predicted at " ; Seconds ; "was" ; Predictede ; " " ; Predictedn  Print #11 , "Predicted at " ; Seconds ; "was" ; Predictede ; " " ; Predictedn
- Call Sendsms() 
  Print #4 , "ULTRAHAB" ; Contents(3) ; Contents(4) ; Contents(5) ; Contents(6);  Print #4 , "ULTRAHAB" ; Contents(3) ; Contents(4) ; Contents(5) ; Contents(6);
  If Cutdown = 0 Then  If Cutdown = 0 Then
Line 334: Line 348:
  End If  End If
  Close #11  Close #11
- Close #10 
  Close #12  Close #12
 +
 Loop Loop
  
Line 366: Line 380:
   K = 0.90909 * K   K = 0.90909 * K
   K = Roottwomgovercda * K                                  'we now have the velocity of decent   K = Roottwomgovercda * K                                  'we now have the velocity of decent
 +  Print #1 , "Descent velocity=" ; K
   K = Deltaa / K                                            'time of decent for this layer   K = Deltaa / K                                            'time of decent for this layer
 +  Print #1 , "descent time=" ; K
   K = K / Deltat                                            'weighting for this layer   K = K / Deltat                                            'weighting for this layer
 +  Print #1 , "Layer weighting=" ; K
 +  K = K + 1                                                 'need to account for ascent drift
   Deltae = K * Deltae   Deltae = K * Deltae
   Deltan = K * Deltan   Deltan = K * Deltan
Line 373: Line 391:
   Predictede = Predictede + Deltae   Predictede = Predictede + Deltae
  End If  End If
- Print #1 , "preidcted north=" ; Predictedn+ Print #1 , "predicted north=" ; Predictedn
  Print #1 , "predicted east=" ; Predictede  Print #1 , "predicted east=" ; Predictede
 End Sub End Sub
Line 416: Line 434:
    Print #1 , "Altitude=" ; Altitude    Print #1 , "Altitude=" ; Altitude
    Print #1 , "Time=" ; Seconds    Print #1 , "Time=" ; Seconds
 +   If Altitude > 500 Then
 +    Videookay = 1
 +   End If
 End Sub End Sub
  
Line 595: Line 616:
 End Sub End Sub
  
 +Sub Landingvideo() 
 +Print #1 , "Landing video" 
 +Videookay = 0 
 +Toggle Cam_right 
 +Waitms 200 
 +Toggle Cam_right 
 +Waitms 300 
 +Toggle Cam_right 
 +Waitms 200 
 +Toggle Cam_right 
 +Waitms 200 
 +Toggle Cam_ok 
 +Waitms 200 
 +Toggle Cam_ok 
 +Waitms 500 
 +Toggle Cam_shutter 
 +Waitms 200 
 +Toggle Cam_shutter 
 +End Sub
  
 '------------------------------------------------------------------------------cutdown '------------------------------------------------------------------------------cutdown
Line 601: Line 640:
 Sub Cutdown() Sub Cutdown()
  Print #1 , "Cutting down !!!!"  Print #1 , "Cutting down !!!!"
 + Cuttingdown = 15
 + Start Watchdog
  Cutdownpin = 1  Cutdownpin = 1
- Wait 12+ For Temp1 = 1 To 12 
 +  Wait 1 
 +  Reset Watchdog 
 + Next Temp1
  Cutdownpin = 0  Cutdownpin = 0
- Cutdown = 1+ Cutdown = 1                                                'so we know we've cutdown 
 + Stop Watchdog 
 + Cuttingdown = 0
 End Sub End Sub
  
projects/mihab/ultracode.1182807725.txt.gz · Last modified: 2008/07/19 23:32 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki