Translate

MEMBUAT MESIN CNC SENDIRI DENGAN MICROCONTROLLER DAN BASCOM AVR

MEMBUAT MESIN CNC SENDIRI DENGAN MIKROKONTROLLER DAN BASCOM AVR


          Pada Postingan kali ini berbeda dengan postingan biasanya karena isi dari postingan malam ini adalah sebuah aplikasi industri yang banyak digunakan untuk cutting pcb, gambar desin dan lain sebagainya, nama lain dari hardware yang dibuat adalah Mesin CNC, mesin ini selain harganya juga mahal, masin ini juga terbilang mewah karena yang punya adalah perusahaan menengah keatas maka dari itu kali ini saya akan buatkan sebuah simulasi mesin CNC menggunakan proteus 7.8, jadi pada simulasi ini terdapat 3 buah motor stepper yang nanti bisa bergerak sesuai inputan yang kita mau dan juga gerakan motor bisa ke CW maupun CCW sesuai keinginan kita, Driver motor yang dipakai adalah IC ULN2003, untuk lebih jelasnya berikut komponen yang dibutuhkan.

 

a. Minimum System ATMega32




 b. 3 Buah Stepper Motor 





c. 3 Buah Driver ULN2003





 d. Program Bascom AVR

$regfile = "m32def.dat"
$crystal = 12000000


Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , Rs = Portc.0 , E = Portc.1

Cursor Off

Ddrd = &B11111111
Ddrb = &B11111111

Config Pina.0 = Input
Config Pina.1 = Input
Config Pina.2 = Input

Set Porta.0
Set Porta.1
Set Porta.2

Dim A As Integer
Dim B As Integer
Dim Nilai1 As Integer
Dim Nilai2 As Integer
Dim Nilai3 As Integer
Dim H As Integer

Dim Step1 As Integer
Dim Step2 As Integer
Dim Step3 As Integer


Dim I As Byte
I = 1
Dim Steper1(99) As Integer
Dim Motorstep1(80) As Eram Integer
Dim Steper2(99) As Integer
Dim Motorstep2(80) As Eram Integer
Dim Steper3(99) As Integer
Dim Motorstep3(80) As Eram Integer

Dim P As Integer
Dim D As Integer
Dim K As Integer
Dim Y As Integer
Dim W As Integer
Dim Z As Integer
Dim N As Integer

N = 1

Nilai1 = 0
Nilai2 = 0
Nilai3 = 0


Dim Stepper1 As Eram Byte
Dim Stepper2 As Eram Byte
Dim Stepper3 As Eram Byte
Dim Pusing As Eram Byte

Declare Sub S1()
Declare Sub S2()
Declare Sub S3()



'——————————-ALIAS-——————————————–
'alias tombol
Sw_ok Alias Pina.0
Sw_up Alias Pina.1
Sw_down Alias Pina.2

Cls



'Kondisi:
Cls
Do
Locate 1 , 1
Lcd "JUMLAH KONDISI"
Locate 2 , 1
Lcd "NILAI = " ; H ; "  "

If Sw_up = 0 Then
Incr H
Waitms 100
End If

If Sw_down = 0 Then
Decr H
Waitms 100
End If

If Sw_ok = 0 Then
Waitms 20
Pusing = H
Bitwait Sw_ok , Set
Exit Do
End If
Loop
Cls


'Setting:
Cls
D = 1
Do

Locate 1 , 1
Lcd "STEPPER 1" ; " - " ; D
Locate 2 , 1
Lcd "Nilai = " ; Steper1(d)

If Sw_up = 0 Then
Cls
Incr Steper1(d)
Waitms 100
End If

If Sw_down = 0 Then
Cls
Decr Steper1(d)
Waitms 100
End If

If Sw_ok = 0 Then
Waitms 20
Motorstep1(d) = Steper1(d)

Bitwait Sw_ok , Set

If D = H Then
Exit Do
Else
Incr D
End If
End If
Loop

Cls

Y = 1
Do

Locate 1 , 1
Lcd "STEPPER 2" ; " - " ; Y
Locate 2 , 1
Lcd "Nilai = " ; Steper2(y) ; "  "

If Sw_up = 0 Then
Cls
Incr Steper2(y)
Waitms 100
End If

If Sw_down = 0 Then
Cls
Decr Steper2(y)
Waitms 100
End If

If Sw_ok = 0 Then
Waitms 20
Motorstep2(y) = Steper2(y)
Bitwait Sw_ok , Set

If Y = H Then
Exit Do
Else
Incr Y
End If
End If
Loop

Cls

Z = 1
Do

Locate 1 , 1
Lcd "STEPPER 3" ; " - " ; Z
Locate 2 , 1
Lcd "Nilai = " ; Steper3(z) ; "  "

If Sw_up = 0 Then
Cls
Incr Steper3(z)
Waitms 100
End If

If Sw_down = 0 Then
Cls
Decr Steper3(z)
Waitms 100
End If

If Sw_ok = 0 Then
Waitms 20
Motorstep3(z) = Steper3(z)
Bitwait Sw_ok , Set

If Z = H Then
Goto Main
Exit Do
Else
Incr Z

End If
End If
Loop



Main:


If Steper1(n) < 0 And Steper2(n) > 0 And Steper3(n) > 0 Then
Steper1(d) = Abs(steper1(d))
D = Abs(d)
Goto Logika1
Elseif Steper1(n) > 0 And Steper2(n) < 0 And Steper3(n) > 0 Then
Steper2(y) = Abs(steper2(y))
Y = Abs(y)
Goto Logika2
Elseif Steper1(n) > 0 And Steper2(n) > 0 And Steper3(n) < 0 Then
Steper3(z) = Abs(steper3(z))
Z = Abs(z)
Goto Logika3
Elseif Steper1(n) < 0 And Steper2(n) < 0 And Steper3(n) > 0 Then
Steper1(d) = Abs(steper1(d))
Steper2(y) = Abs(steper2(y))
D = Abs(d)
Y = Abs(y)
Goto Logika4
Elseif Steper1(n) > 0 And Steper2(n) < 0 And Steper3(n) < 0 Then
Steper2(y) = Abs(steper2(y))
Steper3(z) = Abs(steper3(z))
Y = Abs(y)
Z = Abs(z)
Goto Logika5
Elseif Steper1(n) < 0 And Steper2(n) > 0 And Steper3(n) < 0 Then
Steper1(d) = Abs(steper1(d))
Steper3(z) = Abs(steper3(z))
D = Abs(d)
Z = Abs(z)
Goto Logika6
Elseif Steper1(n) < 0 And Steper2(n) < 0 And Steper3(n) < 0 Then
Steper1(d) = Abs(steper1(d))
Steper2(y) = Abs(steper2(y))
Steper3(z) = Abs(steper3(z))
D = Abs(d)
Y = Abs(y)
Z = Abs(z)

Goto Logika7
End If


Cls

Locate 1 , 1
Lcd "S1= " ; Steper1(n) ; "  S2= " ; Steper2(n)
Locate 2 , 1
Lcd "K= " ; N ; "  S3= " ; Steper3(n)


Step1 = 0
Step2 = 0
Step3 = 0

Do

Portb.0 = 1
Portd.0 = 1
Portd.4 = 1

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 1
Portd.1 = 1
Portd.5 = 1

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 1
Portd.2 = 1
Portd.6 = 1

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300

Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 1
Portd.3 = 1
Portd.7 = 1

Waitms 300


Incr Step1
Incr Step2
Incr Step3

If Step1 = Steper1(n) And Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Final
End If

If Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Stepx1
End If

If Step1 = Steper1(n) And Step2 = Steper2(n) Then
Goto Stepx3
End If

If Step1 = Steper1(n) And Step3 = Steper3(n) Then
Goto Stepx2
End If




If Step1 = Steper1(n) Then

Goto Step2step3

End If

If Step2 = Steper2(n) Then

Goto Step1step3

End If

If Step3 = Steper3(n) Then

Goto Step1step2

End If




Loop


Step2step3:
Do

Portd.0 = 1
Portd.4 = 1

Portd.1 = 0
Portd.5 = 0

Portd.2 = 0
Portd.6 = 0

Portd.3 = 0
Portd.7 = 0

Waitms 300


Portd.0 = 0
Portd.4 = 0

Portd.1 = 1
Portd.5 = 1

Portd.2 = 0
Portd.6 = 0

Portd.3 = 0
Portd.7 = 0

Waitms 300


Portd.0 = 0
Portd.4 = 0

Portd.1 = 0
Portd.5 = 0

Portd.2 = 1
Portd.6 = 1

Portd.3 = 0
Portd.7 = 0

Waitms 300

Portd.0 = 0
Portd.4 = 0

Portd.1 = 0
Portd.5 = 0

Portd.2 = 0
Portd.6 = 0

Portd.3 = 1
Portd.7 = 1

Waitms 300

Incr Step2
Incr Step3

If Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Final
End If

If Step2 = Steper2(n) Then
Goto Stepx3
End If

If Step3 = Steper3(n) Then
Goto Stepx2
End If


Loop
Return


Step1step3:

Do

Portb.0 = 1
Portd.4 = 1

Portb.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.4 = 0

Portb.1 = 1
Portd.5 = 1

Portb.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.5 = 0

Portb.2 = 1
Portd.6 = 1

Portb.3 = 0
Portd.7 = 0

Waitms 300

Portb.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.6 = 0

Portb.3 = 1
Portd.7 = 1

Waitms 300


Incr Step1
Incr Step3

If Step1 = Steper1(n) And Step3 = Steper3(n) Then
Goto Final
End If

If Step1 = Steper1(n) Then
Goto Stepx3
End If

If Step3 = Steper3(n) Then
Goto Stepx1
End If


Loop
Return


Step1step2:

Do

Portb.0 = 1
Portd.0 = 1

Portb.1 = 0
Portd.1 = 0

Portb.2 = 0
Portd.2 = 0

Portb.3 = 0
Portd.3 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0

Portb.1 = 1
Portd.1 = 1

Portb.2 = 0
Portd.2 = 0

Portb.3 = 0
Portd.3 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0

Portb.1 = 0
Portd.1 = 0

Portb.2 = 1
Portd.2 = 1

Portb.3 = 0
Portd.3 = 0

Waitms 300

Portb.0 = 0
Portd.0 = 0

Portb.1 = 0
Portd.1 = 0

Portb.2 = 0
Portd.2 = 0

Portb.3 = 1
Portd.3 = 1

Waitms 300


Incr Step1
Incr Step2

If Step1 = Steper1(n) And Step2 = Steper2(n) Then
Goto Final
End If

If Step1 = Steper1(n) Then
Goto Stepx2
End If

If Step2 = Steper2(n) Then
Goto Stepx1
End If


Loop
Return


Stepx1:

Do


Portb.0 = 1

Portb.1 = 0

Portb.2 = 0

Portb.3 = 0

Waitms 300


Portb.0 = 0

Portb.1 = 1

Portb.2 = 0

Portb.3 = 0

Waitms 300


Portb.0 = 0

Portb.1 = 0

Portb.2 = 1

Portb.3 = 0

Waitms 300

Portb.0 = 0

Portb.1 = 0

Portb.2 = 0

Portb.3 = 1

Waitms 300


Incr Step1

Loop Until Step1 = Steper1(n)
Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return




Stepx2:
Do


Portd.0 = 1

Portd.1 = 0

Portd.2 = 0

Portd.3 = 0

Waitms 300


Portd.0 = 0

Portd.1 = 1

Portd.2 = 0

Portd.3 = 0

Waitms 300


Portd.0 = 0

Portd.1 = 0

Portd.2 = 1

Portd.3 = 0

Waitms 300

Portd.0 = 0

Portd.1 = 0

Portd.2 = 0

Portd.3 = 1

Waitms 300

Incr Step2


Loop Until Step2 = Steper2(n)

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return



Stepx3:
Do



Portd.4 = 1

Portd.5 = 0

Portd.6 = 0

Portd.7 = 0

Waitms 300


Portd.4 = 0

Portd.5 = 1

Portd.6 = 0

Portd.7 = 0

Waitms 300


Portd.4 = 0

Portd.5 = 0

Portd.6 = 1

Portd.7 = 0

Waitms 300

Portd.4 = 0

Portd.5 = 0

Portd.6 = 0

Portd.7 = 1

Waitms 300


Incr Step3


Loop Until Step3 = Steper3(n)

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return



Final:

Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return





'==============================================================================
Logika1:


Cls

Locate 1 , 1
Lcd "S1= " ; Steper1(n) ; "  S2= " ; Steper2(n)
Locate 2 , 1
Lcd "K= " ; N ; "  S3= " ; Steper3(n)


Step1 = 0
Step2 = 0
Step3 = 0

Do

Portb.0 = 0
Portd.0 = 1
Portd.4 = 1

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 1
Portd.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 1
Portd.5 = 1

Portb.2 = 1
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 1
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 1
Portd.6 = 1

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300

Portb.0 = 1
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 1
Portd.7 = 1

Waitms 300


Incr Step1
Incr Step2
Incr Step3

If Step1 = Steper1(n) And Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log1final
End If

If Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log1stepx1
End If

If Step1 = Steper1(n) And Step2 = Steper2(n) Then
Goto Log1stepx3
End If

If Step1 = Steper1(n) And Step3 = Steper3(n) Then
Goto Log1stepx2
End If




If Step1 = Steper1(n) Then

Goto Log1step2step3

End If

If Step2 = Steper2(n) Then

Goto Log1step1step3

End If

If Step3 = Steper3(n) Then

Goto Log1step1step2

End If




Loop


Log1step2step3:
Do

Portd.0 = 1
Portd.4 = 1

Portd.1 = 0
Portd.5 = 0

Portd.2 = 0
Portd.6 = 0

Portd.3 = 0
Portd.7 = 0

Waitms 300


Portd.0 = 0
Portd.4 = 0

Portd.1 = 1
Portd.5 = 1

Portd.2 = 0
Portd.6 = 0

Portd.3 = 0
Portd.7 = 0

Waitms 300


Portd.0 = 0
Portd.4 = 0

Portd.1 = 0
Portd.5 = 0

Portd.2 = 1
Portd.6 = 1

Portd.3 = 0
Portd.7 = 0

Waitms 300

Portd.0 = 0
Portd.4 = 0

Portd.1 = 0
Portd.5 = 0

Portd.2 = 0
Portd.6 = 0

Portd.3 = 1
Portd.7 = 1

Waitms 300

Incr Step2
Incr Step3

If Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log1final
End If

If Step2 = Steper2(n) Then
Goto Log1stepx3
End If

If Step3 = Steper3(n) Then
Goto Log1stepx2
End If


Loop
Return


Log1step1step3:

Do

Portb.0 = 0
Portd.4 = 1

Portb.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.6 = 0

Portb.3 = 1
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.5 = 1

Portb.2 = 1
Portd.6 = 0

Portb.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.4 = 0

Portb.1 = 1
Portd.5 = 0

Portb.2 = 0
Portd.6 = 1

Portb.3 = 0
Portd.7 = 0

Waitms 300

Portb.0 = 1
Portd.4 = 0

Portb.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.7 = 1

Waitms 300


Incr Step1
Incr Step3

If Step1 = Steper1(n) And Step3 = Steper3(n) Then
Goto Log1final
End If

If Step1 = Steper1(n) Then
Goto Log1stepx3
End If

If Step3 = Steper3(n) Then
Goto Log1stepx1
End If


Loop
Return


Log1step1step2:

Do

Portb.0 = 0
Portd.0 = 1

Portb.1 = 0
Portd.1 = 0

Portb.2 = 0
Portd.2 = 0

Portb.3 = 1
Portd.3 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0

Portb.1 = 0
Portd.1 = 1

Portb.2 = 1
Portd.2 = 0

Portb.3 = 0
Portd.3 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0

Portb.1 = 1
Portd.1 = 0

Portb.2 = 0
Portd.2 = 1

Portb.3 = 0
Portd.3 = 0

Waitms 300

Portb.0 = 1
Portd.0 = 0

Portb.1 = 0
Portd.1 = 0

Portb.2 = 0
Portd.2 = 0

Portb.3 = 0
Portd.3 = 1

Waitms 300


Incr Step1
Incr Step2

If Step1 = Steper1(n) And Step2 = Steper2(n) Then
Goto Log1final
End If

If Step1 = Steper1(n) Then
Goto Log1stepx2
End If

If Step2 = Steper2(n) Then
Goto Log1stepx1
End If


Loop
Return


Log1stepx1:

Do


Portb.0 = 0

Portb.1 = 0

Portb.2 = 0

Portb.3 = 1

Waitms 300


Portb.0 = 0

Portb.1 = 0

Portb.2 = 1

Portb.3 = 0

Waitms 300


Portb.0 = 0

Portb.1 = 1

Portb.2 = 0

Portb.3 = 0

Waitms 300

Portb.0 = 1

Portb.1 = 0

Portb.2 = 0

Portb.3 = 0

Waitms 300


Incr Step1

Loop Until Step1 = Steper1(n)
Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return




Log1stepx2:
Do


Portd.0 = 1

Portd.1 = 0

Portd.2 = 0

Portd.3 = 0

Waitms 300


Portd.0 = 0

Portd.1 = 1

Portd.2 = 0

Portd.3 = 0

Waitms 300


Portd.0 = 0

Portd.1 = 0

Portd.2 = 1

Portd.3 = 0

Waitms 300

Portd.0 = 0

Portd.1 = 0

Portd.2 = 0

Portd.3 = 1

Waitms 300

Incr Step2


Loop Until Step2 = Steper2(n)

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return



Log1stepx3:
Do



Portd.4 = 1

Portd.5 = 0

Portd.6 = 0

Portd.7 = 0

Waitms 300


Portd.4 = 0

Portd.5 = 1

Portd.6 = 0

Portd.7 = 0

Waitms 300


Portd.4 = 0

Portd.5 = 0

Portd.6 = 1

Portd.7 = 0

Waitms 300

Portd.4 = 0

Portd.5 = 0

Portd.6 = 0

Portd.7 = 1

Waitms 300


Incr Step3


Loop Until Step3 = Steper3(n)

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return



Log1final:

Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return





'==============================================================================
Logika2:


Cls

Locate 1 , 1
Lcd "S1= " ; Steper1(n) ; "  S2= " ; Steper2(n)
Locate 2 , 1
Lcd "K= " ; N ; "  S3= " ; Steper3(n)


Step1 = 0
Step2 = 0
Step3 = 0

Do

Portb.0 = 1
Portd.0 = 0
Portd.4 = 1

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 1
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 1
Portd.1 = 0
Portd.5 = 1

Portb.2 = 0
Portd.2 = 1
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 1
Portd.5 = 0

Portb.2 = 1
Portd.2 = 0
Portd.6 = 1

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300

Portb.0 = 0
Portd.0 = 1
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 1
Portd.3 = 0
Portd.7 = 1

Waitms 300


Incr Step1
Incr Step2
Incr Step3

If Step1 = Steper1(n) And Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log2final
End If

If Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log2stepx1
End If

If Step1 = Steper1(n) And Step2 = Steper2(n) Then
Goto Log2stepx3
End If

If Step1 = Steper1(n) And Step3 = Steper3(n) Then
Goto Log2stepx2
End If




If Step1 = Steper1(n) Then

Goto Log2step2step3

End If

If Step2 = Steper2(n) Then

Goto Log2step1step3

End If

If Step3 = Steper3(n) Then

Goto Log2step1step2

End If




Loop


Log2step2step3:
Do

Portd.0 = 0
Portd.4 = 1

Portd.1 = 0
Portd.5 = 0

Portd.2 = 0
Portd.6 = 0

Portd.3 = 1
Portd.7 = 0

Waitms 300


Portd.0 = 0
Portd.4 = 0

Portd.1 = 0
Portd.5 = 1

Portd.2 = 1
Portd.6 = 0

Portd.3 = 0
Portd.7 = 0

Waitms 300


Portd.0 = 0
Portd.4 = 0

Portd.1 = 1
Portd.5 = 0

Portd.2 = 0
Portd.6 = 1

Portd.3 = 0
Portd.7 = 0

Waitms 300

Portd.0 = 1
Portd.4 = 0

Portd.1 = 0
Portd.5 = 0

Portd.2 = 0
Portd.6 = 0

Portd.3 = 0
Portd.7 = 1

Waitms 300

Incr Step2
Incr Step3

If Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log2final
End If

If Step2 = Steper2(n) Then
Goto Log2stepx3
End If

If Step3 = Steper3(n) Then
Goto Log2stepx2
End If


Loop
Return


Log2step1step3:

Do

Portb.0 = 1
Portd.4 = 1

Portb.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.4 = 0

Portb.1 = 1
Portd.5 = 1

Portb.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.5 = 0

Portb.2 = 1
Portd.6 = 1

Portb.3 = 0
Portd.7 = 0

Waitms 300

Portb.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.6 = 0

Portb.3 = 1
Portd.7 = 1

Waitms 300


Incr Step1
Incr Step3

If Step1 = Steper1(n) And Step3 = Steper3(n) Then
Goto Log2final
End If

If Step1 = Steper1(n) Then
Goto Log2stepx3
End If

If Step3 = Steper3(n) Then
Goto Log2stepx1
End If


Loop
Return


Log2step1step2:

Do

Portb.0 = 1
Portd.0 = 0

Portb.1 = 0
Portd.1 = 0

Portb.2 = 0
Portd.2 = 0

Portb.3 = 0
Portd.3 = 1

Waitms 300


Portb.0 = 0
Portd.0 = 0

Portb.1 = 1
Portd.1 = 0

Portb.2 = 0
Portd.2 = 1

Portb.3 = 0
Portd.3 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0

Portb.1 = 0
Portd.1 = 1

Portb.2 = 1
Portd.2 = 0

Portb.3 = 0
Portd.3 = 0

Waitms 300

Portb.0 = 0
Portd.0 = 1

Portb.1 = 0
Portd.1 = 0

Portb.2 = 0
Portd.2 = 0

Portb.3 = 1
Portd.3 = 0

Waitms 300


Incr Step1
Incr Step2

If Step1 = Steper1(n) And Step2 = Steper2(n) Then
Goto Log2final
End If

If Step1 = Steper1(n) Then
Goto Log2stepx2
End If

If Step2 = Steper2(n) Then
Goto Log2stepx1
End If


Loop
Return


Log2stepx1:

Do


Portb.0 = 1

Portb.1 = 0

Portb.2 = 0

Portb.3 = 0

Waitms 300


Portb.0 = 0

Portb.1 = 1

Portb.2 = 0

Portb.3 = 0

Waitms 300


Portb.0 = 0

Portb.1 = 0

Portb.2 = 1

Portb.3 = 0

Waitms 300

Portb.0 = 0

Portb.1 = 0

Portb.2 = 0

Portb.3 = 1

Waitms 300


Incr Step1

Loop Until Step1 = Steper1(n)
Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return




Log2stepx2:
Do


Portd.0 = 0

Portd.1 = 0

Portd.2 = 0

Portd.3 = 1

Waitms 300


Portd.0 = 0

Portd.1 = 0

Portd.2 = 1

Portd.3 = 0

Waitms 300


Portd.0 = 0

Portd.1 = 1

Portd.2 = 0

Portd.3 = 0

Waitms 300

Portd.0 = 1

Portd.1 = 0

Portd.2 = 0

Portd.3 = 0

Waitms 300

Incr Step2


Loop Until Step2 = Steper2(n)

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return



Log2stepx3:
Do



Portd.4 = 1

Portd.5 = 0

Portd.6 = 0

Portd.7 = 0

Waitms 300


Portd.4 = 0

Portd.5 = 1

Portd.6 = 0

Portd.7 = 0

Waitms 300


Portd.4 = 0

Portd.5 = 0

Portd.6 = 1

Portd.7 = 0

Waitms 300

Portd.4 = 0

Portd.5 = 0

Portd.6 = 0

Portd.7 = 1

Waitms 300


Incr Step3


Loop Until Step3 = Steper3(n)

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return



Log2final:

Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return






'==============================================================================
Logika3:


Cls

Locate 1 , 1
Lcd "S1= " ; Steper1(n) ; "  S2= " ; Steper2(n)
Locate 2 , 1
Lcd "K= " ; N ; "  S3= " ; Steper3(n)


Step1 = 0
Step2 = 0
Step3 = 0

Do

Portb.0 = 1
Portd.0 = 1
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 1

Waitms 300


Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 1
Portd.1 = 1
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 1

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 1

Portb.2 = 1
Portd.2 = 1
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300

Portb.0 = 0
Portd.0 = 0
Portd.4 = 1

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 1
Portd.3 = 1
Portd.7 = 0

Waitms 300


Incr Step1
Incr Step2
Incr Step3

If Step1 = Steper1(n) And Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log3final
End If

If Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log3stepx1
End If

If Step1 = Steper1(n) And Step2 = Steper2(n) Then
Goto Log3stepx3
End If

If Step1 = Steper1(n) And Step3 = Steper3(n) Then
Goto Log3stepx2
End If




If Step1 = Steper1(n) Then

Goto Log3step2step3

End If

If Step2 = Steper2(n) Then

Goto Log3step1step3

End If

If Step3 = Steper3(n) Then

Goto Log3step1step2

End If




Loop


Log3step2step3:
Do

Portd.0 = 1
Portd.4 = 0

Portd.1 = 0
Portd.5 = 0

Portd.2 = 0
Portd.6 = 0

Portd.3 = 0
Portd.7 = 1

Waitms 300


Portd.0 = 0
Portd.4 = 0

Portd.1 = 1
Portd.5 = 0

Portd.2 = 0
Portd.6 = 1

Portd.3 = 0
Portd.7 = 0

Waitms 300


Portd.0 = 0
Portd.4 = 0

Portd.1 = 0
Portd.5 = 1

Portd.2 = 1
Portd.6 = 0

Portd.3 = 0
Portd.7 = 0

Waitms 300

Portd.0 = 0
Portd.4 = 1

Portd.1 = 0
Portd.5 = 0

Portd.2 = 0
Portd.6 = 0

Portd.3 = 1
Portd.7 = 0

Waitms 300

Incr Step2
Incr Step3

If Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log3final
End If

If Step2 = Steper2(n) Then
Goto Log3stepx3
End If

If Step3 = Steper3(n) Then
Goto Log3stepx2
End If


Loop
Return


Log3step1step3:

Do

Portb.0 = 1
Portd.4 = 0

Portb.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.7 = 1

Waitms 300


Portb.0 = 0
Portd.4 = 0

Portb.1 = 1
Portd.5 = 0

Portb.2 = 0
Portd.6 = 1

Portb.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.5 = 1

Portb.2 = 1
Portd.6 = 0

Portb.3 = 0
Portd.7 = 0

Waitms 300

Portb.0 = 0
Portd.4 = 1

Portb.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.6 = 0

Portb.3 = 1
Portd.7 = 0

Waitms 300


Incr Step1
Incr Step3

If Step1 = Steper1(n) And Step3 = Steper3(n) Then
Goto Log3final
End If

If Step1 = Steper1(n) Then
Goto Log3stepx3
End If

If Step3 = Steper3(n) Then
Goto Log3stepx1
End If


Loop
Return


Log3step1step2:

Do

Portb.0 = 1
Portd.0 = 1

Portb.1 = 0
Portd.1 = 0

Portb.2 = 0
Portd.2 = 0

Portb.3 = 0
Portd.3 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0

Portb.1 = 1
Portd.1 = 1

Portb.2 = 0
Portd.2 = 0

Portb.3 = 0
Portd.3 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0

Portb.1 = 0
Portd.1 = 0

Portb.2 = 1
Portd.2 = 1

Portb.3 = 0
Portd.3 = 0

Waitms 300

Portb.0 = 0
Portd.0 = 0

Portb.1 = 0
Portd.1 = 0

Portb.2 = 0
Portd.2 = 0

Portb.3 = 1
Portd.3 = 1

Waitms 300


Incr Step1
Incr Step2

If Step1 = Steper1(n) And Step2 = Steper2(n) Then
Goto Log3final
End If

If Step1 = Steper1(n) Then
Goto Log3stepx2
End If

If Step2 = Steper2(n) Then
Goto Log3stepx1
End If


Loop
Return


Log3stepx1:

Do


Portb.0 = 1

Portb.1 = 0

Portb.2 = 0

Portb.3 = 0

Waitms 300


Portb.0 = 0

Portb.1 = 1

Portb.2 = 0

Portb.3 = 0

Waitms 300


Portb.0 = 0

Portb.1 = 0

Portb.2 = 1

Portb.3 = 0

Waitms 300

Portb.0 = 0

Portb.1 = 0

Portb.2 = 0

Portb.3 = 1

Waitms 300


Incr Step1

Loop Until Step1 = Steper1(n)
Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return




Log3stepx2:
Do


Portd.0 = 1

Portd.1 = 0

Portd.2 = 0

Portd.3 = 0

Waitms 300


Portd.0 = 0

Portd.1 = 1

Portd.2 = 0

Portd.3 = 0

Waitms 300


Portd.0 = 0

Portd.1 = 0

Portd.2 = 1

Portd.3 = 0

Waitms 300

Portd.0 = 0

Portd.1 = 0

Portd.2 = 0

Portd.3 = 1

Waitms 300

Incr Step2


Loop Until Step2 = Steper2(n)

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return



Log3stepx3:
Do



Portd.4 = 0

Portd.5 = 0

Portd.6 = 0

Portd.7 = 1

Waitms 300


Portd.4 = 0

Portd.5 = 0

Portd.6 = 1

Portd.7 = 0

Waitms 300


Portd.4 = 0

Portd.5 = 1

Portd.6 = 0

Portd.7 = 0

Waitms 300

Portd.4 = 1

Portd.5 = 0

Portd.6 = 0

Portd.7 = 0

Waitms 300


Incr Step3


Loop Until Step3 = Steper3(n)

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return



Log3final:

Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return








'==============================================================================
Logika4:


Cls

Locate 1 , 1
Lcd "S1= " ; Steper1(n) ; "  S2= " ; Steper2(n)
Locate 2 , 1
Lcd "K= " ; N ; "  S3= " ; Steper3(n)


Step1 = 0
Step2 = 0
Step3 = 0

Do

Portb.0 = 0
Portd.0 = 0
Portd.4 = 1

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 1
Portd.3 = 1
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 1

Portb.2 = 1
Portd.2 = 1
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 1
Portd.1 = 1
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 1

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300

Portb.0 = 1
Portd.0 = 1
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 1

Waitms 300


Incr Step1
Incr Step2
Incr Step3

If Step1 = Steper1(n) And Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log4final
End If

If Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log4stepx1
End If

If Step1 = Steper1(n) And Step2 = Steper2(n) Then
Goto Log4stepx3
End If

If Step1 = Steper1(n) And Step3 = Steper3(n) Then
Goto Log4stepx2
End If




If Step1 = Steper1(n) Then

Goto Log4step2step3

End If

If Step2 = Steper2(n) Then

Goto Log4step1step3

End If

If Step3 = Steper3(n) Then

Goto Log4step1step2

End If




Loop


Log4step2step3:
Do

Portd.0 = 0
Portd.4 = 1

Portd.1 = 0
Portd.5 = 0

Portd.2 = 0
Portd.6 = 0

Portd.3 = 1
Portd.7 = 0

Waitms 300


Portd.0 = 0
Portd.4 = 0

Portd.1 = 0
Portd.5 = 1

Portd.2 = 1
Portd.6 = 0

Portd.3 = 0
Portd.7 = 0

Waitms 300


Portd.0 = 0
Portd.4 = 0

Portd.1 = 1
Portd.5 = 0

Portd.2 = 0
Portd.6 = 1

Portd.3 = 0
Portd.7 = 0

Waitms 300

Portd.0 = 1
Portd.4 = 0

Portd.1 = 0
Portd.5 = 0

Portd.2 = 0
Portd.6 = 0

Portd.3 = 0
Portd.7 = 1

Waitms 300

Incr Step2
Incr Step3

If Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log4final
End If

If Step2 = Steper2(n) Then
Goto Log4stepx3
End If

If Step3 = Steper3(n) Then
Goto Log4stepx2
End If


Loop
Return


Log4step1step3:

Do

Portb.0 = 0
Portd.4 = 1

Portb.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.6 = 0

Portb.3 = 1
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.5 = 1

Portb.2 = 1
Portd.6 = 0

Portb.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.4 = 0

Portb.1 = 1
Portd.5 = 0

Portb.2 = 0
Portd.6 = 1

Portb.3 = 0
Portd.7 = 0

Waitms 300

Portb.0 = 1
Portd.4 = 0

Portb.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.7 = 1

Waitms 300


Incr Step1
Incr Step3

If Step1 = Steper1(n) And Step3 = Steper3(n) Then
Goto Log4final
End If

If Step1 = Steper1(n) Then
Goto Log4stepx3
End If

If Step3 = Steper3(n) Then
Goto Log4stepx1
End If


Loop
Return


Log4step1step2:

Do

Portb.0 = 0
Portd.0 = 0

Portb.1 = 0
Portd.1 = 0

Portb.2 = 0
Portd.2 = 0

Portb.3 = 1
Portd.3 = 1

Waitms 300


Portb.0 = 0
Portd.0 = 0

Portb.1 = 0
Portd.1 = 0

Portb.2 = 1
Portd.2 = 1

Portb.3 = 0
Portd.3 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0

Portb.1 = 1
Portd.1 = 1

Portb.2 = 0
Portd.2 = 0

Portb.3 = 0
Portd.3 = 0

Waitms 300

Portb.0 = 1
Portd.0 = 1

Portb.1 = 0
Portd.1 = 0

Portb.2 = 0
Portd.2 = 0

Portb.3 = 0
Portd.3 = 0

Waitms 300


Incr Step1
Incr Step2

If Step1 = Steper1(n) And Step2 = Steper2(n) Then
Goto Log4final
End If

If Step1 = Steper1(n) Then
Goto Log4stepx2
End If

If Step2 = Steper2(n) Then
Goto Log4stepx1
End If


Loop
Return


Log4stepx1:

Do


Portb.0 = 0

Portb.1 = 0

Portb.2 = 0

Portb.3 = 1

Waitms 300


Portb.0 = 0

Portb.1 = 0

Portb.2 = 1

Portb.3 = 0

Waitms 300


Portb.0 = 0

Portb.1 = 1

Portb.2 = 0

Portb.3 = 0

Waitms 300

Portb.0 = 1

Portb.1 = 0

Portb.2 = 0

Portb.3 = 0

Waitms 300


Incr Step1

Loop Until Step1 = Steper1(n)
Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return




Log4stepx2:
Do


Portd.0 = 0

Portd.1 = 0

Portd.2 = 0

Portd.3 = 1

Waitms 300


Portd.0 = 0

Portd.1 = 0

Portd.2 = 1

Portd.3 = 0

Waitms 300


Portd.0 = 0

Portd.1 = 1

Portd.2 = 0

Portd.3 = 0

Waitms 300

Portd.0 = 1

Portd.1 = 0

Portd.2 = 0

Portd.3 = 0

Waitms 300

Incr Step2


Loop Until Step2 = Steper2(n)

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return



Log4stepx3:
Do



Portd.4 = 1

Portd.5 = 0

Portd.6 = 0

Portd.7 = 0

Waitms 300


Portd.4 = 0

Portd.5 = 1

Portd.6 = 0

Portd.7 = 0

Waitms 300


Portd.4 = 0

Portd.5 = 0

Portd.6 = 1

Portd.7 = 0

Waitms 300


Portd.4 = 0

Portd.5 = 0

Portd.6 = 0

Portd.7 = 1

Waitms 300


Incr Step3


Loop Until Step3 = Steper3(n)

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return



Log4final:

Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return








'==============================================================================
Logika5:


Cls

Locate 1 , 1
Lcd "S1= " ; Steper1(n) ; "  S2= " ; Steper2(n)
Locate 2 , 1
Lcd "K= " ; N ; "  S3= " ; Steper3(n)


Step1 = 0
Step2 = 0
Step3 = 0

Do

Portb.0 = 1
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 1
Portd.7 = 1

Waitms 300


Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 1
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 1
Portd.6 = 1

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 1
Portd.5 = 1

Portb.2 = 1
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300

Portb.0 = 0
Portd.0 = 1
Portd.4 = 1

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 1
Portd.3 = 0
Portd.7 = 0

Waitms 300


Incr Step1
Incr Step2
Incr Step3

If Step1 = Steper1(n) And Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log5final
End If

If Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log5stepx1
End If

If Step1 = Steper1(n) And Step2 = Steper2(n) Then
Goto Log5stepx3
End If

If Step1 = Steper1(n) And Step3 = Steper3(n) Then
Goto Log5stepx2
End If




If Step1 = Steper1(n) Then

Goto Log5step2step3

End If

If Step2 = Steper2(n) Then

Goto Log5step1step3

End If

If Step3 = Steper3(n) Then

Goto Log5step1step2

End If




Loop


Log5step2step3:
Do

Portd.0 = 0
Portd.4 = 0

Portd.1 = 0
Portd.5 = 0

Portd.2 = 0
Portd.6 = 0

Portd.3 = 1
Portd.7 = 1

Waitms 300


Portd.0 = 0
Portd.4 = 0

Portd.1 = 0
Portd.5 = 0

Portd.2 = 1
Portd.6 = 1

Portd.3 = 0
Portd.7 = 0

Waitms 300


Portd.0 = 0
Portd.4 = 0

Portd.1 = 1
Portd.5 = 1

Portd.2 = 0
Portd.6 = 0

Portd.3 = 0
Portd.7 = 0

Waitms 300

Portd.0 = 1
Portd.4 = 1

Portd.1 = 0
Portd.5 = 0

Portd.2 = 0
Portd.6 = 0

Portd.3 = 0
Portd.7 = 0

Waitms 300

Incr Step2
Incr Step3

If Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log5final
End If

If Step2 = Steper2(n) Then
Goto Log5stepx3
End If

If Step3 = Steper3(n) Then
Goto Log5stepx2
End If


Loop
Return


Log5step1step3:

Do

Portb.0 = 1
Portd.4 = 0

Portb.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.7 = 1

Waitms 300


Portb.0 = 0
Portd.4 = 0

Portb.1 = 1
Portd.5 = 0

Portb.2 = 0
Portd.6 = 1

Portb.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.5 = 1

Portb.2 = 1
Portd.6 = 0

Portb.3 = 0
Portd.7 = 0

Waitms 300

Portb.0 = 0
Portd.4 = 1

Portb.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.6 = 0

Portb.3 = 1
Portd.7 = 0

Waitms 300


Incr Step1
Incr Step3

If Step1 = Steper1(n) And Step3 = Steper3(n) Then
Goto Log5final
End If

If Step1 = Steper1(n) Then
Goto Log5stepx3
End If

If Step3 = Steper3(n) Then
Goto Log5stepx1
End If


Loop
Return


Log5step1step2:

Do

Portb.0 = 1
Portd.0 = 0

Portb.1 = 0
Portd.1 = 0

Portb.2 = 0
Portd.2 = 0

Portb.3 = 0
Portd.3 = 1

Waitms 300


Portb.0 = 0
Portd.0 = 0

Portb.1 = 1
Portd.1 = 0

Portb.2 = 0
Portd.2 = 1

Portb.3 = 0
Portd.3 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0

Portb.1 = 0
Portd.1 = 1

Portb.2 = 1
Portd.2 = 0

Portb.3 = 0
Portd.3 = 0

Waitms 300

Portb.0 = 0
Portd.0 = 1

Portb.1 = 0
Portd.1 = 0

Portb.2 = 0
Portd.2 = 0

Portb.3 = 1
Portd.3 = 0

Waitms 300


Incr Step1
Incr Step2

If Step1 = Steper1(n) And Step2 = Steper2(n) Then
Goto Log5final
End If

If Step1 = Steper1(n) Then
Goto Log5stepx2
End If

If Step2 = Steper2(n) Then
Goto Log5stepx1
End If


Loop
Return


Log5stepx1:

Do


Portb.0 = 1

Portb.1 = 0

Portb.2 = 0

Portb.3 = 0

Waitms 300


Portb.0 = 0

Portb.1 = 1

Portb.2 = 0

Portb.3 = 0

Waitms 300


Portb.0 = 0

Portb.1 = 0

Portb.2 = 1

Portb.3 = 0

Waitms 300

Portb.0 = 0

Portb.1 = 0

Portb.2 = 0

Portb.3 = 1

Waitms 300


Incr Step1

Loop Until Step1 = Steper1(n)
Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return




Log5stepx2:
Do


Portd.0 = 0

Portd.1 = 0

Portd.2 = 0

Portd.3 = 1

Waitms 300


Portd.0 = 0

