UKHAS Wiki

UK High Altitude Society

User Tools

Site Tools


projects:ukhas_glider_project:slave

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:slave [2007/09/23 21:58] laurencebprojects: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                                             'all +ive as a -ive pulse lenght causes +ive turn +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.3+Const Kalmangyroweight = 0.5
 Const Propogation = 0.98 *(1 -kalmangyroweight) Const Propogation = 0.98 *(1 -kalmangyroweight)
-Const Servocontrolinput = -0.0015 *(1 -kalmangyroweight)    'need to check these with simcode +Const Servocontrolinput = 0.0015 *(1 -kalmangyroweight)     'need to check these with simcode 
-Const Center = 6000                                         'needs to be checked with servo+Const Center = 6200                                         'needs to be checked with servo
 Const Conversionfactor = 16                                 'pwm timer counter is 16 times slower than sw pwm Const Conversionfactor = 16                                 'pwm timer counter is 16 times slower than sw pwm
 Const Lowerpwm = Center - 300 Const Lowerpwm = Center - 300
Line 76: Line 76:
 S = 0 S = 0
 Integral = 0 Integral = 0
 +For Gpbyteone = 0 To 200                                    'to let us check servo alignment
 + Waitms 15
 + Pulseout , Portd , 5 , Center
 +Next
 Start Timer1 Start Timer1
 Start Timer0 Start Timer0
Line 206: Line 210:
 If Gpfloatone > 180 Then If Gpfloatone > 180 Then
  Gpfloatone = Gpfloatone - 360  Gpfloatone = Gpfloatone - 360
-End If                                                      'pid +End If 
-Gpfloattwo = Gpfloatone * Pterm                             'p +Integral = Integral + Gpfloatone                            'i increment                                                     'pid 
-Realrate = Dterm * Filteredrate                             'd   reuses the realrate variable +Gpfloattwo = Gpfloatone * Pterm                             'P 
-Integral Integral + Gpfloatone                            'i +Gpfloatone = Dterm * Filteredrate                           'D 
-Gpfloatone = Integral * Iterm +Gpfloatone Gpfloatone Gpfloattwo                        'add d and p terms 
-If Gpfloatone 30 Then Integral = 30 / Iterm               'wind up prevension +If Gpfloatone > 30 Then Gpfloatone = 30                     'servo limits on d and p 
-If Gpfloatone < -30 Then Integral = -30 / Iterm +If Gpfloatone < -30 Then Gpfloatone = -30 
-Gpfloatone = Gpfloatone + Realrate                          'add d and i terms +Gpfloattwo = Integral * Iterm                               'calculate I 
-Gpfloatone = Gpfloatone + Gpfloattwo                        'add on the p+If Gpfloattwo 25 Then Integral = 25 / Iterm               'wind up prevension 
 +If Gpfloattwo < -25 Then Integral = -25 / Iterm 
 +Gpfloatone = Gpfloatone + Gpfloattwo                        'add I term
 Gpfloatone = Servogain * Gpfloatone                         'servo dependant variable Gpfloatone = Servogain * Gpfloatone                         'servo dependant variable
-If Gpfloatone > 500 Then Gpfloatone = 500                   'servo limits 
-If Gpfloatone < -500 Then Gpfloatone = -500 
 Servo = Gpfloatone                                          'store servo for control input Servo = Gpfloatone                                          'store servo for control input
 Gpintegerone = Gpfloatone Gpintegerone = Gpfloatone
projects/ukhas_glider_project/slave.1190584720.txt.gz · Last modified: 2008/07/19 23:32 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki