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

Next revision
Previous revision
projects:ukhas_glider_project:master [2007/09/04 22:08] – created laurencebprojects:ukhas_glider_project:master [2008/07/19 23:33] (current) – external edit 127.0.0.1
Line 1: Line 1:
-<code>+<code qbasic>
 $regfile = "m168def.dat" $regfile = "m168def.dat"
 $crystal = 16000000 $crystal = 16000000
 $baud = 16000 $baud = 16000
-$hwstack = 64+$hwstack = 32
 $swstack = 64 $swstack = 64
-$framesize = 64 +$framesize = 96 
-Const Servogain = 10 +Open "comc.4:125000,8,N,1" For Output As #
-Const Pterm = +Open "comc.3:125000,8,N,1" For Input As #2 
-Const Iterm = 0.001 +Open "comd.2:4800,8,n,1" For Input As #3                    'rx from pc 
-Const Dterm = 0 +Open "comb.4:19200,8,n,1" For Output As #4                  'Logger 
-Const Kalmangpsweight = 1 +Config Adc Single , Prescaler = Auto , Reference Internal 
-const kalmangyroweight=0.05 +Config Portd.= Output 
-const propogation=0.98*(1-kalmangyroweight) +Config Portb.= Output 
-const servogain=-0.007*(1-kalmangyroweight)                        'need to check these with simcode +Config Portb.= Output
-Const Center 6000                                                           'needs to be checked with servo +
-Baud 125000 +
-Config Portd.= Output +
-Config Portd.= Output +
-Config Portd.= Output+
 Config Portb.1 = Output Config Portb.1 = Output
 +Config Portd.2 = Input                                      'rx from pc
 +Config Portd.6 = Output
 Config Portd.3 = Input Config Portd.3 = Input
