Pada kesempatan kali ini akan dibahs mengenai bagaimana cara mengakses sensor debu atau dust sensor yang bernama GP2Y1010A, sensor ini sangatlah bagus untuk mendeteksi partikel kecil seperti debu, partikel rokok atau yang lainnya, sensor ini bekerja dengan menggunakan sebuah detektor yang mana detektor tersebut telah dilengkapi dengan amplifier sehingga tegangan keluaran dari sensor ini cukup bisa dibaca, range pengukuran yaitu 0 volt sampai 3,75 volt. berikut adalah penjelasan tentang skematik dan programnya.
1. Minimum System ATMega8
2. Cara Mengakses dan Meng-koneksikan ke mikrokontroller
3. Cara konversi tegangan ke dust density
- Masukkan nilai dari grafik diatas sehingga seperti pada tabel berikut.
volt | dust density ( mg / m3 ) |
0.8 | 0 |
1.1 | 0.05 |
1.4 | 0.1 |
1.6 | 0.17 |
2.2 | 0.23 |
2.5 | 0.28 |
2.8 | 0.34 |
3.4 | 0.39 |
3.5 | 0.45 |
3.75 | 0.54 |
- Kemudian pilih persamaan garis liniear dan akan didapatkan rumusnya
4. Program Bascom AVR
$regfile = "m8def.dat"
$crystal = 8000000
Config Lcdpin = Pin , Rs = Portd.6 , E = Portd.4 , Db4 = Portb.1
Config Lcdpin = Pin , Db5 = Portb.2 , Db6 = Portd.2 , Db7 = Portd.3
Config Lcd = 16 * 2
Config Adc = Single , Prescaler = 64 , Reference = Avcc
Config Single = Scientific , Digits = 2
Dim Dataadc As Word
Dim V1 As Single
Dim V2 As Single
Dim Vol As String * 5
Dim Dustval As Single
Ddrb.0 = 1
Portb.0 = 1
Cls
Cursor Off
Start Adc
Do
'aktif low
'GP2Y1010AU0F_SAMPLEDELAY should be 280us to perform the correct reading
'this delay should consider that ADC conversion takes 13 ADC clock cycles
'ADCtime(s) = (1/ADCclock)*13 = (1/FCPU/ADCprescaler)*13
' es (1/(8000000/64))*13 = 0.000104s = 104us
'so to perform reading at correct time
'280 - (1/FCPU/ADCprescaler)*13*1000000 , 1000000 is the conversion factor from s to us
' es. 280 - 104 = 176
Portb.0 = 0 'on
Waitus 176
Dataadc = Getadc(0)
Waitus 40
Portb.0 = 1 'off
Waitus 9680
V1 = Dataadc * 5
V2 = V1 / 1023
Vol = Fusing(v2 , "#.##")
'y = 0.166x - 0.129
Dustval = V2 * 0.166
Dustval = Dustval - 0.129
If V2 < 0.8 Then
Dustval = 0
Elseif V2 > 3.6 Then
Dustval = 0.5
End If
Lowerline
Lcd "Dust= " ; Dustval ; " mg/m3 "
Upperline
Lcd "VOLT= " ; Vol
Waitms 80
Loop
$crystal = 8000000
Config Lcdpin = Pin , Rs = Portd.6 , E = Portd.4 , Db4 = Portb.1
Config Lcdpin = Pin , Db5 = Portb.2 , Db6 = Portd.2 , Db7 = Portd.3
Config Lcd = 16 * 2
Config Adc = Single , Prescaler = 64 , Reference = Avcc
Config Single = Scientific , Digits = 2
Dim Dataadc As Word
Dim V1 As Single
Dim V2 As Single
Dim Vol As String * 5
Dim Dustval As Single
Ddrb.0 = 1
Portb.0 = 1
Cls
Cursor Off
Start Adc
Do
'aktif low
'GP2Y1010AU0F_SAMPLEDELAY should be 280us to perform the correct reading
'this delay should consider that ADC conversion takes 13 ADC clock cycles
'ADCtime(s) = (1/ADCclock)*13 = (1/FCPU/ADCprescaler)*13
' es (1/(8000000/64))*13 = 0.000104s = 104us
'so to perform reading at correct time
'280 - (1/FCPU/ADCprescaler)*13*1000000 , 1000000 is the conversion factor from s to us
' es. 280 - 104 = 176
Portb.0 = 0 'on
Waitus 176
Dataadc = Getadc(0)
Waitus 40
Portb.0 = 1 'off
Waitus 9680
V1 = Dataadc * 5
V2 = V1 / 1023
Vol = Fusing(v2 , "#.##")
'y = 0.166x - 0.129
Dustval = V2 * 0.166
Dustval = Dustval - 0.129
If V2 < 0.8 Then
Dustval = 0
Elseif V2 > 3.6 Then
Dustval = 0.5
End If
Lowerline
Lcd "Dust= " ; Dustval ; " mg/m3 "
Upperline
Lcd "VOLT= " ; Vol
Waitms 80
Loop
5. Video Hasilnya
No comments:
Post a Comment