UKHAS Wiki

UK High Altitude Society

User Tools

Site Tools


projects:ukhas_glider_project:master

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:ukhas_glider_project:master [2007/09/15 23:20] laurencebprojects:ukhas_glider_project:master [2008/07/19 23:33] (current) – external edit 127.0.0.1
Line 51: Line 51:
 Dim Printstring As String * 20 Dim Printstring As String * 20
 Dim K As Single Dim K As Single
-Dim Iterations As Byte +Dim Iterations As Byte , Flashcount As Byte 
-Dim Windxs(255) As Eram Byte +Dim Windxs(251) As Eram Byte 
-Dim Windys(255) As Eram Byte , Placemark As Eram Byte+Dim Windys(251) As Eram Byte , Placemark As Eram Byte 
 +Dim Target_es As Eram Single 
 +Dim Target_ns As Eram Single
 Dim Lock As Bit Dim Lock As Bit
 Dim Gpfloatone As Single , Gpsheading As Single Dim Gpfloatone As Single , Gpsheading As Single
Line 64: Line 66:
 Dim Statuscode As Byte Dim Statuscode As Byte
 Dim Heightupto As Byte , Rxenable As Byte , Servoenable As Byte Dim Heightupto As Byte , Rxenable As Byte , Servoenable As Byte
-Dim Gpbyteone As Byte , Gpbytetwo As Byte , Telcounter As Byte+Dim Gpbyteone As Byte , Gpbytetwo As Byte , Telcounter As Byte , Landcount As Byte
 Dim Gpintegerone As Integer Dim Gpintegerone As Integer
 Dim Intcount As Integer , Timeelapsed As Integer Dim Intcount As Integer , Timeelapsed As Integer
Line 75: Line 77:
 Dim Derivative As Single Dim Derivative As Single
 Dim Target As Single Dim Target As Single
 +Dim Target_e As Single
 +Dim Target_n As Single
 Dim Offset As Single Dim Offset As Single
 Dim Windy_total As Single Dim Windy_total As Single
Line 87: Line 91:
 Dim North As Single Dim North As Single
 Dim East As Single Dim East As Single
-Dim Target_e As Single 
-Dim Target_n As Single 
 Dim Store_east As Single Dim Store_east As Single
 Dim Store_north As Single Dim Store_north As Single
Line 102: Line 104:
 Wind_x = 0 Wind_x = 0
 Wind_y = 0 Wind_y = 0
 +Landcount = 0
 +Telcounter = 0
 +Portd.3 = 1
 Waitms 100 Waitms 100
 Gpintegerone = Getadc(5) Gpintegerone = Getadc(5)
Line 112: Line 117:
  Print "Watchdog reset"  Print "Watchdog reset"
  Start Watchdog  Start Watchdog
 + Target_n = Target_ns
 + Target_e = Target_es
  Select Case Placemark  Select Case Placemark
  Case 1:  Case 1:
Line 125: Line 132:
 'Call Cutdown(1 , 4) 'Call Cutdown(1 , 4)
 Print "wind records:" Print "wind records:"
-For Gpbyteone = 1 To 255+For Gpbyteone = 1 To 251
  Gpbytetwo = Windxs(gpbyteone)  Gpbytetwo = Windxs(gpbyteone)
  Print Gpbyteone ; "," ; Gpbytetwo ; "," ;  Print Gpbyteone ; "," ; Gpbytetwo ; "," ;
Line 155: Line 162:
 Input #3 , Target_e Input #3 , Target_e
 Print Target_e Print Target_e
-Portd.3 = 1                                                 'radiocts pullup +Gpfloatone = Target_ns 
-Print "Launch!"+If Target_n <> Gpfloatone Then Target_ns = Target_n         'store in eeprom 
 +Gpfloatone = Target_es 
 +If Target_e <> Gpfloatone Then Target_es = Target_e 
 +Portd.3 = 1 
 +Print "Launch!"                                             'radiocts pullup
 Start Watchdog Start Watchdog
 Placemark = 1                                               'write eeprom to say in ascent Placemark = 1                                               'write eeprom to say in ascent
Line 199: Line 210:
     Goto Cutdownlbl                                         '4Km/20 minute cutdown     Goto Cutdownlbl                                         '4Km/20 minute cutdown
    End If    End If
-   If Timeelapsed > 900 Then+   If Timeelapsed > 1200 Then
     Print "Time cutdown"     Print "Time cutdown"
     Goto Cutdownlbl     Goto Cutdownlbl