-Config Portd.= Input +Config Portc.= Input 
-Config Portd.= Input +Config Portd.= Input 
-Config Portb.Input +Config Portc.Output 
-Config Portc.= Input +Config Portc.= Input 
-Config Portc.5 = Output +Config Portc.5 = Input 
-Config Portc.= Output +Config Watchdog = 4096 
-Config Portc.3 = Output +'Config Portc.= Output 
-'Config Spi = Soft , Din = Pinc.4 , Dout = Portc.5 , Ss = None , Clock = Portc.2 +'Config Portc.3 = Input 
-'Spiinit +Ledone Alias Portd.7 
-Config Timer1 Timer , Prescale 64 +Ledtwo Alias Portb.0 
-Config Timer0 Timer Prescale = 1024 +Radiocts Alias Pind.3 
-Dim Rate As Integer Temperature As Integer , Lsb As Byte , Msb As Byte       'melexis +'Cts Alias Portd.2 
-Dim Rateread As Byte , Tempread As Byte , Readmelexis As Byte , Mask As Word Maskword As Word Servoenable As Byte +Groundcontrol Alias Pind.4 
-Dim As String * 30                                        'rest +Statusled Alias Portd.
-Dim Contents(5) As String * 20 +Requestsecond Alias Portc.1 
-Dim As Single , R As Single , Gpfloatone As Single , Gpfloattwo As Single , Oldheading As Single Realrate As Single Integral As Single,filteredrate as single, servo as single +Clearsecond Alias Pinc.2 
-Dim Gpbyteone As Byte , Pulses As Byte , Timeout As Byte , Error As Byte +Cutdownpinone Alias Portb.1 
-Dim As Integer , Gpintegerone As Integer , Targetheading As Single , Gpsheading As Single , Heading As Single +Cutdownpintwo Alias Portb.2 
-Dim Gpwordone As Word Pulselenght As Word +Cutdownpinone 
-Rateread &B10010100 +Cutdownpintwo 0 
-Tempread &B10011100 +Baud 4800 
-Readmelexis &B10000000 +Declare Sub Checkvoltage() 
-Maskword &B0000111111111111 +Declare Sub Cutdown(byval Channel As Byte Byval Duration As Byte) 
-Pcmsk2 &B01000000                                         'pcint22 enabled +Declare Sub Radiocomms() 
-Pcmsk0 &B00000001                                         'pcint0 enabled +Echo Off 
-Groundcontrol Alias Portd.4 +Start Adc 
-Rts Alias Pind.3 +Dim Rate As Integer 
-Cts Alias Portd.2 +Dim Temperature As Integer , Error As Byte , Heading As Single , Filteredrate As Single , Pulselenght As Word 
-Servoone Alias Portd.+Dim Pulses As Byte 
-Servotwo Alias Portb.1 +Dim S As String * 100 
-Pulsesdetect Alias Pind.6 +Dim T As String * 15 
-Inputone Alias Pinb.+Dim Printstring As String * 20 
-Inputtwo Alias Pind.7 +Dim K As Single 
-Slave Alias Portc.+Dim Iterations As Byte , Flashcount As Byte 
-Din Alias Pinc.4 +Dim Windxs(251) As Eram Byte 
-Dout Alias Portc.5 +Dim Windys(251) As Eram Byte Placemark As Eram Byte 
-Clock Alias Portc.2 +Dim Target_es As Eram Single 
-Slave = 1 +Dim Target_ns As Eram Single 
-'Declare Sub Ground() +Dim Lock As Bit 
-Declare Sub Talktomelexis() +Dim Gpfloatone As Single Gpsheading As Single 
-Declare Sub Ascent() +Dim As String * 100 
-On Pcint2 Edge +Dim B As String * 6 
-On Pcint0 Copy +Dim Contents(17) As String * 15 
-Set Pcifr.pcif2 +Dim Transfer As String * 11 
-Set Pcifr.pcif0 +Dim N As Byte 
-Enable Pcint2 +Dim I As Byte 
-Enable Pcint0 +Dim Statuscode As Byte 
- +Dim Heightupto As Byte Rxenable As Byte Servoenable As Byte 
-Servotwo = 1 +Dim Gpbyteone As Byte , Gpbytetwo As Byte , Telcounter As Byte , Landcount As Byte 
-Servoone 1 +Dim Gpintegerone As Integer 
-0 +Dim Intcount As Integer , Timeelapsed As Integer 
-Start Timer1 +Dim Store As Integer 
-Start Timer0 +Dim Test As Integer 
-Enable Interrupts +Dim L As Integer 
-Wait 2 +Dim Arrayat As Integer 
 +Dim Rudder As Single 
 +Dim Integral As Single 
 +Dim Derivative As Single 
 +Dim Target As Single 
 +Dim Target_e As Single 
 +Dim Target_n As Single 
 +Dim Offset As Single 
 +Dim Windy_total As Single 
 +Dim Windx_total As Single 
 +Dim Wind_speed As Single 
 +Dim Airspeed As Single 
 +Dim X As Single 
 +Dim Y As Single 
 +Dim V As Single Altitude As Single 
 +Dim Wind_x As Single 
 +Dim Wind_y As Single 
 +Dim North As Single 
 +Dim East As Single 
 +Dim Store_east As Single 
 +Dim Store_north As Single 
 +Dim V_x As Single 
 +Dim V_y As Single 
 +Dim Minutes As String * 7 
 +Dim Degrees As String * 3 
 +Dim Command As String * 10 
 +Statuscode 0 
 +Lock 0 
 +Iterations 0 
 +Timeelapsed 0 
 +Wind_x 0 
 +Wind_y 0 
 +Landcount = 0 
 +Telcounter = 0 
 +Portd.3 = 1 
 +Waitms 100 
 +Gpintegerone = Getadc(5) 
 +Gpfloatone = Gpintegerone 
 +Gpintegerone = Getadc(0) 
 +Gpfloatone = Gpfloatone / Gpintegerone 
 +If Gpfloatone < 0.5 And Gpfloatone > 0.4 Then 
 + Print "Button pressed" 
 +Else 
 + Print "Watchdog reset" 
 + Start Watchdog 
 + Target_n Target_ns 
 + Target_e = Target_es 
 + Select Case Placemark 
 + Case 1: 
 + Goto Cutdownlbl                                            'cutdown if error during ascent 
 + Case 2: 
 + Goto Descentloop 
 + Case Else: 
 + Goto Cutdownlbl 
 + End Select 
 +End If 
 +Waitms 50 
 +Call Checkvoltage() 
 +'Call Cutdown(1 , 4) 
 +Print "wind records:" 
 +For Gpbyteone = 1 To 251 
 + Gpbytetwo Windxs(gpbyteone) 
 + Print Gpbyteone ; "," ; Gpbytetwo ; ","
 + Gpbytetwo Windys(gpbyteone) 
 + Print Gpbytetwo 
 +Next 
 +Print Version() 
 +Print "Demo flight: 4km/20 minute" 
 +Print "Now check gps"
 Do Do
