2 Channel Digital Voltmeter dengan AVR

Duluuu kita pernah posting aplikasi mikrokontroler membuat digital voltmeter. Tapi 1 input. Nah sekarang kita akan buat 2 input. Tampilan 7 segment dengan satuan milli volt (mV). Range 0 mV sampai 5000 mV (5V).  Mikrokontrollernya pakai ATmega8535.
99 proyek arduinoRangkaian sederhana saja :

Rangkaian 2 Ch Digital Voltmeter

Program dengan BASCOM-AVR :

$regfile = “m8535.dat”
$crystal = 16000000
Declare Sub Konversi(x As Word )

Dim Volt1 As Word , Volt2 As Word , Data_adc As Word
Dim Sat As Word , Pul As Word , Rat As Word , Rib As Word

Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Portc = Output
Config Porta = Input
Config Portb = Output
Config Portd = Output

Ddrd.4 = 1
Portc = 0
Porta = &HFF
Start Adc

Banner MM AVRDo
 Data_adc = Getadc(0)
 Volt1 = Data_adc * 5
 Konversi Volt1
 Portc = &B11110111
 Portd = Lookup(sat , Angka)
 Waitms 2
 Portc = &B11111011
 Portd = Lookup(pul , Angka)
 Waitms 2
 Portc = &B11111101
 Portd = Lookup(rat , Angka)
 Waitms 2
 Portc = &B11111110
 Portd = Lookup(rib , Angka)
 Waitms 2
 Data_adc = Getadc(2)
 Volt2 = Data_adc * 5
 Konversi Volt2
 Portc = &B01111111
 Portb = Lookup(sat , Angka)
 Waitms 2
 Portc = &B10111111
 Portb = Lookup(pul , Angka)
 Waitms 2
 Portc = &B11011111
 Portb = Lookup(rat , Angka)
 Waitms 2
 Portc = &B11101111
 Portb = Lookup(rib , Angka)
 Waitms 2
Loop
End

Sub Konversi(x As Word )
   Rib = X / 1000
   Rat = X Mod 1000
   Rat = Rat / 100
   Pul = X Mod 1000
   Pul = Pul Mod 100
   Pul = Pul / 10
   Sat = X Mod 1000
   Sat = Sat Mod 100
   Sat = Sat Mod 10
End Sub

Angka:
   Data &HC0 , &HF9 , &HA4 , &HB0 , &H99 , &H92 , &H82 , &HF8 , &H80 , &H90 , &H7F

Hasilnya :

Hasil 2 Channel Digital Voltmeter

OK, silakan dicoba ya. Untuk input tegangan pakai ADC0 dan ADC2. Ingat input maksimal adalah 5V dc.

This entry was posted in Mikrokontroler AVR and tagged , , , . Bookmark the permalink.