LAMPIRAN A Prosedur Pengoperasian Sistem
xxi
LA.1. Prosedur Pengoperasian Alat Bagian ini menjelaskan tentang bagaimana cara mengoperasikan alat pengukur tingkat kematangan buah yang telah dirancang.Komponen yang diperlukan adalah alat pengukur tingkat kematangan buah dan driver (CP210x_VCP_Windows) untuk alat tersebut. Pertama, sambungkan listrik PLN pada soket 220VAC. Kemudian, sambungkan alat pengukur tingkat kematangan buah dengan komputer menggunakan kabel USB melalui USB Port.Perhatikan lampu indicator.Jika lampu indicator menyala berarti alat sudah mendapatkan arus listrik.Komputer akan melakukan auto detect terhadap alat tersebut. Kemudian, install driver (CP210x_VCP_Windows) untuk alat pengukur tingkat kematangan buah.
Gambar LA.1. Soket 220V AC Setelah
driver
terpasangkan,
lepaskan
kabel
USB
dari
komputer.Kemudian, pasang kembali, 3 buah lampu indikator pada alat akan berkedip yang menandakan proses inisialisasi alat.Lalu, pasangkan sensor ultrasonik sesuai dengan simbol “T” dan “R”.
xxii
Gambar LA.2. Lampu Indikator dan USB Port Lakukan koneksi dari program MatLab ke alat dan tunggu lampu indikator “C”yang menandakan alat sudah terhubung dengan program MatLab menyala. Tempelkan probe transduser pada buah dengan posisi berseberangan pada buah. Kemudian tekan tombol“Trigger” yang berada di kananlampu kontol untuk memulai proses pembacaan buah.
Gambar LA.3. Keterangan Alat xxiii
Setelah tombol ditekan, lampu “P”akan menyala yang menandakan proses pembacaan tingkat kandungan air dan tekstur buah serta proses Analog to Digital Converter sedang berlangsung. Setelah lampu proses padam, disusul dengan lampu “S” menyala yang menandakan proses pengiriman data hasil pengukuran buah sedang dikirimkan ke program MatLab. Setelah pengiriman data selesai, alat kembali dalam posisi standby dan siap untuk melakukan pengukuran kembali pada buah lainnya. Untuk melepas alat dari komputer, lakukan disconnect dari program MatLab atau tutup program MatLab terlebih dahulu dan tunggu hingga lampu “C” tidak lagi menyala yang menandakan alat sudah tidak terkoneksi dengan program MatLab. Setelah lampu koneksi padam, maka alat sudah dapat dilepaskan dari komputer dengan mencabut kabel USB dan mencabut soket 220VAC.
LA.2. Prosedur Penggunaan Program MatLab Bagian ini menjelaskan tentang bagaimana cara menggunakan program MatLab yang telah dirancang. Lakukan install terhadap program stand alone MatLab pada komputer dan kemudian buka program tersebut. Setelah alat dihubungkan dengan komputer, lakukan pemilihan terhadap port yang menjadi koneksi dari komputer ke alat.Kemudian, tekan tombol connect untuk melakukan koneksi dengan alat. Koneksi berhasil ditandai dengan berubahnya tombol connect menjadi disconnect. Selanjutnya, melakukan pemilihan terhadap jenis buah yang ingin dilakukan pembacaan tingkat kematangannya.Jenis buah yang dapat dipilih
xxiv
terdapat pada bagian “Pilih Buah”. Tidak tepatnya pemilihan jenis buah akan mengalami pembacaan tingkat kematangan buah tidak tepat. Kemudian, menunggu alat memulai proses pembacaan dan mengirimkan datanya ke program MatLab. Ketika data diterima, maka akan ditampilkan pada program MatLab sehingga pengguna dapat melihat tingkat kematangan buah. Jika ingin melakukan pembacaan berikutnya, cukup menunggu saja data dari alat. Tapilan akan dibersihkan dan diganti dengan data pembacaan yang baru. Ketika selesai menggunakan program, lakukan disconnect terlebih dahulu dan kemudian keluar dari program atau dapat langsung menekan tombol “Exit” atau menggunakan tanda silang yang terdapat pada kanan atas dari tampilan program tanpa melakukan disconnect terlebih dahulu.
xxv
LAMPIRAN B Data Hasil Penelitian
xxvi
LB.1. Uji Lab Model empiris
Gambar LB.1. Uji Laboratorium Model empiris
xxvii
LB.2. Data Percobaan
Gambar LB.2. Uji Laboratorium Data Percobaan
xxviii
Tabel LB.1. Data Uji Pengetahuan Manusia Buah Alpukat. Hasil Pembacaan Alat Sampel
Kadar Air (%)
Kekerasan
87.74
0.55
86.21
0.58
88.11
0.54
85.47 85.89 86.32 87.45 86.94 85.71
0.63 0.71 0.6 0.75 0.77 0.8
87.53
0.57
error 85.79 86.23 86.92 87.53 87.42 86.59 86.75 87.45 86.9 87.65 85.74 85.93 86.74
error 0.6 0.7 0.68 0.66 0.71 0.74 0.69 0.73 0.73 0.7 0.79 0.77 0.8
87.86
0.55
87.65
0.57
86.25 86.73 87.86 86.61 error error 86.53
0.6 0.69 0.71 0.75 error error 0.68
1
2
3
4
5
8
9
10
11
12
13
Kematangan Lewat Matang Matang Lewat Matang Matang Matang Matang Matang Matang Mengkal Lewat Matang error Matang Matang Matang Matang Matang Matang Matang Mengkal Matang Matang Mengkal Matang Mengkal Lewat Matang Lewat Matang Matang Matang Matang Matang error error Matang
xxix
Hasil Analisa Manusia Persentase Kematangan
Kematangan
142.73 124.84
Lewat Matang
145.85 102.43 100 103.38 99.32 98.43 87.83
Matang
Matang
132.41 error 102.63 100 98.65 99.42 98.63 97.49 102.48 94.83 97.82 98.64 89.94 96.26 88.58
Lewat Matang
Matang
Matang
Matang
Mengkal
138.95 133.56 119.28 104.58 101.37 97.94 error error 105.93
Lewat Matang
Matang
Matang
14
16
17
18
19
20
21
23
24
25
26
27
86.38 87.95
0.57 0.6
88.74
0.57
86.94 86.16 85.86 86.94 86.16 85.86 87.34 87.91 87.2 86.92 86.96 87.42 error
0.68 0.7 0.7 0.71 0.73 0.68 0.74 0.77 0.71 0.67 0.7 0.7 error
86.23
0.56
85.58
0.59
86.74 86.92 85.94 87.75
0.68 0.71 0.7 0.58
88.02
0.56
87.3 86.49 86.63 86.93 85.94 86.62 86.09
0.6 0.73 0.75 0.74 0.74 0.76 0.73
87.43
0.54
87.82
0.55
88.03 88.31
0.57 0.59
88.72
0.56
error
error
Matang Matang Lewat Matang Matang Matang Mengkal Matang Matang Matang Matang Matang Matang Matang Matang Matang error Lewat Matang Lewat Matang Matang Matang Matang Matang Lewat Matang Matang Matang Matang Matang Matang Matang Matang Lewat Matang Lewat Matang Matang Matang Lewat Matang error
xxx
126.84 120.36
Lewat Matang
128.48 106.48 100 97.53 101.28 102.83 105.39 96.48 94.2 98.35 107.28 100 101.47 error
Matang
Matang
Matang
Matang
128.93 Lewat Matang 124.57 106.48 98.67 101.24 127.85 131.39 117.48 97.36 95.86 96.46 95.86 94.67 98.42
Matang
Lewat Matang
Matang
Matang
134.83 132.45
Lewat Matang
131.57 126.78 126.46 error
Lewat Matang
28
29
87.67
0.56
87.38
0.59
87.95
0.59
85.48 85.93 84.99
0.79 0.81 0.78
Lewat Matang Matang Lewat Matang Mengkal Mengkal Matang
132.78 118.37
Lewat Matang
124.92 88.85 86.48 93.47
Mengkal
Tabel LB.2. Data Uji Lab IPB Buah Alpukat. No. Sampel
6
Hasil Pembacaan Alat
Kadar Air (%) 84.51 85.12 86.08 85.23 84.89 85.42 error 86.55 error 85.24
7
87.99 86.51 89.34 error 88.21 86.87 87.37 87.83
15
85.98 87.31 87.01 error error 86.55
Hasil Analisa Lab IPB Kadar Persentase Kekerasan Kematangan Kekerasan Kematangan Air (%) Kematangan 0.65 Matang 121.03 0.68 Matang 123.51 0.77 Mentah 79.71 0.61 Matang 115.91 0.51 Matang 134.48 Lewat 157.61 0.45 Matang 85.99 0.55 Matang error error error Lewat 152.43 0.63 Matang error error error Lewat 147.89 0.6 Matang 0.55 Matang 124.89 0.61 Matang 103.73 0.79 Matang 100 error error error 0.77 Mengkal 84.71 Matang 88.77 0.65 0.7 Mentah 80.43 0.69 Matang 98.01 Lewat 139.04 0.59 Matang 0.63 Matang 119.32 0.66 Matang 106.87 0.6 Matang 97.89 error error error Matang 87.38 0.69 error error error 0.64 Matang 101.23
xxxi
22
30
86.71 87.98 88.01 error 87.67 87.34 85.55 85.98 87.03 86.71 error 86.88 86.01 87.02 86.91 error 84.4 83.56 84.23
0.65 0.71 0.63 error 0.68 0.66 0.79 0.8 0.76 0.75 error 0.69 0.74 0.75 0.71 error 0.69 0.65 0.61
82.99
0.41
83.76 84.55 84.32 error 84.14 error
0.57 0.64 0.64 error 0.65 error
Matang Mengkal Mengkal error Matang Matang Mengkal Mengkal Matang Matang error Matang Matang Matang Matang error Matang Matang Matang Lewat Matang Matang Mengkal Mengkal error Matang error
98.41 85.49 87.34 error 97.99 98.51 87.56 85.31 98.54 99.87 error 97.5 98.13 100 99.52 error 93.47 96.77 97.62
Matang
86.35
0.72
Matang
83.95
0.59
124.03 100 89.33 87.51 error 91.05 error
Tabel LB.3. Data Uji Pengetahuan Manusia Buah Mangga. Hasil Pembacaan Alat Sampel
1
3 4
Kadar Air (%) 87.14 86.93 86.84 86.12 86.58 87.84 85.54 86.34
Kekerasan
Kematangan
0.77 0.8 0.83 0.82 0.8 0.76 0.9 0.88
Matang Matang Matang Matang Matang Matang Mengkal Matang
xxxii
Hasil Analisa Manusia Persentase Kematangan 101.83 100 98.43 102.23 101.89 104.27 80.29 96.39
Kematangan Matang
Matang Matang
6
7
8
9
10
11
12
13
14
15
17
18
19
87.58
0.79
87.89
0.67
error 87.43 86.86 86.69 86.21 86.31 86.03 86.99 error 86.4 86.23 87.69 87.36 86.31 86.46 86.68 error 84.92 85.37 85.98 86.86 error 87.2 84.68 84.93 85.87 85.03 84.98 84.67 86.64 86.69 86.31 87.98 86.34 86.54 error
error 0.7 0.79 0.8 0.84 0.85 0.81 0.79 error 0.88 0.85 0.78 0.76 0.83 0.8 0.8 error 0.97 0.95 0.94 0.75 error 0.78 0.97 0.96 0.93 0.96 0.95 0.97 0.87 0.85 0.84 0.79 0.8 0.83 error
88.02
0.66
87.89
0.69
Matang Lewat Matang error Matang Matang Matang Matang Matang Matang Matang error Matang Matang Matang Matang Matang Matang Matang error Mentah Mengkal Mengkal Matang error Matang Mentah Mentah Mengkal Mentah Mengkal Mentah Matang Matang Matang Matang Matang Matang error Lewat Matang Lewat xxxiii
102.64 134.87 error 108.34 105.84 99.75 97.48 96.86 98.63 104.83 error 95.38 96.49 102.48 105.39 98.92 98.29 98.58 error 82.94 89.84 91.27 106.48 error 103.38 83.49 85.94 92.64 86.53 88.35 85.47 95.37 97.25 97.79 103.64 97.3 96.68 error 130.38 128.64
Lewat Matang
Matang
Matang
Matang Matang Matang
Mentah
Matang
Mentah
Mentah
Matang
Matang
Lewat Matang
87.79 86.56 87.74 87.47 87.68 87.36 85.84 85.31 86.02 86.63 86.32 86.78 86.61 85.84 error 85.57 84.78 86.21 87.98 86.58 86.39 87.84 87.53 86.93 85.68 86.13 85.99
20
21
23
24
25
27
28
29
30
0.79 0.82 0.77 0.76 0.78 0.74 0.97 0.96 0.94 0.87 0.85 0.88 0.86 0.9 error 0.9 0.93 0.88 0.79 0.83 0.81 0.75 0.76 0.79 0.9 0.88 0.89
Matang Matang Matang Matang Matang Matang Matang Mentah Mentah Mengkal Matang Matang Mengkal Matang Mengkal error Mengkal Mengkal Matang Matang Matang Matang Matang Matang Matang Mengkal Matang Mengkal
102.48 96.69 104.58 107.59 104.51 110.58 85.79 88.39 90.28 98.48 98.59 96.46 100 94.84 error 93.98 91.38 97.58 105.39 98.36 100 104.68 103.57 100 95.38 97.46 97.98
Matang
Matang
Mentah
Matang Matang
Mentah
Matang
Matang
Mentah
Tabel LB.4. Data Uji Lab IPB Buah Mangga. No. Sampel
2
Hasil Pembacaan Alat
Kadar Air (%) 81.31 82.45 error 80.44 82.39 81.64
Hasil Analisa Lab IPB Kadar Persentase Kekerasan Kematangan Kekerasan Kematangan Air (%) Kematangan 0.87 Matang 100 0.75 Matang 102.47 error error error Matang 80.8 0.86 0.78 Matang 101.57 0.87 Matang 118.55 0.78 Matang 101.98
xxxiv
5
16
22
26
80.51
0.78
79.77 78.45 81.6 83.32
0.88 0.87 0.87 0.78
86.64
0.68
83.39 error
0.81 error
84.44
0.64
83.62 83.78 83.33 error
0.74 0.75 0.68 error
84.87
0.61
85.47 84.42 84.78 86.33 error 85.73 86.54 84.99 86.23 85.66 86.8 86.53 85.99 85.98 86.34 error 86.51 87.2 86.89 87.03
0.79 0.88 0.87 0.95 error 0.89 0.89 0.91 0.9 0.85 0.88 0.7 0.85 0.92 0.91 error 0.86 0.81 0.83 0.9
86.05
0.69
85.06 85.51
0.72 0.75
Lewat Matang Mengkal Matang Matang Matang Lewat Matang Matang error Lewat Matang Matang Matang Matang error Lewat Matang Matang Matang Matang Mengkal error Matang Matang Mengkal Mengkal Matang Matang Matang Matang Mengkal Mengkal error Matang Matang Matang Mengkal Lewat Matang Matang Matang
102.5 89.66 97.82 100 98.55 142.71 95.99 error 125.41
83.45
0.76
Mengkal
85.91
0.93
Matang
86.76
0.89
Matang
85.98
0.77
129.76 103.28 93.48 100 87.47 error 99.56 101.34 92.67 93.2 97.93 101.25 109.47 100 89.35 92.98 error 102.74 101.38 103.32 90.02 135.34 104.77 102.39
xxxv
Matang
110.61 110.98 111.83 error
85.78 86.98 86.23 85.43 84.99 86.21 error
0.8 0.82 0.8 0.79 0.73 0.8 error
Matang Mengkal Matang Matang Matang Matang error
97.74 92.21 95.98 100 96.21 94.8 error
Tabel LB.5. Data Uji Pengetahuan Manusia Buah Pepaya. Sampel 1
2
3
4
5
Kadar Air (%) 87.39 86.85 86.95 90.54 91.23 error 88.91 87.49 87.12 86.48 87.13 87.69 error 88.43 90.28
7
8
9
Kekerasan
Kematangan
0.83 0.8 0.84 0.49 0.53 error 0.89 0.88 0.88 0.85 0.87 0.84 error 0.89 0.92
Matang Matang Matang Busuk Busuk error Matang Matang Matang Matang Matang Matang error Matang Mengkal Lewat Matang Matang Lewat Matang Lewat Matang Lewat Matang Lewat Matang Matang Matang Lewat Matang
87.84
0.79
87.12
0.82
88.48
0.75
89.54
0.73
88.29
0.77
88.47
0.76
87.59 86.43
0.84 0.81
87.56
0.78
xxxvi
Persentase Kematangan 102.37 107.29 101.48 163.29 154.75 error 98.27 96.48 97.38 100 98.38 102.64 error 95.39 89.29
Kematangan Matang Busuk
Matang
Matang
Matang
128.38 109.32
Lewat Matang
131.49 137.28 127.45
Lewat Matang
130.28 103.72 108.63 127.39
Matang
11
12
13
14
15
16
18
20
21
22
23
86.98 87.01 87.26 error 89.46 error
0.86 0.84 0.84 error 0.9 error
88.59
0.76
87.39
0.8
88.46
0.79
87.95
0.76
87.88
0.77
89.47
0.74
88.38
0.72
87.19
0.74
89.74
0.75
87.5 86.95 87.64 87.59 88.14 88.36 89.03 90.72 90.43
0.81 0.83 0.84 0.88 0.85 0.86 0.96 0.99 0.99
88.92
0.75
87.59
0.77
87.28
0.75
87.35 87.64 error
0.83 0.82 error
86.89
0.79
87.59
0.77
Matang Matang Matang error Mengkal error Lewat Matang Matang Lewat Matang Lewat Matang Lewat Matang Lewat Matang Lewat Matang Lewat Matang Lewat Matang Matang Matang Matang Matang Matang Matang Mengkal Mentah Mentah Lewat Matang Lewat Matang Lewat Matang Matang Matang error Lewat Matang Lewat
xxxvii
98.74 100 101.84 error 89.72 error
Matang
Mengkal
128.38 110.92
Lewat Matang
126.47 129.94 127.38
Lewat Matang
130.28 131.74 129.93
Lewat Matang
127.48 105.26 103.85 102.19 97.39 100 98.38 85.18 80.57 79.98
Matang
Matang
Mentah
129.38 128.84
Lewat Matang
128.59 104.28 106.85 error 127.83 129.84
Matang
Lewat Matang
24
25
26
27
28
30
87.37 90.83 89.26 87.94 87.38 87.99 88.38 87.59 87.89 86.28 88.48 90.26 87.39 87.59 88.39 87.94 error
0.8 0.93 0.91 0.88 0.86 0.86 0.89 0.84 0.85 0.87 0.89 0.9 0.86 0.83 0.81 0.8 error
89.74
0.77
87.29
0.8
Matang Matang Mengkal Mengkal Matang Matang Matang Matang Matang Matang Matang Matang Mengkal Matang Matang Matang Matang error Lewat Matang Matang
107.64 89.34 92.55 96.39 98.27 98.77 95.39 102.38 100 96.37 96.29 93.22 97.84 106.62 106.39 108.64 error 130.26
Mengkal
Matang
Matang
Matang
Matang
Matang
107.75
Tabel LB.6. Data Uji Lab IPB Buah Pepaya. No. Sampel
Hasil Pembacaan Alat
Kadar Air (%) 88.06 88.67 89.21 88.38
6
89.52 88.79 89.33 89.57 error error
Hasil Analisa Lab IPB Kadar Persentase Kekerasan Kematangan Kekerasan Kematangan Air (%) Kematangan Lewat 135.92 0.72 Matang Lewat 145.62 0.65 Matang Lewat 146.28 0.66 Matang Lewat 133.87 0.74 Lewat Matang 89.24 0.7 Matang 0.8 Matang 119.63 0.79 Matang 121.29 0.81 Matang 117.78 Lewat 130.63 0.75 Matang error error error error error error
xxxviii
10
17
19
29
86.86 86.97 87.42 87.53 87.97 86.79 88.02 error 86.99 87.78
0.8 0.82 0.89 0.85 0.9 0.92 0.84 error 0.9 0.83
87.55
0.7
87.67
0.63
87.91
0.69
error 86.69 88.03
error 0.78 0.75
87.7
0.75
87.82
0.8
86.87
0.74
error 88.68 89.03 89.64 error 89.85 89.63 88.85 88.03 error 88.95 89.9 90.31 88.86 error 90.43 89.75 88.9
error 0.9 0.92 0.85 error 0.87 0.91 0.88 0.9 error 0.8 0.89 0.95 0.9 error 0.86 0.91 0.85
Matang Matang Matang Matang Mengkal Mengkal Matang error Mengkal Matang Lewat Matang Lewat Matang Lewat Matang error Matang Matang Lewat Matang Matang Lewat Matang error Mengkal Mengkal Matang error Matang Mengkal Matang Mengkal error Matang Mengkal Mengkal Mengkal error Matang Mengkal Matang
105.23 108.8 98.23 100 89.38 92.64 100 error 88.82 98.73
87.63
0.85
Lewat Matang
87.24
0.74
Mengkal
90.67
0.98
Mengkal
90.23
0.91
135.83 144.34 141.85 error 120.36 122.84 132.75 105.73 134.52 error 89.64 90.53 100 error 98.75 89.92 103.62 88.97 error 109.64 91.93 84.62 88.64 error 97.88 88.23 100
xxxix
Matang
89.85 89.94 88.87
0.89 0.88 0.84
Mengkal Matang Matang
93.72 95.83 101.23
xl
LAMPIRAN C Dokumentasi Penelitian
xli
Gambar LC.1. Form Penyerahan Uji Lab Sampel Model empiris
xlii
Gambar LC.2. Form Penyerahan Uji Lab Sampel Data Percobaan
xliii
Gambar LC.3. Foto 1 Pengambilan Data Sebelum Uji Lab
xliv
Gambar LC.4. Foto 2 Pengambilan Data Sebelum Uji Lab
xlv
Gambar LC.5. Foto 1 Uji Buah Berdasarkan Pengetahuan Manusia
Gambar LC.6. Foto 2 Uji Buah Berdasarkan Pengetahuan Manusia
xlvi
LAMPIRAN D Coding Peranti Lunak
xlvii
LD.1. Coding Alat Modul Main #include <mega8.h> #include <delay.h> #include <string.h> #include
#include #include #include <stdio.h>
#define TRUE
1
#define FALSE
0
#define LED_ON
0
#define LED_OFF
1
#define CONNECT
PORTB.0
#define PROCESS
PORTB.4
#define SENDING
PORTB.5
#define TRIGGER
PIND.3
void Initialization(void); void Processing(unsigned char *Data1, unsigned char *Data2, unsigned char *Data3, unsigned char *Data4, unsigned char *Data5, unsigned char *Data6); unsigned char Connecting(void); unsigned char Disconnect(void);
xlviii
unsigned char Sending(unsigned char *Data1, unsigned char *Data2, unsigned char *Data3, unsigned char *Data4, unsigned char *Data5, unsigned char *Data6);
void main(void) { unsigned char Tries, Status=FALSE; unsigned char Texture1[4], Water1[4]; unsigned char Texture2[4], Water2[4]; unsigned char Texture3[4], Water3[4];
Initialization();
while(1) { while(Connecting() == FALSE); Status = TRUE;
while(1) { while(TRIGGER == TRUE) { if(Disconnect() == TRUE) {
xlix
Status = FALSE; break; } }
if(Status == FALSE) break;
Processing(Texture1, Water1, Texture2, Water2, Texture3, Water3);
for(Tries=0;Tries<3;Tries++) { if(Sending(Texture1, Water1, Texture2, Water2, Texture3, Water3) == TRUE) break; }
if(Tries == 3) SENDING = LED_OFF;
while(TRIGGER == FALSE); } } }
l
void Initialization(void) { DDRB = 0xFF; //DDRC = 0xFF; DDRD = 0x00;
CONNECT = LED_ON; PROCESS = LED_ON; SENDING = LED_ON; delay_ms(250); CONNECT = LED_OFF; PROCESS = LED_OFF; SENDING = LED_OFF;
//PORTC = 0x00; PORTD = 0xFF; Init_UART(9600); ADMUX = 0x00; ADCSRA = 0x81; PORTB.1 = 0; PORTB.2 = 0; //TCCR1A = 0xA2; //TCCR1B = 0x18; //OCR1A = 0x0000;
li
//OCR1B = 0x0000; }
unsigned char Connecting(void) { unsigned char Chk_Con;
Chk_Con = Receive_Data(0); if(Chk_Con == 'C') { Send_Data("C"); Chk_Con = Receive_Data(500); if(Chk_Con == 'Y') { CONNECT = LED_ON; return TRUE; } else return FALSE; } else return FALSE; }
lii
unsigned char Disconnect(void) { unsigned char Chk_Con;
Chk_Con = Receive_Data(5); if(Chk_Con == 'D') { Send_Data("D"); CONNECT = LED_OFF; return TRUE; } else return FALSE; }
void Processing(unsigned char *Data1, unsigned char *Data2, unsigned char *Data3, unsigned char *Data4, unsigned char *Data5, unsigned char *Data6) { int TryCalc; unsigned char tmpData1[2]; unsigned char tmpData2[2]; unsigned char tmpData3[2]; unsigned char tmpData4[2]; unsigned char tmpData5[2];
liii
unsigned char tmpData6[2];
PROCESS = LED_ON;
TryCalc = 0; memset(tmpData1, 0x00, sizeof(tmpData1)); while((tmpData1[0] == 0x00) && (tmpData1[1] == 0x00) && (TryCalc < 3)) { Frequency_35KHz(); Read_ADC(0, tmpData1); TryCalc++; }
delay_ms(1000);
// need delay to clear the sound first
TryCalc = 0; memset(tmpData2, 0x00, sizeof(tmpData2)); while((tmpData2[0] == 0x00) && (tmpData2[1] == 0x00) && (TryCalc < 3)) { Frequency_45KHz(); Read_ADC(0, tmpData2); TryCalc++; }
liv
delay_ms(1000);
// need delay to clear the sound first
TryCalc = 0; memset(tmpData3, 0x00, sizeof(tmpData3)); while((tmpData3[0] == 0x00) && (tmpData3[1] == 0x00) && (TryCalc < 3)) { Frequency_35KHz(); Read_ADC(0, tmpData3); TryCalc++; }
delay_ms(1000);
// need delay to clear the sound first
TryCalc = 0; memset(tmpData4, 0x00, sizeof(tmpData4)); while((tmpData4[0] == 0x00) && (tmpData4[1] == 0x00) && (TryCalc < 3)) { Frequency_45KHz(); Read_ADC(0, tmpData4); TryCalc++; }
delay_ms(1000);
// need delay to clear the sound first
lv
TryCalc = 0; memset(tmpData5, 0x00, sizeof(tmpData5)); while((tmpData5[0] == 0x00) && (tmpData5[1] == 0x00) && (TryCalc < 3)) { Frequency_35KHz(); Read_ADC(0, tmpData5); TryCalc++; }
delay_ms(1000);
// need delay to clear the sound first
TryCalc = 0; memset(tmpData6, 0x00, sizeof(tmpData6)); while((tmpData6[0] == 0x00) && (tmpData6[1] == 0x00) && (TryCalc < 3)) { Frequency_45KHz(); Read_ADC(0, tmpData6); TryCalc++; }
memset(Data1, 0x00, sizeof(Data1)); sprintf(Data1, "%X%X", tmpData1[0], tmpData1[1]); memset(Data2, 0x00, sizeof(Data2)); sprintf(Data2, "%X%X", tmpData2[0], tmpData2[1]);
lvi
memset(Data3, 0x00, sizeof(Data3)); sprintf(Data3, "%X%X", tmpData3[0], tmpData3[1]); memset(Data4, 0x00, sizeof(Data4)); sprintf(Data4, "%X%X", tmpData4[0], tmpData4[1]);
memset(Data5, 0x00, sizeof(Data5)); sprintf(Data5, "%X%X", tmpData5[0], tmpData5[1]); memset(Data6, 0x00, sizeof(Data6)); sprintf(Data6, "%X%X", tmpData6[0], tmpData6[1]);
PROCESS = LED_OFF; }
unsigned char Sending(unsigned char *Data1, unsigned char *Data2, unsigned char *Data3, unsigned char *Data4, unsigned char *Data5, unsigned char *Data6) { unsigned char ACK;
SENDING = LED_ON;
Send_Data(Data1); ACK = Receive_Data(500); if(ACK != 'S')
lvii
return FALSE;
Send_Data(Data2); ACK = Receive_Data(500); if(ACK != 'S') return FALSE;
Send_Data(Data3); ACK = Receive_Data(500); if(ACK != 'S') return FALSE;
Send_Data(Data4); ACK = Receive_Data(500); if(ACK != 'S') return FALSE;
Send_Data(Data5); ACK = Receive_Data(500); if(ACK != 'S') return FALSE;
Send_Data(Data6); ACK = Receive_Data(500);
lviii
if(ACK != 'S') return FALSE;
SENDING = LED_OFF; return TRUE; }
Modul ADClib #include <mega8.h> #include <delay.h> #include <string.h>
#define mode_ADC 0x00 // 0x00 for ADLAR = 0, 0x20 for ADLAR = 1
void Read_ADC(unsigned char pin_adc, unsigned char *Data) { unsigned char pADCH, pADCL;
//DDRC = 0x00; //PORTC = 0x00; delay_ms(2000); memset(Data, 0x00, sizeof(Data)); while(1) {
lix
ADMUX = pin_adc | mode_ADC; ADCSRA |= 0x40; while((ADCSRA & 0x10) == 0); ADCSRA |= 0x10;
pADCL = ADCL; pADCH = ADCH & 0x03;
if(Data[0] < pADCH) Data[1] = 0x00;
if((Data[0] <= pADCH) && (Data[1] < pADCL)) { Data[0] = pADCH; Data[1] = pADCL; } else { TCCR1A = 0x00; TCCR1B = 0x00; PORTB.1 = 0; PORTB.2 = 0; //TCCR1B = 0x18; break;
lx
} delay_ms(500); }
//DDRC = 0xFF; //PORTC = 0x00; }
Modul Ultrasoniclib #include <mega8.h>
void Frequency_35KHz(void) { TCCR1A = 0xA2; //TCCR1B = 0x18; TCCR1B = 0x1A; ICR1 = 0x001B; OCR1A = 0x0018; OCR1B = 0x0018; }
void Frequency_45KHz(void) { TCCR1A = 0xA2;
lxi
//TCCR1B = 0x18; TCCR1B = 0x1A; //ICR1 = 0x0018; ICR1 = 0x0015; OCR1A = 0x0012; OCR1B = 0x0012; }
Modul UARTlib #include <mega8.h> #include <stdio.h> #include <delay.h>
void Init_UART(unsigned long int baud_rate) { const long int oscilator = 8000000; unsigned long int UBRR;
UBRR = (oscilator/(16*baud_rate))-1; UBRRL = UBRR; UBRRH = UBRR>>8; UCSRB = 0x18; UCSRC = 0x86; }
lxii
unsigned char Receive_Data(int Delay) { if(Delay > 0) { while( !(UCSRA & 0x80) ) { delay_ms(1); Delay--; if(Delay == 0) return 0; } return UDR; } else return getchar(); }
void Send_Data(unsigned char *Data) { delay_ms(10);
// need delay to clear the transmition
puts(Data); }
LD.2. Coding Aplikasi
lxiii
function varargout = SoftComputing(varargin) % SOFTCOMPUTING MATLAB code for SoftComputing.fig % SOFTCOMPUTING, by itself, creates a new SOFTCOMPUTING or raises the existing % singleton*. % % H = SOFTCOMPUTING returns the handle to a new SOFTCOMPUTING or the handle to % the existing singleton*. % % SOFTCOMPUTING('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in SOFTCOMPUTING.M with the given input arguments. % % SOFTCOMPUTING('Property','Value',...) creates a new SOFTCOMPUTING or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before SoftComputing_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to SoftComputing_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help SoftComputing % Last Modified by GUIDE v2.5 15-Sep-2013 11:28:53 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @SoftComputing_OpeningFcn, ... 'gui_OutputFcn', @SoftComputing_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT
% --- Executes just before SoftComputing is made visible.
lxiv
function SoftComputing_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to SoftComputing (see VARARGIN) % Choose default command line output for SoftComputing handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes SoftComputing wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. function varargout = SoftComputing_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output;
% Create Own Function --Start function Main_Idle(hObject, eventdata, handles) handles = guidata(handles) RetVal = open_serial(handles.com) if RetVal == 0 set(handles.pushbutton1, 'String', 'Connect') handles.con_stat = false stop(handles.idle_loop) guidata(handles.guifig, handles) return end Water1 = fgetl(handles.com) if isempty(Water1) fclose(handles.com) return end fwrite(handles.com, 'S') Texture1 = fgetl(handles.com) if isempty(Texture1) fclose(handles.com) return end fwrite(handles.com, 'S')
lxv
Water2 = fgetl(handles.com) if isempty(Water2) fclose(handles.com) return end fwrite(handles.com, 'S') Texture2 = fgetl(handles.com) if isempty(Texture2) fclose(handles.com) return end fwrite(handles.com, 'S') Water3 = fgetl(handles.com) if isempty(Water3) fclose(handles.com) return end fwrite(handles.com, 'S') Texture3 = fgetl(handles.com) if isempty(Texture3) fclose(handles.com) return end fwrite(handles.com, 'S') fclose(handles.com) TextureDec = (hex2dec(Texture1) + hex2dec(Texture2) + hex2dec(Texture3)) / 3 WaterDec = (hex2dec(Water1) + hex2dec(Water2) + hex2dec(Water3)) / 3 if (WaterDec > 50) || (TextureDec > 50) fis_figure = readfis(strcat(handles.fruit_choose, '_Air')) result_water = evalfis(WaterDec, fis_figure) fis_figure = readfis(strcat(handles.fruit_choose, '_Tekstur')) result_texture = evalfis(TextureDec, fis_figure) fis_figure = readfis(handles.fruit_choose) result_analysis = evalfis([TextureDec WaterDec], fis_figure) switch handles.fruit_choose case'Mangga' if result_analysis < 70 text_result = 'Mentah' elseif (result_analysis >= 70) && (result_analysis < 80) text_result = 'Mengkal' elseif (result_analysis >= 80) && (result_analysis < 145) text_result = 'Matang' elseif (result_analysis >= 145) && (result_analysis < 180) text_result = 'Lewat Matang' else text_result = 'Busuk' end case'Alpukat' if result_analysis < 80 text_result = 'Mentah' elseif (result_analysis >= 80) && (result_analysis < 90) text_result = 'Mengkal' elseif (result_analysis >= 90) && (result_analysis < 110)
lxvi
text_result = 'Matang' elseif (result_analysis >= 110) && (result_analysis < 130) text_result = 'Lewat Matang' else text_result = 'Busuk' end case'Pepaya' if result_analysis < 75 text_result = 'Mentah' elseif (result_analysis >= 75) && (result_analysis < 90) text_result = 'Mengkal' elseif (result_analysis >= 90) && (result_analysis < 115) text_result = 'Matang' elseif (result_analysis >= 115) && (result_analysis < 165) text_result = 'Lewat Matang' else text_result = 'Busuk' end end set(handles.edit1, 'String', strcat(sprintf('%0.2f', result_water), ' %')) set(handles.edit2, 'String', sprintf('%0.2f', result_texture)) set(handles.edit3, 'String', strcat(sprintf('%0.2f', result_analysis), ' %')) set(handles.edit4, 'String', text_result) else set(handles.edit1, 'String', 'ERROR') set(handles.edit2, 'String', 'ERROR') set(handles.edit3, 'String', 'ERROR') set(handles.edit4, 'String', 'ERROR') end guidata(handles.guifig, handles) function Ret = open_serial(serial_port) try fopen(serial_port) catch Ret = 0 figure = msgbox('Open Port Failed', 'Communication', 'error') uiwait(figure) return end Ret = 1 % Create Own Function --End
% --- Executes during object creation, after setting all properties. function figure1_CreateFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called handles.fruit_choose = 'Mangga' handles.con_stat = false handles.com = serial('COM1', 'Timeout', 1)
lxvii
handles.guifig = gcf handles.idle_loop = timer set(handles.idle_loop, 'ExecutionMode', 'fixedSpacing') set(handles.idle_loop, 'TimerFcn', {@Main_Idle, handles.guifig}) set(handles.idle_loop, 'Period', 0.1) guidata(hObject, handles)
% --- Executes on selection change in popupmenu1. function popupmenu1_Callback(hObject, eventdata, handles) % hObject handle to popupmenu1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu1 com = get(hObject, 'Value') switch com case 1 com = 'COM1' case 2 com = 'COM2' case 3 com = 'COM3' case 4 com = 'COM4' case 5 com = 'COM5' case 6 com = 'COM6' case 7 com = 'COM7' case 8 com = 'COM8' case 9 com = 'COM9' end set(handles.com, 'Port', com) guidata(hObject, handles)
% --- Executes during object creation, after setting all properties. function popupmenu1_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
lxviii
set(hObject,'BackgroundColor','white'); end
% --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) if handles.con_stat == false RetVal = open_serial(handles.com) if RetVal == 0 return end fwrite(handles.com, 'C') Data = fgetl(handles.com) if Data ~= 'C' msgbox('Connection Failed', 'Communication', 'error') return end fwrite(handles.com, 'Y') fclose(handles.com) set(handles.pushbutton1, 'String', 'Disconnect') handles.con_stat = true start(handles.idle_loop) else stop(handles.idle_loop) RetVal = open_serial(handles.com) if RetVal == 0 return end fwrite(handles.com, 'D') Data = fgetl(handles.com) if Data ~= 'D' msgbox('Connection Failed', 'Communication', 'error') return end fclose(handles.com) set(handles.pushbutton1, 'String', 'Connect') handles.con_stat = false end guidata(hObject, handles)
% --- Executes when user attempts to close figure1. function figure1_CloseRequestFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: delete(hObject) closes the figure if handles.con_stat == true stop(handles.idle_loop) RetVal = 1; try fopen(handles.com)
lxix
catch RetVal = 0 end if RetVal == 1 fwrite(handles.com, 'D') fclose(handles.com) end end delete(hObject);
% --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) close
% --- Executes when selected object is changed in uipanel2. function uipanel2_SelectionChangeFcn(hObject, eventdata, handles) % hObject handle to the selected object in uipanel2 % eventdata structure with the following fields (see UIBUTTONGROUP) % EventName: string 'SelectionChanged' (read only) % OldValue: handle of the previously selected object or empty if none was selected % NewValue: handle of the currently selected object % handles structure with handles and user data (see GUIDATA) switch get(eventdata.NewValue, 'Tag') case'radiobutton1' handles.fruit_choose = 'Mangga' case'radiobutton2' handles.fruit_choose = 'Alpukat' case'radiobutton3' handles.fruit_choose = 'Pepaya' end guidata(hObject, handles)
lxx
LAMPIRAN E Datasheet
LE.1. Datasheet Transduser Ultrasonik
lxxi
lxxii
lxxiii
LE.2. Datasheet ATMEGA8
lxxiv
lxxv
lxxvi
LE.3. Datasheet CA3130
lxxvii
lxxviii
lxxix
lxxx
LE.4. Datasheet IRF840
lxxxi
lxxxii