Posted by : Arifah Nur Ainia


Link Jawaban UAS Mata Kuliah Embeded Sistem


Coding Program

$regfile = "m8535.dat"
$crystal = 12000000
ConfigLcdpin = Pin , Db4 = Portc.5 , Db5 = Portc.4 , Db6 = Portc.3 , Db7 = Portc.2 , E = Portc.6 , Rs = Portc.7
'pin-pinlcd yang digunakan
ConfigLcd = 16 * 2
ConfigAdc = Single ,Prescaler = Auto , Reference = Avcc
'------------------------ Konfigurasi
Ddrb.0 = 1                                                  'Portb.0 Sebagai Output
Ddrd = &B11111111                                          
'portDsebagai output'------------------------ Type
Dim Gas_refAs Word
Dim Gas As Single
Dim Lpg As String * 5
Dim VolAs String * 5
Dim TeganganAs Single
Dim TeganganxAs Single
Dim A As Single
Dim Vo As Single
Dim X As Single
Dim Y As Single
Dim RsAs Single
Dim D As Single
Dim E As Single
Dim Ppm As Single
Dim Ro As Single
'------------------------
Deflcdchar1 , 28 , 20 , 28 , 32 , 32 , 32 , 32 , 32
'membuatkarakterderajat
Cls
Cursor Off
Start Adc
'------------------------
Upperline
Lcd "Detektor Gas Lpg"
Portd = &B11111100
'led putihaktif
Wait 90
Cls

Upperline
Lcd "Range Detektor "
Lowerline
Lcd "500 - 10,000 ppm"
Portd = &B11001111  'ledbiruaktif
  Wait 90
Cls

Do
Gas_ref = Getadc(0)   'Nilaitegangan ADC dr out sensor
  Gas = Gas_ref
  Ro = 633750           'kadarRsdalamudarabersih (ADC minimal)

Teganganx = Gas_ref / 1023
Tegangan = Teganganx * 5.15                               'untuknilaimenampilkantegangan

X = 5.15 - Tegangan
Y = X / Tegangan
Rs = Y * 10000                                              'untukmenemukannilaiRs

D = Rs / Ro
E = 112.1 / D       'darigrafik excel ditemukan 112,1x^-0,68
Ppm = E ^ 1.58      '1/0.63
Vol = Fusing(tegangan , "#.##")
  Locate 1 , 1
Lcd "(Vol)="
  Locate 1 , 8
LcdVol
  Locate 2 , 1
LcdChr(0)
  Locate 2 , 2
Lcd "(PPM)=" ; Fusing(ppm , "#.##")

   If Tegangan< 4.45 Then
Portd = &B11110011  'ledhijauaktif
   Portb.0 = 0
   End If
   If Tegangan>= 4.45 Then
Portd = &B00111111  'ledmerahaktif
   Portb.0 = 1                                              'buzzer aktif
   End If

Loop
End

Leave a Reply

Subscribe to Posts | Subscribe to Comments

- Copyright © Whatever I Don't Care - Hatsune Miku - Powered by Blogger - Designed by Johanes Djogan -