Tampilkan postingan dengan label Mikrokontroler. Tampilkan semua postingan
Tampilkan postingan dengan label Mikrokontroler. Tampilkan semua postingan

Sabtu, 09 Maret 2013

LM 35 adalah sensor suhu yang prinsip kerjanya ialah mengkonversi perubahan suhu yang berada disekitarnya menjadi perubahan tegangan. Sensor ini memiliki 3 buah pin yaitu Vin, Ground dan Vout. Tegangan kerja yang dibutuhkan LM35 ialah 4-20V.  Hasil Vout yang diperoleh ialah linear dangan +10mV setiap kenaikan  per  1 derajat celcius.
Salah satu aplikasi dari sensor LM35 ialah digunakan sebagai thermometer digital. Tentunya dengan dipadukan sistem pendukung (mikrokontroler). berikut ini adalah  simulasi sensor LM35 menggunakan ISIS proteus.
Program (BASCOM AVR):



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

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

 Deflcdchar 0 , 14 , 14 , 14 , 32 , 32 , 32 , 32 , 32   'karakter derajat

 Dim Adc_data As Word , Konversi_adc As Single
 Dim Adc_string As String * 10

 Cursor Off

 Config Adc = Single , Prescaler = Auto , Reference = Avcc
 Start Adc

 Locate 1 , 1
 Lcd "  DIGITAL LCD "
 Locate 2 , 1
 Lcd "  THERMOMETER "
 Waitms 700

 Cls

 Do
 Adc_data = Getadc(0)
 Konversi_adc = Adc_data
 Konversi_adc = Konversi_adc / 1024
 Konversi_adc = Konversi_adc * 497                          'kalibrasi
 
 Locate 1 , 1
 Lcd "SUHU:"
 Locate 1 , 7
 Lcd Fusing(konversi_adc , " #.##") ; " "
 Locate 1 , 13
 Lcd Chr(0) ; "C"

 Waitms 100
 Loop
 End
Untuk melakukan kalibrasi maka dapat kita ubah nilai perhitungan pada :
Konversi_adc = Konversi_adc * 497                    
Nilai 497 dapat disesuaikan untuk mencapai nilai yang pas dengan instrumen kalibrator (termometer).
LCD module 16x2 is a display which is used for showing a character given by the system, in this case a information paint system is microcontroller. To communicate with a microcontroller based on the length of the data, the LCD has two interface methods, namely interface 4 bit and 8-bit interface

8 bits interface methods, data written or read by a microcontroller to/from the LCD is done once process. As for the 4-bit interface methods, writing or reading is done twice for 8 bit data. 4 bit LCD interface is set to write mode data, by connecting the foot of R/W to GND. with 4 bit method, the use of I/O ports on the miktokontroller can be reduced so that the port can be used to process other i/o

In this circuit, there is a trimpot (trimmer potentiometer)10KO. The function of the trimpot used to set the contrast of characters displayed on the LCD

Jumat, 28 Desember 2012


Sumber:sukasukapaktri.blogspot.co.id/2012/12/wonderful-running-led-with-atmega8535.html

Projek Wonderful Running Led With Atmega8535. Awalnya dia tertarik untuk belajar mikrokontroler khususnya belajar pemrograman BASCOM AVR.

Wonderful Running LED

Mengapa menggunakan chip ATMEGA8535 itu karena selain banyak di pasaran, IC ini juga memiliki fitur yang cukup kompleks sehingga akan mudah diaplikasikan ke dalam bentuk pengontrolan yang lain. Untuk lebih jelasnya mengenai ATMEGA8535 bisa download datasheetnya di sini.

Sebagai langkah awal pembelajaran, saya aplikasikan mikrokontroler ATMEGA8535 sebagai pengendali running led yang diprogram dengan software BASCOM AVR.




Pemrograman dengan BASCOM AVR




LED akan secara bergantian hidup dan mati sesuai dengan instruksi program yang tersimpan dalam chip mikrokontroler. Dengan bahasa pemrograman basic kita menggunakan istilah pengondisian DO - IF - THEN - END - IF - LOOP.


Berikut contoh programnya:


$regfile = "m8535dat"


$crystal = 11059200


config portb = input


config porta = output


config portc = output


sw1 Alias PORTB.1

LED Alias PORTC



Ddrb = &B00000000

PORTC = &B11111111

'--------------------------------


Do


If sw1 = 0 then


waitms 50

LED = &B00000000

waitms 20

LED = &B11111111

waitms 50

LED = &B00000000

waitms 20

LED = &B11111111

waitms 50

LED = &B00000000

waitms 20

LED = &B11111111

waitms 50

LED = &B00000000

waitms 20

LED = &B11111111

waitms 50

'----------------------------------


LED = &B11111110


waitms 10


LED = &B11111101


waitms 10


LED = &B11111011


waitms 10


LED = &B11110111


waitms 10


LED = &B11101111


waitms 10


LED = &B11011111


waitms 10


LED = &B10111111


waitms 10


LED = &B01111111


'------------------------------------- 1


waitms 10


LED = &B01111110


waitms 10


LED = &B01111101


waitms 10


LED = &B01111011


waitms 10


LED = &B01110111


waitms 10


LED = &B01101111


waitms 10


LED = &B01011111


waitms 10


LED = &B00111111


'------------------------------ 2


waitms 10


LED = &B00111110


waitms 10


LED = &B00111101


waitms 10


LED = &B00111011


waitms 10


LED = &B00110111


waitms 10


LED = &B00101111


waitms 10


LED = &B00011111


'------------------------------- 3


waitms 10


LED = &B00011110


waitms 10


LED = &B00011101


waitms 10


LED = &B00011011


waitms 10


LED = &B00010111


waitms 10


LED = &B00001111


'----------------------------------- 4


waitms 10


LED = &B00001110


waitms 10


LED = &B00001101


waitms 10


LED = &B00001011


waitms 10


LED = &B00000111


'---------------------------------- 5


waitms 10


LED = &B00000110


waitms 10


LED = &B00000101


waitms 10


LED = &B00000011


'---------------------------------- 6


waitms 10


LED = &B00000010


waitms 10


LED = &B00000000


'--------------------------------- 7

waitms 30

LED = &B11100111

waitms 10

LED = &B11000011

waitms 10

LED = &B10000001

waitms 10

LED = &B00000000

waitms 10

LED = &B10000001

waitms 10

LED = &B11000011

waitms 10

LED = &B11100111

waitms 10

LED = &B11111111

'---------------------------------

waitms 30

LED = &B11100111

waitms 10

LED = &B11000011

waitms 10

LED = &B10000001

waitms 10

LED = &B00000000

waitms 10

LED = &B10000001

waitms 10

LED = &B11000011

waitms 10

LED = &B11100111

waitms 10

LED = &B11111111

'--------------------------------

waitms 30

LED = &B11100111

waitms 10

LED = &B11000011

waitms 10

LED = &B10000001

waitms 10

LED = &B00000000

waitms 10

LED = &B10000001

waitms 10

LED = &B11000011

waitms 10
LED = &B11100111
waitms 10
LED = &B11111111
End If
Loop


Videonya dapat dilihat dibawah ini: