Minggu pagi yang cerah, kali ini saya akan menjelaskan bagaimana cara menggunakan fitur ATMega128 yang tidak dimiliki oleh ATMega dibawahnya, yaitu 2 buah port serial, pada ATMega8,16,8535 dan 32 hanya memiliki 1 port serial, namun ATMega128 tidak-lah sama, ia memiliki fitur tambahan, diantaranya yatitu 2 buah port serial, ini sangatlah penting sekali karena dengan 2 port serial, mikrokontroller bisa berkomunikasi dengan 2 device sekaligus, pada contoh video ini di tampilkan dua buah device sebagai slave yaitu mikrokontroller ATMega16 dan sebuah laptop / komputer, jadi ATMega128 mengirimkan ke dua buah device secara berurutan. berikut adalah penjelasan lengkap tentang skematik dan konfigurasinya.
a. ATMega128
b. Minimum System ATMega16
c. Program Master M128 Bascom AVR
$regfile = "m128def.dat"
$crystal = 16000000
Config Com1 = 9600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Config Com2 = 9600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Open "com1:" For Binary As #1
Open "Com2:" For Binary As #2
Do
Print #1 , "#coba 128 Com 1"
Print #2 , "#test 128 Com 2"
Loop
$crystal = 16000000
Config Com1 = 9600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Config Com2 = 9600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Open "com1:" For Binary As #1
Open "Com2:" For Binary As #2
Do
Print #1 , "#coba 128 Com 1"
Print #2 , "#test 128 Com 2"
Loop
d. Program Slave M16 Bascom AVR
$regfile = "m16def.dat"
$crystal = 12000000
$baud = 9600
Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.1 , Db4 = Portc.2
Config Lcdpin = Pin , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcd = 16 * 2
Dim Data_masuk As String * 100
Dim Cmti_pos As Byte , Cmgr_pos As Byte , Index_pos As Byte , Cmd_pos As Byte
Dim Pjg_sms_index As Byte , Pjg_data As Byte
Dim Sms_index As String * 3
Dim Cmd As String * 20
Dim Cmdbin As Byte
Upperline
Lcd "SLAVE MCU"
Lowerline
Lcd "YANUAR M"
Wait 3
Ddrd.6 = 1
Ddrd.7 = 1
Cls
Cursor Off
Do
Input Data_masuk
Upperline
Lcd "DATA MASUK"
Pjg_data = Len(data_masuk)
' Cmti_pos = Instr(data_masuk , "#")
Cmd_pos = Instr(data_masuk , "#")
If Cmd_pos <> 0 Then
Incr Cmd_pos
Cmd = Mid(data_masuk , Cmd_pos , 20)
Lowerline
Lcd Cmd
End If
Loop
$crystal = 12000000
$baud = 9600
Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.1 , Db4 = Portc.2
Config Lcdpin = Pin , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcd = 16 * 2
Dim Data_masuk As String * 100
Dim Cmti_pos As Byte , Cmgr_pos As Byte , Index_pos As Byte , Cmd_pos As Byte
Dim Pjg_sms_index As Byte , Pjg_data As Byte
Dim Sms_index As String * 3
Dim Cmd As String * 20
Dim Cmdbin As Byte
Upperline
Lcd "SLAVE MCU"
Lowerline
Lcd "YANUAR M"
Wait 3
Ddrd.6 = 1
Ddrd.7 = 1
Cls
Cursor Off
Do
Input Data_masuk
Upperline
Lcd "DATA MASUK"
Pjg_data = Len(data_masuk)
' Cmti_pos = Instr(data_masuk , "#")
Cmd_pos = Instr(data_masuk , "#")
If Cmd_pos <> 0 Then
Incr Cmd_pos
Cmd = Mid(data_masuk , Cmd_pos , 20)
Lowerline
Lcd Cmd
End If
Loop
e. VIDEO HASILNYA
No comments:
Post a Comment