projects:ukhas_glider_project:slave
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
projects:ukhas_glider_project:slave [2007/09/15 23:21] – laurenceb | projects:ukhas_glider_project:slave [2008/07/19 23:33] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 7: | Line 7: | ||
$framesize = 64 | $framesize = 64 | ||
Const Servogain = 10 | Const Servogain = 10 | ||
- | Const Pterm = -1 | + | Const Pterm = -0.25 'all -ive as a +ive pulse lenght causes +ive turn |
- | Const Iterm = -0.001 | + | Const Iterm = -0.0003 |
- | Const Dterm = -1 | + | Const Dterm = -0.35 |
- | Const Kalmangpsweight = 0.6 | + | Const Kalmangpsweight = 0.5 |
- | Const Kalmangyroweight = 0.1 | + | Const Kalmangyroweight = 0.5 |
Const Propogation = 0.98 *(1 -kalmangyroweight) | Const Propogation = 0.98 *(1 -kalmangyroweight) | ||
Const Servocontrolinput = 0.0015 *(1 -kalmangyroweight) | Const Servocontrolinput = 0.0015 *(1 -kalmangyroweight) | ||
- | Const Center = 6000 'needs to be checked with servo | + | Const Center = 6200 'needs to be checked with servo |
Const Conversionfactor = 16 ' | Const Conversionfactor = 16 ' | ||
Const Lowerpwm = Center - 300 | Const Lowerpwm = Center - 300 | ||
Line 38: | Line 38: | ||
Dim Rate As Integer , Temperature As Integer , Lsb As Byte , Msb As Byte ' | Dim Rate As Integer , Temperature As Integer , Lsb As Byte , Msb As Byte ' | ||
Dim Rateread As Byte , Tempread As Byte , Readmelexis As Byte , Mask As Word , Maskword As Word , Servoenable As Byte | Dim Rateread As Byte , Tempread As Byte , Readmelexis As Byte , Mask As Word , Maskword As Word , Servoenable As Byte | ||
- | Dim Firstupdate As Bit , Servoexcitecount As Byte | + | Dim Firstupdate As Byte , Servoexcitecount As Byte 'rest |
Dim S 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 | Dim S 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 | ||
Dim Gpbyteone As Byte , Pulses As Byte , Error As Byte , Enablegroundcontrol As Byte | Dim Gpbyteone As Byte , Pulses As Byte , Error As Byte , Enablegroundcontrol As Byte | ||
Line 76: | Line 76: | ||
S = 0 | S = 0 | ||
Integral = 0 | Integral = 0 | ||
+ | For Gpbyteone = 0 To 200 'to let us check servo alignment | ||
+ | | ||
+ | | ||
+ | Next | ||
Start Timer1 | Start Timer1 | ||
Start Timer0 | Start Timer0 | ||
Line 105: | Line 109: | ||
Cts = 0 | Cts = 0 | ||
If Gpbyteone = 1 Then ' | If Gpbyteone = 1 Then ' | ||
- | Firstupdate = 1 'means we treat the first gps update correctly | + | Firstupdate = 2 'means we treat the first gps update correctly |
Waitus 300 | Waitus 300 | ||
Printbin Rate ; Temperature ; Error ; Heading ; Filteredrate ; Pulselenght ; Pulses | Printbin Rate ; Temperature ; Error ; Heading ; Filteredrate ; Pulselenght ; Pulses | ||
Line 148: | Line 152: | ||
| | ||
Cts = 0 | Cts = 0 | ||
- | If Firstupdate = 0 Then 'ie we had another message not long ago | + | If Firstupdate = 0 Or Firstupdate = 1 Then |
Gpfloatone = Gpsheading - Oldheading | Gpfloatone = Gpsheading - Oldheading | ||
If Gpfloatone < -180 Then ' | If Gpfloatone < -180 Then ' | ||
Line 156: | Line 160: | ||
| | ||
End If | End If | ||
- | Gpfloatone = Kalmangpsweight * Gpfloatone | + | If Firstupdate = 0 Then |
+ | Gpfloatone = Kalmangpsweight * Gpfloatone | ||
+ | Else 'if firstupdate=1, | ||
+ | | ||
+ | End If | ||
Heading = Heading + Gpfloatone | Heading = Heading + Gpfloatone | ||
If Heading > 180 Then ' | If Heading > 180 Then ' | ||
Line 164: | Line 172: | ||
| | ||
End If | End If | ||
- | | + | |
- | | + | |
+ | Firstupdate = 1 ' | ||
End If | End If | ||
| | ||
Line 178: | Line 187: | ||
Call Talktomelexis() | Call Talktomelexis() | ||
Gpintegerone = Rate | Gpintegerone = Rate | ||
- | Gpintegerone = Gpintegerone - 1018 | + | Gpintegerone = Gpintegerone - 1009 ' |
Gpfloatone = Gpintegerone | Gpfloatone = Gpintegerone | ||
- | Gpfloatone = Gpfloatone / 13.653 | + | Gpfloatone = Gpfloatone / 6.8265 |
Realrate = Gpfloatone | Realrate = Gpfloatone | ||
Gpfloatone = Gpfloatone * Kalmangyroweight | Gpfloatone = Gpfloatone * Kalmangyroweight | ||
Line 201: | Line 210: | ||
If Gpfloatone > 180 Then | If Gpfloatone > 180 Then | ||
| | ||
- | End If 'pid | + | End If |
- | Gpfloattwo = Gpfloatone * Pterm ' | + | Integral = Integral + Gpfloatone |
- | Realrate | + | Gpfloattwo = Gpfloatone * Pterm ' |
- | Integral | + | Gpfloatone |
- | Gpfloatone = Integral * Iterm | + | Gpfloatone |
- | If Gpfloatone | + | If Gpfloatone |
- | If Gpfloatone | + | If Gpfloatone |
- | Gpfloatone = Gpfloatone + Realrate | + | Gpfloattwo |
- | Gpfloatone = Gpfloatone + Gpfloattwo | + | If Gpfloattwo |
+ | If Gpfloattwo | ||
+ | Gpfloatone = Gpfloatone + Gpfloattwo | ||
Gpfloatone = Servogain * Gpfloatone | Gpfloatone = Servogain * Gpfloatone | ||
- | If Gpfloatone > 500 Then Gpfloatone = 500 ' | ||
- | If Gpfloatone < -500 Then Gpfloatone = -500 | ||
Servo = Gpfloatone | Servo = Gpfloatone | ||
Gpintegerone = Gpfloatone | Gpintegerone = Gpfloatone |
projects/ukhas_glider_project/slave.1189898479.txt.gz · Last modified: 2008/07/19 23:32 (external edit)