Professional Documents
Culture Documents
DC Motor Speed
DC Motor Speed
1. ATMEGA-16
4. Motor-DC
Langkah selanjutnya adalah melakukan simulasi dengan menggunakan beberapa software pendukung,
1. Proteus(ISIS 7 Professional)
2. Bascom-AVR
1. Buatlah rangkaian sesuai dengan gambar di bawah ini dengan menggunakan Software Proteus(ISIS 7
Profesional):
2. setelah selesai merangkai gunakan software Bascom-AVR dengan mengetikkan kode sebagai berikut:
$regfile = “m16def.dat”
$crystal = 1000000
‘================================================================
============
Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Down , Prescale = 1024
‘================================================================
============
‘================================================================
============
‘================================================================
============
A = 100
Pwm1a = A
Portc.0 = 1
Portc.1 = 0
B=0
‘================================================================
============
Do
‘////////////////////////////////////////////////////////////////////////////
If Pinb.0 = 1 Then
A = A + 10
Pwm1a = A
Waitms 250
End If
‘////////////////////////////////////////////////////////////////////////////
If Pinb.1 = 1 Then
A = A – 10
If A <= 10 Then A = 10
Pwm1a = A
Waitms 250
End If
'////////////////////////////////////////////////////////////////////////////
If Pinb.2 = 1 Then
If B = 0 Then
B=1
Portc.0 = 0
Portc.1 = 1
Elseif B = 1 Then
B=0
Portc.0 = 1
Portc.1 = 0
End If
Waitms 250
End If
'////////////////////////////////////////////////////////////////////////////
Call Progress(a)
'////////////////////////////////////////////////////////////////////////////
Loop
'=================================================================
===========
End
'/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Portc.7 = 1
Portc.6 = 0
Porta = 0
End If
If Num = 25 Then
Portc.6 = 1
Portc.7 = 1
Porta = 0
End If
If Num = 50 Then
Portc.6 = 1
Portc.7 = 1
Porta = &B00000001
End If
If Num = 75 Then
Portc.6 = 1
Portc.7 = 1
Porta = &B00000011
End If
Portc.6 = 1
Portc.7 = 1
Porta = &B00000111
End If
Download source
1. ATMEGA-16
2. Keypad-Small-Calc
3. LM016 (LCD)
Langkah selanjutnya adalah melakukan simulasi dengan menggunakan beberapa software pendukung,
software yang dibutuhkan adalah:
1. Proteus(ISIS 7 Professional)
2. Bascom-AVR
1. Buatlah rangkaian sesuai dengan gambar di bawah ini dengan menggunakan Software Proteus(ISIS 7
Profesional):
2. setelah selesai merangkai gunakan software Bascom-AVR dengan mengetikkan kode sebagai berikut:
$regfile = “m16def.dat”
$crystal = 1000000
Config Kbd = Portd , Debounce = 30
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , Rs = Portb.3 , E =
Portb.2
Dim A As Byte
Dim B As Byte
Dim Key As Byte
Dim C As Byte
Dim D As Byte
Dim E As Byte
Dim F As Byte
Cls
Cursor Off
Locate 2 , 1
Lcd “calculator dig”
E=0
B=0
Q:
Waitms 200
‘B = 0
A = Getkbd()
If A > 15 Then
Goto Q
Else
Key = Lookup(a , Dta)
If Key <= 9 Then
D=0
B = 10 * B
B = B + Key
If E = 0 Then C = B
If E = 1 Then D = B
Cls : Lcd B
Elseif Key = 10 Then
Cls
F=1
E=1
B=0
Elseif Key = 11 Then
Cls
E=1
F=2
B=0
Elseif Key = 12 Then
Cls
E=1
F=3
B=0
Elseif Key = 15 Then
Cls
E=1
F=4
B=0
Elseif Key = 13 Then
Cls
E=0
B=0
Elseif Key = 14 Then
If E = 1 Then
Cls
Select Case F
Case 1 :
B=C/D
Case 2:
B=C*D
Case 3:
B=C–D
Case 4:
B=C+D
End Select
Lcd B
End If
End If
End If
Locate 2 , 1
Lcd "calculator dig"
Goto Q
End
Dta:
Data 7 , 8 , 9 , 10 , 4 , 5 , 6 , 11 , 1 , 2 , 3 , 12 , 13 , 0 , 14 , 15
Downloa