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

Next revision
Previous revision
projects:ukhas_glider_project:slave [2007/09/04 22:10] – created laurencebprojects:ukhas_glider_project:slave [2008/07/19 23:33] (current) – external edit 127.0.0.1
Line 3: Line 3:
 $crystal = 16000000 $crystal = 16000000
 $baud = 16000 $baud = 16000
-$hwstack = 40 +$hwstack = 64 
-$swstack = 40 +$swstack = 64 
-$framesize = 40 +$framesize = 64 
-Open "comc.4:125000,8,N,1" For Output As #1 +Const Servogain = 10 
-Open "comc.3:125000,8,N,1" For Input As #2 +Const Pterm = -0.25                                         'all -ive as a +ive pulse lenght causes +ive turn 
-Open "comd.2:4800,8,n,1" For Input As #3                    'rx from pc +Const Iterm = -0.0003 
-Config Adc Single , Prescaler Auto , Reference Internal +Const Dterm = -0.35 
-Config Portd.= Output +Const Kalmangpsweight = 0.5 
-Config Portb.= Output +Const Kalmangyroweight = 0.5 
-Config Portb.= Output+Const Propogation = 0.98 *(-kalmangyroweight) 
 +Const Servocontrolinput = 0.0015 *(-kalmangyroweight)     'need to check these with simcode 
 +Const Center 6200                                         'needs to be checked with servo 
 +Const Conversionfactor 16                                 'pwm timer counter is 16 times slower than sw pwm 
 +Const Lowerpwm Center - 300 
 +Const Upperpwm = Center + 300 
 +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 Portc.= Input +Config Portd.= Input 
-Config Portd.= Input +Config Portd.= Input 
-Config Portc.Output +Config Portb.Input 
-Config Portc.= Input +Config Portc.= Input 
-Config Portc.5 = Input +Config Portc.5 = Output 
-'Config Portc.= Output +Config Portc.= Output 
-'Config Portc.3 = Input +Config Portc.3 = Output 
-Ledone Alias Portd.7 +Config Watchdog = 1024 
-Ledtwo Alias Portb.0 +'Config Spi = Soft , Din = Pinc.4 , Dout = Portc.5 , Ss = None , Clock = Portc.2 
-Radiocts Alias Pind.3 +'Spiinit 
-'Cts Alias Portd.2 +Config Timer1 = Timer , Prescale 64 
-Groundcontrol Alias Pind.4 +Config Timer0 Timer , Prescale 1024 
-Statusled Alias Portd.+Dim Rate As Integer , Temperature As Integer , Lsb As Byte , Msb As Byte       'melexis 
-Requestsecond Alias Portc.1 +Dim Rateread As Byte , Tempread As Byte , Readmelexis As Byte , Mask As Word , Maskword As Word , Servoenable As Byte 
-Clearsecond Alias Pinc.2 +Dim Firstupdate As Byte , Servoexcitecount As Byte          'rest 
-Cutdownpinone Alias Portb.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 
-Cutdownpintwo Alias Portb.2 +Dim Gpbyteone As Byte , Pulses As Byte , Error As Byte , Enablegroundcontrol As Byte 
-Cutdownpinone 0 +Dim As Integer Gpintegerone As Integer Targetheading As Single , Gpsheading As Single , Heading As Single 
-Cutdownpintwo +Dim Gpwordone As Word Pulselenght As Word 
-Baud 4800 +Rateread = &B10010100 
-Declare Sub Checkvoltage() +Tempread = &B10011100 
-Declare Sub Cutdown(byval Channel As Byte , Byval Duration As Byte+Readmelexis = &B10000000 
-Echo Off +Maskword = &B0000111111111111 
-Start Adc +Pcmsk2 = &B01000000                                         'pcint22 enabled 
-Dim As String * 100 +Pcmsk0 = &B00000001                                         'pcint0 enabled 
-Dim T As String * 15 +Groundcontrol Alias Portd.4 
-Dim K As Single +Rts Alias Pind.3 
-Dim Iterations As Byte +Cts Alias Portd.2 
-Dim Windxs(256) As Eram Byte +Servoone Alias Portd.5 
-Dim Windys(256) As Eram Byte +Servotwo Alias Portb.1 
-Dim Lock As Bit +Pulsesdetect Alias Pind.6 
-Dim Gpfloatone As Single , Gpsheading As Single +Inputone Alias Pinb.0 
-Dim R As String * 90 +Inputtwo Alias Pind.7 
-Dim B As String * 6 +Slave Alias Portc.3 
-Dim Contents(17) As String * 15 +Din Alias Pinc.4 
-Dim Transfer As String * 11 +Dout Alias Portc.5 
-Dim N As Byte +Clock Alias Portc.2 
-Dim As Byte +Slave = 1 
-Dim Heightupto As Byte , Rxenable As Byte , Servoenable As Byte +'Declare Sub Ground() 
-Dim Gpbyteone As Byte Gpbytetwo As Byte Telcounter As Byte +Declare Sub Talktomelexis() 
-Dim Gpintegerone As Integer +'Declare Sub Ascent() 
-Dim Intcount As Integer Timeelapsed As Integer +On Pcint0 Edge 
-Dim Store As Integer +On Pcint2 Copy 
-Dim Test As Integer +Set Pcifr.pcif2 
-Dim L As Integer +Set Pcifr.pcif0 
-Dim Arrayat As Integer +Enable Pcint2 
-Dim Rudder As Single +Enable Pcint0 
-Dim Integral As Single +Groundcontrol = 0 
-Dim Derivative As Single +Servotwo 1 
-Dim Target As Single +Servoone 1 
-Dim Offset As Single += 0 
-Dim Windy_total As Single +Integral = 0 
-Dim Windx_total As Single +For Gpbyteone = To 200                                    'to let us check servo alignment 
-Dim Wind_speed As Single + Waitms 15 
-Dim Airspeed As Single + Pulseout Portd 5 , Center
-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 Target_e As Single +
-Dim Target_n 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 +
-Lock = 0 +
-Iterations 0 +
-Timeelapsed 0 +
-Wind_x = 0 +
-Wind_y = 0 +
-Waitms 500 +
-Call Checkvoltage() +
-Waitms 500 +
-'Call Cutdown(1 , 4) +
-Print "wind records:" +
-For Gpbyteone = To 255 +
- Gpbytetwo = Windxs(gpbyteone) +
- Print Gpbyteone ; "," ; Gpbytetwo ; ",+
- Gpbytetwo = Windys(gpbyteone) +
- Print Gpbytetwo+
 Next Next
-Print Version() +Start Timer1 
-Print "Demo flight: 4km/20 minute" +Start Timer0 
-Print "Now check gps"+Enable Interrupts 
 +Start Watchdog 
 Do Do
- Input S + Reset Watchdog 
- B = Mid(s , 2 , 6) + Waitms 15 
- If "$GPGGA" Then + If Pulselenght > 200 And Pulselenght < 600 And Timer1 < 20000 Then       'a valid and recent pulse 
-  Print S                                                   'shows us the GGA string +  Incr Pulses 
-  Split(s , Contents(1","+ Else 
-  0 +  Pulses 
-  Val(contents(10)) +  Groundcontrol = 0 
-  If K <> 0 Then                                            'if nonzero altitude then we've got something + End If 
-   Goto Gotlock+ If Pulses > 10 Then 
 +  Groundcontrol = 1                                         'we enable servo relaying 
 +  Pulses = 10 
 + End If 
 + If Groundcontrol = 0 Then 
 +  Servoone = 1 
 +  Pulseout Portd 5 , Center                             'keep servo centered 
 + End If 
 + Call Talktomelexis(                                      'check gyro 
 + If Rts = 1 Then                                            'check for comms 
 +  Disable Interrupts                                        'disable interrupts with first message 
 +  Cts 1 
 +  Inputbin Gpbyteone 
 +  Cts 0 
 +  If Gpbyteone = 1 Then                                     'if we get a descent command 
 +    Firstupdate = 2                                         'means we treat the first gps update correctly 
 +    Waitus 300 
 +    Printbin Rate ; Temperature ; Error ; Heading ; Filteredrate ; Pulselenght ; Pulses       'removes possible cause of a hang 
 +    Goto Descent 
 +  End If 
 +  Waitus 300 
 +  Printbin Rate ; Temperature ; Error 
 +  Servoone = 1 
 +  Incr Servoexcitecount 
 +  If Servoexcitecount > 10 Then 
 +   Servoexcitecount = 0 
 +   For Gpbyteone = 0 To 10 
 +    Pulseout , Portd , 5 , Lowerpwm                         'wiggle servo 
 +    Waitms 15 
 +   Next 
 +   For Gpbyteone = 0 To 10 
 +    Pulseout , Portd , 5 , Upperpwm 
 +    Waitms 15 
 +   Next
   End If   End If
  End If  End If
-Loop 
-Gotlock: 
-Print "Okay we have GPS" 
-Print "Enter target north and east" 
-Input #3 , Target_n 
-Print Target_n 
-Input #3 , Target_e 
-Print Target_e 
-Print "Launch!" 
-Do 
- While B <> "$GPGGA" 
-  Input R 
-  B = Mid(r , 2 , 6) 
- Wend 
- While B <> "$GPRMC" 
-  Input S 
-  B = Mid(s , 2 , 6) 
- Wend 
-   I = Split(s , Contents(1) , ","                        'process rmc 
-   K = Val(contents(9)) 
-   V = Val(contents(8)) 
-   K = Deg2rad(k) 
-   Wind_x = Sin(k)                                          'WORK OUT WIND IN Y=NORTH frame - the trig library works in radians 
-   Wind_x = Wind_x * V 
-   Wind_y = Cos(k) 
-   Wind_y = Wind_y * V 
-   Windx_total = Windx_total + Wind_x                       'add it to our total wind 
-   Windy_total = Windy_total + Wind_y 
-   Incr L                                                   'incrament the denominator for our averaging 
-   Incr Timeelapsed 
-   I = Split(r , Contents(1) , ","                        'now process gga 
-   K = Val(contents(10)) 
-   K = K / 100 
-   Arrayat = Int(k)                                         'find the altitude in 100m incraments 
-   If Arrayat > Heightupto Then 
-    Incr Heightupto                                         'do we now fall into another (higher) 100m incrament ? 
-    Windx_total = Windx_total / L 
-    Gpbyteone = Windx_total + 127 
-    Windxs(arrayat) = Gpbyteone                             'we are storing as a signed byte 
-    Windy_total = Windy_total / L 
-    Gpbyteone = Windy_total + 127                           'we find the average and shove it in the eeprom 
-    Windys(arrayat) = Gpbyteone 
-    L = 0                                                   'this was forgotten in the flight code doh 
-   End If 
-   If Arrayat > 40 Then 
-    Goto Cutdownlbl                                         '4Km/20 minute cutdown 
-   End If 
-   If Timeelapsed > 900 Then 
-    Goto Cutdownlbl 
-   End If 
-   Requestsecond = 1 
-   While Clearsecond = 0 
-    Waitus 100 
-   Wend 
-   Requestsecond = 0 
-   Print #1 , "#,ascent" 
-   Waitus 200 
-   Input #2 , S 
-   Incr Telcounter 
-   If Telcounter > 10 Then Call Checkvoltage() 
-                                                             ' our callsign is UKHAS 
-   If Radiocts = 1 Then                                     'is CTS=1 from the radio modem? 
-    Print "UKHAS" ; Contents(3) ; Contents(4) ; Contents(5) ; Contents(6) ; Contents(10) ; S 
-   End If 
 Loop Loop
  
-Cutdownlbl: +Descent:
-Call Cutdown(1 , 12) +
- +
- +
 Do Do
- 'insert + Reset Watchdog 
- While <> "$GPGGA" + While Timer0 250                                         'wait for 16ms to elapse
-  Input R +
-  B = Mid(r , 2 , 6) +
- Wend +
- While B <> "$GPRMC" +
-  Input S +
-  B = Mid(s , 2 , 6)+
  Wend  Wend
-   I = Split(s , Contents(1) , ","                        'process rmc + Reset Timer0 
-   Degrees = Left(contents(4) , 2) + If Pulselenght > 200 And Pulselenght 600 And Timer1 20000 Then       'a valid and recent pulse 
-   Minutes = Right(contents(4) , 7) +  Incr Pulses
-   North = 0 +
-   North = Val(minutes) +
-   North = North / 60 +
-   K = 0 +
-   K = Val(degrees) +
-   North = K + North +
-   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 +
-  I = Split(r , Contents(1) , ","                        'now we do the gga +
-  K = Val(contents(10)) +
-  Altitude = K +
- If V = 0 And Altitude < 200 Then                           'turn servo off on landing +
-   Servoenable = 0+
  Else  Else
-   Servoenable = 1 +  Pulses 0 
- End If                                                     'enable ground control near the ground +  Groundcontrol = 0
- If Altitude < 200 Then +
-   Rxenable 1 +
- Else +
-   Rxenable = 0+
  End If  End If
- Requestsecond = 1 + If Pulses > 10 Then 
- While Clearsecond = 0 +  Groundcontrol = 1                                         'we enable servo relaying 
-  Waitus 100 +  Pulses = 10
- Wend +
- Requestsecond = 0 +
- Print #1 , "#," ; Gpsheading ; "," ; Target ; "," ; Servoenable ; "," ; Rxenable +
- Waitus 200 +
- Input #2 , S +
- K = K / 100 +
- Arrayat = Int(k) +
- Gpbyteone = Windxs(arrayat) - 127 +
- Wind_x = Gpbyteone                                         'gives us the correct wind for our altitude +
- Gpbyteone = Windys(arrayat) - 127 +
- Wind_y = Gpbyteone +
- Incr Telcounter +
- If Telcounter > 10 Then Call Checkvoltage() +
- If Radiocts = 1 Then                                       'is CTS=1 from the radio modem? +
-  Print "UKHAS" ; Contents(3) ; Contents(4) ; Contents(5) ; Contents(6) ; Contents(10) ; S+
  End If  End If
 +If Rts = 1 Then                                             'check for comms
 + Cts = 1
 + Inputbin Gpbyteone , Gpsheading , Targetheading , Servoenable , Enablegroundcontrol
 + Cts = 0
 + If Firstupdate = 0 Or Firstupdate = 1 Then                 'ie we had another message not long ago
 +  Gpfloatone = Gpsheading - Oldheading                      'so update the heading estimate
 +  If Gpfloatone < -180 Then                                 'otherwise we dont bother as we dont know what was happening
 +   Gpfloatone = Gpfloatone + 360                            'one second ago
 +  End If
 +  If Gpfloatone > 180 Then
 +   Gpfloatone = Gpfloatone - 360                            'get it in the right range
 +  End If
 +  If Firstupdate = 0 Then
 +   Gpfloatone = Kalmangpsweight * Gpfloatone                'if firstupdate=1, gpsgain=1
 +  Else                                                      'if firstupdate=1, set to zero
 +   Firstupdate = 0
 +  End If
 +  Heading = Heading + Gpfloatone
 +  If Heading > 180 Then                                     'get heading in correct range
 +   Heading = Heading - 360
 +  End If
 +  If Heading < -180 Then
 +   Heading = Heading + 360
 +  End If
 + Else                                                       'ie if firstupdate=2
 +  Targetheading = 0                                         'we set targetheading to zero for first update, as heading is relative
 +  Firstupdate = 1                                           'until we get more recent data, due to gps lag
 + End If
 + Oldheading = Heading                                       ' always store the past heading
 + If Enablegroundcontrol = 1 Then                            'enable ground control
 +  Enable Interrupts
 + Else
 +  Disable Interrupts
 + End If
 + Waitus 250
 + Printbin Rate ; Temperature ; Error ; Heading ; Filteredrate ; Pulselenght ; Pulses
 +End If
 +Call Talktomelexis()
 +Gpintegerone = Rate
 +Gpintegerone = Gpintegerone - 1009                          'center position
 +Gpfloatone = Gpintegerone
 +Gpfloatone = Gpfloatone / 6.8265
 +Realrate = Gpfloatone                                       'now  in degrees per second
 +Gpfloatone = Gpfloatone * Kalmangyroweight                  'gyro term
 +Filteredrate = Propogation * Filteredrate                   'propogation term
 +Filteredrate = Filteredrate + Gpfloatone                    'add them
 +Gpfloatone = Servo * Servocontrolinput                      'control term - need to use rx pwm if under ground control
 +Filteredrate = Filteredrate + Gpfloatone                    'add them
 +Gpfloatone = Filteredrate / 62.5                            'numerical integration over timestep
 +Heading = Heading + Gpfloatone
 +If Heading > 180 Then                                       'get heading in correct range
 + Heading = Heading - 360
 +End If
 +If Heading < -180 Then
 + Heading = Heading + 360
 +End If
 +Gpfloatone = Heading - Targetheading                        'heading offset
 +If Gpfloatone < -180 Then                                   'get it in the right range
 + Gpfloatone = Gpfloatone + 360
 +End If
 +If Gpfloatone > 180 Then
 + Gpfloatone = Gpfloatone - 360
 +End If
 +Integral = Integral + Gpfloatone                            'i increment                                                     'pid
 +Gpfloattwo = Gpfloatone * Pterm                             'P
 +Gpfloatone = Dterm * Filteredrate                           'D
 +Gpfloatone = Gpfloatone + Gpfloattwo                        'add d and p terms
 +If Gpfloatone > 30 Then Gpfloatone = 30                     'servo limits on d and p
 +If Gpfloatone < -30 Then Gpfloatone = -30
 +Gpfloattwo = Integral * Iterm                               'calculate I
 +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
 +Servo = Gpfloatone                                          'store servo for control input
 +Gpintegerone = Gpfloatone
 +If Groundcontrol = 1 Then
 + Gpfloatone = Pulselenght * Conversionfactor
 + Servo = Gpfloatone - Center                                'uses rx pwm if under ground control
 +End If
 +Gpintegerone = Gpintegerone + Center                        'add on pwm center value
 +If Groundcontrol = 0 And Servoenable = 1 Then
 + Servoone = 1                                               'set pwm high
 + Pulseout , Portd , 5 , Gpintegerone                        'only if not under ground control
 +End If
 Loop Loop
  
-Sub Checkvoltage() +Edge: 
-Gpintegerone = Getadc(5) +If Groundcontrol = 1 Then Servoone Not Inputone           'copy 
-Gpfloatone = Gpintegerone +If Inputone = 0 Then 
-Gpfloatone = Gpfloatone * 9.503 + Pulselenght Timer1                                       'read pwm 
-Gpfloatone = Gpfloatone / 1000 +End If 
-If Radiocts = 1 Then Print "Servo voltage=" ; Gpfloatone ; ","; +Timer1 = 0 
-Gpintegerone Getadc(0) +Return
-Print Gpintegerone +
-Gpfloatone Gpintegerone +
-Gpfloatone = Gpfloatone * 4.250 +
-Gpfloatone = Gpfloatone / 1000 +
-If Radiocts = 1 Then Print "Supply voltage=" ; Gpfloatone +
-Telcounter = 0 +
-End Sub+
  
 +Copy:
 +If Groundcontrol = 1 Then Servotwo = Not Inputtwo           'copy
 +Return
  
-Sub Cutdown(byval Channel As Byte , Byval Duration As Byte+Sub Talktomelexis() 
-Gpbyteone = 0 + Clock = 0 
-While Radiocts = 0 And Gpbyteone < 30                       'wait for radio with timeout + Dout = 0 
- Waitms 500 + Slave = 0 
- Incr Gpbyteone + Error = 0 
-Wend + Waitus 1 
-Print "Cutdown channel=" ; Channel ; " Time=" ; Duration + For Gpbyteone = 7 To Step -1                             'spi out 
-If Channel = 1 Then Cutdownpinone = 1 +  Dout = Rateread.gpbyteone 
-If Channel Then Cutdownpintwo = 1 +  Waitus 1 
-Wait Duration +  Clock = 1 
-Cutdownpinone = 0 +  Waitus 1 
-Cutdownpintwo = 0+  Clock = 0 
 + Next 
 + For Gpbyteone = 15 To 0 Step -1                            'extra clock cycles is in datasheet 
 +  Waitus 1 
 +  Clock = 1 
 +  Waitus 1 
 +  Clock = 0 
 + Next 
 + Waitus 1 
 + Slave = 1 
 + Waitus 300 
 + Slave = 0 
 + For Gpbyteone = 7 To 0 Step -1                             'spi out 
 +  Dout = Readmelexis.gpbyteone 
 +  Waitus 1 
 +  Clock 
 +  Waitus 1 
 +  Clock 0 
 + Next 
 + For Gpbyteone 7 To 0 Step -                            'data in 
 +  Waitus 1 
 +  Clock = 1 
 +  Msb.gpbyteone = Din 
 +  Waitus 1 
 +  Clock = 0 
 + Next 
 + For Gpbyteone = 7 To 0 Step -1                             'another byte in 
 +  Waitus 1 
 +  Clock = 1 
 +  Lsb.gpbyteone = Din 
 +  Waitus 1 
 +  Clock = 0 
 + Next 
 + Waitus 1 
 + Slave = 1 
 + Rate = Makeint(lsb , Msb)                                  'create integer 
 + Rate = Rate And Maskword                                   'mask it 
 + Shift Rate , Right , 1                                     'shift it 
 + If Msb.6 Then Error = 1                                'check selftest feature 
 + Slave = 0 
 + Waitus 1 
 + For Gpbyteone 7 To Step -1                             'do the same sort of thing for temp 
 +  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/slave.1188943852.txt.gz · Last modified: 2008/07/19 23:32 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki