SlideShare uma empresa Scribd logo
1 de 93
Baixar para ler offline
Perancangan Heater sebagai Pemanas
Ruangan Menggunakan Sensor Jarak Ping
   Parallax dan Sensor Suhu LM 35
                 Laporan Tugas
       Mata Kuliah Komponen Sistem Kontrol




                      oleh
                 Oka D. Saputra
                   L2F008146




          JURUSAN TEKNIK ELEKTRO
              FAKULTAS TEKNIK
          UNIVERSITAS DIPONEGORO
                SEMARANG, 2011



                        i
KATA PENGANTAR
Alhamdulillah, Segala puji hanya bagi Allah Subhànahu wa Ta’ala, atas segala
limpahan rahmat dan karunia-Nya, sehingga penyusun dapat menyelesaikan laporan
“Perancangan Heater sebagai Pemanas Ruangan Menggunakan Sensor Jarak
Ping Parallax dan Sensor Suhu LM 35 ”.
      Dalam pembuatan dan penyusunan laporan Tugas Akhir, penyusun juga
banyak mendapatkan bantuan dan dukungan dari berbagai pihak. Atas kelancaran
selama pelaksanaan Tugas Akhir dan penyusunan laporan ini, maka penyusun
mengucapkan banyak terima kasih kepada :
1. Bapak Ir. Sudjadi, M.T. selaku Ketua Jurusan Teknik Elektro Fakultas Teknik
   Universitas Diponegoro
2. Bapak Sumardi S.T., M.T. selaku dosen mata kuliah Komponen Sistem Kontrol
   yang mengarahkan penulis dalam pembuatan Tugas Akhir ini
3. Keluargaku tercinta atas segala bentuk dorongan semangat dan dukungannya.
4. Saudara Fairus yang membimbing penulis sehingga tugas akhir ini dapat
   terselesaikan.
5. teman-teman yang mengikuti kuliah Komponen Sistem Kontrol.
6. Serta semua pihak yang tidak dapat penyusun sebutkan satu-persatu.
       Penyusun menyadari bahwa masih terdapat beberapa kekurangan dalam
laporan Tugas Akhir ini. Kritik dan saran yang bersifat membangun sangat penyusun
harapkan dari semua pihak, sebagai pengalaman dan tambahan pengetahuan bagi
penyusun.

       Akhir kata semoga karya ini tidak menjadi yang pertama sekaligus yang
terakhir dan semoga laporan ini dapat bermanfaat bagi mahasiswa Teknik Elektro
Universitas Diponegoro pada khususnya dan masyarakat pada umumnya.

                                                       Semarang, Desember 2011

                                                                        Penyusun




                                        ii
Abstrak
        Banyak Aplikasi yang dapat kita terapkan ketika kita membahas tentang
sistem kontrol. Salah satunya pemanfaatan kemajuan teknologi sensor seperti sensor
jarak ping produksi Parallax, sensor suhu LM 35 dari National Semiconductor dan
juga actuator Heater (dalam hal ini solder) untuk pengendalian suhu ruangan yang
terlalu dingin. Tujuan dari paper ini adalah merancang dan membuat alat yang
dapat mengontrol suhu ruangan dan mendeteksi ada tidaknya pengguna didalam
ruangan tersebut. Dalam perancangan alat, ada beberapa elemen yang menjadi
parameter sebagai inputan agar heater aktif, dalam simulasi ini digunakan sebagai
jarak terdekat antara pengguna ruangan dengan heater adalah 20 cm sedangkan
untuk jarak terjauh adalah 120 cm sedangkan untuk suhu terpanas yang menjadikan
heater off adalah 33ºC.

Keywords — Sensor Ping, Sensor LM35, Heater




                                        iii
DAFTAR ISI


HALAMAN JUDUL ………………………………………………………                    i
KATA PENGANTAR …………………… ……………………………….                  ii
ABSTRAK ……………………………………………………....................       iii
DAFTAR ISI ………………………………………………………………                    iv
DAFTAR GAMBAR……………………………………………………….                    v
DAFTAR TABEL ………………………………………………………….                   v
BAB I PENDAHULUAN ……………………………………………….                  1

      1.1   Latar Belakang …………………………………..………..... 1
      1.2   Tujuan Tugas Akhir ………………………………………..       1
      1.3   Pembatasan Masalah …….………………………………..... 1
      1.4   Sistematika Penulisan ……………………………………..... 2
BAB II DASAR TEORI ……….…………………………..……………..             3
      2.1   Sensor Ping……………………..…………………………… 3
      2.2   Sensor LM 35……………………………………………….            4
      2.3   Mikrokontroller ATMEGA 128 .……………………………. 5
      2.4   LCD ……………………………………………………….                 5
      2.5   LED…….. .…………………………….…………………… 6
      2.6   MOC 3021…………………………………………………..              7
      2.7   Triac…………………………………………………………                7
      2.8   Solder……………………………………………………….               7
BAB III PERANCANGAN ALAT ……………………………..………..            8

      3.1 Perancangan Perangkat Keras …………………….……..… 8
      3.2 Perancangan Perangkat Lunak ……………………………… 9
BAB IV PENJELASAN SOURCE CODE DAN PENGUJIAN ALAT ….... 11
      4.1   Penjelasan Source Code….. ………………………………… 11
      4.2   Pengujian Alat ………………………….…………………… 12
BAB V PENUTUP …………………………………………………………. 14
DAFTAR PUSTAKA



                              iv
DAFTAR GAMBAR
Gambar 2.1 Sensor PING Ultrasonik Range Finder ...................................... 3
Gambar 2.2 Sensor PING Ultrasonik Range Finder timing diagram............. 3
Gambar 2.3 Ilustrasi Sensor Ping .................................................................. 4
Gambar 2.4 Sensor LM35 dan Konfigurasi PIN ........................................... 4
Gambar 2.5 Konfigurasi Pin Atmega 128...................................................... 5
Gambar 2.6 Konfigurasi pin LCD. ................................................................ 6
Gambar 2.7 Simbol LED. .............................................................................. 6
Gambar 2.8 Konfigurasi MOC 3021………………………………………..7
Gambar 2.9 Rangkaian Ekuivalen Triac. ...................................................... .7
Gambar 2.10 Solder ………………………………………………………...7
Gambar 3.1 Blok diagram hardware .............................................................. 8
Gambar 3.2 FSM sistem ................................................................................ 9
Gambar 4.1 saat state Off ............................................................................ 12
Gambar 4.2 saat state Heater On suhu 29ºC dan jarak 20 cm .................... 12
Gambar 4.3 state Heater standBy suhu 35ºC dan jarak 20,70 cm ............... 12




                                             DAFTAR TABEL
Tabel 4.1 Perbandingan Pengukuran Sensor Ping dan Penggaris................ 13




                                                          v
BAB I
                                 PENDAHULUAN


1.1      Latar Belakang
         Pada Akhir-akhir ini teknik kontrol telah menjadi bagian yang sangat penting
dalam kehidupan manusia. Dengan semakin tingginya tingkat kebutuhan maka untuk
memenuhi kebutuhan tersebut dibutuhkan suatu perancangan sistem yang mampu
berjalan secara otomatis. Pada peper ini dilakukan perancangan control suhu ruangan
yang terlalu dingin menggunakan sensor jarak dan sensor suhu. Tujuan dari paper ini
adalah merancang dan membuat alat yang dapat mengontrol suhu ruangan dan
mendeteksi ada tidaknya pengguna didalam ruangan tersebut.
        Smart Heater adalah suatu alat yang dapat digunakan sebagai pemanas
ruangan dan juga mendekteksi adanya pengguna dari pemanas ruangan tersebut.
Kontrol On Off adalah suatu metode yang mudah dan tepat untuk pengontrolan alat
ini dengan hanya menggunakan dua logika yaitu logika HIGH (1) dan logika
LOW(0).


1.2      Tujuan
        1. Merancang Smart Heater yang dapat bekerja sesuai dengan algoritma yang
            telah dirancang.
        2. Mengetahui Prinsip Kerja sistem control khususnya control On-Off,
        3. Memenuhi tugas Komponen Sistem Kontrol yang diajarkan di Jurusan
            Elektro Fakultas Teknik Universitas Diponegoro


1.3      Pembatasan Masalah
        Dalam pembuatan tugas akhir ini penulis membatasi permasalahan sebagai
berikut :
1.    Sistem Kontrol yang digunakan merupakan kontrol On-Off
2.    Sensor yang digunakan adalah sensor ultrasonik yang diproduksi oleh Parallax (
      Sensor PING Ultrasonik Range Finder).


                                          1
2



3.    Range pendeteksian antara 3 cm – 300 cm.
4.    Tugas akhir ini tidak membahas mengenai arsitektur mikrokontroller
5.    Mikrokontroler yang digunakan adalah ATMega128.


1.4      Sistematika Penulisan
        Sistematika penulisan dalam laporan tugas akhir ini adalah sebagai berikut:
        BAB I     PENDAHULUAN
                  Berisi tentang latar belakang masalah, tujuan penulisan, batasan
                  masalah dan sistematika penulisan.


        BAB II DASAR TEORI
                  Berisi tentang teori-teori yang mendukung dalam perancangan tugas
                  akhir ini, yaitu tentang mikrokontroler atmega128, sensor ping,
                  sensor LM35, LCD, MOC3021, Triac BT139.


        BAB III PERANCANGAN
                  Berisi tentang perancangan perangkat lunak (software) dan
                  perangkat keras (hardware) dari sistem yang digunakan pada Smart
                  Heater dan indikator led.


        BAB IV PENGUJIAN DAN ANALISA
                  Berisi tentang pengujian dan analisa terhadap perangkat lunak dan
                  perangkat keras yang telah dibuat serta pengujian sistem secara
                  keseluruhan.


        BAB V PENUTUP
                  Berisi kesimpulan dan saran.
3



                                         BAB II
                                    DASAR TEORI


2.1    Sensor Ping
       Sensor yang digunakan pada pembuatan tugas Komponen ini merupakan
                                            [1]
sebuah sensor ultrasonik buatan Parallax          ( Sensor PING Ultrasonik Range Finder).
Rangkaian lengkap sensor ditunjukkan pada Gambar 2.1




                      Gambar 2.1 Sensor PING Ultrasonik Range Finder.
Sensor PING ini secara khusus didesain untuk dapat mengukur jarak sebuah benda
padat (solid).Range jarak yang mampu diukur oleh sensor PING adalah 3 cm sampai
dengan 300 cm. Sensor PING mendeteksi jarak objek dengan cara memancarkan
gelombang ultrasonik (>20kHz) selama waktu pemancaran kemudian mendeteksi
pantulannya.




               Gambar 2.2 Sensor PING Ultrasonik Range Finder timing diagram.


                                             3
4



Sensor PING memancarkan gelombang ultrasonik sesuai dengan pulsa trigger dari
mikrokontroler sebagai pengendali.Gambar 2 menunjukkan timing diagram dari
Sensor PING. Lebar pulsa high (tIN) akan sesuai dengan lama waktu tempuh
gelombang ultrasonik untuk 2x jarak ukur dengan objek seperti yang ditunjukkan
pada Gambar 3, maka jarak yang diukur dapat dirumuskan sebagai berikut :


        t IN sx344m / s 
                         meter
Jarak=          2       




                               Gambar 2.3 Ilustrasi cara kerja sensor PING

2.2      Sensor LM 35
         Salah satu sensor suhu adalah sensor LM35 [2]. Berikut gambar sensor LM35.




                              Gambar 2.4 Sensor LM35 dan Konfigurasi PIN


         Sensor suhu LM35 adalah komponen elektronika yang memiliki fungsi untuk
mengubah besaran suhu menjadi besaran listrik dalam bentuk tegangan. Sensor Suhu
LM35 yang dipakai dalam paper ini berupa komponen elektronika elektronika yang
diproduksi oleh National Semiconductor. Secara prinsip sensor akan melakukan
penginderaan pada saat perubahan suhu setiap suhu 1 ºC akan menunjukan perubahan
tegangan sebesar 10 mV.
5



2.3    Mikrokontroller ATMEGA 128
Berikut ini konfigurasi Pin pada Atmega 128.




                          Gambar 2.5 Konfigurasi Pin Atmega 128



Mikrokontroler ATMEGA128 termasuk dalam mikrokontroler keluarga AVR.
Dengan fitur-fitur eksternal clock sampai 16 MHz, 53 Pin/Port yang bias digunakan
sebagai I/O dan beberapa fungsi khusus seperti pada port F dilengkapi dengan ACD,
timer 8 dan 16 bit dan lain sebagainya.


2.4    LCD
       Modul LCD (Liquid Crystal Display) adalah salah satu alat yang digunakan
sebagai tampilan. Pada dasarnya sistem pengaturan LCD memiliki standar yang sama
walaupun sangat banyak macamnya baik ditinjau dariperusahaan pembuat maupun
dari ukurannya.
       LCD yang digunakan merupakan modul dot-matrix tampilan kristal cair
(LCD) dengan tampilan 16 x 2 baris dengan konsumsi daya rendah. Modul LCD ini
telah dilengkapi dengan mikrokontroler yang didesain khusus untuk mengendalikan
6



LCD, berfungsi sebagai pengatur (system controller) dan penghasil karakter
(character generator).
       Konfigurasi pin dari LCD ditunjukkan pada Gambar 2.6




                                 Gambar 2.6 Konfigurasi pin LCD
       Modul LCD memiliki karakteristik sebagai berikut:
       • Terdapat 16 x 2 karakter huruf yang bisa ditampilkan.
       • Setiap huruf terdiri dari 5x7 dot-matrix cursor.
       • Terdapat 192 macam karakter.
       • Terdapat 80 x 8 bit display RAM (maksimal 80 karakter).
       • Memiliki kemampuan penulisan dengan 8 bit maupun dengan 4 bit.
       • Dibangun dengan osilator lokal.
       • Satu sumber tegangan 5 volt.
       • Otomatis reset saat tegangan dihidupkan.
       • Bekerja pada suhu 0 0C sampai 55 0C.


2.5    LED
       LED (Light Emitting Diode) atau dioda pancaran cahaya adalah suatu bahan
padat sejenis dioda yang mengkonversi arus listrik menjadi cahaya. Dalam
penggunannya digunakan sebagai penanda berupa nyala lampu pijar. Strukturnya
juga sama dengan dioda, elektron yang menerjang sambungan P-N juga melepaskan
energi berupa energi panas dan energi cahaya. Untuk mendapatkan emisi cahaya pada
semikonduktor, doping yang dipakai adalah gallium, arsenic, dan phosporus. Jenis
doping yang berbeda menghasilkan warna cahaya yang berbeda pula.




                                 Gambar 2.7 Simbol LED
7



2.6    MOC 3021
       Fungsi dari MOC ini adalah sebagai isolator agar bagian DC yang ada pada
kontrol mikrokontroller tidak langsung terhubung dengan bagian AC yang ada pada
triac. Berikut gambar konfigurasi MOC 3021




                           Gambar 2.8 Konfigurasi MOC 3021
2.7    TRIAC
       Untuk pengontrolan pada tegangan AC, umumnya digunakan bidirectional
triode thyristor atau dikenal dengan triac. Triac dapat bersifat konduktif dalam dua
arah. Dalam hal ini dapat dianggap sebagai dua buah tryristor tersambung secara
antiparallel dengan koneksi gerbang seperti gambar berikut[3].




                             Gambar 2.9 Rangkaian Ekuivalen Triac

2.8    Solder
        Pada perancangan ini untuk mengambarkan sebuah element pemanas
menggunakan solder. Dalam perancangan sistem panas dari solder inilah yang akan
di kontrol.




                                  Gambar 2.10 Solder
8



                                        BAB III
                                  PERANCANGAN


3.1      Perancangan Perangkat Keras
         Perangkat keras dari sistem yang akan dibangun meliputi sistem minimum
mikrokontroler ATMEGA 128, Push Button, LCD, Power Supply AC dan DC,
Indikator LED, Sensor LM 35, Sensor jarak Ping, Triac BT 139, MOC 3021 dan
Heater. Berikut blok digram dari koneksi komponen tersebut




                             Gambar 3.1 Blok diagram hardware
         Tiap-tiap bagian dari diagram blok sistem dapat dijelaskan sebagai berikut:
      1. Atmega 128 berfungsi sebagai otak dari alat.
      2. Sensor Ping berfungsi sebagai masukan data untuk mengetahui adanya
         pengguna atau tidak.
      3. Sensor LM35 berfungsi untuk mengukur nilai suhu dari heater.
      4. Regulator
          a. 220 volt AC berfungsi sebagai tegangan masukkan heater
          b. 5 volt DC volt berfungsi sebagai supply mikro dan sensor-sensor
      5. LCD berfunsi sebagai tampilan untuk state sistem

                                                  8
9



      6. Push Button berfungsi sebagai inputan untuk menyala dan mematikan sistem
      7. MOC 3021 berfungsi sebagai isolator untuk mengamankan antara arus AC
         dan DC.
      8. LED berfungsi sebagai indicator nyala heater.
      9. Triac berfungsi sebagai pengontrol nyala dan matinya heater.


3.2      Perancangan Perangkat Lunak
         Bahasa pemrograman yang digunakan dalam pembuatan perangkat lunak
menggunakan bahasa C untuk proses pengontrolan melalui AVR ATmega 128
dengan bantuan software CVAVR. Dalam perancangan Software menggunakan
metode Finite State Machine, metode ini dipilih karena lebih mudah dalam
implementasi ke source code. Berikut FSM sistem yang dirancang.




                                     Gambar 3.2 FSM sistem


        Berikut cara kerja dari sistem Heater pemanas ruangan
  1. Heater dinyalakan menggunakan tombol.
  2. Apabila penggunakan yang menyalakan sistem terdeksi berada didalam ruangan
        (asumsi jarak terdekat 20cm dan jarak terjauh 120 cm dari heater) maka sistem
        pemanas dan lampu LED indicator akan menyala.
10



3. Apabila pengguna berada pada jarak kurang dari 20 cm maka heater akan mati
   dan sistem akan menyala secara otomatis apabila pengguna terdeteksi berada
   pada jarak lebih dari 20 cm.
4. Apabila pengguna berada pada jarak lebih dari 120 cm dan selama 3 detik tidak
   kembali kedalam jarak tersebut maka sistem akan mati secara otomatis
5. Apabila suhu ruangan lebih dari 33ºC maka sistem akan mati secara otomatis.
6. Sistem juga dapat dimatikan secara otomatis menggunakan tombol yang
   disediakan.
11



                                         BAB IV
                            PENJELASAN SOURCE CODE
                                  DAN PENGUJIAN ALAT


4.1      Penjelasan Source Code
         Berikut beberapa source code yang digunakan dalam perancangan sistem
yaitu:
      Blok Fungsi Akses Ping
       DirSig=1; //Set sebagai output
       SigOut=1; //Pengiriman sinyal dimulai
       delay_us(5);
       SigOut=0; //Pengiriman sinyal selesai
       DirSig=0; //Set as input
       SigOut=1; //Pullup activated
       TCNT1=0; // mereset timer
       while (SigIn==0)
           {}
       TCCR1B=0x02; //mengeset timer dgan frekuensi 2 MHZ
         while (SigIn==1)
           {}
         TCCR1B=0x00; // mematikan timer
         distance=(TCNT1*0.0086106);
                   // t=n/f // n=jumlah gel // f=frekuensi
                   // s=v*t // v=344.434m/s // v=34443.4cm/s
                   // 2s=v*t >> karena waktu tempuh 2 kali
                   // 2s=34443.4* n /2000.000 >>>> 4MHZ
                   // s= n * 0.0086106
 Blok Fungsi Suhu
      tegangan=read_adc(0);



                                                   11
12



    tegangan=tegangan*4.89;               //tegangan       sensor       dalam      //millivolt
    5000mV/1023=4.89mV
    suhu=tegangan/10; // mengubah nilai tegangan kedalam //suhu dengan membagai
    bilangan 10 yang merupakan //konstanta kelipatan kenaikan suhu pada LM 35


4.2      Pengujian Alat
Pengujian Sistem terlihat pada gambar berikut ini
 Pada saat sistem berada pada state Heater off




                                    Gambar 4.1 saat state Off

 Pada saat sistem berada pada state Heater On




                       Gambar 4.2 saat state Heater On suhu 29ºC dan jarak 20 cm

     Pada saat sistem berada pada state heater standBy




                 Gambar 4.3 state Heater standBy suhu 35ºC dan jarak 20,70 cm
13



Perbandingan pengukuran jarak antara hasil ukur dengan alat ukur penggaris. Pada
pengujian ini dilakukan dengan cara menggunakan buku (30x21) cm2                 yang
diletakkan diatas penggaris kemudian dilihat hasil pengukuran pada LCD dan letak
buku pada penggaris. Dari cara tersebut diperoleh data di tabel berikut ini.
Tabel 4.1 Perbandingan Pengukuran Sensor Ping dan Penggaris
         Pengukaran            Hasil
                                              Error
  No      Penggaris        Pengukuran
                                              (cm)
             (cm)           PING (cm)
  1          3.00              3.08             0.08
  2          5.00              5.65             0.65
  3          8.00              8.07             0.07
  4         10.00              10.22            0.22
  5         12.00              12.37            0.37
  6         15.00              15.15            0.15
  7         17.00              16.85           -0.15
  8         20.00              19.93           -0.07
  9         25.00              24.97           -0.03
  10        30.00              30.07            0.07
             Rata-Rata Error                    0.14
Dari tabel 4.1 tersebut terlihat bahwa rata-rata error yang dihasilkan dari pengukuran
adalah sebesar 0.14 cm.
14



                                   Bab V
                                Kesimpulan
      Dari hasil pengujian diperoleh bahwa sistem yang dihasilkan sesuai dengan
rancangan yaitu sistem hasil pengujian menunjukkan performa yang sesuai dengan
yang telah dirancang yaitu Perancangan Heater sebagai pemanas ruangan
menggunakan sensor Ping sebagai pendekteksi adanya pengguna (rentang kerja 100
cm dari 20 cm sampai 120 cm) dan sensor suhu LM 35 digunakan sebagai input agar
suhu yang dihasilkan tidak terlalu panas yaitu dibawah 33ºC. Kemudian hasil
pengkuran menggunakan sensor ping memperlihatkan keluaran yang cukup baik
dengan rata-rata error yaitu 0.14 cm. Dengan adanya pembuktian bahwa jarak yang
dihasilkan oleh sensor ping hampir mendekati sebenarnya maka sensor ini cocok
untuk diaplikasi dalam perancangan sistem pemanas ruangan dalam hal ini
mendeteksi adanya keberadaan pengguna.




                                          14
Daftar Pustaka

[1] --- Sensor Ping Data Sheet ,
    http://www.google.co.id/url?sa=t&rct=j&q=ping%20parallax&source=web&cd=2&ved=0CCcQ
    FjAB&url=http%3A%2F%2Fwww.parallax.com%2Fdl%2Fdocs%2Fprod%2Facc%2F28015-
    PING-
    v1.3.pdf&ei=BYDwTr7MGc7prQeR0LjiDw&usg=AFQjCNHh0CMP8LzfryTUSMxqhpYrvluv8
    g Desember 2011
[2] --- Sensor LM 35 Data Sheet, www.national.com/ds/LM/LM35.pdf
    Desember 2011
[3] Syahadi, M., Aplikasi Kontrol Proporsional Integral Berbasis Mikrokontroller Atmega 8535
    untuk Pengaturan Suhu pada Alat Pengering Kertas , Skripsi S-1, Universitas Diponegoro,
    Semarang, 2008.
BIODATA PENULIS




Oka Danil Saputra, dilahirkan di Jambi, 17 Juli 1990, saat ini menempuh studi
strara 1 di Teknik Elektro Undip konsenterasi Kontrol.
Lampiran

1. Listing Program
   /*****************************************************
   This program was produced by the
   CodeWizardAVR V2.03.4 Standard
   Automatic Program Generator
   © Copyright 1998-2008 Pavel Haiduc, HP InfoTech s.r.l.
   http://www.hpinfotech.com
   Project :
   Version :
   Date : 12/21/2011
   Author :
   Company :
   Comments:
   Chip type        : ATmega128
   Program type       : Application
   Clock frequency : 16.000000 MHz
   Memory model         : Small
   External RAM size : 0
   Data Stack size : 1024
   *****************************************************/
   enum {start,mati};
   #include <mega128.h>
   #include <delay.h>
   #include <math.h>
   #include <stdio.h>
   #include <stdlib.h>

   // Alphanumeric LCD Module functions
   #asm
      .equ __lcd_port=0x15 ;PORTC
   #endasm
   #include <lcd.h>

   #define LED PORTA.0
   #define Heater PORTD.0
   #define Pb1 PINE.0
   #define On    1
#define Off    0

//Alokasi Port PING//
#define SigOut PORTB.1
#define SigIn PINB.1
#define DirSig DDRB.1
/////////////////////
#define ADC_VREF_TYPE 0x40

// Read the AD conversion result
unsigned int read_adc(unsigned char adc_input)
{
ADMUX=adc_input | (ADC_VREF_TYPE & 0xff);
// Delay needed for the stabilization of the ADC input voltage
delay_us(10);
// Start the AD conversion
ADCSRA|=0x40;
// Wait for the AD conversion to complete
while ((ADCSRA & 0x10)==0);
ADCSRA|=0x10;
return ADCW;
}
void baca_ping();
void baca_suhu();
unsigned char suhu,state;
unsigned int tegangan;
char Baris1[16],Baris2[16];
float distance;
// Declare your global variables here

void main(void)
{
// Declare your local variables here

// Input/Output Ports initialization
// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In
Func0=Out
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T
State0=0
PORTA=0x00;
DDRA=0x01;

// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In
Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T
State0=T
PORTB=0x00;
DDRB=0x00;

// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In
Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T
State0=T
PORTC=0x00;
DDRC=0x00;

// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In
Func0=Out
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T
State0=0
PORTD=0x00;
DDRD=0x01;

// Port E initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In
Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T
State0=T
PORTE=0xFF;
DDRE=0x00;

// Port F initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In
Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T
State0=T
PORTF=0x00;
DDRF=0x00;

// Port G initialization
// Func4=In Func3=In Func2=In Func1=In Func0=In
// State4=T State3=T State2=T State1=T State0=T
PORTG=0x00;
DDRG=0x00;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=FFh
// OC0 output: Disconnected
ASSR=0x00;
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 2000.000 kHz
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// OC1C output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
// Compare C Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x02;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
OCR1CH=0x00;
OCR1CL=0x00;

// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;

// Timer/Counter 3 initialization
// Clock source: System Clock
// Clock value: Timer 3 Stopped
// Mode: Normal top=FFFFh
// Noise Canceler: Off
// Input Capture on Falling Edge
// OC3A output: Discon.
// OC3B output: Discon.
// OC3C output: Discon.
// Timer 3 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
// Compare C Match Interrupt: Off
TCCR3A=0x00;
TCCR3B=0x00;
TCNT3H=0x00;
TCNT3L=0x00;
ICR3H=0x00;
ICR3L=0x00;
OCR3AH=0x00;
OCR3AL=0x00;
OCR3BH=0x00;
OCR3BL=0x00;
OCR3CH=0x00;
OCR3CL=0x00;

// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
// INT3: Off
// INT4: Off
// INT5: Off
// INT6: Off
// INT7: Off
EICRA=0x00;
EICRB=0x00;
EIMSK=0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;
ETIMSK=0x00;

// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;

// ADC initialization
// ADC Clock frequency: 250.000 kHz
// ADC Voltage Reference: AVCC pin
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0x86;

// LCD module initialization
lcd_init(16);
lcd_clear(); lcd_putsf("Heater_Off");
state=mati;

while (1)
   {
   // Place your code here
   if    (!Pb1) {
                 if (state==mati) {state=start; delay_ms(200); }
                 else if (state==start) {state=mati;
                                 lcd_clear(); lcd_putsf("Heater_Off");
                                 delay_ms(200); //200
                                }
               }

   if (state==start)
   {
     lcd_clear();
     //LED=1; Heater=1;
     baca_suhu();       baca_ping();
     lcd_gotoxy(0,1);lcd_putsf("Jarak=");
     ftoa(distance,2,Baris2); lcd_gotoxy(7,1); lcd_puts(Baris2);
     lcd_putsf(" cm");
     if (distance<=20 || distance>=120 || suhu>33)
     {
           LED=0; Heater=0;
           lcd_clear();
           sprintf(Baris1,"Suhu =%3d H_SB",suhu);
           lcd_gotoxy(0,0);lcd_puts(Baris1);
           lcd_gotoxy(0,1);lcd_putsf("Jarak=");
           ftoa(distance,2,Baris2); lcd_gotoxy(7,1); lcd_puts(Baris2);
           lcd_putsf(" cm");
           delay_ms(200); //100

          baca_ping();
          if ( distance>=120) //|| suhu>33 )
          {
             lcd_clear();
             lcd_gotoxy(0,0);lcd_putsf("Waiting...");
             lcd_gotoxy(0,1);lcd_putsf("3 Detik");
delay_ms(3000); // delay waiting
              baca_ping();
              if ( distance>=120 || suhu>33 ) {state=mati; lcd_clear();
lcd_putsf("Heater_Off"); }
           }
      }
      else { LED=1; Heater=1; sprintf(Baris1,"Suhu =%3d H_On",suhu);
      lcd_gotoxy(0,0);lcd_puts(Baris1);
       }
    }
    else if (state==mati) { LED=Off; Heater=Off; }
    delay_ms(200); // 100
   };
};


void baca_ping()
{
     DirSig=1; //Set sebagai output
     SigOut=1; //Pengiriman sinyal dimulai
     delay_us(5);
     SigOut=0; //Pengiriman sinyal selesai
     DirSig=0; //Set as input
     SigOut=1; //Pullup activated
     TCNT1=0; // mereset timer
     while (SigIn==0)
        {}
     TCCR1B=0x02; //mengeset timer dgan frekuensi 2 MHZ
     while (SigIn==1)
        {}
     TCCR1B=0x00; // mematikan timer
     distance=(TCNT1*0.0086106);
               // t=n/f // n=jumlah gel // f=frekuensi
               // s=v*t // v=344.434m/s // v=34443.4cm/s
               // 2s=v*t >> karena waktu tempuh 2 kali
               // 2s=34443.4* n /2000.000 >>>> 4MHZ
               // s= n * 0.0086106
}
void baca_suhu()
{
     tegangan=read_adc(0);
     tegangan=tegangan*4.89; //tegangan sensor dalam milivolt
     suhu=tegangan/10;
}
599 Menlo Drive, Suite 100        General: info@parallax.com
                                      Rocklin, California 95765, USA    Technical: support@parallax.com
                                      Office: (916) 624-8333            Web Site: www.parallax.com
                                      Fax: (916) 624-8003               Educational: www.stampsinclass.com




PING)))™ Ultrasonic Distance Sensor (#28015)
The Parallax PING))) ultrasonic distance sensor provides precise, non-contact distance measurements
from about 2 cm (0.8 inches) to 3 meters (3.3 yards). It is very easy to connect to BASIC Stamp® or
Javelin Stamp microcontrollers, requiring only one I/O pin.

The PING))) sensor works by transmitting an ultrasonic (well above human hearing range) burst and
providing an output pulse that corresponds to the time required for the burst echo to return to the
sensor. By measuring the echo pulse width the distance to target can easily be calculated.



Features

    •   Supply Voltage – 5 VDC
    •   Supply Current – 30 mA typ; 35 mA max
    •   Range – 2 cm to 3 m (0.8 in to 3.3 yrds)
    •   Input Trigger – positive TTL pulse, 2 uS min, 5 µs typ.
    •   Echo Pulse – positive TTL pulse, 115 uS to 18.5 ms
    •   Echo Hold-off – 750 µs from fall of Trigger pulse
    •   Burst Frequency – 40 kHz for 200 µs
    •   Burst Indicator LED shows sensor activity
    •   Delay before next measurement – 200 µs
    •   Size – 22 mm H x 46 mm W x 16 mm D (0.84 in x 1.8 in x 0.6 in)


Dimensions




© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006                       Page 1 of 13
Pin Definitions

 GND            Ground (Vss)
 5V             5 VDC (Vdd)
 SIG            Signal (I/O pin)

The PING))) sensor has a male 3-pin header used to supply power
(5 VDC), ground, and signal. The header allows the sensor to be
plugged into a solderless breadboard, or to be located remotely
through the use of a standard servo extender cable (Parallax part
#805-00002). Standard connections are show in the diagram to
the right.

Quick-Start Circuit

This circuit allows you to quickly connect your PING))) sensor to a BASIC Stamp® 2 via the Board of
Education® breadboard area. The PING))) module’s GND pin connects to Vss, the 5 V pin connects to
Vdd, and the SIG pin connects to I/O pin P15. This circuit will work with the example program
Ping_Demo.BS2 listed on page 7.




Servo Cable and Port Cautions

If you want to connect your PING))) sensor to a Board of Education
using a servo extension cable, follow these steps:

    1. When plugging the cable onto the PING))) sensor, connect
       Black to GND, Red to 5 V, and White to SIG.
    2. Check to see if your Board of Education servo ports have a
       jumper, as shown at right.
    3. If your Board of Education servo ports have a jumper, set it
       to Vdd as shown.
    4. If your Board of Education servo ports do not have a
       jumper, do not use them with the PING))) sensor. These
       ports only provide Vin, not Vdd, and this may damage your
       PING))) sensor. Go to the next step.
    5. Connect the servo cable directly to the breadboard with a            Board of Education Servo Port
       3-pin header. Then, use jumper wires to connect Black to                  Jumper, Set to Vdd
       Vss, Red to Vdd, and White to I/O pin P15.



© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006              Page 2 of 13
Theory of Operation

The PING))) sensor detects objects by emitting a short ultrasonic burst and then "listening" for the echo.
Under control of a host microcontroller (trigger pulse), the sensor emits a short 40 kHz (ultrasonic) burst.
This burst travels through the air at about 1130 feet per second, hits an object and then bounces back to
the sensor. The PING))) sensor provides an output pulse to the host that will terminate when the echo
is detected, hence the width of this pulse corresponds to the distance to the target.




Test Data

The test data on the following pages is based on the PING))) sensor, tested in the Parallax lab, while
connected to a BASIC Stamp microcontroller module. The test surface was a linoleum floor, so the
sensor was elevated to minimize floor reflections in the data. All tests were conducted at room
temperature, indoors, in a protected environment. The target was always centered at the same elevation
as the PING))) sensor.




© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006               Page 3 of 13
Test 1

Sensor Elevation:    40 in. (101.6 cm)
Target:              3.5 in. (8.9 cm) diameter cylinder, 4 ft. (121.9 cm) tall – vertical orientation




© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006                  Page 4 of 13
Test 2

Sensor Elevation:    40 in. (101.6 cm)
Target:              12 in. x 12 in. (30.5 cm x 30.5 cm) cardboard, mounted on 1 in. (2.5 cm) pole
                     ● target positioned parallel to backplane of sensor




© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006            Page 5 of 13
Program Example: BASIC Stamp 2 Microcontroller

The following program demonstrates the use of the PING))) sensor with the BASIC Stamp 2
microcontroller.   Any model of BASIC Stamp 2 module will work with this program as conditional
compilation techniques are used to make adjustments based on the module that is connected.

The heart of the program is the Get_Sonar subroutine. This routine starts by making the output bit of
the selected IO pin zero – this will cause the successive PULSOUT to be low-high-low as required for
triggering the PING))) sensor. After the trigger pulse falls the sensor will wait about 200 microseconds
before transmitting the ultrasonic burst. This allows the BS2 to load and prepare the next instruction.
That instruction, PULSIN, is used to measure the high-going pulse that corresponds to the distance to
the target object.

The raw return value from PULSIN must be scaled due to resolution differences between the various
members of the BS2 family. After the raw value is converted to microseconds, it is divided by two in
order to remove the "return trip" of the echo pulse. The value now held in rawDist is the distance to the
target in microseconds.

Conversion from microseconds to inches (or centimeters) is now a simple matter of math. The generally-
accepted value for the speed-of-sound is 1130 feet per second. This works out to 13,560 inches per
second or one inch in 73.746 microseconds. The question becomes, how do we divide our pulse
measurement value by the floating-point number 73.746?

Another way to divide by 73.746 is to multiply by 0.01356. For new BASIC Stamp users this may seem a
dilemma but in fact there is a special operator, **, that allows us to do just that. The ** operator has
the affect of multiplying a value by units of 1/65,536. To find the parameter for ** then, we simply
multiply 0.01356 by 65,536; the result is 888.668 (we'll round up to 889).

Conversion to centimeters uses the same process and the result of the program is shown below:




© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006            Page 6 of 13
' =========================================================================
'
'   File....... Ping_Demo.BS2
'   Purpose.... Demo Code for Parallax PING))) Sonar Sensor
'   Author..... Parallax, Inc.
'   E-mail..... support@parallax.com
'   Started....
'   Updated.... 08 JUN 2005
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


'   -----[ Program Description ]---------------------------------------------
'
'   This program demonstrates the use of the Parallax PING))) sensor and then
'   converting the raw measurement to English (inches) and Metric (cm) units.
'
'   Sonar Math:
'
'   At sea level sound travels through air at 1130 feet per second.                     This
'   equates to 1 inch in 73.746 uS, or 1 cm in 29.034 uS).
'
'   Since the PING))) sensor measures the time required for the sound wave to
'   travel from the sensor and back. The result -- after conversion to
'   microseconds for the BASIC Stamp module in use -- is divided by two to
'   remove the return portion of the echo pulse. The final raw result is
'   the duration from the front of the sensor to the target in microseconds.


' -----[ I/O Definitions ]-------------------------------------------------

Ping                  PIN         15


' -----[ Constants ]-------------------------------------------------------

#SELECT $STAMP
  #CASE BS2, BS2E
    Trigger     CON     5                                           ' trigger pulse = 10 uS
    Scale       CON     $200                                        ' raw x 2.00 = uS
  #CASE BS2SX, BS2P, BS2PX
    Trigger     CON     13
    Scale       CON     $0CD                                        ' raw x 0.80 = uS
  #CASE BS2PE
    Trigger     CON     5
    Scale       CON     $1E1                                        ' raw x 1.88 = uS
#ENDSELECT

RawToIn               CON         889                               ' 1 / 73.746 (with **)
RawToCm               CON         2257                              ' 1 / 29.034 (with **)

IsHigh                CON         1                                 ' for PULSOUT
IsLow                 CON         0




© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006         Page 7 of 13
' -----[ Variables ]-------------------------------------------------------

rawDist               VAR         Word                              ' raw measurement
inches                VAR         Word
cm                    VAR         Word


' -----[ Initialization ]--------------------------------------------------

Reset:
  DEBUG CLS,
        "Parallax PING))) Sonar",               CR,                 ' setup report screen
        "======================",               CR,
        CR,
        "Time (uS).....        ",               CR,
        "Inches........        ",               CR,
        "Centimeters...        "


' -----[ Program Code ]----------------------------------------------------

Main:
  DO
    GOSUB Get_Sonar                                                 ' get sensor value
    inches = rawDist ** RawToIn                                     ' convert to inches
    cm = rawDist ** RawToCm                                         ' convert to centimeters

     DEBUG CRSRXY, 15, 3,                                           ' update report screen
           DEC rawDist, CLREOL,
           CRSRXY, 15, 4,
           DEC inches, CLREOL,
           CRSRXY, 15, 5,
           DEC cm, CLREOL

      PAUSE 100
    LOOP
    END


' -----[ Subroutines ]-----------------------------------------------------

'   This subroutine triggers the PING))) sonar sensor and measures
'   the echo pulse. The raw value from the sensor is converted to
'   microseconds based on the Stamp module in use. This value is
'   divided by two to remove the return trip -- the result value is
'   the distance from the sensor to the target in microseconds.

Get_Sonar:
  Ping = IsLow                                                      '   make trigger 0-1-0
  PULSOUT Ping, Trigger                                             '   activate sensor
  PULSIN Ping, IsHigh, rawDist                                      '   measure echo pulse
  rawDist = rawDist */ Scale                                        '   convert to uS
  rawDist = rawDist / 2                                             '   remove return trip
  RETURN




© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006            Page 8 of 13
Program Example: BASIC Stamp 1 Microcontroller
' =========================================================================
'
'   File....... Ping_Demo.BS1
'   Purpose.... Demo Code for Parallax PING))) Sonar Sensor
'   Author..... Parallax, Inc.
'   E-mail..... support@parallax.com
'   Started....
'   Updated.... 06 JUN 2006
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


'   -----[ Program Description ]---------------------------------------------
'
'   This program demonstrates the use of the Parallax PING))) sensor and then
'   converting the raw measurement to English (inches) and Metric (cm) units.
'
'   Sonar Math:
'
'   At sea level sound travels through air at 1130 feet per second.                     This
'   equates to 1 inch in 73.746 uS, or 1 cm in 29.034 uS).
'
'   Since the PING))) sensor measures the time required for the sound wave to
'   travel from the sensor and back. The result -- after conversion to
'   microseconds for the BASIC Stamp module in use -- is divided by two to
'   remove the return portion of the echo pulse. The final raw result is
'   the duration from the front of the sensor to the target in microseconds.


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL     Ping                   = 7


' -----[ Constants ]-------------------------------------------------------

SYMBOL     Trigger                = 1                               ' 10 uS trigger pulse
SYMBOL     Scale                  = 10                              ' raw x 10.00 = uS

SYMBOL     RawToIn                = 889                             ' 1 / 73.746 (with **)
SYMBOL     RawToCm                = 2257                            ' 1 / 29.034 (with **)

SYMBOL     IsHigh                 = 1                               ' for PULSOUT
SYMBOL     IsLow                  = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL     rawDist                = W1                              ' raw measurement
SYMBOL     inches                 = W2
SYMBOL     cm                     = W3



© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006           Page 9 of 13
' -----[ Program Code ]----------------------------------------------------

Main:
  GOSUB Get_Sonar                                                   ' get sensor value
  inches = rawDist ** RawToIn                                       ' convert to inches
  cm = rawDist ** RawToCm                                           ' convert to centimeters

    DEBUG   CLS                                                     ' report
    DEBUG   "Time (uS)..... ", #rawDist, CR
    DEBUG   "Inches........ ", #inches, CR
    DEBUG   "Centimeters... ", #cm

    PAUSE 500
    GOTO Main

    END


' -----[ Subroutines ]-----------------------------------------------------

'   This subroutine triggers the PING))) sonar sensor and measures
'   the echo pulse. The raw value from the sensor is converted to
'   microseconds based on the Stamp module in use. This value is
'   divided by two to remove the return trip -- the result value is
'   the distance from the sensor to the target in microseconds.

Get_Sonar:
  LOW Ping                                                          '   make trigger 0-1-0
  PULSOUT Ping, Trigger                                             '   activate sensor
  PULSIN Ping, IsHigh, rawDist                                      '   measure echo pulse
  rawDist = rawDist * Scale                                         '   convert to uS
  rawDist = rawDist / 2                                             '   remove return trip
  RETURN




© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006            Page 10 of 13
Program Example: Javelin Stamp Microcontroller

This class file implements several methods for using the PING))) sensor:

package stamp.peripheral.sensor;

import stamp.core.*;


/**
 * This class provides an interface to the Parallax PING))) ultrasonic
 * range finder module.
 * <p>
 * <i>Usage:</i><br>
 * <code>
 *   Ping range = new Ping(CPU.pin0);       // trigger and echo on P0
 * </code>
 * <p>
 * Detailed documentation for the PING))) Sensor can be found at: <br>
 * http://www.parallax.com/detail.asp?product_id=28015
 * <p>
 *
 * @version 1.0 03 FEB 2005
 */
public final class Ping {

  private int ioPin;

  /**
   * Creates PING))) range finder object
   *
   * @param ioPin PING))) trigger and echo return pin
   */
  public Ping (int ioPin) {
    this.ioPin = ioPin;
  }


  /**
   * Returns raw distance value from the PING))) sensor.
   *
   * @return Raw distance value from PING)))
   */
  public int getRaw() {

      int echoRaw = 0;

      CPU.writePin(ioPin, false);               // setup for high-going pulse
      CPU.pulseOut(1, ioPin);                   // send trigger pulse
      echoRaw = CPU.pulseIn(2171, ioPin, true); // measure echo return

      // return echo pulse if in range; zero if out-of-range
      return (echoRaw < 2131) ? echoRaw : 0;
  }




© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006   Page 11 of 13
/*
     * The PING))) returns a pulse width of 73.746 uS per inch. Since the
     * Javelin pulseIn() round-trip echo time is in 8.68 uS units, this is the
     * same as a one-way trip in 4.34 uS units. Dividing 73.746 by 4.34 we
     * get a time-per-inch conversion factor of 16.9922 (x 0.058851).
     *
     * Values to derive conversion factors are selected to prevent roll-over
     * past the 15-bit positive values of Javelin Stamp integers.
     */

    /**
     * @return PING))) distance value in inches
     */
    public int getIn() {
      return (getRaw() * 3 / 51);               // raw * 0.058824
    }


    /**
     * @return PING))) distance value in tenths of inches
     */
    public int getIn10() {
      return (getRaw() * 3 / 5);                // raw / 1.6667
    }


    /*
     * The PING))) returns a pulse width of 29.033 uS per centimeter. As the
     * Javelin pulseIn() round-trip echo time is in 8.68 uS units, this is the
     * same as a one-way trip in 4.34 uS units. Dividing 29.033 by 4.34 we
     * get a time-per-centimeter conversion factor of 6.6896.
     *
     * Values to derive conversion factors are selected to prevent roll-over
     * past the 15-bit positive values of Javelin Stamp integers.
     */

    /**
     * @return PING))) distance value in centimeters
     */
    public int getCm() {
      return (getRaw() * 3 / 20);               // raw / 6.6667
    }


    /**
     * @return PING))) distance value in millimeters
     */
    public int getMm() {
      return (getRaw() * 3 / 2);                // raw / 0.6667
    }
}




This simple demo illustrates the use of the PING))) ultrasonic range finder class with the Javelin Stamp:



© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006             Page 12 of 13
import stamp.core.*;
import stamp.peripheral.sensor.Ping;


public class testPing {

    public static final char HOME = 0x01;

    public static void main() {

        Ping range = new Ping(CPU.pin0);
        StringBuffer msg = new StringBuffer();

        int distance;

        while (true) {
          // measure distance to target in inches
          distance = range.getIn();

            // create and display measurement message
            msg.clear();
            msg.append(HOME);
            msg.append(distance);
            msg.append(" "   n");
            System.out.print(msg.toString());

            // wait 0.5 seconds between readings
            CPU.delay(5000);
        }
    }
}




© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006   Page 13 of 13
Perancangan Heater sebagai Pemanas
Ruangan Menggunakan Sensor Jarak Ping
   Parallax dan Sensor Suhu LM 35
                 Laporan Tugas
       Mata Kuliah Komponen Sistem Kontrol




                      oleh
                 Oka D. Saputra
                   L2F008146




          JURUSAN TEKNIK ELEKTRO
              FAKULTAS TEKNIK
          UNIVERSITAS DIPONEGORO
                SEMARANG, 2011



                        i
KATA PENGANTAR
Alhamdulillah, Segala puji hanya bagi Allah Subhànahu wa Ta’ala, atas segala
limpahan rahmat dan karunia-Nya, sehingga penyusun dapat menyelesaikan laporan
“Perancangan Heater sebagai Pemanas Ruangan Menggunakan Sensor Jarak
Ping Parallax dan Sensor Suhu LM 35 ”.
      Dalam pembuatan dan penyusunan laporan Tugas Akhir, penyusun juga
banyak mendapatkan bantuan dan dukungan dari berbagai pihak. Atas kelancaran
selama pelaksanaan Tugas Akhir dan penyusunan laporan ini, maka penyusun
mengucapkan banyak terima kasih kepada :
1. Bapak Ir. Sudjadi, M.T. selaku Ketua Jurusan Teknik Elektro Fakultas Teknik
   Universitas Diponegoro
2. Bapak Sumardi S.T., M.T. selaku dosen mata kuliah Komponen Sistem Kontrol
   yang mengarahkan penulis dalam pembuatan Tugas Akhir ini
3. Keluargaku tercinta atas segala bentuk dorongan semangat dan dukungannya.
4. Saudara Fairus yang membimbing penulis sehingga tugas akhir ini dapat
   terselesaikan.
5. teman-teman yang mengikuti kuliah Komponen Sistem Kontrol.
6. Serta semua pihak yang tidak dapat penyusun sebutkan satu-persatu.
       Penyusun menyadari bahwa masih terdapat beberapa kekurangan dalam
laporan Tugas Akhir ini. Kritik dan saran yang bersifat membangun sangat penyusun
harapkan dari semua pihak, sebagai pengalaman dan tambahan pengetahuan bagi
penyusun.

       Akhir kata semoga karya ini tidak menjadi yang pertama sekaligus yang
terakhir dan semoga laporan ini dapat bermanfaat bagi mahasiswa Teknik Elektro
Universitas Diponegoro pada khususnya dan masyarakat pada umumnya.

                                                       Semarang, Desember 2011

                                                                        Penyusun




                                        ii
Abstrak
        Banyak Aplikasi yang dapat kita terapkan ketika kita membahas tentang
sistem kontrol. Salah satunya pemanfaatan kemajuan teknologi sensor seperti sensor
jarak ping produksi Parallax, sensor suhu LM 35 dari National Semiconductor dan
juga actuator Heater (dalam hal ini solder) untuk pengendalian suhu ruangan yang
terlalu dingin. Tujuan dari paper ini adalah merancang dan membuat alat yang
dapat mengontrol suhu ruangan dan mendeteksi ada tidaknya pengguna didalam
ruangan tersebut. Dalam perancangan alat, ada beberapa elemen yang menjadi
parameter sebagai inputan agar heater aktif, dalam simulasi ini digunakan sebagai
jarak terdekat antara pengguna ruangan dengan heater adalah 20 cm sedangkan
untuk jarak terjauh adalah 120 cm sedangkan untuk suhu terpanas yang menjadikan
heater off adalah 33ºC.

Keywords — Sensor Ping, Sensor LM35, Heater




                                        iii
DAFTAR ISI


HALAMAN JUDUL ………………………………………………………                    i
KATA PENGANTAR …………………… ……………………………….                  ii
ABSTRAK ……………………………………………………....................       iii
DAFTAR ISI ………………………………………………………………                    iv
DAFTAR GAMBAR……………………………………………………….                    v
DAFTAR TABEL ………………………………………………………….                   v
BAB I PENDAHULUAN ……………………………………………….                  1

      1.1   Latar Belakang …………………………………..………..... 1
      1.2   Tujuan Tugas Akhir ………………………………………..       1
      1.3   Pembatasan Masalah …….………………………………..... 1
      1.4   Sistematika Penulisan ……………………………………..... 2
BAB II DASAR TEORI ……….…………………………..……………..             3
      2.1   Sensor Ping……………………..…………………………… 3
      2.2   Sensor LM 35……………………………………………….            4
      2.3   Mikrokontroller ATMEGA 128 .……………………………. 5
      2.4   LCD ……………………………………………………….                 5
      2.5   LED…….. .…………………………….…………………… 6
      2.6   MOC 3021…………………………………………………..              7
      2.7   Triac…………………………………………………………                7
      2.8   Solder……………………………………………………….               7
BAB III PERANCANGAN ALAT ……………………………..………..            8

      3.1 Perancangan Perangkat Keras …………………….……..… 8
      3.2 Perancangan Perangkat Lunak ……………………………… 9
BAB IV PENJELASAN SOURCE CODE DAN PENGUJIAN ALAT ….... 11
      4.1   Penjelasan Source Code….. ………………………………… 11
      4.2   Pengujian Alat ………………………….…………………… 12
BAB V PENUTUP …………………………………………………………. 14
DAFTAR PUSTAKA



                              iv
DAFTAR GAMBAR
Gambar 2.1 Sensor PING Ultrasonik Range Finder ...................................... 3
Gambar 2.2 Sensor PING Ultrasonik Range Finder timing diagram............. 3
Gambar 2.3 Ilustrasi Sensor Ping .................................................................. 4
Gambar 2.4 Sensor LM35 dan Konfigurasi PIN ........................................... 4
Gambar 2.5 Konfigurasi Pin Atmega 128...................................................... 5
Gambar 2.6 Konfigurasi pin LCD. ................................................................ 6
Gambar 2.7 Simbol LED. .............................................................................. 6
Gambar 2.8 Konfigurasi MOC 3021………………………………………..7
Gambar 2.9 Rangkaian Ekuivalen Triac. ...................................................... .7
Gambar 2.10 Solder ………………………………………………………...7
Gambar 3.1 Blok diagram hardware .............................................................. 8
Gambar 3.2 FSM sistem ................................................................................ 9
Gambar 4.1 saat state Off ............................................................................ 12
Gambar 4.2 saat state Heater On suhu 29ºC dan jarak 20 cm .................... 12
Gambar 4.3 state Heater standBy suhu 35ºC dan jarak 20,70 cm ............... 12




                                             DAFTAR TABEL
Tabel 4.1 Perbandingan Pengukuran Sensor Ping dan Penggaris................ 13




                                                          v
BAB I
                                 PENDAHULUAN


1.1      Latar Belakang
         Pada Akhir-akhir ini teknik kontrol telah menjadi bagian yang sangat penting
dalam kehidupan manusia. Dengan semakin tingginya tingkat kebutuhan maka untuk
memenuhi kebutuhan tersebut dibutuhkan suatu perancangan sistem yang mampu
berjalan secara otomatis. Pada peper ini dilakukan perancangan control suhu ruangan
yang terlalu dingin menggunakan sensor jarak dan sensor suhu. Tujuan dari paper ini
adalah merancang dan membuat alat yang dapat mengontrol suhu ruangan dan
mendeteksi ada tidaknya pengguna didalam ruangan tersebut.
        Smart Heater adalah suatu alat yang dapat digunakan sebagai pemanas
ruangan dan juga mendekteksi adanya pengguna dari pemanas ruangan tersebut.
Kontrol On Off adalah suatu metode yang mudah dan tepat untuk pengontrolan alat
ini dengan hanya menggunakan dua logika yaitu logika HIGH (1) dan logika
LOW(0).


1.2      Tujuan
        1. Merancang Smart Heater yang dapat bekerja sesuai dengan algoritma yang
            telah dirancang.
        2. Mengetahui Prinsip Kerja sistem control khususnya control On-Off,
        3. Memenuhi tugas Komponen Sistem Kontrol yang diajarkan di Jurusan
            Elektro Fakultas Teknik Universitas Diponegoro


1.3      Pembatasan Masalah
        Dalam pembuatan tugas akhir ini penulis membatasi permasalahan sebagai
berikut :
1.    Sistem Kontrol yang digunakan merupakan kontrol On-Off
2.    Sensor yang digunakan adalah sensor ultrasonik yang diproduksi oleh Parallax (
      Sensor PING Ultrasonik Range Finder).


                                          1
2



3.    Range pendeteksian antara 3 cm – 300 cm.
4.    Tugas akhir ini tidak membahas mengenai arsitektur mikrokontroller
5.    Mikrokontroler yang digunakan adalah ATMega128.


1.4      Sistematika Penulisan
        Sistematika penulisan dalam laporan tugas akhir ini adalah sebagai berikut:
        BAB I     PENDAHULUAN
                  Berisi tentang latar belakang masalah, tujuan penulisan, batasan
                  masalah dan sistematika penulisan.


        BAB II DASAR TEORI
                  Berisi tentang teori-teori yang mendukung dalam perancangan tugas
                  akhir ini, yaitu tentang mikrokontroler atmega128, sensor ping,
                  sensor LM35, LCD, MOC3021, Triac BT139.


        BAB III PERANCANGAN
                  Berisi tentang perancangan perangkat lunak (software) dan
                  perangkat keras (hardware) dari sistem yang digunakan pada Smart
                  Heater dan indikator led.


        BAB IV PENGUJIAN DAN ANALISA
                  Berisi tentang pengujian dan analisa terhadap perangkat lunak dan
                  perangkat keras yang telah dibuat serta pengujian sistem secara
                  keseluruhan.


        BAB V PENUTUP
                  Berisi kesimpulan dan saran.
3



                                         BAB II
                                    DASAR TEORI


2.1    Sensor Ping
       Sensor yang digunakan pada pembuatan tugas Komponen ini merupakan
                                            [1]
sebuah sensor ultrasonik buatan Parallax          ( Sensor PING Ultrasonik Range Finder).
Rangkaian lengkap sensor ditunjukkan pada Gambar 2.1




                      Gambar 2.1 Sensor PING Ultrasonik Range Finder.
Sensor PING ini secara khusus didesain untuk dapat mengukur jarak sebuah benda
padat (solid).Range jarak yang mampu diukur oleh sensor PING adalah 3 cm sampai
dengan 300 cm. Sensor PING mendeteksi jarak objek dengan cara memancarkan
gelombang ultrasonik (>20kHz) selama waktu pemancaran kemudian mendeteksi
pantulannya.




               Gambar 2.2 Sensor PING Ultrasonik Range Finder timing diagram.


                                             3
4



Sensor PING memancarkan gelombang ultrasonik sesuai dengan pulsa trigger dari
mikrokontroler sebagai pengendali.Gambar 2 menunjukkan timing diagram dari
Sensor PING. Lebar pulsa high (tIN) akan sesuai dengan lama waktu tempuh
gelombang ultrasonik untuk 2x jarak ukur dengan objek seperti yang ditunjukkan
pada Gambar 3, maka jarak yang diukur dapat dirumuskan sebagai berikut :


        t IN sx344m / s 
                         meter
Jarak=          2       




                               Gambar 2.3 Ilustrasi cara kerja sensor PING

2.2      Sensor LM 35
         Salah satu sensor suhu adalah sensor LM35 [2]. Berikut gambar sensor LM35.




                              Gambar 2.4 Sensor LM35 dan Konfigurasi PIN


         Sensor suhu LM35 adalah komponen elektronika yang memiliki fungsi untuk
mengubah besaran suhu menjadi besaran listrik dalam bentuk tegangan. Sensor Suhu
LM35 yang dipakai dalam paper ini berupa komponen elektronika elektronika yang
diproduksi oleh National Semiconductor. Secara prinsip sensor akan melakukan
penginderaan pada saat perubahan suhu setiap suhu 1 ºC akan menunjukan perubahan
tegangan sebesar 10 mV.
5



2.3    Mikrokontroller ATMEGA 128
Berikut ini konfigurasi Pin pada Atmega 128.




                          Gambar 2.5 Konfigurasi Pin Atmega 128



Mikrokontroler ATMEGA128 termasuk dalam mikrokontroler keluarga AVR.
Dengan fitur-fitur eksternal clock sampai 16 MHz, 53 Pin/Port yang bias digunakan
sebagai I/O dan beberapa fungsi khusus seperti pada port F dilengkapi dengan ACD,
timer 8 dan 16 bit dan lain sebagainya.


2.4    LCD
       Modul LCD (Liquid Crystal Display) adalah salah satu alat yang digunakan
sebagai tampilan. Pada dasarnya sistem pengaturan LCD memiliki standar yang sama
walaupun sangat banyak macamnya baik ditinjau dariperusahaan pembuat maupun
dari ukurannya.
       LCD yang digunakan merupakan modul dot-matrix tampilan kristal cair
(LCD) dengan tampilan 16 x 2 baris dengan konsumsi daya rendah. Modul LCD ini
telah dilengkapi dengan mikrokontroler yang didesain khusus untuk mengendalikan
6



LCD, berfungsi sebagai pengatur (system controller) dan penghasil karakter
(character generator).
       Konfigurasi pin dari LCD ditunjukkan pada Gambar 2.6




                                 Gambar 2.6 Konfigurasi pin LCD
       Modul LCD memiliki karakteristik sebagai berikut:
       • Terdapat 16 x 2 karakter huruf yang bisa ditampilkan.
       • Setiap huruf terdiri dari 5x7 dot-matrix cursor.
       • Terdapat 192 macam karakter.
       • Terdapat 80 x 8 bit display RAM (maksimal 80 karakter).
       • Memiliki kemampuan penulisan dengan 8 bit maupun dengan 4 bit.
       • Dibangun dengan osilator lokal.
       • Satu sumber tegangan 5 volt.
       • Otomatis reset saat tegangan dihidupkan.
       • Bekerja pada suhu 0 0C sampai 55 0C.


2.5    LED
       LED (Light Emitting Diode) atau dioda pancaran cahaya adalah suatu bahan
padat sejenis dioda yang mengkonversi arus listrik menjadi cahaya. Dalam
penggunannya digunakan sebagai penanda berupa nyala lampu pijar. Strukturnya
juga sama dengan dioda, elektron yang menerjang sambungan P-N juga melepaskan
energi berupa energi panas dan energi cahaya. Untuk mendapatkan emisi cahaya pada
semikonduktor, doping yang dipakai adalah gallium, arsenic, dan phosporus. Jenis
doping yang berbeda menghasilkan warna cahaya yang berbeda pula.




                                 Gambar 2.7 Simbol LED
7



2.6    MOC 3021
       Fungsi dari MOC ini adalah sebagai isolator agar bagian DC yang ada pada
kontrol mikrokontroller tidak langsung terhubung dengan bagian AC yang ada pada
triac. Berikut gambar konfigurasi MOC 3021




                           Gambar 2.8 Konfigurasi MOC 3021
2.7    TRIAC
       Untuk pengontrolan pada tegangan AC, umumnya digunakan bidirectional
triode thyristor atau dikenal dengan triac. Triac dapat bersifat konduktif dalam dua
arah. Dalam hal ini dapat dianggap sebagai dua buah tryristor tersambung secara
antiparallel dengan koneksi gerbang seperti gambar berikut[3].




                             Gambar 2.9 Rangkaian Ekuivalen Triac

2.8    Solder
        Pada perancangan ini untuk mengambarkan sebuah element pemanas
menggunakan solder. Dalam perancangan sistem panas dari solder inilah yang akan
di kontrol.




                                  Gambar 2.10 Solder
8



                                        BAB III
                                  PERANCANGAN


3.1      Perancangan Perangkat Keras
         Perangkat keras dari sistem yang akan dibangun meliputi sistem minimum
mikrokontroler ATMEGA 128, Push Button, LCD, Power Supply AC dan DC,
Indikator LED, Sensor LM 35, Sensor jarak Ping, Triac BT 139, MOC 3021 dan
Heater. Berikut blok digram dari koneksi komponen tersebut




                             Gambar 3.1 Blok diagram hardware
         Tiap-tiap bagian dari diagram blok sistem dapat dijelaskan sebagai berikut:
      1. Atmega 128 berfungsi sebagai otak dari alat.
      2. Sensor Ping berfungsi sebagai masukan data untuk mengetahui adanya
         pengguna atau tidak.
      3. Sensor LM35 berfungsi untuk mengukur nilai suhu dari heater.
      4. Regulator
          a. 220 volt AC berfungsi sebagai tegangan masukkan heater
          b. 5 volt DC volt berfungsi sebagai supply mikro dan sensor-sensor
      5. LCD berfunsi sebagai tampilan untuk state sistem

                                                  8
9



      6. Push Button berfungsi sebagai inputan untuk menyala dan mematikan sistem
      7. MOC 3021 berfungsi sebagai isolator untuk mengamankan antara arus AC
         dan DC.
      8. LED berfungsi sebagai indicator nyala heater.
      9. Triac berfungsi sebagai pengontrol nyala dan matinya heater.


3.2      Perancangan Perangkat Lunak
         Bahasa pemrograman yang digunakan dalam pembuatan perangkat lunak
menggunakan bahasa C untuk proses pengontrolan melalui AVR ATmega 128
dengan bantuan software CVAVR. Dalam perancangan Software menggunakan
metode Finite State Machine, metode ini dipilih karena lebih mudah dalam
implementasi ke source code. Berikut FSM sistem yang dirancang.




                                     Gambar 3.2 FSM sistem


        Berikut cara kerja dari sistem Heater pemanas ruangan
  1. Heater dinyalakan menggunakan tombol.
  2. Apabila penggunakan yang menyalakan sistem terdeksi berada didalam ruangan
        (asumsi jarak terdekat 20cm dan jarak terjauh 120 cm dari heater) maka sistem
        pemanas dan lampu LED indicator akan menyala.
10



3. Apabila pengguna berada pada jarak kurang dari 20 cm maka heater akan mati
   dan sistem akan menyala secara otomatis apabila pengguna terdeteksi berada
   pada jarak lebih dari 20 cm.
4. Apabila pengguna berada pada jarak lebih dari 120 cm dan selama 3 detik tidak
   kembali kedalam jarak tersebut maka sistem akan mati secara otomatis
5. Apabila suhu ruangan lebih dari 33ºC maka sistem akan mati secara otomatis.
6. Sistem juga dapat dimatikan secara otomatis menggunakan tombol yang
   disediakan.
11



                                         BAB IV
                            PENJELASAN SOURCE CODE
                                  DAN PENGUJIAN ALAT


4.1      Penjelasan Source Code
         Berikut beberapa source code yang digunakan dalam perancangan sistem
yaitu:
      Blok Fungsi Akses Ping
       DirSig=1; //Set sebagai output
       SigOut=1; //Pengiriman sinyal dimulai
       delay_us(5);
       SigOut=0; //Pengiriman sinyal selesai
       DirSig=0; //Set as input
       SigOut=1; //Pullup activated
       TCNT1=0; // mereset timer
       while (SigIn==0)
           {}
       TCCR1B=0x02; //mengeset timer dgan frekuensi 2 MHZ
         while (SigIn==1)
           {}
         TCCR1B=0x00; // mematikan timer
         distance=(TCNT1*0.0086106);
                   // t=n/f // n=jumlah gel // f=frekuensi
                   // s=v*t // v=344.434m/s // v=34443.4cm/s
                   // 2s=v*t >> karena waktu tempuh 2 kali
                   // 2s=34443.4* n /2000.000 >>>> 4MHZ
                   // s= n * 0.0086106
 Blok Fungsi Suhu
      tegangan=read_adc(0);



                                                   11
12



    tegangan=tegangan*4.89;               //tegangan       sensor       dalam      //millivolt
    5000mV/1023=4.89mV
    suhu=tegangan/10; // mengubah nilai tegangan kedalam //suhu dengan membagai
    bilangan 10 yang merupakan //konstanta kelipatan kenaikan suhu pada LM 35


4.2      Pengujian Alat
Pengujian Sistem terlihat pada gambar berikut ini
 Pada saat sistem berada pada state Heater off




                                    Gambar 4.1 saat state Off

 Pada saat sistem berada pada state Heater On




                       Gambar 4.2 saat state Heater On suhu 29ºC dan jarak 20 cm

     Pada saat sistem berada pada state heater standBy




                 Gambar 4.3 state Heater standBy suhu 35ºC dan jarak 20,70 cm
13



Perbandingan pengukuran jarak antara hasil ukur dengan alat ukur penggaris. Pada
pengujian ini dilakukan dengan cara menggunakan buku (30x21) cm2                 yang
diletakkan diatas penggaris kemudian dilihat hasil pengukuran pada LCD dan letak
buku pada penggaris. Dari cara tersebut diperoleh data di tabel berikut ini.
Tabel 4.1 Perbandingan Pengukuran Sensor Ping dan Penggaris
         Pengukaran            Hasil
                                              Error
  No      Penggaris        Pengukuran
                                              (cm)
             (cm)           PING (cm)
  1          3.00              3.08             0.08
  2          5.00              5.65             0.65
  3          8.00              8.07             0.07
  4         10.00              10.22            0.22
  5         12.00              12.37            0.37
  6         15.00              15.15            0.15
  7         17.00              16.85           -0.15
  8         20.00              19.93           -0.07
  9         25.00              24.97           -0.03
  10        30.00              30.07            0.07
             Rata-Rata Error                    0.14
Dari tabel 4.1 tersebut terlihat bahwa rata-rata error yang dihasilkan dari pengukuran
adalah sebesar 0.14 cm.
14



                                   Bab V
                                Kesimpulan
      Dari hasil pengujian diperoleh bahwa sistem yang dihasilkan sesuai dengan
rancangan yaitu sistem hasil pengujian menunjukkan performa yang sesuai dengan
yang telah dirancang yaitu Perancangan Heater sebagai pemanas ruangan
menggunakan sensor Ping sebagai pendekteksi adanya pengguna (rentang kerja 100
cm dari 20 cm sampai 120 cm) dan sensor suhu LM 35 digunakan sebagai input agar
suhu yang dihasilkan tidak terlalu panas yaitu dibawah 33ºC. Kemudian hasil
pengkuran menggunakan sensor ping memperlihatkan keluaran yang cukup baik
dengan rata-rata error yaitu 0.14 cm. Dengan adanya pembuktian bahwa jarak yang
dihasilkan oleh sensor ping hampir mendekati sebenarnya maka sensor ini cocok
untuk diaplikasi dalam perancangan sistem pemanas ruangan dalam hal ini
mendeteksi adanya keberadaan pengguna.




                                          14
Daftar Pustaka

[1] --- Sensor Ping Data Sheet ,
    http://www.google.co.id/url?sa=t&rct=j&q=ping%20parallax&source=web&cd=2&ved=0CCcQ
    FjAB&url=http%3A%2F%2Fwww.parallax.com%2Fdl%2Fdocs%2Fprod%2Facc%2F28015-
    PING-
    v1.3.pdf&ei=BYDwTr7MGc7prQeR0LjiDw&usg=AFQjCNHh0CMP8LzfryTUSMxqhpYrvluv8
    g Desember 2011
[2] --- Sensor LM 35 Data Sheet, www.national.com/ds/LM/LM35.pdf
    Desember 2011
[3] Syahadi, M., Aplikasi Kontrol Proporsional Integral Berbasis Mikrokontroller Atmega 8535
    untuk Pengaturan Suhu pada Alat Pengering Kertas , Skripsi S-1, Universitas Diponegoro,
    Semarang, 2008.
BIODATA PENULIS




Oka Danil Saputra, dilahirkan di Jambi, 17 Juli 1990, saat ini menempuh studi
strara 1 di Teknik Elektro Undip konsenterasi Kontrol.
Lampiran

1. Listing Program
   /*****************************************************
   This program was produced by the
   CodeWizardAVR V2.03.4 Standard
   Automatic Program Generator
   © Copyright 1998-2008 Pavel Haiduc, HP InfoTech s.r.l.
   http://www.hpinfotech.com
   Project :
   Version :
   Date : 12/21/2011
   Author :
   Company :
   Comments:
   Chip type        : ATmega128
   Program type       : Application
   Clock frequency : 16.000000 MHz
   Memory model         : Small
   External RAM size : 0
   Data Stack size : 1024
   *****************************************************/
   enum {start,mati};
   #include <mega128.h>
   #include <delay.h>
   #include <math.h>
   #include <stdio.h>
   #include <stdlib.h>

   // Alphanumeric LCD Module functions
   #asm
      .equ __lcd_port=0x15 ;PORTC
   #endasm
   #include <lcd.h>

   #define LED PORTA.0
   #define Heater PORTD.0
   #define Pb1 PINE.0
   #define On    1
#define Off    0

//Alokasi Port PING//
#define SigOut PORTB.1
#define SigIn PINB.1
#define DirSig DDRB.1
/////////////////////
#define ADC_VREF_TYPE 0x40

// Read the AD conversion result
unsigned int read_adc(unsigned char adc_input)
{
ADMUX=adc_input | (ADC_VREF_TYPE & 0xff);
// Delay needed for the stabilization of the ADC input voltage
delay_us(10);
// Start the AD conversion
ADCSRA|=0x40;
// Wait for the AD conversion to complete
while ((ADCSRA & 0x10)==0);
ADCSRA|=0x10;
return ADCW;
}
void baca_ping();
void baca_suhu();
unsigned char suhu,state;
unsigned int tegangan;
char Baris1[16],Baris2[16];
float distance;
// Declare your global variables here

void main(void)
{
// Declare your local variables here

// Input/Output Ports initialization
// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In
Func0=Out
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T
State0=0
PORTA=0x00;
DDRA=0x01;

// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In
Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T
State0=T
PORTB=0x00;
DDRB=0x00;

// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In
Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T
State0=T
PORTC=0x00;
DDRC=0x00;

// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In
Func0=Out
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T
State0=0
PORTD=0x00;
DDRD=0x01;

// Port E initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In
Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T
State0=T
PORTE=0xFF;
DDRE=0x00;

// Port F initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In
Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T
State0=T
PORTF=0x00;
DDRF=0x00;

// Port G initialization
// Func4=In Func3=In Func2=In Func1=In Func0=In
// State4=T State3=T State2=T State1=T State0=T
PORTG=0x00;
DDRG=0x00;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=FFh
// OC0 output: Disconnected
ASSR=0x00;
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 2000.000 kHz
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// OC1C output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
// Compare C Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x02;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
OCR1CH=0x00;
OCR1CL=0x00;

// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;

// Timer/Counter 3 initialization
// Clock source: System Clock
// Clock value: Timer 3 Stopped
// Mode: Normal top=FFFFh
// Noise Canceler: Off
// Input Capture on Falling Edge
// OC3A output: Discon.
// OC3B output: Discon.
// OC3C output: Discon.
// Timer 3 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
// Compare C Match Interrupt: Off
TCCR3A=0x00;
TCCR3B=0x00;
TCNT3H=0x00;
TCNT3L=0x00;
ICR3H=0x00;
ICR3L=0x00;
OCR3AH=0x00;
OCR3AL=0x00;
OCR3BH=0x00;
OCR3BL=0x00;
OCR3CH=0x00;
OCR3CL=0x00;

// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
// INT3: Off
// INT4: Off
// INT5: Off
// INT6: Off
// INT7: Off
EICRA=0x00;
EICRB=0x00;
EIMSK=0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;
ETIMSK=0x00;

// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;

// ADC initialization
// ADC Clock frequency: 250.000 kHz
// ADC Voltage Reference: AVCC pin
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0x86;

// LCD module initialization
lcd_init(16);
lcd_clear(); lcd_putsf("Heater_Off");
state=mati;

while (1)
   {
   // Place your code here
   if    (!Pb1) {
                 if (state==mati) {state=start; delay_ms(200); }
                 else if (state==start) {state=mati;
                                 lcd_clear(); lcd_putsf("Heater_Off");
                                 delay_ms(200); //200
                                }
               }

   if (state==start)
   {
     lcd_clear();
     //LED=1; Heater=1;
     baca_suhu();       baca_ping();
     lcd_gotoxy(0,1);lcd_putsf("Jarak=");
     ftoa(distance,2,Baris2); lcd_gotoxy(7,1); lcd_puts(Baris2);
     lcd_putsf(" cm");
     if (distance<=20 || distance>=120 || suhu>33)
     {
           LED=0; Heater=0;
           lcd_clear();
           sprintf(Baris1,"Suhu =%3d H_SB",suhu);
           lcd_gotoxy(0,0);lcd_puts(Baris1);
           lcd_gotoxy(0,1);lcd_putsf("Jarak=");
           ftoa(distance,2,Baris2); lcd_gotoxy(7,1); lcd_puts(Baris2);
           lcd_putsf(" cm");
           delay_ms(200); //100

          baca_ping();
          if ( distance>=120) //|| suhu>33 )
          {
             lcd_clear();
             lcd_gotoxy(0,0);lcd_putsf("Waiting...");
             lcd_gotoxy(0,1);lcd_putsf("3 Detik");
delay_ms(3000); // delay waiting
              baca_ping();
              if ( distance>=120 || suhu>33 ) {state=mati; lcd_clear();
lcd_putsf("Heater_Off"); }
           }
      }
      else { LED=1; Heater=1; sprintf(Baris1,"Suhu =%3d H_On",suhu);
      lcd_gotoxy(0,0);lcd_puts(Baris1);
       }
    }
    else if (state==mati) { LED=Off; Heater=Off; }
    delay_ms(200); // 100
   };
};


void baca_ping()
{
     DirSig=1; //Set sebagai output
     SigOut=1; //Pengiriman sinyal dimulai
     delay_us(5);
     SigOut=0; //Pengiriman sinyal selesai
     DirSig=0; //Set as input
     SigOut=1; //Pullup activated
     TCNT1=0; // mereset timer
     while (SigIn==0)
        {}
     TCCR1B=0x02; //mengeset timer dgan frekuensi 2 MHZ
     while (SigIn==1)
        {}
     TCCR1B=0x00; // mematikan timer
     distance=(TCNT1*0.0086106);
               // t=n/f // n=jumlah gel // f=frekuensi
               // s=v*t // v=344.434m/s // v=34443.4cm/s
               // 2s=v*t >> karena waktu tempuh 2 kali
               // 2s=34443.4* n /2000.000 >>>> 4MHZ
               // s= n * 0.0086106
}
void baca_suhu()
{
     tegangan=read_adc(0);
     tegangan=tegangan*4.89; //tegangan sensor dalam milivolt
     suhu=tegangan/10;
}
599 Menlo Drive, Suite 100        General: info@parallax.com
                                      Rocklin, California 95765, USA    Technical: support@parallax.com
                                      Office: (916) 624-8333            Web Site: www.parallax.com
                                      Fax: (916) 624-8003               Educational: www.stampsinclass.com




PING)))™ Ultrasonic Distance Sensor (#28015)
The Parallax PING))) ultrasonic distance sensor provides precise, non-contact distance measurements
from about 2 cm (0.8 inches) to 3 meters (3.3 yards). It is very easy to connect to BASIC Stamp® or
Javelin Stamp microcontrollers, requiring only one I/O pin.

The PING))) sensor works by transmitting an ultrasonic (well above human hearing range) burst and
providing an output pulse that corresponds to the time required for the burst echo to return to the
sensor. By measuring the echo pulse width the distance to target can easily be calculated.



Features

    •   Supply Voltage – 5 VDC
    •   Supply Current – 30 mA typ; 35 mA max
    •   Range – 2 cm to 3 m (0.8 in to 3.3 yrds)
    •   Input Trigger – positive TTL pulse, 2 uS min, 5 µs typ.
    •   Echo Pulse – positive TTL pulse, 115 uS to 18.5 ms
    •   Echo Hold-off – 750 µs from fall of Trigger pulse
    •   Burst Frequency – 40 kHz for 200 µs
    •   Burst Indicator LED shows sensor activity
    •   Delay before next measurement – 200 µs
    •   Size – 22 mm H x 46 mm W x 16 mm D (0.84 in x 1.8 in x 0.6 in)


Dimensions




© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006                       Page 1 of 13
Pin Definitions

 GND            Ground (Vss)
 5V             5 VDC (Vdd)
 SIG            Signal (I/O pin)

The PING))) sensor has a male 3-pin header used to supply power
(5 VDC), ground, and signal. The header allows the sensor to be
plugged into a solderless breadboard, or to be located remotely
through the use of a standard servo extender cable (Parallax part
#805-00002). Standard connections are show in the diagram to
the right.

Quick-Start Circuit

This circuit allows you to quickly connect your PING))) sensor to a BASIC Stamp® 2 via the Board of
Education® breadboard area. The PING))) module’s GND pin connects to Vss, the 5 V pin connects to
Vdd, and the SIG pin connects to I/O pin P15. This circuit will work with the example program
Ping_Demo.BS2 listed on page 7.




Servo Cable and Port Cautions

If you want to connect your PING))) sensor to a Board of Education
using a servo extension cable, follow these steps:

    1. When plugging the cable onto the PING))) sensor, connect
       Black to GND, Red to 5 V, and White to SIG.
    2. Check to see if your Board of Education servo ports have a
       jumper, as shown at right.
    3. If your Board of Education servo ports have a jumper, set it
       to Vdd as shown.
    4. If your Board of Education servo ports do not have a
       jumper, do not use them with the PING))) sensor. These
       ports only provide Vin, not Vdd, and this may damage your
       PING))) sensor. Go to the next step.
    5. Connect the servo cable directly to the breadboard with a            Board of Education Servo Port
       3-pin header. Then, use jumper wires to connect Black to                  Jumper, Set to Vdd
       Vss, Red to Vdd, and White to I/O pin P15.



© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006              Page 2 of 13
Theory of Operation

The PING))) sensor detects objects by emitting a short ultrasonic burst and then "listening" for the echo.
Under control of a host microcontroller (trigger pulse), the sensor emits a short 40 kHz (ultrasonic) burst.
This burst travels through the air at about 1130 feet per second, hits an object and then bounces back to
the sensor. The PING))) sensor provides an output pulse to the host that will terminate when the echo
is detected, hence the width of this pulse corresponds to the distance to the target.




Test Data

The test data on the following pages is based on the PING))) sensor, tested in the Parallax lab, while
connected to a BASIC Stamp microcontroller module. The test surface was a linoleum floor, so the
sensor was elevated to minimize floor reflections in the data. All tests were conducted at room
temperature, indoors, in a protected environment. The target was always centered at the same elevation
as the PING))) sensor.




© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006               Page 3 of 13
Test 1

Sensor Elevation:    40 in. (101.6 cm)
Target:              3.5 in. (8.9 cm) diameter cylinder, 4 ft. (121.9 cm) tall – vertical orientation




© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006                  Page 4 of 13
Test 2

Sensor Elevation:    40 in. (101.6 cm)
Target:              12 in. x 12 in. (30.5 cm x 30.5 cm) cardboard, mounted on 1 in. (2.5 cm) pole
                     ● target positioned parallel to backplane of sensor




© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006            Page 5 of 13
Program Example: BASIC Stamp 2 Microcontroller

The following program demonstrates the use of the PING))) sensor with the BASIC Stamp 2
microcontroller.   Any model of BASIC Stamp 2 module will work with this program as conditional
compilation techniques are used to make adjustments based on the module that is connected.

The heart of the program is the Get_Sonar subroutine. This routine starts by making the output bit of
the selected IO pin zero – this will cause the successive PULSOUT to be low-high-low as required for
triggering the PING))) sensor. After the trigger pulse falls the sensor will wait about 200 microseconds
before transmitting the ultrasonic burst. This allows the BS2 to load and prepare the next instruction.
That instruction, PULSIN, is used to measure the high-going pulse that corresponds to the distance to
the target object.

The raw return value from PULSIN must be scaled due to resolution differences between the various
members of the BS2 family. After the raw value is converted to microseconds, it is divided by two in
order to remove the "return trip" of the echo pulse. The value now held in rawDist is the distance to the
target in microseconds.

Conversion from microseconds to inches (or centimeters) is now a simple matter of math. The generally-
accepted value for the speed-of-sound is 1130 feet per second. This works out to 13,560 inches per
second or one inch in 73.746 microseconds. The question becomes, how do we divide our pulse
measurement value by the floating-point number 73.746?