Portd.1 = 0

Portd.2 = 1

Portd.3 = 0

Waitms 300


Portd.0 = 0

Portd.1 = 1

Portd.2 = 0

Portd.3 = 0

Waitms 300

Portd.0 = 1

Portd.1 = 0

Portd.2 = 0

Portd.3 = 0

Waitms 300

Incr Step2


Loop Until Step2 = Steper2(n)

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return



Log5stepx3:
Do



Portd.4 = 0

Portd.5 = 0

Portd.6 = 0

Portd.7 = 1

Waitms 300


Portd.4 = 0

Portd.5 = 0

Portd.6 = 1

Portd.7 = 0

Waitms 300


Portd.4 = 0

Portd.5 = 1

Portd.6 = 0

Portd.7 = 0

Waitms 300

Portd.4 = 1

Portd.5 = 0

Portd.6 = 0

Portd.7 = 0

Waitms 300


Incr Step3


Loop Until Step3 = Steper3(n)

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return



Log5final:

Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return











'==============================================================================
Logika6:


Cls

Locate 1 , 1
Lcd "S1= " ; Steper1(n) ; "  S2= " ; Steper2(n)
Locate 2 , 1
Lcd "K= " ; N ; "  S3= " ; Steper3(n)


Step1 = 0
Step2 = 0
Step3 = 0

Do

Portb.0 = 0
Portd.0 = 1
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 1
Portd.3 = 0
Portd.7 = 1

Waitms 300


Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 1
Portd.5 = 0

Portb.2 = 1
Portd.2 = 0
Portd.6 = 1

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 1
Portd.1 = 0
Portd.5 = 1

Portb.2 = 0
Portd.2 = 1
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300

Portb.0 = 1
Portd.0 = 0
Portd.4 = 1

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 1
Portd.7 = 0

Waitms 300


Incr Step1
Incr Step2
Incr Step3

If Step1 = Steper1(n) And Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log6final
End If

If Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log6stepx1
End If

If Step1 = Steper1(n) And Step2 = Steper2(n) Then
Goto Log6stepx3
End If

If Step1 = Steper1(n) And Step3 = Steper3(n) Then
Goto Log6stepx2
End If




If Step1 = Steper1(n) Then

Goto Log6step2step3

End If

If Step2 = Steper2(n) Then

Goto Log6step1step3

End If

If Step3 = Steper3(n) Then

Goto Log6step1step2

End If




Loop


Log6step2step3:
Do

Portd.0 = 1
Portd.4 = 0

Portd.1 = 0
Portd.5 = 0

Portd.2 = 0
Portd.6 = 0

Portd.3 = 0
Portd.7 = 1

Waitms 300


Portd.0 = 0
Portd.4 = 0

Portd.1 = 1
Portd.5 = 0

Portd.2 = 0
Portd.6 = 1

Portd.3 = 0
Portd.7 = 0

Waitms 300


Portd.0 = 0
Portd.4 = 0

Portd.1 = 0
Portd.5 = 1

Portd.2 = 1
Portd.6 = 0

Portd.3 = 0
Portd.7 = 0

Waitms 300

Portd.0 = 0
Portd.4 = 1

Portd.1 = 0
Portd.5 = 0

Portd.2 = 0
Portd.6 = 0

Portd.3 = 1
Portd.7 = 0

Waitms 300

Incr Step2
Incr Step3

If Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log6final
End If

If Step2 = Steper2(n) Then
Goto Log6stepx3
End If

If Step3 = Steper3(n) Then
Goto Log6stepx2
End If


Loop
Return


Log6step1step3:

Do

Portb.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.6 = 0

Portb.3 = 1
Portd.7 = 1

Waitms 300


Portb.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.5 = 0

Portb.2 = 1
Portd.6 = 1

Portb.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.4 = 0

Portb.1 = 1
Portd.5 = 1

Portb.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.7 = 0

Waitms 300

Portb.0 = 1
Portd.4 = 1

Portb.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.7 = 0

Waitms 300


Incr Step1
Incr Step3

If Step1 = Steper1(n) And Step3 = Steper3(n) Then
Goto Log6final
End If

If Step1 = Steper1(n) Then
Goto Log6stepx3
End If

If Step3 = Steper3(n) Then
Goto Log6stepx1
End If


Loop
Return


Log6step1step2:

Do

Portb.0 = 0
Portd.0 = 1

Portb.1 = 0
Portd.1 = 0

Portb.2 = 0
Portd.2 = 0

Portb.3 = 1
Portd.3 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0

Portb.1 = 0
Portd.1 = 1

Portb.2 = 1
Portd.2 = 0

Portb.3 = 0
Portd.3 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0

Portb.1 = 1
Portd.1 = 0

Portb.2 = 0
Portd.2 = 1

Portb.3 = 0
Portd.3 = 0

Waitms 300

Portb.0 = 1
Portd.0 = 0

Portb.1 = 0
Portd.1 = 0

Portb.2 = 0
Portd.2 = 0

Portb.3 = 0
Portd.3 = 1

Waitms 300


Incr Step1
Incr Step2

If Step1 = Steper1(n) And Step2 = Steper2(n) Then
Goto Log6final
End If

If Step1 = Steper1(n) Then
Goto Log6stepx2
End If

If Step2 = Steper2(n) Then
Goto Log6stepx1
End If


Loop
Return


Log6stepx1:

Do


Portb.0 = 0

Portb.1 = 0

Portb.2 = 0

Portb.3 = 1

Waitms 300


Portb.0 = 0

Portb.1 = 0

Portb.2 = 1

Portb.3 = 0

Waitms 300


Portb.0 = 0

Portb.1 = 1

Portb.2 = 0

Portb.3 = 0

Waitms 300

Portb.0 = 1

Portb.1 = 0

Portb.2 = 0

Portb.3 = 0

Waitms 300


Incr Step1

Loop Until Step1 = Steper1(n)
Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return




Log6stepx2:
Do


Portd.0 = 1

Portd.1 = 0

Portd.2 = 0

Portd.3 = 0

Waitms 300


Portd.0 = 0

Portd.1 = 1

Portd.2 = 0

Portd.3 = 0

Waitms 300


Portd.0 = 0

Portd.1 = 0

Portd.2 = 1

Portd.3 = 0

Waitms 300

Portd.0 = 0

Portd.1 = 0

Portd.2 = 0

Portd.3 = 1

Waitms 300

Incr Step2


Loop Until Step2 = Steper2(n)

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return



Log6stepx3:
Do



Portd.4 = 0

Portd.5 = 0

Portd.6 = 0

Portd.7 = 1

Waitms 300


Portd.4 = 0

Portd.5 = 0

Portd.6 = 1

Portd.7 = 0

Waitms 300


Portd.4 = 0

Portd.5 = 1

Portd.6 = 0

Portd.7 = 0

Waitms 300

Portd.4 = 1

Portd.5 = 0

Portd.6 = 0

Portd.7 = 0

Waitms 300


Incr Step3


Loop Until Step3 = Steper3(n)

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return



Log6final:

Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return










'==============================================================================
Logika7:


Cls

Locate 1 , 1
Lcd "S1= " ; Steper1(n) ; "  S2= " ; Steper2(n)
Locate 2 , 1
Lcd "K= " ; N ; "  S3= " ; Steper3(n)


Step1 = 0
Step2 = 0
Step3 = 0

Do

Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 1
Portd.3 = 1
Portd.7 = 1

Waitms 300


Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 1
Portd.2 = 1
Portd.6 = 1

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 1
Portd.1 = 1
Portd.5 = 1

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300

Portb.0 = 1
Portd.0 = 1
Portd.4 = 1

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300


Incr Step1
Incr Step2
Incr Step3

If Step1 = Steper1(n) And Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log7final
End If

If Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log7stepx1
End If

If Step1 = Steper1(n) And Step2 = Steper2(n) Then
Goto Log7stepx3
End If

If Step1 = Steper1(n) And Step3 = Steper3(n) Then
Goto Log7stepx2
End If




If Step1 = Steper1(n) Then

Goto Log7step2step3

End If

If Step2 = Steper2(n) Then

Goto Log7step1step3

End If

If Step3 = Steper3(n) Then

Goto Log7step1step2

End If




Loop


Log7step2step3:
Do

Portd.0 = 0
Portd.4 = 0

Portd.1 = 0
Portd.5 = 0

Portd.2 = 0
Portd.6 = 0

Portd.3 = 1
Portd.7 = 1

Waitms 300


Portd.0 = 0
Portd.4 = 0

Portd.1 = 0
Portd.5 = 0

Portd.2 = 1
Portd.6 = 1

Portd.3 = 0
Portd.7 = 0

Waitms 300


Portd.0 = 0
Portd.4 = 0

Portd.1 = 1
Portd.5 = 1

Portd.2 = 0
Portd.6 = 0

Portd.3 = 0
Portd.7 = 0

Waitms 300

Portd.0 = 1
Portd.4 = 1

Portd.1 = 0
Portd.5 = 0

Portd.2 = 0
Portd.6 = 0

Portd.3 = 0
Portd.7 = 0

Waitms 300

Incr Step2
Incr Step3

If Step2 = Steper2(n) And Step3 = Steper3(n) Then
Goto Log7final
End If

If Step2 = Steper2(n) Then
Goto Log7stepx3
End If

If Step3 = Steper3(n) Then
Goto Log7stepx2
End If


Loop
Return


Log7step1step3:

Do

Portb.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.6 = 0

Portb.3 = 1
Portd.7 = 1

Waitms 300


Portb.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.5 = 0

Portb.2 = 1
Portd.6 = 1

Portb.3 = 0
Portd.7 = 0

Waitms 300


Portb.0 = 0
Portd.4 = 0

Portb.1 = 1
Portd.5 = 1

Portb.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.7 = 0

Waitms 300

Portb.0 = 1
Portd.4 = 1

Portb.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.7 = 0

Waitms 300


Incr Step1
Incr Step3

If Step1 = Steper1(n) And Step3 = Steper3(n) Then
Goto Log7final
End If

If Step1 = Steper1(n) Then
Goto Log7stepx3
End If

If Step3 = Steper3(n) Then
Goto Log7stepx1
End If


Loop
Return


Log7step1step2:

Do

Portb.0 = 0
Portd.0 = 0

Portb.1 = 0
Portd.1 = 0

Portb.2 = 0
Portd.2 = 0

Portb.3 = 1
Portd.3 = 1

Waitms 300


Portb.0 = 0
Portd.0 = 0

Portb.1 = 0
Portd.1 = 0

Portb.2 = 1
Portd.2 = 1

Portb.3 = 0
Portd.3 = 0

Waitms 300


Portb.0 = 0
Portd.0 = 0

Portb.1 = 1
Portd.1 = 1

Portb.2 = 0
Portd.2 = 0

Portb.3 = 0
Portd.3 = 0

Waitms 300

Portb.0 = 1
Portd.0 = 1

Portb.1 = 0
Portd.1 = 0

Portb.2 = 0
Portd.2 = 0

Portb.3 = 0
Portd.3 = 0

Waitms 300


Incr Step1
Incr Step2

If Step1 = Steper1(n) And Step2 = Steper2(n) Then
Goto Log7final
End If

If Step1 = Steper1(n) Then
Goto Log7stepx2
End If

If Step2 = Steper2(n) Then
Goto Log7stepx1
End If


Loop
Return


Log7stepx1:

Do


Portb.0 = 0

Portb.1 = 0

Portb.2 = 0

Portb.3 = 1

Waitms 300


Portb.0 = 0

Portb.1 = 0

Portb.2 = 1

Portb.3 = 0

Waitms 300


Portb.0 = 0

Portb.1 = 1

Portb.2 = 0

Portb.3 = 0

Waitms 300

Portb.0 = 1

Portb.1 = 0

Portb.2 = 0

Portb.3 = 0

Waitms 300


Incr Step1

Loop Until Step1 = Steper1(n)
Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return




Log7stepx2:
Do


Portd.0 = 0

Portd.1 = 0

Portd.2 = 0

Portd.3 = 1

Waitms 300


Portd.0 = 0

Portd.1 = 0

Portd.2 = 1

Portd.3 = 0

Waitms 300


Portd.0 = 0

Portd.1 = 1

Portd.2 = 0

Portd.3 = 0

Waitms 300

Portd.0 = 1

Portd.1 = 0

Portd.2 = 0

Portd.3 = 0

Waitms 300

Incr Step2


Loop Until Step2 = Steper2(n)

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return



Log7stepx3:
Do



Portd.4 = 0

Portd.5 = 0

Portd.6 = 0

Portd.7 = 1

Waitms 300


Portd.4 = 0

Portd.5 = 0

Portd.6 = 1

Portd.7 = 0

Waitms 300


Portd.4 = 0

Portd.5 = 1

Portd.6 = 0

Portd.7 = 0

Waitms 300

Portd.4 = 1

Portd.5 = 0

Portd.6 = 0

Portd.7 = 0

Waitms 300


Incr Step3


Loop Until Step3 = Steper3(n)

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return



Log7final:

Portb.0 = 0
Portd.0 = 0
Portd.4 = 0

Portb.1 = 0
Portd.1 = 0
Portd.5 = 0

Portb.2 = 0
Portd.2 = 0
Portd.6 = 0

Portb.3 = 0
Portd.3 = 0
Portd.7 = 0

Waitms 300

Do
If N = H Then

Cls
Upperline
Lcd "SISTEM OFF"

Exit Do
End
Else
Incr N
Goto Main
End If
Loop

End
Return





 e. Video Hasilnya


   













1 comment:

  1. terimakasih
    saya sudah coba rangkaian dan source codenya di proteus 7
    tapi seperti apa aplikasinya
    apa fungsi ketiga pushnya

    ReplyDelete