Translate

Membuat Alat Pengukur Intensitas Cahaya Menggunakan Sensor LDR dan Penyimpanan EEPROM

Membuat Alat Pengukur Intensitas Cahaya Menggunakan Sensor LDR dan Penyimpanan EEPROM


            Pada kesempatan yang berbahagia kali ini saya akan menjelaskan mengenai bagaimana cara membuat alat untuk mengukur intensitas cahaya, sebenarnya alat ini tidak digunakan untuk cahaya lampu atau matahari melainkan untuk mengukur pantulan cahaya akibat gelas ukur, sehingga akan terlihat level kekeruhan air dari air yang terdapat didalam gelas tersebut. jika telah diketahui nilai tegangannya maka dimasukkan ke dalam rumus agar menjadi seperti Turbidimeter sesungguhnya. untuk lebih jelasnya berikut skema dan programnya.



 a. Minimum System




 b. Sensor LDR





c. Program Bascom AVR

$regfile = "m8535.dat"
$crystal = 11059200

Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.2 , Db4 = Portc.4
Config Lcdpin = Pin , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7
Config Lcd = 16 * 2

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

Dim Dataadc As Word
Dim Dataadc1 As Word
Dim Dataadc2 As Word
Dim Dataadc3 As Word

Dim Simpan1 As Eram Single
Dim Simpan2 As Eram Single
Dim Simpan3 As Eram Single
Dim Simpan4 As Eram Single
Dim Simpan5 As Eram Single
Dim Simpan6 As Eram Single
Dim Simpan7 As Eram Single
Dim Simpan8 As Eram Single
Dim Simpan9 As Eram Single
Dim Simpan10 As Eram Single

Dim W As Integer

Dim Tampil1 As Single
Dim Tampil2 As Single
Dim Tampil3 As Single
Dim Tampil4 As Single
Dim Tampil5 As Single
Dim Tampil6 As Single
Dim Tampil7 As Single
Dim Tampil8 As Single
Dim Tampil9 As Single
Dim Tampil10 As Single


Dim Teg1 As Single
Dim Teg2 As Single
Dim Teg3 As Single
Dim Teg4 As Single

Dim Z1 As Single
Dim Z2 As Single
Dim Z3 As Single
Dim Z4 As Single
Dim N As Integer

Dim Z As Single
Dim T As Single

'tombol start
Ddrb.2 = 0
Set Portb.2

'tombol reset
Ddrb.1 = 0
Set Portb.1

'tombol save
Ddrb.0 = 0
Set Portb.0

N = 1

Cls
Cursor Off

Start Adc

Simpan1 = 0
Simpan2 = 0
Simpan3 = 0
Simpan4 = 0
Simpan5 = 0
Simpan6 = 0
Simpan7 = 0
Simpan8 = 0
Simpan9 = 0
Simpan10 = 0

Main:

Wait 1

Do

Dataadc = Getadc(0)
Dataadc1 = Getadc(1)
Dataadc2 = Getadc(2)
Dataadc3 = Getadc(3)

Teg1 = Dataadc * 5
Teg1 = Teg1 / 1023

Teg2 = Dataadc1 * 5
Teg2 = Teg2 / 1023

Teg3 = Dataadc2 * 5
Teg3 = Teg3 / 1023

Teg4 = Dataadc3 * 5
Teg4 = Teg4 / 1023

Z1 = 1 * Teg4
Z2 = 1 * Teg3
Z3 = 1 * Teg1
Z4 = 1 * Teg2

Z = Z1 + Z2
Z = Z + Z3
Z = Z + Z4

T = Teg2 / Z


If Pinb.1 = 0 Then
Waitms 200
Goto Tampil
End If


Locate 1 , 1
Lcd Fusing(teg1 , "#.##") ; "  " ; Fusing(teg2 , "#.##")

Locate 1 , 12
Lcd Fusing(t , "#.##")


Locate 2 , 1
Lcd Fusing(teg3 , "#.##") ; "  " ; Fusing(teg4 , "#.##")


If Pinb.0 = 0 And N > 10 Then
Waitms 200
N = 1
End If


If Pinb.0 = 0 And N = 1 Then
Waitms 200
Incr N

Cls
Upperline
Lcd "Save data 1"
Lowerline
Lcd T
Wait 3

Simpan1 = T

Elseif Pinb.0 = 0 And N = 2 Then
Waitms 200
Incr N

Cls
Upperline
Lcd "Save data 2"
Lowerline
Lcd T

Wait 3

Simpan2 = T

Elseif Pinb.0 = 0 And N = 3 Then
Waitms 200
Incr N

Cls
Upperline
Lcd "Save data 3"
Lowerline
Lcd T

Wait 3

Simpan3 = T

Elseif Pinb.0 = 0 And N = 4 Then
Waitms 200
Incr N

Cls
Upperline
Lcd "Save data 4"
Lowerline
Lcd T

Wait 3

Simpan4 = T

Elseif Pinb.0 = 0 And N = 5 Then
Waitms 200
Incr N

Cls
Upperline
Lcd "Save data 5"
Lowerline
Lcd T

Wait 3

Simpan5 = T

Elseif Pinb.0 = 0 And N = 6 Then
Waitms 200
Incr N

Cls
Upperline
Lcd "Save data 6"
Lowerline
Lcd T

Wait 3

Simpan6 = T

Elseif Pinb.0 = 0 And N = 7 Then
Waitms 200
Incr N

Cls
Upperline
Lcd "Save data 7"
Lowerline
Lcd T

Wait 3

Simpan7 = T

Elseif Pinb.0 = 0 And N = 8 Then
Waitms 200
Incr N

Cls
Upperline
Lcd "Save data 8"
Lowerline
Lcd T

Wait 3

Simpan8 = T

Elseif Pinb.0 = 0 And N = 9 Then
Waitms 200
Incr N

Cls
Upperline
Lcd "Save data 9"
Lowerline
Lcd T

Wait 3

Simpan9 = T

Elseif Pinb.0 = 0 And N = 10 Then
Waitms 200

Incr N

Cls
Upperline
Lcd "Save data 10"
Lowerline
Lcd T

Wait 3

Simpan10 = T

End If

Waitms 200
Cls

Loop

Tampil:
Cls

W = 1

Wait 3

Do

If Pinb.0 = 0 Then
Waitms 200
Incr W
End If

If Pinb.2 = 0 Then
Waitms 200
Decr W
End If


If W = 1 Then
Cls
Tampil1 = Simpan1
Upperline
Lcd "Data ke " ; W
Lowerline
Lcd Tampil1
Waitms 500

Elseif W = 2 Then
Cls
Tampil2 = Simpan2
Upperline
Lcd "Data ke " ; W

Lowerline
Lcd Tampil2
Waitms 500

Elseif W = 3 Then
Cls
Tampil3 = Simpan3
Upperline
Lcd "Data ke " ; W

Lowerline
Lcd Tampil3
Waitms 500

Elseif W = 4 Then
Cls
Tampil4 = Simpan4
Upperline
Lcd "Data ke " ; W

Lowerline
Lcd Tampil4
Waitms 500

Elseif W = 5 Then
Cls
Tampil5 = Simpan5
Upperline
Lcd "Data ke " ; W

Lowerline
Lcd Tampil5
Waitms 500

Elseif W = 6 Then
Cls
Tampil6 = Simpan6
Upperline
Lcd "Data ke " ; W

Lowerline
Lcd Tampil6
Waitms 500

Elseif W = 7 Then
Cls
Tampil7 = Simpan7
Upperline
Lcd "Data ke " ; W

Lowerline
Lcd Tampil7
Waitms 500

Elseif W = 8 Then
Cls
Tampil8 = Simpan8
Upperline
Lcd "Data ke " ; W

Lowerline
Lcd Tampil8
Waitms 500

Elseif W = 9 Then
Cls
Tampil9 = Simpan9
Upperline
Lcd "Data ke " ; W

Lowerline
Lcd Tampil9
Waitms 500

Elseif W = 10 Then
Cls
Tampil10 = Simpan10
Upperline
Lcd "Data ke " ; W

Lowerline
Lcd Tampil10
Waitms 500

End If


If Pinb.1 = 0 Then
Waitms 200
Cls
Goto Main
End If

If W > 10 Then
W = 1
End If

If W < 1 Then
W = 10
End If

Loop




d. Cara Penggunaan Alat

           Cara penggunaan alat ini yaitu pertama hubungkan power supply 12 volt ke minimum system, kemudian hubungkan rangkaian LDR ke port ADC mikrokontroller, setelah itu akan terlihat nilai intensitas cahayanya di LCD display. terdapat rumus yang digunakan untuk mengukur tingkat kekeruhan air, nilai tersebut bisa disimpan sebanyak 10 kali. jadi tiap pengukuran bisa disimpan ke eeprom dengan menggunakan tombol save. untuk melihat data yang disimpan tekan tombol tampil.  









 

No comments:

Post a Comment