Line 220: Line 231:
  
 Cutdownlbl: Cutdownlbl:
 +If L > 0 Then                                               'set a valid wind for cutdown altitude
 + Wind_x = Windx_total / L
 + Wind_y = Windy_total / L
 +End If
 Call Cutdown(1 , 12) Call Cutdown(1 , 12)
 Placemark = 2                                               'write eeprom Placemark = 2                                               'write eeprom
Line 226: Line 241:
 Requestsecond = 1 Requestsecond = 1
 While Clearsecond = 0 While Clearsecond = 0
- Waitus 10 + Waitus 10                                                  'I did commented this out as we should give the slave a message 1 second before the first valid gps 
-Wend +Wend                                                        'but that was a stupid idea as in the slave code, when if first enters the decent loop 
-Requestsecond = 0 +Requestsecond = 0                                           'it waits for a new gps before doing anything other than running off the gyro 
-Waitus 50+Waitus 50                                                   ' the first update after this then goes into the gps lag compensation stage, but NOT YET !!!!
 Printbin #1 , Statuscode                                    'we are going down so let the slave know Printbin #1 , Statuscode                                    'we are going down so let the slave know
  
Line 334: Line 349:
   K = Val(contents(10))   K = Val(contents(10))
   Altitude = K   Altitude = K
- If V 0 And Altitude < 300 Then                           'turn servo off on landing + If V 0.5 And Altitude < 250 Then                         'we have landed ? 
-   Servoenable = 0+  Incr Landcount
  Else  Else
-   Servoenable 1 +  Landcount 0 
- End If                                                     'enable ground control near the ground + End If 
- If Altitude < 300 Then + If Landcount > 4 Then 
-   Rxenable = 1+   Landcount = 5                                            'ie we had 5 stationary gps updates 
 +   Incr Flashcount                                          'flashes leds 
 +   If Flashcount > 9 Then 
 +    Cutdownpintwo = 1 
 +    Flashcount = 0 
 +   Else 
 +    Cutdownpintwo = 0                                       'turn off landing lights 
 +   End If 
 +   Servoenable = 0                                          'turn servo off on landing
  Else  Else
-   Rxenable = 0+  If Altitude < 300 Then                                    'so we are moving but low 
 +    Cutdownpintwo = 1                                       'turn on landing lights 
 +    Rxenable = 1                                            'enable ground control near the ground 
 +  Else 
 +    Cutdownpintwo = 0 
 +    Rxenable = 0 
 +  End If 
 +  Flashcount = 0 
 +  Servoenable = 1                                           'always enable servo
  End If  End If
  Requestsecond = 1  Requestsecond = 1
Line 357: Line 388:
  Incr Arrayat                                               'as minimum altitude incrament=0 but array starts at 1  Incr Arrayat                                               'as minimum altitude incrament=0 but array starts at 1
  Gpbyteone = Windxs(arrayat)                                'gives us the correct wind for our altitude  Gpbyteone = Windxs(arrayat)                                'gives us the correct wind for our altitude
- Wind_x = Gpbyteone - 127 + If Gpbyteone <> 255 Then Wind_x = Gpbyteone - 127          'handles an unrecorded eeprom byte
- If Wind_x = 128 Then Wind_x = 0                            'handles an unrecorded eeprom byte+
  Gpbyteone = Windys(arrayat)  Gpbyteone = Windys(arrayat)
- Wind_y = Gpbyteone - 127 + If Gpbyteone <> 255 Then Wind_y = Gpbyteone - 127          'handles unrecorded
- If Wind_y = 128 Then Wind_y = 0                            'handles unrecorded+
  Incr Telcounter  Incr Telcounter
  If Telcounter > 10 Then Call Checkvoltage()  If Telcounter > 10 Then Call Checkvoltage()
  If Radiocts = 1 Then                                       'is CTS=1 from the radio modem?  If Radiocts = 1 Then                                       'is CTS=1 from the radio modem?
   Call Radiocomms()   Call Radiocomms()
-  Printstring = Str(gpsheading) 
-  Printstring = Left(printstring , 8) 
- 
  End If  End If
 Loop Loop
  
 Sub Checkvoltage() Sub Checkvoltage()
 +S = "UKHASD,"
 Gpintegerone = Getadc(5) Gpintegerone = Getadc(5)
 Gpfloatone = Gpintegerone Gpfloatone = Gpintegerone
 Gpfloatone = Gpfloatone * 9.503 Gpfloatone = Gpfloatone * 9.503
 Gpfloatone = Gpfloatone / 1000 Gpfloatone = Gpfloatone / 1000
-If Radiocts 1 Then Print "Servo voltage=" ; Gpfloatone ; ",";+Printstring Str(gpfloatone )                              'servo 
 +S + Printstring 
 +S = S + ","
 Gpintegerone = Getadc(0) Gpintegerone = Getadc(0)
 Gpfloatone = Gpintegerone Gpfloatone = Gpintegerone
 Gpfloatone = Gpfloatone * 4.250 Gpfloatone = Gpfloatone * 4.250
 Gpfloatone = Gpfloatone / 1000 Gpfloatone = Gpfloatone / 1000
-If Radiocts 1 Then Print "Supply voltage=" ; Gpfloatone+Printstring Str(gpfloatone ) 
 +S = S + Printstring 
 +S = S + "," 
 +Printstring Str(pulselenght) 
 +S = S + Printstring 
 +S = S + "," 
 +Printstring = Str(pulses) 
 +S = S + Printstring 
 +Print S 
 +Print #4 , S
 Telcounter = 0 Telcounter = 0
 End Sub End Sub
Line 391: Line 429:
 While Radiocts = 0 And Gpbyteone < 30                       'wait for radio with timeout While Radiocts = 0 And Gpbyteone < 30                       'wait for radio with timeout
  Waitms 500  Waitms 500
 + Reset Watchdog
  Incr Gpbyteone  Incr Gpbyteone
 Wend Wend
-Print "Cutdown channel=" ; Channel ; " Time=" ; Duration+Print "UKHASC,Cutdown channel=" ; Channel ; " Time=" ; Duration
 If Channel = 1 Then Cutdownpinone = 1 If Channel = 1 Then Cutdownpinone = 1
 If Channel = 2 Then Cutdownpintwo = 1 If Channel = 2 Then Cutdownpintwo = 1
Line 405: Line 444:
  
 Sub Radiocomms() Sub Radiocomms()
- Print "UKHAS>" ; Contents(3) ; Contents(4) ; Contents(5) ; Contents(6) ; Contents(10) ;       'nmea data + If Statuscode = 0 Then 
- Print #4 , "UKHAS>Contents(3) Contents(4) Contents(5) Contents(6) Contents(10) ;+  S = "UKHAS>" 
 + Else 
 +  S = "UKHAS<" 
 + End If 
 + S = S + Contents(3) 
 + S = S + Contents(4) 
 + S = S + Contents(5) 
 + S = S + Contents(6) 
 + S = S + Contents(10)                                       'nmea data
  Printstring = Fusing(gpsheading , "#.#")  Printstring = Fusing(gpsheading , "#.#")
- Print "," Printstring; + Printstring = "," Printstring 
- Print #4 , ","Printstring;+ S = S + Printstring
  Printstring = Fusing(target , "#.#")  Printstring = Fusing(target , "#.#")
- Print "," Printstring; + Printstring = "," Printstring 
- Print #4 , ","Printstring;+ S = S + Printstring
  Printstring = Str(rate)  Printstring = Str(rate)
- Print "," Printstring; + Printstring = "," Printstring 
- Print #4 , ","Printstring;+ S = S + Printstring
  Printstring = Str(temperature)  Printstring = Str(temperature)
- Print "," Printstring; + Printstring = "," Printstring 
- Print #4 , ","Printstring; + S = S + Printstring 
- Print "," ; Error; + Printstring = Str(error) 
- Print #4 , Error;+ Printstring = "," + Printstring 
 + S = S + Printstring
  Printstring = Fusing(heading , "#.#")  Printstring = Fusing(heading , "#.#")
- Print "," Printstring; + Printstring = "," Printstring 
- Print #4 , ","Printstring;+ S = S + Printstring
  Printstring = Fusing(filteredrate , "#.#")  Printstring = Fusing(filteredrate , "#.#")
- Print "," Printstring; + Printstring = "," Printstring 
- Print #4 , ","Printstring; + S = S + Printstring 
- Printstring Str(pulselenght+ Gpbyteone Checksum(s
- Print ",; Printstring; + S = S + "*
- Print #4 , "," ; Printstring; + Printstring = Hex(gpbyteone
- Printstring = Str(pulses+ S = S + Printstring 
- Print ","Printstring + Print S 
- Print #4 , "," ; Printstring                               'we copy everything to the logger+ Print #4 , S
 End Sub End Sub
 </code> </code>
- 
projects/ukhas_glider_project/master.1189898435.txt.gz · Last modified: 2008/07/19 23:32 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki