projects:ukhas_glider_project:master
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
projects:ukhas_glider_project:master [2007/09/10 22:50] – laurenceb | projects:ukhas_glider_project:master [2008/07/19 23:33] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 9: | Line 9: | ||
Open " | Open " | ||
Open " | Open " | ||
- | ' | + | Open " |
Config Adc = Single , Prescaler = Auto , Reference = Internal | Config Adc = Single , Prescaler = Auto , Reference = Internal | ||
Config Portd.7 = Output | Config Portd.7 = Output | ||
Line 41: | Line 41: | ||
Declare Sub Checkvoltage() | Declare Sub Checkvoltage() | ||
Declare Sub Cutdown(byval Channel As Byte , Byval Duration As Byte) | Declare Sub Cutdown(byval Channel As Byte , Byval Duration As Byte) | ||
+ | Declare Sub Radiocomms() | ||
Echo Off | Echo Off | ||
Start Adc | Start Adc | ||
+ | Dim Rate As Integer | ||
+ | Dim Temperature As Integer , Error As Byte , Heading As Single , Filteredrate As Single , Pulselenght As Word | ||
+ | Dim Pulses As Byte | ||
Dim S As String * 100 | Dim S As String * 100 | ||
Dim T As String * 15 | Dim T As String * 15 | ||
+ | Dim Printstring As String * 20 | ||
Dim K As Single | Dim K As Single | ||
- | Dim Iterations As Byte | + | Dim Iterations |
- | 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 57: | Line 64: | ||
Dim N As Byte | Dim N As Byte | ||
Dim I As Byte | Dim I 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 |
Dim Gpintegerone As Integer | Dim Gpintegerone As Integer | ||
Dim Intcount As Integer , Timeelapsed As Integer | Dim Intcount As Integer , Timeelapsed As Integer | ||
Line 69: | 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 81: | 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 90: | Line 98: | ||
Dim Degrees As String * 3 | Dim Degrees As String * 3 | ||
Dim Command As String * 10 | Dim Command As String * 10 | ||
+ | Statuscode = 0 | ||
Lock = 0 | Lock = 0 | ||
Iterations = 0 | Iterations = 0 | ||
Line 95: | 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 105: | Line 117: | ||
Print " | Print " | ||
Start Watchdog | Start Watchdog | ||
+ | | ||
+ | | ||
| | ||
Case 1: | Case 1: | ||
Line 118: | 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 |
| | ||
Print Gpbyteone ; "," | Print Gpbyteone ; "," | ||
Line 148: | Line 162: | ||
Input #3 , Target_e | Input #3 , Target_e | ||
Print Target_e | Print Target_e | ||
- | Portd.3 = 1 ' | + | Gpfloatone = Target_ns |
- | Print " | + | If Target_n <> Gpfloatone Then Target_ns = Target_n |
+ | Gpfloatone = Target_es | ||
+ | If Target_e <> Gpfloatone Then Target_es = Target_e | ||
+ | Portd.3 = 1 | ||
+ | Print " | ||
Start Watchdog | Start Watchdog | ||
- | Placemark = 1 | + | Placemark = 1 'write eeprom to say in ascent |
Do | Do | ||
Reset Watchdog | Reset Watchdog | ||
Line 192: | Line 210: | ||
Goto Cutdownlbl | Goto Cutdownlbl | ||
End If | End If | ||
- | If Timeelapsed > 900 Then | + | If Timeelapsed > 1200 Then |
Print "Time cutdown" | Print "Time cutdown" | ||
Goto Cutdownlbl | Goto Cutdownlbl | ||
Line 201: | Line 219: | ||
Wend | Wend | ||
| | ||
- | Print #1 , "#, | + | Waitus 50 |
- | | + | |
- | Input #2 , S | + | |
+ | Inputbin | ||
Incr Telcounter | Incr Telcounter | ||
- | If Telcounter > 10 Then Call Checkvoltage() | + | If Telcounter > 10 Then Call Checkvoltage() |
- | ' our callsign is UKHAS | + | |
If Radiocts = 1 Then ' | If Radiocts = 1 Then ' | ||
- | | + | |
End If | End If | ||
Loop | Loop | ||
Cutdownlbl: | Cutdownlbl: | ||
- | Placemark | + | If L > 0 Then ' |
+ | | ||
+ | | ||
+ | End If | ||
Call Cutdown(1 , 12) | Call Cutdown(1 , 12) | ||
+ | Placemark = 2 ' | ||
+ | Descentloop: | ||
+ | Statuscode = 1 | ||
+ | Requestsecond = 1 | ||
+ | While Clearsecond = 0 | ||
+ | | ||
+ | Wend 'but that was a stupid idea as in the slave code, when if first enters the decent loop | ||
+ | Requestsecond = 0 ' | ||
+ | Waitus 50 ' | ||
+ | Printbin #1 , Statuscode | ||
- | Descentloop: | ||
Do | Do | ||
Reset Watchdog | Reset Watchdog | ||
Line 319: | Line 349: | ||
K = Val(contents(10)) | K = Val(contents(10)) | ||
Altitude = K | Altitude = K | ||
- | If V = 0 And Altitude < 300 Then | + | If V < 0.5 And Altitude < 250 Then |
- | Servoenable = 0 | + | Incr Landcount |
Else | Else | ||
- | | + | Landcount |
- | End If ' | + | End If |
- | | + | |
- | Rxenable | + | Landcount = 5 'ie we had 5 stationary gps updates |
+ | Incr Flashcount | ||
+ | If Flashcount > 9 Then | ||
+ | Cutdownpintwo | ||
+ | Flashcount = 0 | ||
+ | | ||
+ | Cutdownpintwo = 0 ' | ||
+ | End If | ||
+ | | ||
Else | Else | ||
- | | + | If Altitude < 300 Then 'so we are moving but low |
+ | Cutdownpintwo = 1 ' | ||
+ | | ||
+ | Else | ||
+ | Cutdownpintwo | ||
+ | Rxenable = 0 | ||
+ | End If | ||
+ | Flashcount = 0 | ||
+ | Servoenable = 1 ' | ||
End If | End If | ||
| | ||
Line 334: | Line 380: | ||
Wend | Wend | ||
| | ||
- | Print #1 , "#," | + | Waitus 50 'make sure slave is ready |
+ | | ||
| | ||
- | Input #2 , S | + | Inputbin |
K = K / 100 | K = K / 100 | ||
| | ||
Incr Arrayat | Incr Arrayat | ||
| | ||
- | | + | If Gpbyteone <> 255 Then Wind_x = Gpbyteone - 127 ' |
| | ||
- | | + | If Gpbyteone <> 255 Then Wind_y = Gpbyteone - 127 ' |
Incr Telcounter | Incr Telcounter | ||
If Telcounter > 10 Then Call Checkvoltage() | If Telcounter > 10 Then Call Checkvoltage() | ||
If Radiocts = 1 Then ' | If Radiocts = 1 Then ' | ||
- | | + | |
End If | End If | ||
Loop | Loop | ||
Sub Checkvoltage() | Sub Checkvoltage() | ||
+ | S = " | ||
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 | + | Printstring |
+ | S = 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 | + | Printstring |
+ | S = S + Printstring | ||
+ | S = S + "," | ||
+ | Printstring | ||
+ | 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 370: | Line 429: | ||
While Radiocts = 0 And Gpbyteone < 30 ' | While Radiocts = 0 And Gpbyteone < 30 ' | ||
| | ||
+ | Reset Watchdog | ||
Incr Gpbyteone | Incr Gpbyteone | ||
Wend | Wend | ||
- | Print " | + | Print "UKHASC,Cutdown channel=" |
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 382: | Line 442: | ||
Cutdownpintwo = 0 | Cutdownpintwo = 0 | ||
End Sub | End Sub | ||
- | </ | ||
+ | Sub Radiocomms() | ||
+ | If Statuscode = 0 Then | ||
+ | S = " | ||
+ | Else | ||
+ | S = " | ||
+ | End If | ||
+ | S = S + Contents(3) | ||
+ | S = S + Contents(4) | ||
+ | S = S + Contents(5) | ||
+ | S = S + Contents(6) | ||
+ | S = S + Contents(10) | ||
+ | | ||
+ | | ||
+ | S = S + Printstring | ||
+ | | ||
+ | | ||
+ | S = S + Printstring | ||
+ | | ||
+ | | ||
+ | S = S + Printstring | ||
+ | | ||
+ | | ||
+ | S = S + Printstring | ||
+ | | ||
+ | | ||
+ | S = S + Printstring | ||
+ | | ||
+ | | ||
+ | S = S + Printstring | ||
+ | | ||
+ | | ||
+ | S = S + Printstring | ||
+ | | ||
+ | S = S + " | ||
+ | | ||
+ | S = S + Printstring | ||
+ | Print S | ||
+ | Print #4 , S | ||
+ | End Sub | ||
+ | </ |
projects/ukhas_glider_project/master.1189464612.txt.gz · Last modified: 2008/07/19 23:32 (external edit)