Another way to divide by 73.746 is to multiply by 0.01356. For new BASIC Stamp users this may seem a
dilemma but in fact there is a special operator, **, that allows us to do just that. The ** operator has
the affect of multiplying a value by units of 1/65,536. To find the parameter for ** then, we simply
multiply 0.01356 by 65,536; the result is 888.668 (we'll round up to 889).

Conversion to centimeters uses the same process and the result of the program is shown below:




© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006            Page 6 of 13
' =========================================================================
'
'   File....... Ping_Demo.BS2
'   Purpose.... Demo Code for Parallax PING))) Sonar Sensor
'   Author..... Parallax, Inc.
'   E-mail..... support@parallax.com
'   Started....
'   Updated.... 08 JUN 2005
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


'   -----[ Program Description ]---------------------------------------------
'
'   This program demonstrates the use of the Parallax PING))) sensor and then
'   converting the raw measurement to English (inches) and Metric (cm) units.
'
'   Sonar Math:
'
'   At sea level sound travels through air at 1130 feet per second.                     This
'   equates to 1 inch in 73.746 uS, or 1 cm in 29.034 uS).
'
'   Since the PING))) sensor measures the time required for the sound wave to
'   travel from the sensor and back. The result -- after conversion to
'   microseconds for the BASIC Stamp module in use -- is divided by two to
'   remove the return portion of the echo pulse. The final raw result is
'   the duration from the front of the sensor to the target in microseconds.


' -----[ I/O Definitions ]-------------------------------------------------

Ping                  PIN         15


' -----[ Constants ]-------------------------------------------------------

#SELECT $STAMP
  #CASE BS2, BS2E
    Trigger     CON     5                                           ' trigger pulse = 10 uS
    Scale       CON     $200                                        ' raw x 2.00 = uS
  #CASE BS2SX, BS2P, BS2PX
    Trigger     CON     13
    Scale       CON     $0CD                                        ' raw x 0.80 = uS
  #CASE BS2PE
    Trigger     CON     5
    Scale       CON     $1E1                                        ' raw x 1.88 = uS
#ENDSELECT

RawToIn               CON         889                               ' 1 / 73.746 (with **)
RawToCm               CON         2257                              ' 1 / 29.034 (with **)

IsHigh                CON         1                                 ' for PULSOUT
IsLow                 CON         0




© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006         Page 7 of 13
' -----[ Variables ]-------------------------------------------------------

rawDist               VAR         Word                              ' raw measurement
inches                VAR         Word
cm                    VAR         Word


' -----[ Initialization ]--------------------------------------------------

Reset:
  DEBUG CLS,
        "Parallax PING))) Sonar",               CR,                 ' setup report screen
        "======================",               CR,
        CR,
        "Time (uS).....        ",               CR,
        "Inches........        ",               CR,
        "Centimeters...        "


' -----[ Program Code ]----------------------------------------------------

Main:
  DO
    GOSUB Get_Sonar                                                 ' get sensor value
    inches = rawDist ** RawToIn                                     ' convert to inches
    cm = rawDist ** RawToCm                                         ' convert to centimeters

     DEBUG CRSRXY, 15, 3,                                           ' update report screen
           DEC rawDist, CLREOL,
           CRSRXY, 15, 4,
           DEC inches, CLREOL,
           CRSRXY, 15, 5,
           DEC cm, CLREOL

      PAUSE 100
    LOOP
    END


' -----[ Subroutines ]-----------------------------------------------------

'   This subroutine triggers the PING))) sonar sensor and measures
'   the echo pulse. The raw value from the sensor is converted to
'   microseconds based on the Stamp module in use. This value is
'   divided by two to remove the return trip -- the result value is
'   the distance from the sensor to the target in microseconds.

Get_Sonar:
  Ping = IsLow                                                      '   make trigger 0-1-0
  PULSOUT Ping, Trigger                                             '   activate sensor
  PULSIN Ping, IsHigh, rawDist                                      '   measure echo pulse
  rawDist = rawDist */ Scale                                        '   convert to uS
  rawDist = rawDist / 2                                             '   remove return trip
  RETURN




© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006            Page 8 of 13
Program Example: BASIC Stamp 1 Microcontroller
' =========================================================================
'
'   File....... Ping_Demo.BS1
'   Purpose.... Demo Code for Parallax PING))) Sonar Sensor
'   Author..... Parallax, Inc.
'   E-mail..... support@parallax.com
'   Started....
'   Updated.... 06 JUN 2006
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


'   -----[ Program Description ]---------------------------------------------
'
'   This program demonstrates the use of the Parallax PING))) sensor and then
'   converting the raw measurement to English (inches) and Metric (cm) units.
'
'   Sonar Math:
'
'   At sea level sound travels through air at 1130 feet per second.                     This
'   equates to 1 inch in 73.746 uS, or 1 cm in 29.034 uS).
'
'   Since the PING))) sensor measures the time required for the sound wave to
'   travel from the sensor and back. The result -- after conversion to
'   microseconds for the BASIC Stamp module in use -- is divided by two to
'   remove the return portion of the echo pulse. The final raw result is
'   the duration from the front of the sensor to the target in microseconds.


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL     Ping                   = 7


' -----[ Constants ]-------------------------------------------------------

SYMBOL     Trigger                = 1                               ' 10 uS trigger pulse
SYMBOL     Scale                  = 10                              ' raw x 10.00 = uS

SYMBOL     RawToIn                = 889                             ' 1 / 73.746 (with **)
SYMBOL     RawToCm                = 2257                            ' 1 / 29.034 (with **)

SYMBOL     IsHigh                 = 1                               ' for PULSOUT
SYMBOL     IsLow                  = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL     rawDist                = W1                              ' raw measurement
SYMBOL     inches                 = W2
SYMBOL     cm                     = W3



© Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006           Page 9 of 13
simulasi-pemanas-ruang-menggunakan-sensor-ping-dan-lm35
simulasi-pemanas-ruang-menggunakan-sensor-ping-dan-lm35
simulasi-pemanas-ruang-menggunakan-sensor-ping-dan-lm35
simulasi-pemanas-ruang-menggunakan-sensor-ping-dan-lm35
simulasi-pemanas-ruang-menggunakan-sensor-ping-dan-lm35
simulasi-pemanas-ruang-menggunakan-sensor-ping-dan-lm35
simulasi-pemanas-ruang-menggunakan-sensor-ping-dan-lm35
simulasi-pemanas-ruang-menggunakan-sensor-ping-dan-lm35
simulasi-pemanas-ruang-menggunakan-sensor-ping-dan-lm35
simulasi-pemanas-ruang-menggunakan-sensor-ping-dan-lm35
simulasi-pemanas-ruang-menggunakan-sensor-ping-dan-lm35

Mais conteúdo relacionado

Mais procurados

Riko hadiarto 151354027_b200_saski
Riko hadiarto 151354027_b200_saskiRiko hadiarto 151354027_b200_saski
Riko hadiarto 151354027_b200_saski
Riko Hadiarto
 
B300 - Sistem Kendali PID Suhu Ruangan Menggunakan LM35 Sebagai Sensor dan Dr...
B300 - Sistem Kendali PID Suhu Ruangan Menggunakan LM35 Sebagai Sensor dan Dr...B300 - Sistem Kendali PID Suhu Ruangan Menggunakan LM35 Sebagai Sensor dan Dr...
B300 - Sistem Kendali PID Suhu Ruangan Menggunakan LM35 Sebagai Sensor dan Dr...
AnggiaRamadhanty
 
Sensor temperatur dengan output led
Sensor temperatur dengan output ledSensor temperatur dengan output led
Sensor temperatur dengan output led
Ilham Khoir
 
Perancangan Penghitung Pengunjung Perpustakaan Berbasis Mikrokontroller AT89...
Perancangan  Penghitung Pengunjung Perpustakaan Berbasis Mikrokontroller AT89...Perancangan  Penghitung Pengunjung Perpustakaan Berbasis Mikrokontroller AT89...
Perancangan Penghitung Pengunjung Perpustakaan Berbasis Mikrokontroller AT89...
Ohen Razak
 
Riko hadiarto 151354027_b100-b600_saski
Riko hadiarto 151354027_b100-b600_saskiRiko hadiarto 151354027_b100-b600_saski
Riko hadiarto 151354027_b100-b600_saski
Riko Hadiarto
 

Mais procurados (18)

Riko hadiarto 151354027_b200_saski
Riko hadiarto 151354027_b200_saskiRiko hadiarto 151354027_b200_saski
Riko hadiarto 151354027_b200_saski
 
Tugas 2
Tugas 2Tugas 2
Tugas 2
 
Tugas 2
Tugas 2Tugas 2
Tugas 2
 
Skt4 c b200_reni setiowati_131354026_proyek mandiri
Skt4 c b200_reni setiowati_131354026_proyek mandiriSkt4 c b200_reni setiowati_131354026_proyek mandiri
Skt4 c b200_reni setiowati_131354026_proyek mandiri
 
Dokumen b100 b600 project mandiri sistem kendali suhu menggunakan lm35, mosfe...
Dokumen b100 b600 project mandiri sistem kendali suhu menggunakan lm35, mosfe...Dokumen b100 b600 project mandiri sistem kendali suhu menggunakan lm35, mosfe...
Dokumen b100 b600 project mandiri sistem kendali suhu menggunakan lm35, mosfe...
 
[Digital Control - Light Intensity Control with PID] by Albert Stefanus -
[Digital Control - Light Intensity Control with PID] by Albert Stefanus - [Digital Control - Light Intensity Control with PID] by Albert Stefanus -
[Digital Control - Light Intensity Control with PID] by Albert Stefanus -
 
Sistem Kendali Suhu Ruangan dengan Metode PID Menggunakan LM35 dan Triac Be...
Sistem Kendali  Suhu Ruangan dengan Metode PID  Menggunakan LM35 dan Triac Be...Sistem Kendali  Suhu Ruangan dengan Metode PID  Menggunakan LM35 dan Triac Be...
Sistem Kendali Suhu Ruangan dengan Metode PID Menggunakan LM35 dan Triac Be...
 
B300 - Sistem Kendali PID Suhu Ruangan Menggunakan LM35 Sebagai Sensor dan Dr...
B300 - Sistem Kendali PID Suhu Ruangan Menggunakan LM35 Sebagai Sensor dan Dr...B300 - Sistem Kendali PID Suhu Ruangan Menggunakan LM35 Sebagai Sensor dan Dr...
B300 - Sistem Kendali PID Suhu Ruangan Menggunakan LM35 Sebagai Sensor dan Dr...
 
B100 - B600 Water Level Control dengan metode PID
B100 - B600 Water Level Control dengan metode PIDB100 - B600 Water Level Control dengan metode PID
B100 - B600 Water Level Control dengan metode PID
 
Skd 131311062-laporan akhir
Skd 131311062-laporan akhirSkd 131311062-laporan akhir
Skd 131311062-laporan akhir
 
Sensor temperatur dengan output led berbasis arduino
Sensor temperatur dengan output led berbasis arduinoSensor temperatur dengan output led berbasis arduino
Sensor temperatur dengan output led berbasis arduino
 
Sensor temperatur dengan output led
Sensor temperatur dengan output ledSensor temperatur dengan output led
Sensor temperatur dengan output led
 
Laporan Jemuran ikan asin otomatis
Laporan Jemuran ikan asin otomatisLaporan Jemuran ikan asin otomatis
Laporan Jemuran ikan asin otomatis
 
Sistem Pengendalian Suhu Ruangan Dengan TRIAC dan Sensor Suhu LM35 Berbasis PID
Sistem Pengendalian Suhu Ruangan Dengan TRIAC dan Sensor Suhu LM35 Berbasis PIDSistem Pengendalian Suhu Ruangan Dengan TRIAC dan Sensor Suhu LM35 Berbasis PID
Sistem Pengendalian Suhu Ruangan Dengan TRIAC dan Sensor Suhu LM35 Berbasis PID
 
Jurnal
JurnalJurnal
Jurnal
 
Perancangan Penghitung Pengunjung Perpustakaan Berbasis Mikrokontroller AT89...
Perancangan  Penghitung Pengunjung Perpustakaan Berbasis Mikrokontroller AT89...Perancangan  Penghitung Pengunjung Perpustakaan Berbasis Mikrokontroller AT89...
Perancangan Penghitung Pengunjung Perpustakaan Berbasis Mikrokontroller AT89...
 
Riko hadiarto 151354027_b100-b600_saski
Riko hadiarto 151354027_b100-b600_saskiRiko hadiarto 151354027_b100-b600_saski
Riko hadiarto 151354027_b100-b600_saski
 
SMART WASTE (hospital safety box monitoring) di RSU HERMINA ARCAMANIK
SMART WASTE (hospital safety box monitoring) di RSU HERMINA ARCAMANIKSMART WASTE (hospital safety box monitoring) di RSU HERMINA ARCAMANIK
SMART WASTE (hospital safety box monitoring) di RSU HERMINA ARCAMANIK
 

Semelhante a simulasi-pemanas-ruang-menggunakan-sensor-ping-dan-lm35

2. abstrak dan daftar isi, tabel dan gambar
2. abstrak dan daftar isi, tabel dan gambar2. abstrak dan daftar isi, tabel dan gambar
2. abstrak dan daftar isi, tabel dan gambar
Ian March
 
Sensor temperatur dengan output led berbasis Arduino UNO
Sensor temperatur dengan output led berbasis Arduino UNOSensor temperatur dengan output led berbasis Arduino UNO
Sensor temperatur dengan output led berbasis Arduino UNO
Ely Rohaeti
 
Sensor dan transduser
Sensor dan transduserSensor dan transduser
Sensor dan transduser
liesyn
 
Tugas jurnal basindo rian
Tugas jurnal basindo rianTugas jurnal basindo rian
Tugas jurnal basindo rian
Muhamad Iqbal
 

Semelhante a simulasi-pemanas-ruang-menggunakan-sensor-ping-dan-lm35 (20)

"Kendali Temperature Ruangan dengan PID Berbasis Arduino" Document B100-600
"Kendali Temperature Ruangan dengan PID Berbasis Arduino" Document B100-600"Kendali Temperature Ruangan dengan PID Berbasis Arduino" Document B100-600
"Kendali Temperature Ruangan dengan PID Berbasis Arduino" Document B100-600
 
Sistem Kendali Temperatur Ruangan dengan TRIAC menggunakan metode PID berbasi...
Sistem Kendali Temperatur Ruangan dengan TRIAC menggunakan metode PID berbasi...Sistem Kendali Temperatur Ruangan dengan TRIAC menggunakan metode PID berbasi...
Sistem Kendali Temperatur Ruangan dengan TRIAC menggunakan metode PID berbasi...
 
2. abstrak dan daftar isi, tabel dan gambar
2. abstrak dan daftar isi, tabel dan gambar2. abstrak dan daftar isi, tabel dan gambar
2. abstrak dan daftar isi, tabel dan gambar
 
Sistem Kendali suhu ruangan dengan pid backward difference berbasis arduino, ...
Sistem Kendali suhu ruangan dengan pid backward difference berbasis arduino, ...Sistem Kendali suhu ruangan dengan pid backward difference berbasis arduino, ...
Sistem Kendali suhu ruangan dengan pid backward difference berbasis arduino, ...
 
Jemuran ikan asin otomatis
Jemuran ikan asin otomatis Jemuran ikan asin otomatis
Jemuran ikan asin otomatis
 
Atap jemuran ikan asin otomatis
Atap jemuran ikan asin otomatisAtap jemuran ikan asin otomatis
Atap jemuran ikan asin otomatis
 
B100 b600 nursalim-waterheater_controlwithpid
B100 b600 nursalim-waterheater_controlwithpidB100 b600 nursalim-waterheater_controlwithpid
B100 b600 nursalim-waterheater_controlwithpid
 
Skt4 c b400_reni setiowati_13135406_proyek mandiri
Skt4 c b400_reni setiowati_13135406_proyek mandiriSkt4 c b400_reni setiowati_13135406_proyek mandiri
Skt4 c b400_reni setiowati_13135406_proyek mandiri
 
Sistem kendali suhu ruangan dengan metode pid berbasis arduino uno, triac, da...
Sistem kendali suhu ruangan dengan metode pid berbasis arduino uno, triac, da...Sistem kendali suhu ruangan dengan metode pid berbasis arduino uno, triac, da...
Sistem kendali suhu ruangan dengan metode pid berbasis arduino uno, triac, da...
 
Skd 131311061-laporan-akhir
Skd 131311061-laporan-akhirSkd 131311061-laporan-akhir
Skd 131311061-laporan-akhir
 
Pengendali suhu dengan PID berbasis arduino dan MOSFET
Pengendali suhu dengan PID berbasis arduino dan MOSFETPengendali suhu dengan PID berbasis arduino dan MOSFET
Pengendali suhu dengan PID berbasis arduino dan MOSFET
 
DOKUMEN B200: SISTEM KENDALI POSISI GORDEN DENGAN MENGGUNAKAN METODA PID
DOKUMEN B200: SISTEM KENDALI POSISI GORDEN DENGAN MENGGUNAKAN METODA PID DOKUMEN B200: SISTEM KENDALI POSISI GORDEN DENGAN MENGGUNAKAN METODA PID
DOKUMEN B200: SISTEM KENDALI POSISI GORDEN DENGAN MENGGUNAKAN METODA PID
 
Sensor temperatur dengan output led berbasis Arduino UNO
Sensor temperatur dengan output led berbasis Arduino UNOSensor temperatur dengan output led berbasis Arduino UNO
Sensor temperatur dengan output led berbasis Arduino UNO
 
Sensor temperatur dengan output led berbasis Arduino UNO
Sensor temperatur dengan output led berbasis Arduino UNOSensor temperatur dengan output led berbasis Arduino UNO
Sensor temperatur dengan output led berbasis Arduino UNO
 
Sensor dan transduser
Sensor dan transduserSensor dan transduser
Sensor dan transduser
 
Laporan Akhir SKD -
Laporan Akhir SKD - Laporan Akhir SKD -
Laporan Akhir SKD -
 
[Kendali Suhu dengan TRIAC dan Sensor LM35] Sutan Dafari B300
[Kendali Suhu dengan TRIAC dan Sensor LM35] Sutan Dafari B300[Kendali Suhu dengan TRIAC dan Sensor LM35] Sutan Dafari B300
[Kendali Suhu dengan TRIAC dan Sensor LM35] Sutan Dafari B300
 
Sensor temperatur dengan output led
Sensor temperatur dengan output ledSensor temperatur dengan output led
Sensor temperatur dengan output led
 
Tugas jurnal basindo rian
Tugas jurnal basindo rianTugas jurnal basindo rian
Tugas jurnal basindo rian
 
Teknik Penulisan Karya Ilmiah
Teknik Penulisan Karya IlmiahTeknik Penulisan Karya Ilmiah
Teknik Penulisan Karya Ilmiah
 

Último

Bab 7 - Perilaku Ekonomi dan Kesejahteraan Sosial.pptx
Bab 7 - Perilaku Ekonomi dan Kesejahteraan Sosial.pptxBab 7 - Perilaku Ekonomi dan Kesejahteraan Sosial.pptx
Bab 7 - Perilaku Ekonomi dan Kesejahteraan Sosial.pptx
ssuser35630b
 
aksi nyata penyebaran pemahaman merdeka belajar
aksi nyata penyebaran pemahaman merdeka belajaraksi nyata penyebaran pemahaman merdeka belajar
aksi nyata penyebaran pemahaman merdeka belajar
HafidRanggasi
 
PPT PERUBAHAN LINGKUNGAN MATA PELAJARAN BIOLOGI KELAS X.pptx
PPT PERUBAHAN LINGKUNGAN MATA PELAJARAN BIOLOGI KELAS X.pptxPPT PERUBAHAN LINGKUNGAN MATA PELAJARAN BIOLOGI KELAS X.pptx
PPT PERUBAHAN LINGKUNGAN MATA PELAJARAN BIOLOGI KELAS X.pptx
dpp11tya
 

Último (20)

PELAKSANAAN + Link-Link MATERI Training_ "Effective INVENTORY & WAREHOUSING M...
PELAKSANAAN + Link-Link MATERI Training_ "Effective INVENTORY & WAREHOUSING M...PELAKSANAAN + Link-Link MATERI Training_ "Effective INVENTORY & WAREHOUSING M...
PELAKSANAAN + Link-Link MATERI Training_ "Effective INVENTORY & WAREHOUSING M...
 
AKSI NYATA BERBAGI PRAKTIK BAIK MELALUI PMM
AKSI NYATA BERBAGI PRAKTIK BAIK MELALUI PMMAKSI NYATA BERBAGI PRAKTIK BAIK MELALUI PMM
AKSI NYATA BERBAGI PRAKTIK BAIK MELALUI PMM
 
vIDEO kelayakan berita untuk mahasiswa.ppsx
vIDEO kelayakan berita untuk mahasiswa.ppsxvIDEO kelayakan berita untuk mahasiswa.ppsx
vIDEO kelayakan berita untuk mahasiswa.ppsx
 
Pendidikan-Bahasa-Indonesia-di-SD MODUL 3 .pptx
Pendidikan-Bahasa-Indonesia-di-SD MODUL 3 .pptxPendidikan-Bahasa-Indonesia-di-SD MODUL 3 .pptx
Pendidikan-Bahasa-Indonesia-di-SD MODUL 3 .pptx
 
POWER POINT MODUL 1 PEBI4223 (PENDIDIKAN LINGKUNGAN HIDUP)
POWER POINT MODUL 1 PEBI4223 (PENDIDIKAN LINGKUNGAN HIDUP)POWER POINT MODUL 1 PEBI4223 (PENDIDIKAN LINGKUNGAN HIDUP)
POWER POINT MODUL 1 PEBI4223 (PENDIDIKAN LINGKUNGAN HIDUP)
 
MATEMATIKA EKONOMI MATERI ANUITAS DAN NILAI ANUITAS
MATEMATIKA EKONOMI MATERI ANUITAS DAN NILAI ANUITASMATEMATIKA EKONOMI MATERI ANUITAS DAN NILAI ANUITAS
MATEMATIKA EKONOMI MATERI ANUITAS DAN NILAI ANUITAS
 
Modul Projek - Batik Ecoprint - Fase B.pdf
Modul Projek  - Batik Ecoprint - Fase B.pdfModul Projek  - Batik Ecoprint - Fase B.pdf
Modul Projek - Batik Ecoprint - Fase B.pdf
 
Integrasi nasional dalam bingkai bhinneka tunggal ika
Integrasi nasional dalam bingkai bhinneka tunggal ikaIntegrasi nasional dalam bingkai bhinneka tunggal ika
Integrasi nasional dalam bingkai bhinneka tunggal ika
 
Bab 7 - Perilaku Ekonomi dan Kesejahteraan Sosial.pptx
Bab 7 - Perilaku Ekonomi dan Kesejahteraan Sosial.pptxBab 7 - Perilaku Ekonomi dan Kesejahteraan Sosial.pptx
Bab 7 - Perilaku Ekonomi dan Kesejahteraan Sosial.pptx
 
Keterampilan menyimak kelas bawah tugas UT
Keterampilan menyimak kelas bawah tugas UTKeterampilan menyimak kelas bawah tugas UT
Keterampilan menyimak kelas bawah tugas UT
 
2 KISI-KISI Ujian Sekolah Dasar mata pelajaranPPKn 2024.pdf
2 KISI-KISI Ujian Sekolah Dasar  mata pelajaranPPKn 2024.pdf2 KISI-KISI Ujian Sekolah Dasar  mata pelajaranPPKn 2024.pdf
2 KISI-KISI Ujian Sekolah Dasar mata pelajaranPPKn 2024.pdf
 
MODUL 1 Pembelajaran Kelas Rangkap-compressed.pdf
MODUL 1 Pembelajaran Kelas Rangkap-compressed.pdfMODUL 1 Pembelajaran Kelas Rangkap-compressed.pdf
MODUL 1 Pembelajaran Kelas Rangkap-compressed.pdf
 
RENCANA + Link2 Materi Pelatihan/BimTek "PTK 007 Rev-5 Thn 2023 (PENGADAAN) &...
RENCANA + Link2 Materi Pelatihan/BimTek "PTK 007 Rev-5 Thn 2023 (PENGADAAN) &...RENCANA + Link2 Materi Pelatihan/BimTek "PTK 007 Rev-5 Thn 2023 (PENGADAAN) &...
RENCANA + Link2 Materi Pelatihan/BimTek "PTK 007 Rev-5 Thn 2023 (PENGADAAN) &...
 
PELAKSANAAN + Link-Link MATERI Training_ "Effective INVENTORY & WAREHOUSING...
PELAKSANAAN  + Link-Link MATERI Training_ "Effective INVENTORY &  WAREHOUSING...PELAKSANAAN  + Link-Link MATERI Training_ "Effective INVENTORY &  WAREHOUSING...
PELAKSANAAN + Link-Link MATERI Training_ "Effective INVENTORY & WAREHOUSING...
 
aksi nyata penyebaran pemahaman merdeka belajar
aksi nyata penyebaran pemahaman merdeka belajaraksi nyata penyebaran pemahaman merdeka belajar
aksi nyata penyebaran pemahaman merdeka belajar
 
presentasi lembaga negara yang ada di indonesia
presentasi lembaga negara yang ada di indonesiapresentasi lembaga negara yang ada di indonesia
presentasi lembaga negara yang ada di indonesia
 
Perumusan Visi dan Prakarsa Perubahan.pptx
Perumusan Visi dan Prakarsa Perubahan.pptxPerumusan Visi dan Prakarsa Perubahan.pptx
Perumusan Visi dan Prakarsa Perubahan.pptx
 
REFLEKSI MANDIRI_Prakarsa Perubahan BAGJA Modul 1.3.pdf
REFLEKSI MANDIRI_Prakarsa Perubahan BAGJA Modul 1.3.pdfREFLEKSI MANDIRI_Prakarsa Perubahan BAGJA Modul 1.3.pdf
REFLEKSI MANDIRI_Prakarsa Perubahan BAGJA Modul 1.3.pdf
 
Sosialisasi PPDB SulSel tahun 2024 di Sulawesi Selatan
Sosialisasi PPDB SulSel tahun 2024 di Sulawesi SelatanSosialisasi PPDB SulSel tahun 2024 di Sulawesi Selatan
Sosialisasi PPDB SulSel tahun 2024 di Sulawesi Selatan
 
PPT PERUBAHAN LINGKUNGAN MATA PELAJARAN BIOLOGI KELAS X.pptx
PPT PERUBAHAN LINGKUNGAN MATA PELAJARAN BIOLOGI KELAS X.pptxPPT PERUBAHAN LINGKUNGAN MATA PELAJARAN BIOLOGI KELAS X.pptx
PPT PERUBAHAN LINGKUNGAN MATA PELAJARAN BIOLOGI KELAS X.pptx
 

simulasi-pemanas-ruang-menggunakan-sensor-ping-dan-lm35

  • 1. Perancangan Heater sebagai Pemanas Ruangan Menggunakan Sensor Jarak Ping Parallax dan Sensor Suhu LM 35 Laporan Tugas Mata Kuliah Komponen Sistem Kontrol oleh Oka D. Saputra L2F008146 JURUSAN TEKNIK ELEKTRO FAKULTAS TEKNIK UNIVERSITAS DIPONEGORO SEMARANG, 2011 i
  • 2. KATA PENGANTAR Alhamdulillah, Segala puji hanya bagi Allah Subhànahu wa Ta’ala, atas segala limpahan rahmat dan karunia-Nya, sehingga penyusun dapat menyelesaikan laporan “Perancangan Heater sebagai Pemanas Ruangan Menggunakan Sensor Jarak Ping Parallax dan Sensor Suhu LM 35 ”. Dalam pembuatan dan penyusunan laporan Tugas Akhir, penyusun juga banyak mendapatkan bantuan dan dukungan dari berbagai pihak. Atas kelancaran selama pelaksanaan Tugas Akhir dan penyusunan laporan ini, maka penyusun mengucapkan banyak terima kasih kepada : 1. Bapak Ir. Sudjadi, M.T. selaku Ketua Jurusan Teknik Elektro Fakultas Teknik Universitas Diponegoro 2. Bapak Sumardi S.T., M.T. selaku dosen mata kuliah Komponen Sistem Kontrol yang mengarahkan penulis dalam pembuatan Tugas Akhir ini 3. Keluargaku tercinta atas segala bentuk dorongan semangat dan dukungannya. 4. Saudara Fairus yang membimbing penulis sehingga tugas akhir ini dapat terselesaikan. 5. teman-teman yang mengikuti kuliah Komponen Sistem Kontrol. 6. Serta semua pihak yang tidak dapat penyusun sebutkan satu-persatu. Penyusun menyadari bahwa masih terdapat beberapa kekurangan dalam laporan Tugas Akhir ini. Kritik dan saran yang bersifat membangun sangat penyusun harapkan dari semua pihak, sebagai pengalaman dan tambahan pengetahuan bagi penyusun. Akhir kata semoga karya ini tidak menjadi yang pertama sekaligus yang terakhir dan semoga laporan ini dapat bermanfaat bagi mahasiswa Teknik Elektro Universitas Diponegoro pada khususnya dan masyarakat pada umumnya. Semarang, Desember 2011 Penyusun ii
  • 3. Abstrak Banyak Aplikasi yang dapat kita terapkan ketika kita membahas tentang sistem kontrol. Salah satunya pemanfaatan kemajuan teknologi sensor seperti sensor jarak ping produksi Parallax, sensor suhu LM 35 dari National Semiconductor dan juga actuator Heater (dalam hal ini solder) untuk pengendalian suhu ruangan yang terlalu dingin. Tujuan dari paper ini adalah merancang dan membuat alat yang dapat mengontrol suhu ruangan dan mendeteksi ada tidaknya pengguna didalam ruangan tersebut. Dalam perancangan alat, ada beberapa elemen yang menjadi parameter sebagai inputan agar heater aktif, dalam simulasi ini digunakan sebagai jarak terdekat antara pengguna ruangan dengan heater adalah 20 cm sedangkan untuk jarak terjauh adalah 120 cm sedangkan untuk suhu terpanas yang menjadikan heater off adalah 33ºC. Keywords — Sensor Ping, Sensor LM35, Heater iii
  • 4. DAFTAR ISI HALAMAN JUDUL ……………………………………………………… i KATA PENGANTAR …………………… ………………………………. ii ABSTRAK …………………………………………………….................... iii DAFTAR ISI ……………………………………………………………… iv DAFTAR GAMBAR………………………………………………………. v DAFTAR TABEL …………………………………………………………. v BAB I PENDAHULUAN ………………………………………………. 1 1.1 Latar Belakang …………………………………..………..... 1 1.2 Tujuan Tugas Akhir ……………………………………….. 1 1.3 Pembatasan Masalah …….………………………………..... 1 1.4 Sistematika Penulisan ……………………………………..... 2 BAB II DASAR TEORI ……….…………………………..…………….. 3 2.1 Sensor Ping……………………..…………………………… 3 2.2 Sensor LM 35………………………………………………. 4 2.3 Mikrokontroller ATMEGA 128 .……………………………. 5 2.4 LCD ………………………………………………………. 5 2.5 LED…….. .…………………………….…………………… 6 2.6 MOC 3021………………………………………………….. 7 2.7 Triac………………………………………………………… 7 2.8 Solder………………………………………………………. 7 BAB III PERANCANGAN ALAT ……………………………..……….. 8 3.1 Perancangan Perangkat Keras …………………….……..… 8 3.2 Perancangan Perangkat Lunak ……………………………… 9 BAB IV PENJELASAN SOURCE CODE DAN PENGUJIAN ALAT ….... 11 4.1 Penjelasan Source Code….. ………………………………… 11 4.2 Pengujian Alat ………………………….…………………… 12 BAB V PENUTUP …………………………………………………………. 14 DAFTAR PUSTAKA iv
  • 5. DAFTAR GAMBAR Gambar 2.1 Sensor PING Ultrasonik Range Finder ...................................... 3 Gambar 2.2 Sensor PING Ultrasonik Range Finder timing diagram............. 3 Gambar 2.3 Ilustrasi Sensor Ping .................................................................. 4 Gambar 2.4 Sensor LM35 dan Konfigurasi PIN ........................................... 4 Gambar 2.5 Konfigurasi Pin Atmega 128...................................................... 5 Gambar 2.6 Konfigurasi pin LCD. ................................................................ 6 Gambar 2.7 Simbol LED. .............................................................................. 6 Gambar 2.8 Konfigurasi MOC 3021………………………………………..7 Gambar 2.9 Rangkaian Ekuivalen Triac. ...................................................... .7 Gambar 2.10 Solder ………………………………………………………...7 Gambar 3.1 Blok diagram hardware .............................................................. 8 Gambar 3.2 FSM sistem ................................................................................ 9 Gambar 4.1 saat state Off ............................................................................ 12 Gambar 4.2 saat state Heater On suhu 29ºC dan jarak 20 cm .................... 12 Gambar 4.3 state Heater standBy suhu 35ºC dan jarak 20,70 cm ............... 12 DAFTAR TABEL Tabel 4.1 Perbandingan Pengukuran Sensor Ping dan Penggaris................ 13 v
  • 6. BAB I PENDAHULUAN 1.1 Latar Belakang Pada Akhir-akhir ini teknik kontrol telah menjadi bagian yang sangat penting dalam kehidupan manusia. Dengan semakin tingginya tingkat kebutuhan maka untuk memenuhi kebutuhan tersebut dibutuhkan suatu perancangan sistem yang mampu berjalan secara otomatis. Pada peper ini dilakukan perancangan control suhu ruangan yang terlalu dingin menggunakan sensor jarak dan sensor suhu. Tujuan dari paper ini adalah merancang dan membuat alat yang dapat mengontrol suhu ruangan dan mendeteksi ada tidaknya pengguna didalam ruangan tersebut. Smart Heater adalah suatu alat yang dapat digunakan sebagai pemanas ruangan dan juga mendekteksi adanya pengguna dari pemanas ruangan tersebut. Kontrol On Off adalah suatu metode yang mudah dan tepat untuk pengontrolan alat ini dengan hanya menggunakan dua logika yaitu logika HIGH (1) dan logika LOW(0). 1.2 Tujuan 1. Merancang Smart Heater yang dapat bekerja sesuai dengan algoritma yang telah dirancang. 2. Mengetahui Prinsip Kerja sistem control khususnya control On-Off, 3. Memenuhi tugas Komponen Sistem Kontrol yang diajarkan di Jurusan Elektro Fakultas Teknik Universitas Diponegoro 1.3 Pembatasan Masalah Dalam pembuatan tugas akhir ini penulis membatasi permasalahan sebagai berikut : 1. Sistem Kontrol yang digunakan merupakan kontrol On-Off 2. Sensor yang digunakan adalah sensor ultrasonik yang diproduksi oleh Parallax ( Sensor PING Ultrasonik Range Finder). 1
  • 7. 2 3. Range pendeteksian antara 3 cm – 300 cm. 4. Tugas akhir ini tidak membahas mengenai arsitektur mikrokontroller 5. Mikrokontroler yang digunakan adalah ATMega128. 1.4 Sistematika Penulisan Sistematika penulisan dalam laporan tugas akhir ini adalah sebagai berikut: BAB I PENDAHULUAN Berisi tentang latar belakang masalah, tujuan penulisan, batasan masalah dan sistematika penulisan. BAB II DASAR TEORI Berisi tentang teori-teori yang mendukung dalam perancangan tugas akhir ini, yaitu tentang mikrokontroler atmega128, sensor ping, sensor LM35, LCD, MOC3021, Triac BT139. BAB III PERANCANGAN Berisi tentang perancangan perangkat lunak (software) dan perangkat keras (hardware) dari sistem yang digunakan pada Smart Heater dan indikator led. BAB IV PENGUJIAN DAN ANALISA Berisi tentang pengujian dan analisa terhadap perangkat lunak dan perangkat keras yang telah dibuat serta pengujian sistem secara keseluruhan. BAB V PENUTUP Berisi kesimpulan dan saran.
  • 8. 3 BAB II DASAR TEORI 2.1 Sensor Ping Sensor yang digunakan pada pembuatan tugas Komponen ini merupakan [1] sebuah sensor ultrasonik buatan Parallax ( Sensor PING Ultrasonik Range Finder). Rangkaian lengkap sensor ditunjukkan pada Gambar 2.1 Gambar 2.1 Sensor PING Ultrasonik Range Finder. Sensor PING ini secara khusus didesain untuk dapat mengukur jarak sebuah benda padat (solid).Range jarak yang mampu diukur oleh sensor PING adalah 3 cm sampai dengan 300 cm. Sensor PING mendeteksi jarak objek dengan cara memancarkan gelombang ultrasonik (>20kHz) selama waktu pemancaran kemudian mendeteksi pantulannya. Gambar 2.2 Sensor PING Ultrasonik Range Finder timing diagram. 3
  • 9. 4 Sensor PING memancarkan gelombang ultrasonik sesuai dengan pulsa trigger dari mikrokontroler sebagai pengendali.Gambar 2 menunjukkan timing diagram dari Sensor PING. Lebar pulsa high (tIN) akan sesuai dengan lama waktu tempuh gelombang ultrasonik untuk 2x jarak ukur dengan objek seperti yang ditunjukkan pada Gambar 3, maka jarak yang diukur dapat dirumuskan sebagai berikut :  t IN sx344m / s    meter Jarak=  2  Gambar 2.3 Ilustrasi cara kerja sensor PING 2.2 Sensor LM 35 Salah satu sensor suhu adalah sensor LM35 [2]. Berikut gambar sensor LM35. Gambar 2.4 Sensor LM35 dan Konfigurasi PIN Sensor suhu LM35 adalah komponen elektronika yang memiliki fungsi untuk mengubah besaran suhu menjadi besaran listrik dalam bentuk tegangan. Sensor Suhu LM35 yang dipakai dalam paper ini berupa komponen elektronika elektronika yang diproduksi oleh National Semiconductor. Secara prinsip sensor akan melakukan penginderaan pada saat perubahan suhu setiap suhu 1 ºC akan menunjukan perubahan tegangan sebesar 10 mV.
  • 10. 5 2.3 Mikrokontroller ATMEGA 128 Berikut ini konfigurasi Pin pada Atmega 128. Gambar 2.5 Konfigurasi Pin Atmega 128 Mikrokontroler ATMEGA128 termasuk dalam mikrokontroler keluarga AVR. Dengan fitur-fitur eksternal clock sampai 16 MHz, 53 Pin/Port yang bias digunakan sebagai I/O dan beberapa fungsi khusus seperti pada port F dilengkapi dengan ACD, timer 8 dan 16 bit dan lain sebagainya. 2.4 LCD Modul LCD (Liquid Crystal Display) adalah salah satu alat yang digunakan sebagai tampilan. Pada dasarnya sistem pengaturan LCD memiliki standar yang sama walaupun sangat banyak macamnya baik ditinjau dariperusahaan pembuat maupun dari ukurannya. LCD yang digunakan merupakan modul dot-matrix tampilan kristal cair (LCD) dengan tampilan 16 x 2 baris dengan konsumsi daya rendah. Modul LCD ini telah dilengkapi dengan mikrokontroler yang didesain khusus untuk mengendalikan
  • 11. 6 LCD, berfungsi sebagai pengatur (system controller) dan penghasil karakter (character generator). Konfigurasi pin dari LCD ditunjukkan pada Gambar 2.6 Gambar 2.6 Konfigurasi pin LCD Modul LCD memiliki karakteristik sebagai berikut: • Terdapat 16 x 2 karakter huruf yang bisa ditampilkan. • Setiap huruf terdiri dari 5x7 dot-matrix cursor. • Terdapat 192 macam karakter. • Terdapat 80 x 8 bit display RAM (maksimal 80 karakter). • Memiliki kemampuan penulisan dengan 8 bit maupun dengan 4 bit. • Dibangun dengan osilator lokal. • Satu sumber tegangan 5 volt. • Otomatis reset saat tegangan dihidupkan. • Bekerja pada suhu 0 0C sampai 55 0C. 2.5 LED LED (Light Emitting Diode) atau dioda pancaran cahaya adalah suatu bahan padat sejenis dioda yang mengkonversi arus listrik menjadi cahaya. Dalam penggunannya digunakan sebagai penanda berupa nyala lampu pijar. Strukturnya juga sama dengan dioda, elektron yang menerjang sambungan P-N juga melepaskan energi berupa energi panas dan energi cahaya. Untuk mendapatkan emisi cahaya pada semikonduktor, doping yang dipakai adalah gallium, arsenic, dan phosporus. Jenis doping yang berbeda menghasilkan warna cahaya yang berbeda pula. Gambar 2.7 Simbol LED
  • 12. 7 2.6 MOC 3021 Fungsi dari MOC ini adalah sebagai isolator agar bagian DC yang ada pada kontrol mikrokontroller tidak langsung terhubung dengan bagian AC yang ada pada triac. Berikut gambar konfigurasi MOC 3021 Gambar 2.8 Konfigurasi MOC 3021 2.7 TRIAC Untuk pengontrolan pada tegangan AC, umumnya digunakan bidirectional triode thyristor atau dikenal dengan triac. Triac dapat bersifat konduktif dalam dua arah. Dalam hal ini dapat dianggap sebagai dua buah tryristor tersambung secara antiparallel dengan koneksi gerbang seperti gambar berikut[3]. Gambar 2.9 Rangkaian Ekuivalen Triac 2.8 Solder Pada perancangan ini untuk mengambarkan sebuah element pemanas menggunakan solder. Dalam perancangan sistem panas dari solder inilah yang akan di kontrol. Gambar 2.10 Solder
  • 13. 8 BAB III PERANCANGAN 3.1 Perancangan Perangkat Keras Perangkat keras dari sistem yang akan dibangun meliputi sistem minimum mikrokontroler ATMEGA 128, Push Button, LCD, Power Supply AC dan DC, Indikator LED, Sensor LM 35, Sensor jarak Ping, Triac BT 139, MOC 3021 dan Heater. Berikut blok digram dari koneksi komponen tersebut Gambar 3.1 Blok diagram hardware Tiap-tiap bagian dari diagram blok sistem dapat dijelaskan sebagai berikut: 1. Atmega 128 berfungsi sebagai otak dari alat. 2. Sensor Ping berfungsi sebagai masukan data untuk mengetahui adanya pengguna atau tidak. 3. Sensor LM35 berfungsi untuk mengukur nilai suhu dari heater. 4. Regulator a. 220 volt AC berfungsi sebagai tegangan masukkan heater b. 5 volt DC volt berfungsi sebagai supply mikro dan sensor-sensor 5. LCD berfunsi sebagai tampilan untuk state sistem 8
  • 14. 9 6. Push Button berfungsi sebagai inputan untuk menyala dan mematikan sistem 7. MOC 3021 berfungsi sebagai isolator untuk mengamankan antara arus AC dan DC. 8. LED berfungsi sebagai indicator nyala heater. 9. Triac berfungsi sebagai pengontrol nyala dan matinya heater. 3.2 Perancangan Perangkat Lunak Bahasa pemrograman yang digunakan dalam pembuatan perangkat lunak menggunakan bahasa C untuk proses pengontrolan melalui AVR ATmega 128 dengan bantuan software CVAVR. Dalam perancangan Software menggunakan metode Finite State Machine, metode ini dipilih karena lebih mudah dalam implementasi ke source code. Berikut FSM sistem yang dirancang. Gambar 3.2 FSM sistem Berikut cara kerja dari sistem Heater pemanas ruangan 1. Heater dinyalakan menggunakan tombol. 2. Apabila penggunakan yang menyalakan sistem terdeksi berada didalam ruangan (asumsi jarak terdekat 20cm dan jarak terjauh 120 cm dari heater) maka sistem pemanas dan lampu LED indicator akan menyala.
  • 15. 10 3. Apabila pengguna berada pada jarak kurang dari 20 cm maka heater akan mati dan sistem akan menyala secara otomatis apabila pengguna terdeteksi berada pada jarak lebih dari 20 cm. 4. Apabila pengguna berada pada jarak lebih dari 120 cm dan selama 3 detik tidak kembali kedalam jarak tersebut maka sistem akan mati secara otomatis 5. Apabila suhu ruangan lebih dari 33ºC maka sistem akan mati secara otomatis. 6. Sistem juga dapat dimatikan secara otomatis menggunakan tombol yang disediakan.
  • 16. 11 BAB IV PENJELASAN SOURCE CODE DAN PENGUJIAN ALAT 4.1 Penjelasan Source Code Berikut beberapa source code yang digunakan dalam perancangan sistem yaitu:  Blok Fungsi Akses Ping DirSig=1; //Set sebagai output SigOut=1; //Pengiriman sinyal dimulai delay_us(5); SigOut=0; //Pengiriman sinyal selesai DirSig=0; //Set as input SigOut=1; //Pullup activated TCNT1=0; // mereset timer while (SigIn==0) {} TCCR1B=0x02; //mengeset timer dgan frekuensi 2 MHZ while (SigIn==1) {} TCCR1B=0x00; // mematikan timer distance=(TCNT1*0.0086106); // t=n/f // n=jumlah gel // f=frekuensi // s=v*t // v=344.434m/s // v=34443.4cm/s // 2s=v*t >> karena waktu tempuh 2 kali // 2s=34443.4* n /2000.000 >>>> 4MHZ // s= n * 0.0086106  Blok Fungsi Suhu tegangan=read_adc(0); 11
  • 17. 12 tegangan=tegangan*4.89; //tegangan sensor dalam //millivolt 5000mV/1023=4.89mV suhu=tegangan/10; // mengubah nilai tegangan kedalam //suhu dengan membagai bilangan 10 yang merupakan //konstanta kelipatan kenaikan suhu pada LM 35 4.2 Pengujian Alat Pengujian Sistem terlihat pada gambar berikut ini  Pada saat sistem berada pada state Heater off Gambar 4.1 saat state Off  Pada saat sistem berada pada state Heater On Gambar 4.2 saat state Heater On suhu 29ºC dan jarak 20 cm  Pada saat sistem berada pada state heater standBy Gambar 4.3 state Heater standBy suhu 35ºC dan jarak 20,70 cm
  • 18. 13 Perbandingan pengukuran jarak antara hasil ukur dengan alat ukur penggaris. Pada pengujian ini dilakukan dengan cara menggunakan buku (30x21) cm2 yang diletakkan diatas penggaris kemudian dilihat hasil pengukuran pada LCD dan letak buku pada penggaris. Dari cara tersebut diperoleh data di tabel berikut ini. Tabel 4.1 Perbandingan Pengukuran Sensor Ping dan Penggaris Pengukaran Hasil Error No Penggaris Pengukuran (cm) (cm) PING (cm) 1 3.00 3.08 0.08 2 5.00 5.65 0.65 3 8.00 8.07 0.07 4 10.00 10.22 0.22 5 12.00 12.37 0.37 6 15.00 15.15 0.15 7 17.00 16.85 -0.15 8 20.00 19.93 -0.07 9 25.00 24.97 -0.03 10 30.00 30.07 0.07 Rata-Rata Error 0.14 Dari tabel 4.1 tersebut terlihat bahwa rata-rata error yang dihasilkan dari pengukuran adalah sebesar 0.14 cm.
  • 19. 14 Bab V Kesimpulan Dari hasil pengujian diperoleh bahwa sistem yang dihasilkan sesuai dengan rancangan yaitu sistem hasil pengujian menunjukkan performa yang sesuai dengan yang telah dirancang yaitu Perancangan Heater sebagai pemanas ruangan menggunakan sensor Ping sebagai pendekteksi adanya pengguna (rentang kerja 100 cm dari 20 cm sampai 120 cm) dan sensor suhu LM 35 digunakan sebagai input agar suhu yang dihasilkan tidak terlalu panas yaitu dibawah 33ºC. Kemudian hasil pengkuran menggunakan sensor ping memperlihatkan keluaran yang cukup baik dengan rata-rata error yaitu 0.14 cm. Dengan adanya pembuktian bahwa jarak yang dihasilkan oleh sensor ping hampir mendekati sebenarnya maka sensor ini cocok untuk diaplikasi dalam perancangan sistem pemanas ruangan dalam hal ini mendeteksi adanya keberadaan pengguna. 14
  • 20. Daftar Pustaka [1] --- Sensor Ping Data Sheet , http://www.google.co.id/url?sa=t&rct=j&q=ping%20parallax&source=web&cd=2&ved=0CCcQ FjAB&url=http%3A%2F%2Fwww.parallax.com%2Fdl%2Fdocs%2Fprod%2Facc%2F28015- PING- v1.3.pdf&ei=BYDwTr7MGc7prQeR0LjiDw&usg=AFQjCNHh0CMP8LzfryTUSMxqhpYrvluv8 g Desember 2011 [2] --- Sensor LM 35 Data Sheet, www.national.com/ds/LM/LM35.pdf Desember 2011 [3] Syahadi, M., Aplikasi Kontrol Proporsional Integral Berbasis Mikrokontroller Atmega 8535 untuk Pengaturan Suhu pada Alat Pengering Kertas , Skripsi S-1, Universitas Diponegoro, Semarang, 2008.
  • 21. BIODATA PENULIS Oka Danil Saputra, dilahirkan di Jambi, 17 Juli 1990, saat ini menempuh studi strara 1 di Teknik Elektro Undip konsenterasi Kontrol.
  • 22. Lampiran 1. Listing Program /***************************************************** This program was produced by the CodeWizardAVR V2.03.4 Standard Automatic Program Generator © Copyright 1998-2008 Pavel Haiduc, HP InfoTech s.r.l. http://www.hpinfotech.com Project : Version : Date : 12/21/2011 Author : Company : Comments: Chip type : ATmega128 Program type : Application Clock frequency : 16.000000 MHz Memory model : Small External RAM size : 0 Data Stack size : 1024 *****************************************************/ enum {start,mati}; #include <mega128.h> #include <delay.h> #include <math.h> #include <stdio.h> #include <stdlib.h> // Alphanumeric LCD Module functions #asm .equ __lcd_port=0x15 ;PORTC #endasm #include <lcd.h> #define LED PORTA.0 #define Heater PORTD.0 #define Pb1 PINE.0 #define On 1
  • 23. #define Off 0 //Alokasi Port PING// #define SigOut PORTB.1 #define SigIn PINB.1 #define DirSig DDRB.1 ///////////////////// #define ADC_VREF_TYPE 0x40 // Read the AD conversion result unsigned int read_adc(unsigned char adc_input) { ADMUX=adc_input | (ADC_VREF_TYPE & 0xff); // Delay needed for the stabilization of the ADC input voltage delay_us(10); // Start the AD conversion ADCSRA|=0x40; // Wait for the AD conversion to complete while ((ADCSRA & 0x10)==0); ADCSRA|=0x10; return ADCW; } void baca_ping(); void baca_suhu(); unsigned char suhu,state; unsigned int tegangan; char Baris1[16],Baris2[16]; float distance; // Declare your global variables here void main(void) { // Declare your local variables here // Input/Output Ports initialization // Port A initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=Out
  • 24. // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=0 PORTA=0x00; DDRA=0x01; // Port B initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTB=0x00; DDRB=0x00; // Port C initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTC=0x00; DDRC=0x00; // Port D initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=Out // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=0 PORTD=0x00; DDRD=0x01; // Port E initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTE=0xFF; DDRE=0x00; // Port F initialization
  • 25. // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTF=0x00; DDRF=0x00; // Port G initialization // Func4=In Func3=In Func2=In Func1=In Func0=In // State4=T State3=T State2=T State1=T State0=T PORTG=0x00; DDRG=0x00; // Timer/Counter 0 initialization // Clock source: System Clock // Clock value: Timer 0 Stopped // Mode: Normal top=FFh // OC0 output: Disconnected ASSR=0x00; TCCR0=0x00; TCNT0=0x00; OCR0=0x00; // Timer/Counter 1 initialization // Clock source: System Clock // Clock value: 2000.000 kHz // Mode: Normal top=FFFFh // OC1A output: Discon. // OC1B output: Discon. // OC1C output: Discon. // Noise Canceler: Off // Input Capture on Falling Edge // Timer 1 Overflow Interrupt: Off // Input Capture Interrupt: Off // Compare A Match Interrupt: Off // Compare B Match Interrupt: Off // Compare C Match Interrupt: Off TCCR1A=0x00; TCCR1B=0x02;
  • 26. TCNT1H=0x00; TCNT1L=0x00; ICR1H=0x00; ICR1L=0x00; OCR1AH=0x00; OCR1AL=0x00; OCR1BH=0x00; OCR1BL=0x00; OCR1CH=0x00; OCR1CL=0x00; // Timer/Counter 2 initialization // Clock source: System Clock // Clock value: Timer 2 Stopped // Mode: Normal top=FFh // OC2 output: Disconnected TCCR2=0x00; TCNT2=0x00; OCR2=0x00; // Timer/Counter 3 initialization // Clock source: System Clock // Clock value: Timer 3 Stopped // Mode: Normal top=FFFFh // Noise Canceler: Off // Input Capture on Falling Edge // OC3A output: Discon. // OC3B output: Discon. // OC3C output: Discon. // Timer 3 Overflow Interrupt: Off // Input Capture Interrupt: Off // Compare A Match Interrupt: Off // Compare B Match Interrupt: Off // Compare C Match Interrupt: Off TCCR3A=0x00; TCCR3B=0x00; TCNT3H=0x00; TCNT3L=0x00; ICR3H=0x00;
  • 27. ICR3L=0x00; OCR3AH=0x00; OCR3AL=0x00; OCR3BH=0x00; OCR3BL=0x00; OCR3CH=0x00; OCR3CL=0x00; // External Interrupt(s) initialization // INT0: Off // INT1: Off // INT2: Off // INT3: Off // INT4: Off // INT5: Off // INT6: Off // INT7: Off EICRA=0x00; EICRB=0x00; EIMSK=0x00; // Timer(s)/Counter(s) Interrupt(s) initialization TIMSK=0x00; ETIMSK=0x00; // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off ACSR=0x80; SFIOR=0x00; // ADC initialization // ADC Clock frequency: 250.000 kHz // ADC Voltage Reference: AVCC pin ADMUX=ADC_VREF_TYPE & 0xff; ADCSRA=0x86; // LCD module initialization lcd_init(16);
  • 28. lcd_clear(); lcd_putsf("Heater_Off"); state=mati; while (1) { // Place your code here if (!Pb1) { if (state==mati) {state=start; delay_ms(200); } else if (state==start) {state=mati; lcd_clear(); lcd_putsf("Heater_Off"); delay_ms(200); //200 } } if (state==start) { lcd_clear(); //LED=1; Heater=1; baca_suhu(); baca_ping(); lcd_gotoxy(0,1);lcd_putsf("Jarak="); ftoa(distance,2,Baris2); lcd_gotoxy(7,1); lcd_puts(Baris2); lcd_putsf(" cm"); if (distance<=20 || distance>=120 || suhu>33) { LED=0; Heater=0; lcd_clear(); sprintf(Baris1,"Suhu =%3d H_SB",suhu); lcd_gotoxy(0,0);lcd_puts(Baris1); lcd_gotoxy(0,1);lcd_putsf("Jarak="); ftoa(distance,2,Baris2); lcd_gotoxy(7,1); lcd_puts(Baris2); lcd_putsf(" cm"); delay_ms(200); //100 baca_ping(); if ( distance>=120) //|| suhu>33 ) { lcd_clear(); lcd_gotoxy(0,0);lcd_putsf("Waiting..."); lcd_gotoxy(0,1);lcd_putsf("3 Detik");
  • 29. delay_ms(3000); // delay waiting baca_ping(); if ( distance>=120 || suhu>33 ) {state=mati; lcd_clear(); lcd_putsf("Heater_Off"); } } } else { LED=1; Heater=1; sprintf(Baris1,"Suhu =%3d H_On",suhu); lcd_gotoxy(0,0);lcd_puts(Baris1); } } else if (state==mati) { LED=Off; Heater=Off; } delay_ms(200); // 100 }; }; void baca_ping() { DirSig=1; //Set sebagai output SigOut=1; //Pengiriman sinyal dimulai delay_us(5); SigOut=0; //Pengiriman sinyal selesai DirSig=0; //Set as input SigOut=1; //Pullup activated TCNT1=0; // mereset timer while (SigIn==0) {} TCCR1B=0x02; //mengeset timer dgan frekuensi 2 MHZ while (SigIn==1) {} TCCR1B=0x00; // mematikan timer distance=(TCNT1*0.0086106); // t=n/f // n=jumlah gel // f=frekuensi // s=v*t // v=344.434m/s // v=34443.4cm/s // 2s=v*t >> karena waktu tempuh 2 kali // 2s=34443.4* n /2000.000 >>>> 4MHZ // s= n * 0.0086106 }
  • 30. void baca_suhu() { tegangan=read_adc(0); tegangan=tegangan*4.89; //tegangan sensor dalam milivolt suhu=tegangan/10; }
  • 31. 599 Menlo Drive, Suite 100 General: info@parallax.com Rocklin, California 95765, USA Technical: support@parallax.com Office: (916) 624-8333 Web Site: www.parallax.com Fax: (916) 624-8003 Educational: www.stampsinclass.com PING)))™ Ultrasonic Distance Sensor (#28015) The Parallax PING))) ultrasonic distance sensor provides precise, non-contact distance measurements from about 2 cm (0.8 inches) to 3 meters (3.3 yards). It is very easy to connect to BASIC Stamp® or Javelin Stamp microcontrollers, requiring only one I/O pin. The PING))) sensor works by transmitting an ultrasonic (well above human hearing range) burst and providing an output pulse that corresponds to the time required for the burst echo to return to the sensor. By measuring the echo pulse width the distance to target can easily be calculated. Features • Supply Voltage – 5 VDC • Supply Current – 30 mA typ; 35 mA max • Range – 2 cm to 3 m (0.8 in to 3.3 yrds) • Input Trigger – positive TTL pulse, 2 uS min, 5 µs typ. • Echo Pulse – positive TTL pulse, 115 uS to 18.5 ms • Echo Hold-off – 750 µs from fall of Trigger pulse • Burst Frequency – 40 kHz for 200 µs • Burst Indicator LED shows sensor activity • Delay before next measurement – 200 µs • Size – 22 mm H x 46 mm W x 16 mm D (0.84 in x 1.8 in x 0.6 in) Dimensions © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 1 of 13
  • 32. Pin Definitions GND Ground (Vss) 5V 5 VDC (Vdd) SIG Signal (I/O pin) The PING))) sensor has a male 3-pin header used to supply power (5 VDC), ground, and signal. The header allows the sensor to be plugged into a solderless breadboard, or to be located remotely through the use of a standard servo extender cable (Parallax part #805-00002). Standard connections are show in the diagram to the right. Quick-Start Circuit This circuit allows you to quickly connect your PING))) sensor to a BASIC Stamp® 2 via the Board of Education® breadboard area. The PING))) module’s GND pin connects to Vss, the 5 V pin connects to Vdd, and the SIG pin connects to I/O pin P15. This circuit will work with the example program Ping_Demo.BS2 listed on page 7. Servo Cable and Port Cautions If you want to connect your PING))) sensor to a Board of Education using a servo extension cable, follow these steps: 1. When plugging the cable onto the PING))) sensor, connect Black to GND, Red to 5 V, and White to SIG. 2. Check to see if your Board of Education servo ports have a jumper, as shown at right. 3. If your Board of Education servo ports have a jumper, set it to Vdd as shown. 4. If your Board of Education servo ports do not have a jumper, do not use them with the PING))) sensor. These ports only provide Vin, not Vdd, and this may damage your PING))) sensor. Go to the next step. 5. Connect the servo cable directly to the breadboard with a Board of Education Servo Port 3-pin header. Then, use jumper wires to connect Black to Jumper, Set to Vdd Vss, Red to Vdd, and White to I/O pin P15. © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 2 of 13
  • 33. Theory of Operation The PING))) sensor detects objects by emitting a short ultrasonic burst and then "listening" for the echo. Under control of a host microcontroller (trigger pulse), the sensor emits a short 40 kHz (ultrasonic) burst. This burst travels through the air at about 1130 feet per second, hits an object and then bounces back to the sensor. The PING))) sensor provides an output pulse to the host that will terminate when the echo is detected, hence the width of this pulse corresponds to the distance to the target. Test Data The test data on the following pages is based on the PING))) sensor, tested in the Parallax lab, while connected to a BASIC Stamp microcontroller module. The test surface was a linoleum floor, so the sensor was elevated to minimize floor reflections in the data. All tests were conducted at room temperature, indoors, in a protected environment. The target was always centered at the same elevation as the PING))) sensor. © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 3 of 13
  • 34. Test 1 Sensor Elevation: 40 in. (101.6 cm) Target: 3.5 in. (8.9 cm) diameter cylinder, 4 ft. (121.9 cm) tall – vertical orientation © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 4 of 13
  • 35. Test 2 Sensor Elevation: 40 in. (101.6 cm) Target: 12 in. x 12 in. (30.5 cm x 30.5 cm) cardboard, mounted on 1 in. (2.5 cm) pole ● target positioned parallel to backplane of sensor © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 5 of 13
  • 36. Program Example: BASIC Stamp 2 Microcontroller The following program demonstrates the use of the PING))) sensor with the BASIC Stamp 2 microcontroller. Any model of BASIC Stamp 2 module will work with this program as conditional compilation techniques are used to make adjustments based on the module that is connected. The heart of the program is the Get_Sonar subroutine. This routine starts by making the output bit of the selected IO pin zero – this will cause the successive PULSOUT to be low-high-low as required for triggering the PING))) sensor. After the trigger pulse falls the sensor will wait about 200 microseconds before transmitting the ultrasonic burst. This allows the BS2 to load and prepare the next instruction. That instruction, PULSIN, is used to measure the high-going pulse that corresponds to the distance to the target object. The raw return value from PULSIN must be scaled due to resolution differences between the various members of the BS2 family. After the raw value is converted to microseconds, it is divided by two in order to remove the "return trip" of the echo pulse. The value now held in rawDist is the distance to the target in microseconds. Conversion from microseconds to inches (or centimeters) is now a simple matter of math. The generally- accepted value for the speed-of-sound is 1130 feet per second. This works out to 13,560 inches per second or one inch in 73.746 microseconds. The question becomes, how do we divide our pulse measurement value by the floating-point number 73.746? Another way to divide by 73.746 is to multiply by 0.01356. For new BASIC Stamp users this may seem a dilemma but in fact there is a special operator, **, that allows us to do just that. The ** operator has the affect of multiplying a value by units of 1/65,536. To find the parameter for ** then, we simply multiply 0.01356 by 65,536; the result is 888.668 (we'll round up to 889). Conversion to centimeters uses the same process and the result of the program is shown below: © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 6 of 13
  • 37. ' ========================================================================= ' ' File....... Ping_Demo.BS2 ' Purpose.... Demo Code for Parallax PING))) Sonar Sensor ' Author..... Parallax, Inc. ' E-mail..... support@parallax.com ' Started.... ' Updated.... 08 JUN 2005 ' ' {$STAMP BS2} ' {$PBASIC 2.5} ' ' ========================================================================= ' -----[ Program Description ]--------------------------------------------- ' ' This program demonstrates the use of the Parallax PING))) sensor and then ' converting the raw measurement to English (inches) and Metric (cm) units. ' ' Sonar Math: ' ' At sea level sound travels through air at 1130 feet per second. This ' equates to 1 inch in 73.746 uS, or 1 cm in 29.034 uS). ' ' Since the PING))) sensor measures the time required for the sound wave to ' travel from the sensor and back. The result -- after conversion to ' microseconds for the BASIC Stamp module in use -- is divided by two to ' remove the return portion of the echo pulse. The final raw result is ' the duration from the front of the sensor to the target in microseconds. ' -----[ I/O Definitions ]------------------------------------------------- Ping PIN 15 ' -----[ Constants ]------------------------------------------------------- #SELECT $STAMP #CASE BS2, BS2E Trigger CON 5 ' trigger pulse = 10 uS Scale CON $200 ' raw x 2.00 = uS #CASE BS2SX, BS2P, BS2PX Trigger CON 13 Scale CON $0CD ' raw x 0.80 = uS #CASE BS2PE Trigger CON 5 Scale CON $1E1 ' raw x 1.88 = uS #ENDSELECT RawToIn CON 889 ' 1 / 73.746 (with **) RawToCm CON 2257 ' 1 / 29.034 (with **) IsHigh CON 1 ' for PULSOUT IsLow CON 0 © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 7 of 13
  • 38. ' -----[ Variables ]------------------------------------------------------- rawDist VAR Word ' raw measurement inches VAR Word cm VAR Word ' -----[ Initialization ]-------------------------------------------------- Reset: DEBUG CLS, "Parallax PING))) Sonar", CR, ' setup report screen "======================", CR, CR, "Time (uS)..... ", CR, "Inches........ ", CR, "Centimeters... " ' -----[ Program Code ]---------------------------------------------------- Main: DO GOSUB Get_Sonar ' get sensor value inches = rawDist ** RawToIn ' convert to inches cm = rawDist ** RawToCm ' convert to centimeters DEBUG CRSRXY, 15, 3, ' update report screen DEC rawDist, CLREOL, CRSRXY, 15, 4, DEC inches, CLREOL, CRSRXY, 15, 5, DEC cm, CLREOL PAUSE 100 LOOP END ' -----[ Subroutines ]----------------------------------------------------- ' This subroutine triggers the PING))) sonar sensor and measures ' the echo pulse. The raw value from the sensor is converted to ' microseconds based on the Stamp module in use. This value is ' divided by two to remove the return trip -- the result value is ' the distance from the sensor to the target in microseconds. Get_Sonar: Ping = IsLow ' make trigger 0-1-0 PULSOUT Ping, Trigger ' activate sensor PULSIN Ping, IsHigh, rawDist ' measure echo pulse rawDist = rawDist */ Scale ' convert to uS rawDist = rawDist / 2 ' remove return trip RETURN © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 8 of 13
  • 39. Program Example: BASIC Stamp 1 Microcontroller ' ========================================================================= ' ' File....... Ping_Demo.BS1 ' Purpose.... Demo Code for Parallax PING))) Sonar Sensor ' Author..... Parallax, Inc. ' E-mail..... support@parallax.com ' Started.... ' Updated.... 06 JUN 2006 ' ' {$STAMP BS1} ' {$PBASIC 1.0} ' ' ========================================================================= ' -----[ Program Description ]--------------------------------------------- ' ' This program demonstrates the use of the Parallax PING))) sensor and then ' converting the raw measurement to English (inches) and Metric (cm) units. ' ' Sonar Math: ' ' At sea level sound travels through air at 1130 feet per second. This ' equates to 1 inch in 73.746 uS, or 1 cm in 29.034 uS). ' ' Since the PING))) sensor measures the time required for the sound wave to ' travel from the sensor and back. The result -- after conversion to ' microseconds for the BASIC Stamp module in use -- is divided by two to ' remove the return portion of the echo pulse. The final raw result is ' the duration from the front of the sensor to the target in microseconds. ' -----[ I/O Definitions ]------------------------------------------------- SYMBOL Ping = 7 ' -----[ Constants ]------------------------------------------------------- SYMBOL Trigger = 1 ' 10 uS trigger pulse SYMBOL Scale = 10 ' raw x 10.00 = uS SYMBOL RawToIn = 889 ' 1 / 73.746 (with **) SYMBOL RawToCm = 2257 ' 1 / 29.034 (with **) SYMBOL IsHigh = 1 ' for PULSOUT SYMBOL IsLow = 0 ' -----[ Variables ]------------------------------------------------------- SYMBOL rawDist = W1 ' raw measurement SYMBOL inches = W2 SYMBOL cm = W3 © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 9 of 13
  • 40. ' -----[ Program Code ]---------------------------------------------------- Main: GOSUB Get_Sonar ' get sensor value inches = rawDist ** RawToIn ' convert to inches cm = rawDist ** RawToCm ' convert to centimeters DEBUG CLS ' report DEBUG "Time (uS)..... ", #rawDist, CR DEBUG "Inches........ ", #inches, CR DEBUG "Centimeters... ", #cm PAUSE 500 GOTO Main END ' -----[ Subroutines ]----------------------------------------------------- ' This subroutine triggers the PING))) sonar sensor and measures ' the echo pulse. The raw value from the sensor is converted to ' microseconds based on the Stamp module in use. This value is ' divided by two to remove the return trip -- the result value is ' the distance from the sensor to the target in microseconds. Get_Sonar: LOW Ping ' make trigger 0-1-0 PULSOUT Ping, Trigger ' activate sensor PULSIN Ping, IsHigh, rawDist ' measure echo pulse rawDist = rawDist * Scale ' convert to uS rawDist = rawDist / 2 ' remove return trip RETURN © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 10 of 13
  • 41. Program Example: Javelin Stamp Microcontroller This class file implements several methods for using the PING))) sensor: package stamp.peripheral.sensor; import stamp.core.*; /** * This class provides an interface to the Parallax PING))) ultrasonic * range finder module. * <p> * <i>Usage:</i><br> * <code> * Ping range = new Ping(CPU.pin0); // trigger and echo on P0 * </code> * <p> * Detailed documentation for the PING))) Sensor can be found at: <br> * http://www.parallax.com/detail.asp?product_id=28015 * <p> * * @version 1.0 03 FEB 2005 */ public final class Ping { private int ioPin; /** * Creates PING))) range finder object * * @param ioPin PING))) trigger and echo return pin */ public Ping (int ioPin) { this.ioPin = ioPin; } /** * Returns raw distance value from the PING))) sensor. * * @return Raw distance value from PING))) */ public int getRaw() { int echoRaw = 0; CPU.writePin(ioPin, false); // setup for high-going pulse CPU.pulseOut(1, ioPin); // send trigger pulse echoRaw = CPU.pulseIn(2171, ioPin, true); // measure echo return // return echo pulse if in range; zero if out-of-range return (echoRaw < 2131) ? echoRaw : 0; } © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 11 of 13
  • 42. /* * The PING))) returns a pulse width of 73.746 uS per inch. Since the * Javelin pulseIn() round-trip echo time is in 8.68 uS units, this is the * same as a one-way trip in 4.34 uS units. Dividing 73.746 by 4.34 we * get a time-per-inch conversion factor of 16.9922 (x 0.058851). * * Values to derive conversion factors are selected to prevent roll-over * past the 15-bit positive values of Javelin Stamp integers. */ /** * @return PING))) distance value in inches */ public int getIn() { return (getRaw() * 3 / 51); // raw * 0.058824 } /** * @return PING))) distance value in tenths of inches */ public int getIn10() { return (getRaw() * 3 / 5); // raw / 1.6667 } /* * The PING))) returns a pulse width of 29.033 uS per centimeter. As the * Javelin pulseIn() round-trip echo time is in 8.68 uS units, this is the * same as a one-way trip in 4.34 uS units. Dividing 29.033 by 4.34 we * get a time-per-centimeter conversion factor of 6.6896. * * Values to derive conversion factors are selected to prevent roll-over * past the 15-bit positive values of Javelin Stamp integers. */ /** * @return PING))) distance value in centimeters */ public int getCm() { return (getRaw() * 3 / 20); // raw / 6.6667 } /** * @return PING))) distance value in millimeters */ public int getMm() { return (getRaw() * 3 / 2); // raw / 0.6667 } } This simple demo illustrates the use of the PING))) ultrasonic range finder class with the Javelin Stamp: © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 12 of 13
  • 43. import stamp.core.*; import stamp.peripheral.sensor.Ping; public class testPing { public static final char HOME = 0x01; public static void main() { Ping range = new Ping(CPU.pin0); StringBuffer msg = new StringBuffer(); int distance; while (true) { // measure distance to target in inches distance = range.getIn(); // create and display measurement message msg.clear(); msg.append(HOME); msg.append(distance); msg.append(" " n"); System.out.print(msg.toString()); // wait 0.5 seconds between readings CPU.delay(5000); } } } © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 13 of 13
  • 44. Perancangan Heater sebagai Pemanas Ruangan Menggunakan Sensor Jarak Ping Parallax dan Sensor Suhu LM 35 Laporan Tugas Mata Kuliah Komponen Sistem Kontrol oleh Oka D. Saputra L2F008146 JURUSAN TEKNIK ELEKTRO FAKULTAS TEKNIK UNIVERSITAS DIPONEGORO SEMARANG, 2011 i
  • 45. KATA PENGANTAR Alhamdulillah, Segala puji hanya bagi Allah Subhànahu wa Ta’ala, atas segala limpahan rahmat dan karunia-Nya, sehingga penyusun dapat menyelesaikan laporan “Perancangan Heater sebagai Pemanas Ruangan Menggunakan Sensor Jarak Ping Parallax dan Sensor Suhu LM 35 ”. Dalam pembuatan dan penyusunan laporan Tugas Akhir, penyusun juga banyak mendapatkan bantuan dan dukungan dari berbagai pihak. Atas kelancaran selama pelaksanaan Tugas Akhir dan penyusunan laporan ini, maka penyusun mengucapkan banyak terima kasih kepada : 1. Bapak Ir. Sudjadi, M.T. selaku Ketua Jurusan Teknik Elektro Fakultas Teknik Universitas Diponegoro 2. Bapak Sumardi S.T., M.T. selaku dosen mata kuliah Komponen Sistem Kontrol yang mengarahkan penulis dalam pembuatan Tugas Akhir ini 3. Keluargaku tercinta atas segala bentuk dorongan semangat dan dukungannya. 4. Saudara Fairus yang membimbing penulis sehingga tugas akhir ini dapat terselesaikan. 5. teman-teman yang mengikuti kuliah Komponen Sistem Kontrol. 6. Serta semua pihak yang tidak dapat penyusun sebutkan satu-persatu. Penyusun menyadari bahwa masih terdapat beberapa kekurangan dalam laporan Tugas Akhir ini. Kritik dan saran yang bersifat membangun sangat penyusun harapkan dari semua pihak, sebagai pengalaman dan tambahan pengetahuan bagi penyusun. Akhir kata semoga karya ini tidak menjadi yang pertama sekaligus yang terakhir dan semoga laporan ini dapat bermanfaat bagi mahasiswa Teknik Elektro Universitas Diponegoro pada khususnya dan masyarakat pada umumnya. Semarang, Desember 2011 Penyusun ii
  • 46. Abstrak Banyak Aplikasi yang dapat kita terapkan ketika kita membahas tentang sistem kontrol. Salah satunya pemanfaatan kemajuan teknologi sensor seperti sensor jarak ping produksi Parallax, sensor suhu LM 35 dari National Semiconductor dan juga actuator Heater (dalam hal ini solder) untuk pengendalian suhu ruangan yang terlalu dingin. Tujuan dari paper ini adalah merancang dan membuat alat yang dapat mengontrol suhu ruangan dan mendeteksi ada tidaknya pengguna didalam ruangan tersebut. Dalam perancangan alat, ada beberapa elemen yang menjadi parameter sebagai inputan agar heater aktif, dalam simulasi ini digunakan sebagai jarak terdekat antara pengguna ruangan dengan heater adalah 20 cm sedangkan untuk jarak terjauh adalah 120 cm sedangkan untuk suhu terpanas yang menjadikan heater off adalah 33ºC. Keywords — Sensor Ping, Sensor LM35, Heater iii
  • 47. DAFTAR ISI HALAMAN JUDUL ……………………………………………………… i KATA PENGANTAR …………………… ………………………………. ii ABSTRAK …………………………………………………….................... iii DAFTAR ISI ……………………………………………………………… iv DAFTAR GAMBAR………………………………………………………. v DAFTAR TABEL …………………………………………………………. v BAB I PENDAHULUAN ………………………………………………. 1 1.1 Latar Belakang …………………………………..………..... 1 1.2 Tujuan Tugas Akhir ……………………………………….. 1 1.3 Pembatasan Masalah …….………………………………..... 1 1.4 Sistematika Penulisan ……………………………………..... 2 BAB II DASAR TEORI ……….…………………………..…………….. 3 2.1 Sensor Ping……………………..…………………………… 3 2.2 Sensor LM 35………………………………………………. 4 2.3 Mikrokontroller ATMEGA 128 .……………………………. 5 2.4 LCD ………………………………………………………. 5 2.5 LED…….. .…………………………….…………………… 6 2.6 MOC 3021………………………………………………….. 7 2.7 Triac………………………………………………………… 7 2.8 Solder………………………………………………………. 7 BAB III PERANCANGAN ALAT ……………………………..……….. 8 3.1 Perancangan Perangkat Keras …………………….……..… 8 3.2 Perancangan Perangkat Lunak ……………………………… 9 BAB IV PENJELASAN SOURCE CODE DAN PENGUJIAN ALAT ….... 11 4.1 Penjelasan Source Code….. ………………………………… 11 4.2 Pengujian Alat ………………………….…………………… 12 BAB V PENUTUP …………………………………………………………. 14 DAFTAR PUSTAKA iv
  • 48. DAFTAR GAMBAR Gambar 2.1 Sensor PING Ultrasonik Range Finder ...................................... 3 Gambar 2.2 Sensor PING Ultrasonik Range Finder timing diagram............. 3 Gambar 2.3 Ilustrasi Sensor Ping .................................................................. 4 Gambar 2.4 Sensor LM35 dan Konfigurasi PIN ........................................... 4 Gambar 2.5 Konfigurasi Pin Atmega 128...................................................... 5 Gambar 2.6 Konfigurasi pin LCD. ................................................................ 6 Gambar 2.7 Simbol LED. .............................................................................. 6 Gambar 2.8 Konfigurasi MOC 3021………………………………………..7 Gambar 2.9 Rangkaian Ekuivalen Triac. ...................................................... .7 Gambar 2.10 Solder ………………………………………………………...7 Gambar 3.1 Blok diagram hardware .............................................................. 8 Gambar 3.2 FSM sistem ................................................................................ 9 Gambar 4.1 saat state Off ............................................................................ 12 Gambar 4.2 saat state Heater On suhu 29ºC dan jarak 20 cm .................... 12 Gambar 4.3 state Heater standBy suhu 35ºC dan jarak 20,70 cm ............... 12 DAFTAR TABEL Tabel 4.1 Perbandingan Pengukuran Sensor Ping dan Penggaris................ 13 v
  • 49. BAB I PENDAHULUAN 1.1 Latar Belakang Pada Akhir-akhir ini teknik kontrol telah menjadi bagian yang sangat penting dalam kehidupan manusia. Dengan semakin tingginya tingkat kebutuhan maka untuk memenuhi kebutuhan tersebut dibutuhkan suatu perancangan sistem yang mampu berjalan secara otomatis. Pada peper ini dilakukan perancangan control suhu ruangan yang terlalu dingin menggunakan sensor jarak dan sensor suhu. Tujuan dari paper ini adalah merancang dan membuat alat yang dapat mengontrol suhu ruangan dan mendeteksi ada tidaknya pengguna didalam ruangan tersebut. Smart Heater adalah suatu alat yang dapat digunakan sebagai pemanas ruangan dan juga mendekteksi adanya pengguna dari pemanas ruangan tersebut. Kontrol On Off adalah suatu metode yang mudah dan tepat untuk pengontrolan alat ini dengan hanya menggunakan dua logika yaitu logika HIGH (1) dan logika LOW(0). 1.2 Tujuan 1. Merancang Smart Heater yang dapat bekerja sesuai dengan algoritma yang telah dirancang. 2. Mengetahui Prinsip Kerja sistem control khususnya control On-Off, 3. Memenuhi tugas Komponen Sistem Kontrol yang diajarkan di Jurusan Elektro Fakultas Teknik Universitas Diponegoro 1.3 Pembatasan Masalah Dalam pembuatan tugas akhir ini penulis membatasi permasalahan sebagai berikut : 1. Sistem Kontrol yang digunakan merupakan kontrol On-Off 2. Sensor yang digunakan adalah sensor ultrasonik yang diproduksi oleh Parallax ( Sensor PING Ultrasonik Range Finder). 1
  • 50. 2 3. Range pendeteksian antara 3 cm – 300 cm. 4. Tugas akhir ini tidak membahas mengenai arsitektur mikrokontroller 5. Mikrokontroler yang digunakan adalah ATMega128. 1.4 Sistematika Penulisan Sistematika penulisan dalam laporan tugas akhir ini adalah sebagai berikut: BAB I PENDAHULUAN Berisi tentang latar belakang masalah, tujuan penulisan, batasan masalah dan sistematika penulisan. BAB II DASAR TEORI Berisi tentang teori-teori yang mendukung dalam perancangan tugas akhir ini, yaitu tentang mikrokontroler atmega128, sensor ping, sensor LM35, LCD, MOC3021, Triac BT139. BAB III PERANCANGAN Berisi tentang perancangan perangkat lunak (software) dan perangkat keras (hardware) dari sistem yang digunakan pada Smart Heater dan indikator led. BAB IV PENGUJIAN DAN ANALISA Berisi tentang pengujian dan analisa terhadap perangkat lunak dan perangkat keras yang telah dibuat serta pengujian sistem secara keseluruhan. BAB V PENUTUP Berisi kesimpulan dan saran.
  • 51. 3 BAB II DASAR TEORI 2.1 Sensor Ping Sensor yang digunakan pada pembuatan tugas Komponen ini merupakan [1] sebuah sensor ultrasonik buatan Parallax ( Sensor PING Ultrasonik Range Finder). Rangkaian lengkap sensor ditunjukkan pada Gambar 2.1 Gambar 2.1 Sensor PING Ultrasonik Range Finder. Sensor PING ini secara khusus didesain untuk dapat mengukur jarak sebuah benda padat (solid).Range jarak yang mampu diukur oleh sensor PING adalah 3 cm sampai dengan 300 cm. Sensor PING mendeteksi jarak objek dengan cara memancarkan gelombang ultrasonik (>20kHz) selama waktu pemancaran kemudian mendeteksi pantulannya. Gambar 2.2 Sensor PING Ultrasonik Range Finder timing diagram. 3
  • 52. 4 Sensor PING memancarkan gelombang ultrasonik sesuai dengan pulsa trigger dari mikrokontroler sebagai pengendali.Gambar 2 menunjukkan timing diagram dari Sensor PING. Lebar pulsa high (tIN) akan sesuai dengan lama waktu tempuh gelombang ultrasonik untuk 2x jarak ukur dengan objek seperti yang ditunjukkan pada Gambar 3, maka jarak yang diukur dapat dirumuskan sebagai berikut :  t IN sx344m / s    meter Jarak=  2  Gambar 2.3 Ilustrasi cara kerja sensor PING 2.2 Sensor LM 35 Salah satu sensor suhu adalah sensor LM35 [2]. Berikut gambar sensor LM35. Gambar 2.4 Sensor LM35 dan Konfigurasi PIN Sensor suhu LM35 adalah komponen elektronika yang memiliki fungsi untuk mengubah besaran suhu menjadi besaran listrik dalam bentuk tegangan. Sensor Suhu LM35 yang dipakai dalam paper ini berupa komponen elektronika elektronika yang diproduksi oleh National Semiconductor. Secara prinsip sensor akan melakukan penginderaan pada saat perubahan suhu setiap suhu 1 ºC akan menunjukan perubahan tegangan sebesar 10 mV.
  • 53. 5 2.3 Mikrokontroller ATMEGA 128 Berikut ini konfigurasi Pin pada Atmega 128. Gambar 2.5 Konfigurasi Pin Atmega 128 Mikrokontroler ATMEGA128 termasuk dalam mikrokontroler keluarga AVR. Dengan fitur-fitur eksternal clock sampai 16 MHz, 53 Pin/Port yang bias digunakan sebagai I/O dan beberapa fungsi khusus seperti pada port F dilengkapi dengan ACD, timer 8 dan 16 bit dan lain sebagainya. 2.4 LCD Modul LCD (Liquid Crystal Display) adalah salah satu alat yang digunakan sebagai tampilan. Pada dasarnya sistem pengaturan LCD memiliki standar yang sama walaupun sangat banyak macamnya baik ditinjau dariperusahaan pembuat maupun dari ukurannya. LCD yang digunakan merupakan modul dot-matrix tampilan kristal cair (LCD) dengan tampilan 16 x 2 baris dengan konsumsi daya rendah. Modul LCD ini telah dilengkapi dengan mikrokontroler yang didesain khusus untuk mengendalikan
  • 54. 6 LCD, berfungsi sebagai pengatur (system controller) dan penghasil karakter (character generator). Konfigurasi pin dari LCD ditunjukkan pada Gambar 2.6 Gambar 2.6 Konfigurasi pin LCD Modul LCD memiliki karakteristik sebagai berikut: • Terdapat 16 x 2 karakter huruf yang bisa ditampilkan. • Setiap huruf terdiri dari 5x7 dot-matrix cursor. • Terdapat 192 macam karakter. • Terdapat 80 x 8 bit display RAM (maksimal 80 karakter). • Memiliki kemampuan penulisan dengan 8 bit maupun dengan 4 bit. • Dibangun dengan osilator lokal. • Satu sumber tegangan 5 volt. • Otomatis reset saat tegangan dihidupkan. • Bekerja pada suhu 0 0C sampai 55 0C. 2.5 LED LED (Light Emitting Diode) atau dioda pancaran cahaya adalah suatu bahan padat sejenis dioda yang mengkonversi arus listrik menjadi cahaya. Dalam penggunannya digunakan sebagai penanda berupa nyala lampu pijar. Strukturnya juga sama dengan dioda, elektron yang menerjang sambungan P-N juga melepaskan energi berupa energi panas dan energi cahaya. Untuk mendapatkan emisi cahaya pada semikonduktor, doping yang dipakai adalah gallium, arsenic, dan phosporus. Jenis doping yang berbeda menghasilkan warna cahaya yang berbeda pula. Gambar 2.7 Simbol LED
  • 55. 7 2.6 MOC 3021 Fungsi dari MOC ini adalah sebagai isolator agar bagian DC yang ada pada kontrol mikrokontroller tidak langsung terhubung dengan bagian AC yang ada pada triac. Berikut gambar konfigurasi MOC 3021 Gambar 2.8 Konfigurasi MOC 3021 2.7 TRIAC Untuk pengontrolan pada tegangan AC, umumnya digunakan bidirectional triode thyristor atau dikenal dengan triac. Triac dapat bersifat konduktif dalam dua arah. Dalam hal ini dapat dianggap sebagai dua buah tryristor tersambung secara antiparallel dengan koneksi gerbang seperti gambar berikut[3]. Gambar 2.9 Rangkaian Ekuivalen Triac 2.8 Solder Pada perancangan ini untuk mengambarkan sebuah element pemanas menggunakan solder. Dalam perancangan sistem panas dari solder inilah yang akan di kontrol. Gambar 2.10 Solder
  • 56. 8 BAB III PERANCANGAN 3.1 Perancangan Perangkat Keras Perangkat keras dari sistem yang akan dibangun meliputi sistem minimum mikrokontroler ATMEGA 128, Push Button, LCD, Power Supply AC dan DC, Indikator LED, Sensor LM 35, Sensor jarak Ping, Triac BT 139, MOC 3021 dan Heater. Berikut blok digram dari koneksi komponen tersebut Gambar 3.1 Blok diagram hardware Tiap-tiap bagian dari diagram blok sistem dapat dijelaskan sebagai berikut: 1. Atmega 128 berfungsi sebagai otak dari alat. 2. Sensor Ping berfungsi sebagai masukan data untuk mengetahui adanya pengguna atau tidak. 3. Sensor LM35 berfungsi untuk mengukur nilai suhu dari heater. 4. Regulator a. 220 volt AC berfungsi sebagai tegangan masukkan heater b. 5 volt DC volt berfungsi sebagai supply mikro dan sensor-sensor 5. LCD berfunsi sebagai tampilan untuk state sistem 8
  • 57. 9 6. Push Button berfungsi sebagai inputan untuk menyala dan mematikan sistem 7. MOC 3021 berfungsi sebagai isolator untuk mengamankan antara arus AC dan DC. 8. LED berfungsi sebagai indicator nyala heater. 9. Triac berfungsi sebagai pengontrol nyala dan matinya heater. 3.2 Perancangan Perangkat Lunak Bahasa pemrograman yang digunakan dalam pembuatan perangkat lunak menggunakan bahasa C untuk proses pengontrolan melalui AVR ATmega 128 dengan bantuan software CVAVR. Dalam perancangan Software menggunakan metode Finite State Machine, metode ini dipilih karena lebih mudah dalam implementasi ke source code. Berikut FSM sistem yang dirancang. Gambar 3.2 FSM sistem Berikut cara kerja dari sistem Heater pemanas ruangan 1. Heater dinyalakan menggunakan tombol. 2. Apabila penggunakan yang menyalakan sistem terdeksi berada didalam ruangan (asumsi jarak terdekat 20cm dan jarak terjauh 120 cm dari heater) maka sistem pemanas dan lampu LED indicator akan menyala.
  • 58. 10 3. Apabila pengguna berada pada jarak kurang dari 20 cm maka heater akan mati dan sistem akan menyala secara otomatis apabila pengguna terdeteksi berada pada jarak lebih dari 20 cm. 4. Apabila pengguna berada pada jarak lebih dari 120 cm dan selama 3 detik tidak kembali kedalam jarak tersebut maka sistem akan mati secara otomatis 5. Apabila suhu ruangan lebih dari 33ºC maka sistem akan mati secara otomatis. 6. Sistem juga dapat dimatikan secara otomatis menggunakan tombol yang disediakan.
  • 59. 11 BAB IV PENJELASAN SOURCE CODE DAN PENGUJIAN ALAT 4.1 Penjelasan Source Code Berikut beberapa source code yang digunakan dalam perancangan sistem yaitu:  Blok Fungsi Akses Ping DirSig=1; //Set sebagai output SigOut=1; //Pengiriman sinyal dimulai delay_us(5); SigOut=0; //Pengiriman sinyal selesai DirSig=0; //Set as input SigOut=1; //Pullup activated TCNT1=0; // mereset timer while (SigIn==0) {} TCCR1B=0x02; //mengeset timer dgan frekuensi 2 MHZ while (SigIn==1) {} TCCR1B=0x00; // mematikan timer distance=(TCNT1*0.0086106); // t=n/f // n=jumlah gel // f=frekuensi // s=v*t // v=344.434m/s // v=34443.4cm/s // 2s=v*t >> karena waktu tempuh 2 kali // 2s=34443.4* n /2000.000 >>>> 4MHZ // s= n * 0.0086106  Blok Fungsi Suhu tegangan=read_adc(0); 11
  • 60. 12 tegangan=tegangan*4.89; //tegangan sensor dalam //millivolt 5000mV/1023=4.89mV suhu=tegangan/10; // mengubah nilai tegangan kedalam //suhu dengan membagai bilangan 10 yang merupakan //konstanta kelipatan kenaikan suhu pada LM 35 4.2 Pengujian Alat Pengujian Sistem terlihat pada gambar berikut ini  Pada saat sistem berada pada state Heater off Gambar 4.1 saat state Off  Pada saat sistem berada pada state Heater On Gambar 4.2 saat state Heater On suhu 29ºC dan jarak 20 cm  Pada saat sistem berada pada state heater standBy Gambar 4.3 state Heater standBy suhu 35ºC dan jarak 20,70 cm
  • 61. 13 Perbandingan pengukuran jarak antara hasil ukur dengan alat ukur penggaris. Pada pengujian ini dilakukan dengan cara menggunakan buku (30x21) cm2 yang diletakkan diatas penggaris kemudian dilihat hasil pengukuran pada LCD dan letak buku pada penggaris. Dari cara tersebut diperoleh data di tabel berikut ini. Tabel 4.1 Perbandingan Pengukuran Sensor Ping dan Penggaris Pengukaran Hasil Error No Penggaris Pengukuran (cm) (cm) PING (cm) 1 3.00 3.08 0.08 2 5.00 5.65 0.65 3 8.00 8.07 0.07 4 10.00 10.22 0.22 5 12.00 12.37 0.37 6 15.00 15.15 0.15 7 17.00 16.85 -0.15 8 20.00 19.93 -0.07 9 25.00 24.97 -0.03 10 30.00 30.07 0.07 Rata-Rata Error 0.14 Dari tabel 4.1 tersebut terlihat bahwa rata-rata error yang dihasilkan dari pengukuran adalah sebesar 0.14 cm.
  • 62. 14 Bab V Kesimpulan Dari hasil pengujian diperoleh bahwa sistem yang dihasilkan sesuai dengan rancangan yaitu sistem hasil pengujian menunjukkan performa yang sesuai dengan yang telah dirancang yaitu Perancangan Heater sebagai pemanas ruangan menggunakan sensor Ping sebagai pendekteksi adanya pengguna (rentang kerja 100 cm dari 20 cm sampai 120 cm) dan sensor suhu LM 35 digunakan sebagai input agar suhu yang dihasilkan tidak terlalu panas yaitu dibawah 33ºC. Kemudian hasil pengkuran menggunakan sensor ping memperlihatkan keluaran yang cukup baik dengan rata-rata error yaitu 0.14 cm. Dengan adanya pembuktian bahwa jarak yang dihasilkan oleh sensor ping hampir mendekati sebenarnya maka sensor ini cocok untuk diaplikasi dalam perancangan sistem pemanas ruangan dalam hal ini mendeteksi adanya keberadaan pengguna. 14
  • 63. Daftar Pustaka [1] --- Sensor Ping Data Sheet , http://www.google.co.id/url?sa=t&rct=j&q=ping%20parallax&source=web&cd=2&ved=0CCcQ FjAB&url=http%3A%2F%2Fwww.parallax.com%2Fdl%2Fdocs%2Fprod%2Facc%2F28015- PING- v1.3.pdf&ei=BYDwTr7MGc7prQeR0LjiDw&usg=AFQjCNHh0CMP8LzfryTUSMxqhpYrvluv8 g Desember 2011 [2] --- Sensor LM 35 Data Sheet, www.national.com/ds/LM/LM35.pdf Desember 2011 [3] Syahadi, M., Aplikasi Kontrol Proporsional Integral Berbasis Mikrokontroller Atmega 8535 untuk Pengaturan Suhu pada Alat Pengering Kertas , Skripsi S-1, Universitas Diponegoro, Semarang, 2008.
  • 64. BIODATA PENULIS Oka Danil Saputra, dilahirkan di Jambi, 17 Juli 1990, saat ini menempuh studi strara 1 di Teknik Elektro Undip konsenterasi Kontrol.
  • 65. Lampiran 1. Listing Program /***************************************************** This program was produced by the CodeWizardAVR V2.03.4 Standard Automatic Program Generator © Copyright 1998-2008 Pavel Haiduc, HP InfoTech s.r.l. http://www.hpinfotech.com Project : Version : Date : 12/21/2011 Author : Company : Comments: Chip type : ATmega128 Program type : Application Clock frequency : 16.000000 MHz Memory model : Small External RAM size : 0 Data Stack size : 1024 *****************************************************/ enum {start,mati}; #include <mega128.h> #include <delay.h> #include <math.h> #include <stdio.h> #include <stdlib.h> // Alphanumeric LCD Module functions #asm .equ __lcd_port=0x15 ;PORTC #endasm #include <lcd.h> #define LED PORTA.0 #define Heater PORTD.0 #define Pb1 PINE.0 #define On 1
  • 66. #define Off 0 //Alokasi Port PING// #define SigOut PORTB.1 #define SigIn PINB.1 #define DirSig DDRB.1 ///////////////////// #define ADC_VREF_TYPE 0x40 // Read the AD conversion result unsigned int read_adc(unsigned char adc_input) { ADMUX=adc_input | (ADC_VREF_TYPE & 0xff); // Delay needed for the stabilization of the ADC input voltage delay_us(10); // Start the AD conversion ADCSRA|=0x40; // Wait for the AD conversion to complete while ((ADCSRA & 0x10)==0); ADCSRA|=0x10; return ADCW; } void baca_ping(); void baca_suhu(); unsigned char suhu,state; unsigned int tegangan; char Baris1[16],Baris2[16]; float distance; // Declare your global variables here void main(void) { // Declare your local variables here // Input/Output Ports initialization // Port A initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=Out
  • 67. // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=0 PORTA=0x00; DDRA=0x01; // Port B initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTB=0x00; DDRB=0x00; // Port C initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTC=0x00; DDRC=0x00; // Port D initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=Out // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=0 PORTD=0x00; DDRD=0x01; // Port E initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTE=0xFF; DDRE=0x00; // Port F initialization
  • 68. // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTF=0x00; DDRF=0x00; // Port G initialization // Func4=In Func3=In Func2=In Func1=In Func0=In // State4=T State3=T State2=T State1=T State0=T PORTG=0x00; DDRG=0x00; // Timer/Counter 0 initialization // Clock source: System Clock // Clock value: Timer 0 Stopped // Mode: Normal top=FFh // OC0 output: Disconnected ASSR=0x00; TCCR0=0x00; TCNT0=0x00; OCR0=0x00; // Timer/Counter 1 initialization // Clock source: System Clock // Clock value: 2000.000 kHz // Mode: Normal top=FFFFh // OC1A output: Discon. // OC1B output: Discon. // OC1C output: Discon. // Noise Canceler: Off // Input Capture on Falling Edge // Timer 1 Overflow Interrupt: Off // Input Capture Interrupt: Off // Compare A Match Interrupt: Off // Compare B Match Interrupt: Off // Compare C Match Interrupt: Off TCCR1A=0x00; TCCR1B=0x02;
  • 69. TCNT1H=0x00; TCNT1L=0x00; ICR1H=0x00; ICR1L=0x00; OCR1AH=0x00; OCR1AL=0x00; OCR1BH=0x00; OCR1BL=0x00; OCR1CH=0x00; OCR1CL=0x00; // Timer/Counter 2 initialization // Clock source: System Clock // Clock value: Timer 2 Stopped // Mode: Normal top=FFh // OC2 output: Disconnected TCCR2=0x00; TCNT2=0x00; OCR2=0x00; // Timer/Counter 3 initialization // Clock source: System Clock // Clock value: Timer 3 Stopped // Mode: Normal top=FFFFh // Noise Canceler: Off // Input Capture on Falling Edge // OC3A output: Discon. // OC3B output: Discon. // OC3C output: Discon. // Timer 3 Overflow Interrupt: Off // Input Capture Interrupt: Off // Compare A Match Interrupt: Off // Compare B Match Interrupt: Off // Compare C Match Interrupt: Off TCCR3A=0x00; TCCR3B=0x00; TCNT3H=0x00; TCNT3L=0x00; ICR3H=0x00;
  • 70. ICR3L=0x00; OCR3AH=0x00; OCR3AL=0x00; OCR3BH=0x00; OCR3BL=0x00; OCR3CH=0x00; OCR3CL=0x00; // External Interrupt(s) initialization // INT0: Off // INT1: Off // INT2: Off // INT3: Off // INT4: Off // INT5: Off // INT6: Off // INT7: Off EICRA=0x00; EICRB=0x00; EIMSK=0x00; // Timer(s)/Counter(s) Interrupt(s) initialization TIMSK=0x00; ETIMSK=0x00; // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off ACSR=0x80; SFIOR=0x00; // ADC initialization // ADC Clock frequency: 250.000 kHz // ADC Voltage Reference: AVCC pin ADMUX=ADC_VREF_TYPE & 0xff; ADCSRA=0x86; // LCD module initialization lcd_init(16);
  • 71. lcd_clear(); lcd_putsf("Heater_Off"); state=mati; while (1) { // Place your code here if (!Pb1) { if (state==mati) {state=start; delay_ms(200); } else if (state==start) {state=mati; lcd_clear(); lcd_putsf("Heater_Off"); delay_ms(200); //200 } } if (state==start) { lcd_clear(); //LED=1; Heater=1; baca_suhu(); baca_ping(); lcd_gotoxy(0,1);lcd_putsf("Jarak="); ftoa(distance,2,Baris2); lcd_gotoxy(7,1); lcd_puts(Baris2); lcd_putsf(" cm"); if (distance<=20 || distance>=120 || suhu>33) { LED=0; Heater=0; lcd_clear(); sprintf(Baris1,"Suhu =%3d H_SB",suhu); lcd_gotoxy(0,0);lcd_puts(Baris1); lcd_gotoxy(0,1);lcd_putsf("Jarak="); ftoa(distance,2,Baris2); lcd_gotoxy(7,1); lcd_puts(Baris2); lcd_putsf(" cm"); delay_ms(200); //100 baca_ping(); if ( distance>=120) //|| suhu>33 ) { lcd_clear(); lcd_gotoxy(0,0);lcd_putsf("Waiting..."); lcd_gotoxy(0,1);lcd_putsf("3 Detik");
  • 72. delay_ms(3000); // delay waiting baca_ping(); if ( distance>=120 || suhu>33 ) {state=mati; lcd_clear(); lcd_putsf("Heater_Off"); } } } else { LED=1; Heater=1; sprintf(Baris1,"Suhu =%3d H_On",suhu); lcd_gotoxy(0,0);lcd_puts(Baris1); } } else if (state==mati) { LED=Off; Heater=Off; } delay_ms(200); // 100 }; }; void baca_ping() { DirSig=1; //Set sebagai output SigOut=1; //Pengiriman sinyal dimulai delay_us(5); SigOut=0; //Pengiriman sinyal selesai DirSig=0; //Set as input SigOut=1; //Pullup activated TCNT1=0; // mereset timer while (SigIn==0) {} TCCR1B=0x02; //mengeset timer dgan frekuensi 2 MHZ while (SigIn==1) {} TCCR1B=0x00; // mematikan timer distance=(TCNT1*0.0086106); // t=n/f // n=jumlah gel // f=frekuensi // s=v*t // v=344.434m/s // v=34443.4cm/s // 2s=v*t >> karena waktu tempuh 2 kali // 2s=34443.4* n /2000.000 >>>> 4MHZ // s= n * 0.0086106 }
  • 73. void baca_suhu() { tegangan=read_adc(0); tegangan=tegangan*4.89; //tegangan sensor dalam milivolt suhu=tegangan/10; }
  • 74. 599 Menlo Drive, Suite 100 General: info@parallax.com Rocklin, California 95765, USA Technical: support@parallax.com Office: (916) 624-8333 Web Site: www.parallax.com Fax: (916) 624-8003 Educational: www.stampsinclass.com PING)))™ Ultrasonic Distance Sensor (#28015) The Parallax PING))) ultrasonic distance sensor provides precise, non-contact distance measurements from about 2 cm (0.8 inches) to 3 meters (3.3 yards). It is very easy to connect to BASIC Stamp® or Javelin Stamp microcontrollers, requiring only one I/O pin. The PING))) sensor works by transmitting an ultrasonic (well above human hearing range) burst and providing an output pulse that corresponds to the time required for the burst echo to return to the sensor. By measuring the echo pulse width the distance to target can easily be calculated. Features • Supply Voltage – 5 VDC • Supply Current – 30 mA typ; 35 mA max • Range – 2 cm to 3 m (0.8 in to 3.3 yrds) • Input Trigger – positive TTL pulse, 2 uS min, 5 µs typ. • Echo Pulse – positive TTL pulse, 115 uS to 18.5 ms • Echo Hold-off – 750 µs from fall of Trigger pulse • Burst Frequency – 40 kHz for 200 µs • Burst Indicator LED shows sensor activity • Delay before next measurement – 200 µs • Size – 22 mm H x 46 mm W x 16 mm D (0.84 in x 1.8 in x 0.6 in) Dimensions © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 1 of 13
  • 75. Pin Definitions GND Ground (Vss) 5V 5 VDC (Vdd) SIG Signal (I/O pin) The PING))) sensor has a male 3-pin header used to supply power (5 VDC), ground, and signal. The header allows the sensor to be plugged into a solderless breadboard, or to be located remotely through the use of a standard servo extender cable (Parallax part #805-00002). Standard connections are show in the diagram to the right. Quick-Start Circuit This circuit allows you to quickly connect your PING))) sensor to a BASIC Stamp® 2 via the Board of Education® breadboard area. The PING))) module’s GND pin connects to Vss, the 5 V pin connects to Vdd, and the SIG pin connects to I/O pin P15. This circuit will work with the example program Ping_Demo.BS2 listed on page 7. Servo Cable and Port Cautions If you want to connect your PING))) sensor to a Board of Education using a servo extension cable, follow these steps: 1. When plugging the cable onto the PING))) sensor, connect Black to GND, Red to 5 V, and White to SIG. 2. Check to see if your Board of Education servo ports have a jumper, as shown at right. 3. If your Board of Education servo ports have a jumper, set it to Vdd as shown. 4. If your Board of Education servo ports do not have a jumper, do not use them with the PING))) sensor. These ports only provide Vin, not Vdd, and this may damage your PING))) sensor. Go to the next step. 5. Connect the servo cable directly to the breadboard with a Board of Education Servo Port 3-pin header. Then, use jumper wires to connect Black to Jumper, Set to Vdd Vss, Red to Vdd, and White to I/O pin P15. © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 2 of 13
  • 76. Theory of Operation The PING))) sensor detects objects by emitting a short ultrasonic burst and then "listening" for the echo. Under control of a host microcontroller (trigger pulse), the sensor emits a short 40 kHz (ultrasonic) burst. This burst travels through the air at about 1130 feet per second, hits an object and then bounces back to the sensor. The PING))) sensor provides an output pulse to the host that will terminate when the echo is detected, hence the width of this pulse corresponds to the distance to the target. Test Data The test data on the following pages is based on the PING))) sensor, tested in the Parallax lab, while connected to a BASIC Stamp microcontroller module. The test surface was a linoleum floor, so the sensor was elevated to minimize floor reflections in the data. All tests were conducted at room temperature, indoors, in a protected environment. The target was always centered at the same elevation as the PING))) sensor. © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 3 of 13
  • 77. Test 1 Sensor Elevation: 40 in. (101.6 cm) Target: 3.5 in. (8.9 cm) diameter cylinder, 4 ft. (121.9 cm) tall – vertical orientation © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 4 of 13
  • 78. Test 2 Sensor Elevation: 40 in. (101.6 cm) Target: 12 in. x 12 in. (30.5 cm x 30.5 cm) cardboard, mounted on 1 in. (2.5 cm) pole ● target positioned parallel to backplane of sensor © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 5 of 13
  • 79. Program Example: BASIC Stamp 2 Microcontroller The following program demonstrates the use of the PING))) sensor with the BASIC Stamp 2 microcontroller. Any model of BASIC Stamp 2 module will work with this program as conditional compilation techniques are used to make adjustments based on the module that is connected. The heart of the program is the Get_Sonar subroutine. This routine starts by making the output bit of the selected IO pin zero – this will cause the successive PULSOUT to be low-high-low as required for triggering the PING))) sensor. After the trigger pulse falls the sensor will wait about 200 microseconds before transmitting the ultrasonic burst. This allows the BS2 to load and prepare the next instruction. That instruction, PULSIN, is used to measure the high-going pulse that corresponds to the distance to the target object. The raw return value from PULSIN must be scaled due to resolution differences between the various members of the BS2 family. After the raw value is converted to microseconds, it is divided by two in order to remove the "return trip" of the echo pulse. The value now held in rawDist is the distance to the target in microseconds. Conversion from microseconds to inches (or centimeters) is now a simple matter of math. The generally- accepted value for the speed-of-sound is 1130 feet per second. This works out to 13,560 inches per second or one inch in 73.746 microseconds. The question becomes, how do we divide our pulse measurement value by the floating-point number 73.746? Another way to divide by 73.746 is to multiply by 0.01356. For new BASIC Stamp users this may seem a dilemma but in fact there is a special operator, **, that allows us to do just that. The ** operator has the affect of multiplying a value by units of 1/65,536. To find the parameter for ** then, we simply multiply 0.01356 by 65,536; the result is 888.668 (we'll round up to 889). Conversion to centimeters uses the same process and the result of the program is shown below: © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 6 of 13
  • 80. ' ========================================================================= ' ' File....... Ping_Demo.BS2 ' Purpose.... Demo Code for Parallax PING))) Sonar Sensor ' Author..... Parallax, Inc. ' E-mail..... support@parallax.com ' Started.... ' Updated.... 08 JUN 2005 ' ' {$STAMP BS2} ' {$PBASIC 2.5} ' ' ========================================================================= ' -----[ Program Description ]--------------------------------------------- ' ' This program demonstrates the use of the Parallax PING))) sensor and then ' converting the raw measurement to English (inches) and Metric (cm) units. ' ' Sonar Math: ' ' At sea level sound travels through air at 1130 feet per second. This ' equates to 1 inch in 73.746 uS, or 1 cm in 29.034 uS). ' ' Since the PING))) sensor measures the time required for the sound wave to ' travel from the sensor and back. The result -- after conversion to ' microseconds for the BASIC Stamp module in use -- is divided by two to ' remove the return portion of the echo pulse. The final raw result is ' the duration from the front of the sensor to the target in microseconds. ' -----[ I/O Definitions ]------------------------------------------------- Ping PIN 15 ' -----[ Constants ]------------------------------------------------------- #SELECT $STAMP #CASE BS2, BS2E Trigger CON 5 ' trigger pulse = 10 uS Scale CON $200 ' raw x 2.00 = uS #CASE BS2SX, BS2P, BS2PX Trigger CON 13 Scale CON $0CD ' raw x 0.80 = uS #CASE BS2PE Trigger CON 5 Scale CON $1E1 ' raw x 1.88 = uS #ENDSELECT RawToIn CON 889 ' 1 / 73.746 (with **) RawToCm CON 2257 ' 1 / 29.034 (with **) IsHigh CON 1 ' for PULSOUT IsLow CON 0 © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 7 of 13
  • 81. ' -----[ Variables ]------------------------------------------------------- rawDist VAR Word ' raw measurement inches VAR Word cm VAR Word ' -----[ Initialization ]-------------------------------------------------- Reset: DEBUG CLS, "Parallax PING))) Sonar", CR, ' setup report screen "======================", CR, CR, "Time (uS)..... ", CR, "Inches........ ", CR, "Centimeters... " ' -----[ Program Code ]---------------------------------------------------- Main: DO GOSUB Get_Sonar ' get sensor value inches = rawDist ** RawToIn ' convert to inches cm = rawDist ** RawToCm ' convert to centimeters DEBUG CRSRXY, 15, 3, ' update report screen DEC rawDist, CLREOL, CRSRXY, 15, 4, DEC inches, CLREOL, CRSRXY, 15, 5, DEC cm, CLREOL PAUSE 100 LOOP END ' -----[ Subroutines ]----------------------------------------------------- ' This subroutine triggers the PING))) sonar sensor and measures ' the echo pulse. The raw value from the sensor is converted to ' microseconds based on the Stamp module in use. This value is ' divided by two to remove the return trip -- the result value is ' the distance from the sensor to the target in microseconds. Get_Sonar: Ping = IsLow ' make trigger 0-1-0 PULSOUT Ping, Trigger ' activate sensor PULSIN Ping, IsHigh, rawDist ' measure echo pulse rawDist = rawDist */ Scale ' convert to uS rawDist = rawDist / 2 ' remove return trip RETURN © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 8 of 13
  • 82. Program Example: BASIC Stamp 1 Microcontroller ' ========================================================================= ' ' File....... Ping_Demo.BS1 ' Purpose.... Demo Code for Parallax PING))) Sonar Sensor ' Author..... Parallax, Inc. ' E-mail..... support@parallax.com ' Started.... ' Updated.... 06 JUN 2006 ' ' {$STAMP BS1} ' {$PBASIC 1.0} ' ' ========================================================================= ' -----[ Program Description ]--------------------------------------------- ' ' This program demonstrates the use of the Parallax PING))) sensor and then ' converting the raw measurement to English (inches) and Metric (cm) units. ' ' Sonar Math: ' ' At sea level sound travels through air at 1130 feet per second. This ' equates to 1 inch in 73.746 uS, or 1 cm in 29.034 uS). ' ' Since the PING))) sensor measures the time required for the sound wave to ' travel from the sensor and back. The result -- after conversion to ' microseconds for the BASIC Stamp module in use -- is divided by two to ' remove the return portion of the echo pulse. The final raw result is ' the duration from the front of the sensor to the target in microseconds. ' -----[ I/O Definitions ]------------------------------------------------- SYMBOL Ping = 7 ' -----[ Constants ]------------------------------------------------------- SYMBOL Trigger = 1 ' 10 uS trigger pulse SYMBOL Scale = 10 ' raw x 10.00 = uS SYMBOL RawToIn = 889 ' 1 / 73.746 (with **) SYMBOL RawToCm = 2257 ' 1 / 29.034 (with **) SYMBOL IsHigh = 1 ' for PULSOUT SYMBOL IsLow = 0 ' -----[ Variables ]------------------------------------------------------- SYMBOL rawDist = W1 ' raw measurement SYMBOL inches = W2 SYMBOL cm = W3 © Parallax, Inc. • PING)))TM Ultrasonic Distance Sensor (#28015) • v1.3 6/13/2006 Page 9 of 13