Translate

Simulasi Proteus Monitor Suhu lm35 dan Jam digital RTC BASCOM AVR

Simulasi Proteus Monitor Suhu lm35 dan Jam digital RTC BASCOM AVR


         Pada kesempatan kali ini saya akan menejelaskan mengenai bagaimana cara menampilkan nilau suhu menggunakan simulasi proteus dan juga menampilkan jam digital dengan RTC. simulasi ini menggunakan Proteus 7 dan program menggunakan Bascom AVR. untuk lebih jelasnya berikut adalah programnya.



a. Program Bascom AVR

$regfile = "m16def.dat"
$crystal = 12000000
$baud = 9600

$lib "ds1307clock.lib"

Config Lcdpin = Pin , Rs = Portc.6 , E = Portc.7 , Db4 = Portc.2
Config Lcdpin = Pin , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcd = 16 * 2
Config Adc = Single , Prescaler = Auto , Reference = Avcc

Cls
Cursor Off

Dim Dataadc As Word
Dim Suhu As Single

Config Sda = Portc.1
Config Scl = Portc.0
Const Ds1307w = &HD0
Const Ds1307r = &HD1

Config Clock = User

Dim Weekday As Byte
Dim Char As String * 10 , Tanda As String * 1
Dim Jam As String * 10 , Menit As String * 10 , Detik As String * 10
Dim Hari As String * 10 , Bulan As String * 10 , Tahun As String * 10
Dim A As Byte , B As Byte , C As Byte
Dim X As Byte , Y As Byte , Z As Byte
Dim Waktu As String * 10
Dim Tanggal As String * 10

Time$ = "15:30:00"
Date$ = "04-30-11"

_hour = 7
_min = 32
_sec = 0
Gosub Settime

_day = 20
_month = 3
_year = 19
Gosub Setdate

Start Adc

Mulai:
Do

Dataadc = Getadc(0)
Suhu = Dataadc * 5
Suhu = Suhu / 1023
Suhu = Suhu * 100

Print "Tanggal: " ; Date$
Print "Waktu:" ; Time$

Cls

Locate 1 , 1
Lcd "Waktu : " ; _hour ; "-" ; _min ; "-" ; _sec

Locate 2 , 1
Lcd "Suhu " ; Fusing(suhu , "#.##") ; " c      "

'Wait 1

Loop
End


Getdatetime:
  I2cstart
  I2cwbyte Ds1307w
  I2cwbyte 0

  I2cstart
  I2cwbyte Ds1307r
  I2crbyte _sec , Ack
  I2crbyte _min , Ack
  I2crbyte _hour , Ack
  I2crbyte Weekday , Ack
  I2crbyte _day , Ack
  I2crbyte _month , Ack
  I2crbyte _year , Nack
  I2cstop
  _sec = Makedec(_sec) : _min = Makedec(_min) : _hour = Makedec(_hour)
  _day = Makedec(_day) : _month = Makedec(_month) : _year = Makedec(_year)
Return

Setdate:
  _day = Makebcd(_day) : _month = Makebcd(_month) : _year = Makebcd(_year)
  I2cstart
  I2cwbyte Ds1307w
  I2cwbyte 4
  I2cwbyte _day
  I2cwbyte _month
  I2cwbyte _year
  I2cstop
Return

Settime:
  _sec = Makebcd(_sec) : _min = Makebcd(_min) : _hour = Makebcd(_hour)
  I2cstart
  I2cwbyte Ds1307w
  I2cwbyte 0
  I2cwbyte _sec
  I2cwbyte _min
  I2cwbyte _hour
  I2cstop
Return




b. VIDEO HASILNYA







No comments:

Post a Comment