- Incr Timeout + Input S 
- If Timeout > 250 Then Timeout 250 + Mid(s , 2 , 6) 
- While Timer0 < 250 + If "$GPGGA" Then 
- Wend +  Print S                                                   'shows us the GGA string 
- Reset Timer0 +  = Split(, Contents(1) , ","
- If Pulselenght > 250 And Pulselenght < 500 And Timer1 < 20000 Then +  0 
-  Incr Pulses +  Val(contents(10)
- Else +  If <> 0 Then                                            'if nonzero altitude then we've got something 
-  Pulses +   Goto Gotlock
-  Groundcontrol = 0 +
- End If +
- If Pulses > 10 Then +
-  Groundcontrol = 1                                         'we enable servo relaying +
-  Pulses = 10 +
- End If +
-If Rts = 1 Then                                             'check for comms +
- Cts = 1 +
- Input T +
- Cts = 0 +
- Gpbyteone = Split(, Contents(1) , ","+
- If Gpbyteone 2 Then Call Ascent()                        'go to servo waggle if short message +
- Contents(2+
- If Timeout 80 Then                                       'ie we had another message not long ago +
-  Gpsheading = Val(t) +
-  Gpfloatone = Gpsheading - Oldheading              'so dont update +
-  If Gpfloatone < -180 Then +
-   Gpfloatone = Gpfloatone + 360+
   End If   End If
-  If Gpfloatone > 180 Then 
-   Gpfloatone = Gpfloatone - 360 
-  End If 
-  Gpfloatone = Kalmangpsweight * Gpfloatone 
-  Heading = Heading + Gpfloatone 
  End If  End If
- Oldheading = Heading                                     'but always store the past heading +Loop 
- Timeout = 0 +Gotlock: 
- T = Contents(3) +Print "Okay we have GPS" 
- Targetheading = Val(t) +Print "check rc ground control, then" 
- T = Contents(4) +Print "Enter target north and east" 
- Servoenable Val(t) +Input #, Target_n 
- Contents(5) +Print Target_n 
- Gpbyteone Val(t) +Input #3 , Target_e 
- If Gpbyteone = 1 Then +Print Target_e 
-  Enable Interrupts +Gpfloatone Target_ns 
- Else +If Target_n <> Gpfloatone Then Target_ns Target_n         'store in eeprom 
-  Disable Interrupts +Gpfloatone Target_es 
- End If +If Target_e <> Gpfloatone Then Target_es = Target_e 
- Waitus 250 +Portd.3 = 1 
- Print "#," ; Rate ; "," ; Temperature ; "," ; Error ; "," ; Heading ; "," ; Pulselenght ; "," ; Pulses +Print "Launch!"                                             'radiocts pullup 
-End If +Start Watchdog 
-Call Talktomelexis() +Placemark = 1                                               'write eeprom to say in ascent 
-Gpintegerone Rate +Do 
-Gpintegerone Gpintegerone 1018 + Reset Watchdog 
-Gpfloatone Gpintegerone + Do 
-Gpfloatone Gpfloatone / 13.653 +  Input U 
-Realrate Gpfloatone                                       'now  in degrees per second +  B = Mid(u 6) 
-gpfloatone=gpfloatone*kalmangyroweight + Loop Until B = "$GPGGA" 
-filteredrate=propogation*filteredrate + Do 
-filteredrate=filteredrate+gpfloatone +  Input S 
-gpfloatone=servo*servogain +  B = Mid(s 6) 
-filteredrate=filteredrate+gpfloatone + Loop Until B = "$GPRMC" 
-gpfloatone=filteredrate/62.5 +   I = Split(s , Contents(1) , ",")                         'process rmc 
-Heading Heading + gpfloatone +   K = Val(contents(9)) 
-If Heading 360 Then +   V = Val(contents(8)
- Heading Heading - 360 +   K Deg2rad(k) 
-End If +   Wind_x Sin(k)                                          'WORK OUT WIND IN Y=NORTH frame the trig library works in radians 
-If Heading < 0 Then +   Wind_x Wind_x * V 
- Heading Heading 360 +   Wind_y Cos(k) 
-End If +   Wind_y Wind_y V 
-Gpfloatone Targetheading - Heading                        'heading offset +   Windx_total Windx_total + Wind_x                       'add it to our total wind 
-If Gpfloatone < -180 Then +   Windy_total Windy_total Wind_y 
- Gpfloatone = Gpfloatone + 360 +   Incr L                                                   'incrament the denominator for our averaging 
-End If +   Incr Timeelapsed 
-If Gpfloatone 180 Then +   Split(u , Contents(1) , ","                        'now process gga 
- Gpfloatone = Gpfloatone - 360 +   K Val(contents(10)) 
-End If +   K 100 
-Gpfloattwo Gpfloatone * Pterm +   Arrayat Int(k)                                         'find the altitude in 100m incraments 
-Realrate Dterm * Realrate                                 'pid +   If Arrayat Heightupto Then 
-Integral = Integral + Heading +    Incr Heightupto                                         'do we now fall into another (higher) 100m incrament ? 
-Gpfloatone = Integral * Iterm +    Windx_total Windx_total / L 
-If Gpfloatone > 30 Then Integral 30 / Iterm               'wind up prevension +    Gpbyteone = Windx_total + 127 
-If Gpfloatone < -30 Then Integral = -30 / Iterm +    Windxs(heightupto) = Gpbyteone                          'we are storing as a signed byte 
-Gpfloatone = Gpfloatone + Realrate +    Windy_total Windy_total / L 
-Gpfloatone = Gpfloatone + Gpfloattwo +    Gpbyteone = Windy_total 127                           'we find the average and shove it in the eeprom 
-Gpfloatone = Servogain * Gpfloatone +    Windys(heightupto) = Gpbyteone 
-If Gpfloatone 500 Then Gpfloatone = 500                   'limits +    0                                                   'this was forgotten in the flight code doh 
-If Gpfloatone < -500 Then Gpfloatone = -500 +   End If 
-servo=gpfloatone                                                        'store servo +   If Arrayat > 40 Then 
-Gpintegerone Gpfloatone +    Print "Altitude cutdown" ; Arrayat 
-Gpintegerone = Gpintegerone + Center +    Goto Cutdownlbl                                         '4Km/20 minute cutdown 
-Portd.5 = 1 +   End If 
-If Groundcontrol = 0 And Servoenable = 1 Then Pulseout , Portd , 5 , Gpintegerone       'only if not under ground control+   If Timeelapsed 1200 Then 
 +    Print "Time cutdown" 
 +    Goto Cutdownlbl 
 +   End If 
 +   Requestsecond 1 
 +   While Clearsecond 0 
 +    Waitus 10 
 +   Wend 
 +   Requestsecond 0 
 +   Waitus 50 
 +   Printbin #1 , Statuscode 
 +   Waitus 150                                               'tells slave we are going up 
 +   Inputbin #2 , Rate , Temperature , Error 
 +   Incr Telcounter 
 +   If Telcounter 10 Then Call Checkvoltage()              our callsign is UKHAS 
 +   If Radiocts = 1 Then                                     'is CTS=1 from the radio modem? 
 +    Call Radiocomms() 
 +   End If
 Loop Loop
  
-Edge+Cutdownlbl
-If Groundcontrol = 1 Then Servotwo = Not Inputtwo +If L > 0 Then                                               'set a valid wind for cutdown altitude 
-If Inputtwo 0 Then + Wind_x Windx_total / L 
- Pulselenght Timer1+ Wind_y Windy_total / L
 End If End If
-Timer1 = 0 +Call Cutdown(1 , 12) 
-Return+Placemark = 2                                               'write eeprom 
 +Descentloop: 
 +Statuscode = 1 
 +Requestsecond = 1 
 +While Clearsecond = 0 
 + Waitus 10                                                  'I did commented this out as we should give the slave a message 1 second before the first valid gps 
 +Wend                                                        'but that was a stupid idea as in the slave code, when if first enters the decent loop 
 +Requestsecond = 0                                           'it waits for a new gps before doing anything other than running off the gyro 
 +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
  
-Copy: 
-If Groundcontrol = 1 Then Servoone = Not Inputone 
-Return 
  
-Sub Ascent() 
-Integral = 0                                                'reset integral 
-Waitus 250 
-Print "#," ; Rate ; "," ; Temperature 
 Do Do
- Waitms 15 + Reset Watchdog 
- Pulseout Portd Center                              'keep servo centered + 'insert 
- Call Talktomelexis() +    Do 
- If Rts Then                                            'check for comms +     Input U 
-  Cts = 1 +     B = Mid(u 6) 
-  Input T +    Loop Until B = "$GPGGA" 
-  Cts = 0 +    Do 
-  Gpbyteone = Split(, Contents(1) , ","+     Input S 
-  If Gpbyteone > 2 Then Exit Sub +     B = Mid(s 2 , 6) 
-  Waitus 250 +    Loop Until B = "$GPRMC" 
-  Print "#," ; Rate ; "," ; Temperature ; "," ; Error +   I = Split(s , Contents(1) , ","                        'process rmc 
-  Portd.5 = 1 +   Degrees = Left(contents(4) , 2
-  For Gpbyteone = 0 To 10 +   Minutes = Right(contents(4) , 7) 
-   Pulseout , Portd , 5 , 5500                              'wiggle servo +   North = 0 
-   Waitms 15 +   North = Val(minutes) 
-  Next +   North = North / 60 
-  For Gpbyteone = 0 To 10 +   K = 0 
-   Pulseout Portd 6500 +   K = Val(degrees) 
-   Waitms 15 +   North = K + North 
-  Next+   Degrees = Left(contents(6) , 3) 
 +   Minutes = Right(contents(6) , 7) 
 +   East = 0 
 +   East = Val(minutes) 
 +   East = East / 60 
 +   K = 0 
 +   K = Val(degrees) 
 +   East = K + East 
 +   If Contents(7) "W" Then 
 +    East = -east 
 +   End If 
 +   East = Target_e - East 
 +   K = Deg2rad(north) 
 +   K = Cos(k) 
 +   East = East * K                                          'distance to target in equatorial degree units 
 +   North = Target_n - North 
 +   K = East / North 
 +   Target = Atn(k) 
 +   Target = Rad2deg(target) 
 +   If North < 0 Then                                        'direction to target 
 +    Target = Target - 180 
 +   End If 
 +   If Target < -180 Then 
 +    Target = Target + 360                                   'gets it in +-180 degree range 
 +   End If 
 +   K = 0 
 +   K = Val(contents(9)) 
 +   V = 0 
 +   V = Val(contents(8)) 
 +   If V < 0.5 Then                                          'off if we crashed 
 +    If V = 0 Then 
 +     V = 0.01 
 +    End If 
 +    Statusled = 0 
 +   Else                                                     'indicator LED 
 +    'Incr Timeelapsed 
 +    Toggle Statusled 
 +   End If 
 +   K = Deg2rad(k) 
 +   X = Sin(k) 
 +   X = X * V 
 +   Y = Cos(k) 
 +   Y = Y * V 
 +   X = X - Wind_x                                           'wind compensation  in Y=NORTH frame 
 +   Y = Y - Wind_y 
 +   Airspeed = X * X 
 +   K = Y * Y 
 +   Airspeed = Airspeed + K 
 +   Airspeed = Sqr(airspeed) 
 +   If Y = 0 Then 
 +    X = 0 
 +    Else 
 +    X = X / Y                                               'stops us getting infinity 
 +   End If 
 +   K = Atn(x) 
 +   K = Rad2deg(k) 
 +   If Y < 0 Then 
 +    K = K - 180 
 +   End If                                                   'all to keep us in +-180 degree range 
 +   If K < -180 Then 
 +    K = K + 360                                             'K is now our air vector heading 
 +   End If 
 +   Gpsheading = K 
 +   K = K - Target                                           'k is now our heading offset (from now on is just for 
 +   If K < -180 Then                                         'the pretty leds) 
 +    K = K + 360 
 +   End If 
 +   If K > 180 Then 
 +    K = K - 360 
 +   End If 
 +   If K > 0 Then 
 +    Ledone = 0                                              'left/right indictor LEDs 
 +    Ledtwo = 1 
 +   Else 
 +    Ledone = 1 
 +    Ledtwo = 0 
 +   End If 
 + 'end insert 
 +  = Split(, Contents(1) , ","                         'now we do the gga 
 +  K = Val(contents(10)) 
 +  Altitude = K 
 + If V < 0.5 And Altitude < 250 Then                         'we have landed ? 
 +  Incr Landcount 
 + Else 
 +  Landcount = 0 
 + End If 
 + If Landcount > 4 Then 
 +   Landcount =                                            '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 
 +  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 
 + Requestsecond = 1 
 + While Clearsecond = 0 
 +  Waitus 10 
 + Wend 
 + Requestsecond = 0 
 + Waitus 50                                                  'make sure slave is ready 
 + Printbin #1 Statuscode ; Gpsheading ; Target ; Servoenable ; Rxenable 
 + Waitus 200 
 + Inputbin #2 Rate , Temperature , Error , Heading , Filteredrate , Pulselenght Pulses 
 + K = K / 100 
 + Arrayat = Int(k) 
 + Incr Arrayat                                               'as minimum altitude incrament=0 but array starts at 1 
 + Gpbyteone = Windxs(arrayat)                                'gives us the correct wind for our altitude 
 + If Gpbyteone <> 255 Then Wind_x = Gpbyteone - 127          'handles an unrecorded eeprom byte 
 + Gpbyteone = Windys(arrayat) 
 + If Gpbyteone <> 255 Then Wind_y = Gpbyteone - 127          'handles unrecorded 
 + Incr Telcounter 
 + If Telcounter > 10 Then Call Checkvoltage() 
 + If Radiocts = 1 Then                                       'is CTS=1 from the radio modem? 
 +  Call Radiocomms()
  End If  End If
 Loop Loop
 +
 +Sub Checkvoltage()
 +S = "UKHASD,"
 +Gpintegerone = Getadc(5)
 +Gpfloatone = Gpintegerone
 +Gpfloatone = Gpfloatone * 9.503
 +Gpfloatone = Gpfloatone / 1000
 +Printstring = Str(gpfloatone )                              'servo
 +S = S + Printstring
 +S = S + ","
 +Gpintegerone = Getadc(0)
 +Gpfloatone = Gpintegerone
 +Gpfloatone = Gpfloatone * 4.250
 +Gpfloatone = Gpfloatone / 1000
 +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
 End Sub End Sub
  
  
-'Sub Ground() +Sub Cutdown(byval Channel As Byte , Byval Duration As Byte
-'Groundcontrol 1 +Gpbyteone 0 
-'While Timer1 < 20000 And Pulselenght > 200 And Pulselenght 600 +While Radiocts = 0 And Gpbyteone 30                       'wait for radio with timeout 
- 'Servoone = Not Inputone + Waitms 500 
- 'Servotwo = Not Inputtwo + Reset Watchdog 
-'Wend + Incr Gpbyteone 
-'Servotwo = 1 +Wend 
-'Servoone = 1 +Print "UKHASC,Cutdown channel=" ; Channel ; " Time=" ; Duration 
-'Groundcontrol = 0 +If Channel = 1 Then Cutdownpinone = 1 
-'End Sub+If Channel = 2 Then Cutdownpintwo = 1 
 +For Gpbyteone = 0 To Duration 
 + Wait 1 
 + Reset Watchdog 
 +Next 
 +Cutdownpinone = 0 
 +Cutdownpintwo = 0 
 +End Sub
  
- +Sub Radiocomms() 
- + If Statuscode = 0 Then 
-Sub Talktomelexis() +  "UKHAS>" 
- Clock = 0 + Else 
- Dout = 0 +  "UKHAS<" 
- Slave = 0 + End If 
- Error = 0 + S + Contents(3) 
- Waitus 1 + S + Contents(4) 
- For Gpbyteone = 7 To 0 Step -1 + S + Contents(5) 
-  Dout Rateread.gpbyteone + S + Contents(6) 
-  Waitus 1 + S + Contents(10)                                       'nmea data 
-  Clock 1 + Printstring Fusing(gpsheading , "#.#") 
-  Waitus 1 + Printstring "," + Printstring 
-  Clock 0 + S + Printstring 
- Next + Printstring Fusing(target , "#.#") 
- For Gpbyteone 15 To 0 Step -1 + Printstring "," + Printstring 
-  Waitus 1 + S + Printstring 
-  Clock 1 + Printstring Str(rate) 
-  Waitus 1 + Printstring "," + Printstring 
-  Clock + S + Printstring 
- Next + Printstring Str(temperature) 
- Waitus 1 + Printstring "," + Printstring 
- Slave 1 + S + Printstring 
- Waitus 300 + Printstring Str(error
- Slave + Printstring "," + Printstring 
- For Gpbyteone = 7 To 0 Step -1 + S + Printstring 
-  Dout = Readmelexis.gpbyteone + Printstring Fusing(heading , "#.#") 
-  Waitus 1 + Printstring "," + Printstring 
-  Clock 1 + S + Printstring 
-  Waitus 1 + Printstring Fusing(filteredrate , "#.#") 
-  Clock 0 + Printstring "," + Printstring 
- Next + S + Printstring 
- For Gpbyteone 7 To 0 Step -1 + Gpbyteone = Checksum(s) 
-  Waitus 1 + S + "*" 
-  Clock 1 + Printstring Hex(gpbyteone) 
-  Msb.gpbyteone Din + S + Printstring 
-  Waitus 1 + Print S 
-  Clock 0 + Print #4 S
- Next +
- For Gpbyteone 7 To 0 Step -1 +
-  Waitus 1 +
-  Clock 1 +
-  Lsb.gpbyteone Din +
-  Waitus 1 +
-  Clock +
- Next +
- Waitus 1 +
- Slave 1 +
- Rate Makeint(lsb , Msb+
- Rate Rate And Maskword +
- Shift Rate , Right 1 +
- If Msb.6 1 Then Error = 1 +
- Slave +
- Waitus 1 +
- For Gpbyteone = 7 To 0 Step -1 +
-  Dout = Tempread.gpbyteone +
-  Waitus 1 +
-  Clock 1 +
-  Waitus 1 +
-  Clock 0 +
- Next +
- For Gpbyteone 15 To 0 Step -1 +
-  Waitus 1 +
-  Clock = 1 +
-  Waitus 1 +
-  Clock = 0 +
- Next +
- Waitus 1 +
- Slave = 1 +
- Waitus 300 +
- Slave = 0 +
- For Gpbyteone = 7 To 0 Step -1 +
-  Dout = Readmelexis.gpbyteone +
-  Waitus 1 +
-  Clock 1 +
-  Waitus 1 +
-  Clock 0 +
- Next +
- For Gpbyteone = 7 To 0 Step -1 +
-  Waitus 1 +
-  Clock 1 +
-  Msb.gpbyteone Din +
-  Waitus 1 +
-  Clock = 0 +
- Next +
- For Gpbyteone = 7 To 0 Step -1 +
-  Waitus 1 +
-  Clock = 1 +
-  Lsb.gpbyteone = Din +
-  Waitus 1 +
-  Clock = 0 +
- Next +
- Waitus 1 +
- Slave = 1 +
- Temperature = Makeint(lsb , Msb+
- If Msb.6 = 1 Then Error 1 +
- Temperature = Temperature And Maskword +
- Shift Temperature , Right 1+
 End Sub End Sub
 </code> </code>
projects/ukhas_glider_project/master.1188943682.txt.gz · Last modified: 2008/07/19 23:32 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki