سلام من چهار شنبه همین هفته مسابقه داریم میخواستم از اساتید خواهش کنم یه نگاه به این برنامه بندازن ببینم میشه سرعت پردازش را بالا آورد و سرعت ربات رو بهتر کرد.
توضیحات :
عکس سنسور ها ضمیمه شده (8 سنسور که به صورت هشتی بسته شده)
این از برنامه
کد php:
$regfile = "m32def.dat"
$crystal = 12000000
Config Porta = Input 'PORT A IS Input == PinA
Config Portb = Output
Declare Sub Forward()
Declare Sub Move_left()
Declare Sub Move_right()
Declare Sub Back()
Dim S0 As Bit
Dim S1 As Bit
Dim S2 As Bit
Dim S3 As Bit
Dim S4 As Bit
Dim S5 As Bit
Dim S6 As Bit
Dim S7 As Bit
S0 Alias Pina.0 'sensor0
S1 Alias Pina.1 'sensor1
S2 Alias Pina.2
S3 Alias Pina.3
S4 Alias Pina.4
S5 Alias Pina.5
S6 Alias Pina.6
S7 Alias Pina.7
Do
New_period:
If S0 = 0 And S7 = 0 Then Goto White_line
While S3 = 0 And S4 = 0
Call Forward()
Wend
While S3 = 0 And S4 = 1
Call Forward()
Wend
While S0 = 1 And S1 = 1 And S2 = 1 And S3 = 0 And S4 = 1 And S5 = 1 And S6 = 1 And S7 = 1
Call Forward()
Wend
While S0 = 1 And S1 = 1 And S2 = 1 And S3 = 1 And S4 = 0 And S5 = 1 And S6 = 1 And S7 = 1
Call Forward()
Wend
If S0 = 1 And S1 = 1 And S2 = 1 And S3 = 1 Then Goto Right_motor
If S5 = 1 And S6 = 1 And S7 = 1 And S3 = 1 Then Goto Left_motor
' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Left_motor:
While S0 = 0 And S1 = 1 And S2 = 1 And S4 = 0
Call Move_left()
Wend
While S0 = 1 And S1 = 0 And S2 = 1 And S4 = 0
Call Move_left()
Wend
While S0 = 1 And S1 = 1 And S2 = 0 And S4 = 0
Call Move_left()
Wend
While S0 = 1 And S1 = 0 And S2 = 0 And S4 = 0
Call Move_left()
Wend
While S0 = 0 And S1 = 1 And S2 = 0 And S4 = 0
Call Move_left()
Wend
While S0 = 0 And S1 = 0 And S2 = 1 And S4 = 0
Portb.7 = 0
Portb.6 = 1
Portb.5 = 0
Portb.4 = 1
Portb.3 = 1
Portb.2 = 0
Portb.1 = 1
Portb.0 = 1
Wend
While S0 = 0 And S1 = 0 And S2 = 0 And S4 = 0
Call Move_left()
Wend
While S0 = 0 And S1 = 1 And S2 = 1 And S4 = 1
Call Move_left()
Wend
'''''
While S0 = 1 And S1 = 0 And S2 = 1 And S4 = 1
Call Move_left()
Wend
While S0 = 1 And S1 = 1 And S2 = 0 And S4 = 1
Call Move_left()
Wend
While S0 = 1 And S1 = 0 And S2 = 0 And S4 = 1
Call Move_left()
Wend
While S0 = 0 And S1 = 1 And S2 = 0 And S4 = 1
Call Move_left()
Wend
While S0 = 0 And S1 = 0 And S2 = 1 And S4 = 1
Call Move_left()
Wend
While S0 = 0 And S1 = 0 And S2 = 0 And S4 = 1
Call Move_left()
Wend
' - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Right_motor:
While S4 = 0 And S5 = 1 And S6 = 1 And S7 = 0
Call Move_right()
Wend
While S4 = 0 And S5 = 1 And S6 = 0 And S7 = 1
Call Move_right()
Wend
While S4 = 0 And S5 = 0 And S6 = 1 And S7 = 1
Call Move_right()
Wend
While S4 = 0 And S5 = 0 And S6 = 0 And S7 = 1
Call Move_right()
Wend
While S4 = 0 And S5 = 0 And S6 = 1 And S7 = 0
Call Move_right()
Wend
While S4 = 0 And S5 = 1 And S6 = 0 And S7 = 0
Portb.7 = 1
Portb.6 = 0
Portb.5 = 1
Portb.4 = 0
Portb.3 = 0
Portb.2 = 1
Portb.1 = 1
Portb.0 = 1
Wend
While S4 = 0 And S5 = 0 And S6 = 0 And S7 = 0
Call Move_right()
Wend
''''''''''''''''''''''''''
While S4 = 1 And S5 = 1 And S6 = 1 And S7 = 0
Call Move_right()
Wend
While S4 = 1 And S5 = 1 And S6 = 0 And S7 = 1
Call Move_right()
Wend
While S4 = 1 And S5 = 0 And S6 = 1 And S7 = 1
Call Move_right()
Wend
While S4 = 1 And S5 = 0 And S6 = 0 And S7 = 1
Call Move_right()
Wend
While S4 = 1 And S5 = 0 And S6 = 1 And S7 = 0
Call Move_right()
Wend
While S4 = 1 And S5 = 1 And S6 = 0 And S7 = 0
Call Move_right()
Wend
While S4 = 1 And S5 = 0 And S6 = 0 And S7 = 0
Call Move_right()
Wend
Loop
White_line:
Do
If S0 = 1 And S7 = 1 Then Goto New_period
While S3 = 1
Portb.7 = 1
Portb.6 = 1
Portb.5 = 1
Portb.4 = 0
Portb.3 = 1
Portb.2 = 0
Portb.1 = 1
Portb.0 = 1
Wend
While S3 = 1 And S4 = 1
Portb.7 = 1
Portb.6 = 1
Portb.5 = 1
Portb.4 = 0
Portb.3 = 1
Portb.2 = 0
Portb.1 = 1
Portb.0 = 1
Wend
If S0 = 0 And S1 = 0 And S2 = 0 And S5 = 0 And S6 = 0 And S7 = 0 Then
While S3 = 0 And S4 = 0
Call Back()
Wend
Portb.7 = 1
Portb.6 = 1
Portb.5 = 1
Portb.4 = 0
Portb.3 = 1
Portb.2 = 0
Portb.1 = 1
Portb.0 = 1
Goto New_period
End If
While S5 = 0 And S6 = 0 And S7 = 0
While S3 = 0
Portb.7 = 1
Portb.6 = 0
Portb.5 = 0
Portb.4 = 0
Portb.3 = 1
Portb.2 = 0
Portb.1 = 1
Portb.0 = 1
Wend
Wend
While S0 = 0 And S1 = 0 And S2 = 0
While S3 = 0
Portb.7 = 1
Portb.6 = 0
Portb.5 = 1
Portb.4 = 0
Portb.3 = 0
Portb.2 = 0
Portb.1 = 1
Portb.0 = 1
Wend
Wend
Loop
Sub Forward()
While S3 = 0
Portb.7 = 1
Portb.6 = 1
Portb.5 = 1
Portb.4 = 0
Portb.3 = 1
Portb.2 = 0
Portb.1 = 1
Portb.0 = 1
Wend
End Sub
Sub Back()
Portb.7 = 0
Portb.6 = 0
Portb.5 = 0
Portb.4 = 1
Portb.3 = 0
Portb.2 = 1
Portb.1 = 1
Portb.0 = 1
End Sub
Sub Move_left()
While S3 = 1
Portb.7 = 0
Portb.6 = 1
Portb.5 = 0
Portb.4 = 0
Portb.3 = 1
Portb.2 = 0
Portb.1 = 1
Portb.0 = 1
Wend
End Sub
Sub Move_right()
While S3 = 1
Portb.7 = 1
Portb.6 = 0
Portb.5 = 1
Portb.4 = 0
Portb.3 = 0
Portb.2 = 0
Portb.1 = 1
Portb.0 = 1
Wend
End Sub
از دوستان خواهش میکنم که نگاهی بندارن شاید برنامه کمتر بشه و سرعت پردازش بالاتر بره.
تشکر