76769015 Simulasi Pemanas Ruang Menggunakan Sensor Ping Dan LM35

93
  i 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

Transcript of 76769015 Simulasi Pemanas Ruang Menggunakan Sensor Ping Dan LM35

Perancangan Heater sebagai Pemanas Ruangan Menggunakan Sensor Jarak Ping Parallax dan Sensor Suhu LM 35Laporan 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 Subhnahu wa Taala, 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 33C. Keywords Sensor Ping, Sensor LM35, Heater

iii

DAFTAR ISI HALAMAN JUDUL KATA PENGANTAR . ABSTRAK .................... DAFTAR ISI DAFTAR GAMBAR. DAFTAR TABEL . BAB I PENDAHULUAN . 1.1 1.2 1.3 1.4

i ii iii iv v v 1

Latar Belakang ....... 1 Tujuan Tugas Akhir .. 1 Pembatasan Masalah ...... 1 Sistematika Penulisan ..... 2 3 Sensor Ping.. 3 Sensor LM 35. LCD . MOC 3021.. Triac Solder. 4 Mikrokontroller ATMEGA 128 .. 5 5 LED.. .. 6 7 7 7 8

BAB II DASAR TEORI ..... 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8

BAB III PERANCANGAN ALAT ....

3.1 Perancangan Perangkat Keras ... 8 3.2 Perancangan Perangkat Lunak 9 BAB IV PENJELASAN SOURCE CODE DAN PENGUJIAN ALAT .... 11 4.1 4.2 Penjelasan Source Code.. 11 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 29C dan jarak 20 cm .................... 12 Gambar 4.3 state Heater standBy suhu 35C 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. 2. Sistem Kontrol yang digunakan merupakan kontrol On-Off Sensor yang digunakan adalah sensor ultrasonik yang diproduksi oleh Parallax ( Sensor PING Ultrasonik Range Finder).

1

2

3. 4. 5.

Range pendeteksian antara 3 cm 300 cm. Tugas akhir ini tidak membahas mengenai arsitektur mikrokontroller 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 2 Jarak=

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 33C 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; 5000mV/1023=4.89mV

//tegangan

sensor

dalam

//millivolt

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 29C dan jarak 20 cm

Pada saat sistem berada pada state heater standBy

Gambar 4.3 state Heater standBy suhu 35C 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 No Penggaris (cm) 1 2 3 4 5 6 7 8 9 10 3.00 5.00 8.00 10.00 12.00 15.00 17.00 20.00 25.00 30.00 Rata-Rata Error Hasil Pengukuran PING (cm) 3.08 5.65 8.07 10.22 12.37 15.15 16.85 19.93 24.97 30.07 Error (cm) 0.08 0.65 0.07 0.22 0.37 0.15 -0.15 -0.07 -0.03 0.07 0.14

Dari tabel 4.1 tersebut terlihat bahwa rata-rata error yang dihasilkan dari pengukuran adalah sebesar 0.14 cm.

14

Bab V KesimpulanDari 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 33C. 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%2F28015PINGv1.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 #include #include #include #include // Alphanumeric LCD Module functions #asm .equ __lcd_port=0x15 ;PORTC #endasm #include #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=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 Rocklin, California 95765, USA Office: (916) 624-8333 Fax: (916) 624-8003

General: [email protected] Technical: [email protected] Web Site: www.parallax.com 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 DefinitionsGND 5V SIG Ground (Vss) 5 VDC (Vdd) 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 CircuitThis circuit allows you to quickly connect your PING))) sensor to a BASIC Stamp 2 via the Board of Education breadboard area. The PING))) modules 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 CautionsIf 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 3-pin header. Then, use jumper wires to connect Black to Vss, Red to Vdd, and White to I/O pin P15.

Board of Education Servo Port Jumper, Set to Vdd

Parallax, Inc. PING)))TM Ultrasonic Distance Sensor (#28015) v1.3 6/13/2006

Page 2 of 13

Theory of OperationThe 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 DataThe 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: Target: 40 in. (101.6 cm) 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: Target: 40 in. (101.6 cm) 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 MicrocontrollerThe 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 generallyaccepted 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..... [email protected] ' 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. equates to 1 inch in 73.746 uS, or 1 cm in 29.034 uS). This

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 Scale CON $200 #CASE BS2SX, BS2P, BS2PX Trigger CON 13 Scale CON $0CD #CASE BS2PE Trigger CON 5 Scale CON $1E1 #ENDSELECT RawToIn RawToCm IsHigh IsLow CON CON CON CON 889 2257 1 0

' trigger pulse = 10 uS ' raw x 2.00 = uS

' raw x 0.80 = uS

' raw x 1.88 = uS

' 1 / 73.746 (with **) ' 1 / 29.034 (with **) ' for PULSOUT

Parallax, Inc. PING)))TM Ultrasonic Distance Sensor (#28015) v1.3 6/13/2006

Page 7 of 13

' -----[ Variables ]------------------------------------------------------rawDist inches cm VAR VAR VAR Word Word Word ' raw measurement

' -----[ Initialization ]-------------------------------------------------Reset: DEBUG CLS, "Parallax PING))) Sonar", "======================", CR, "Time (uS)..... ", "Inches........ ", "Centimeters... "

CR, CR, CR, CR,

' setup report screen

' -----[ Program Code ]---------------------------------------------------Main: DO GOSUB Get_Sonar inches = rawDist ** RawToIn cm = rawDist ** RawToCm DEBUG CRSRXY, 15, 3, DEC rawDist, CLREOL, CRSRXY, 15, 4, DEC inches, CLREOL, CRSRXY, 15, 5, DEC cm, CLREOL PAUSE 100 LOOP END

' get sensor value ' convert to inches ' convert to centimeters ' update report screen

' -----[ 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 PULSOUT Ping, Trigger PULSIN Ping, IsHigh, rawDist rawDist = rawDist */ Scale rawDist = rawDist / 2 RETURN

' ' ' ' '

make trigger 0-1-0 activate sensor measure echo pulse convert to uS remove return trip

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..... [email protected] ' 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. equates to 1 inch in 73.746 uS, or 1 cm in 29.034 uS). This

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 SYMBOL SYMBOL SYMBOL SYMBOL SYMBOL Trigger Scale RawToIn RawToCm IsHigh IsLow = 1 = 10 = 889 = 2257 = 1 = 0 ' 10 uS trigger pulse ' raw x 10.00 = uS ' 1 / 73.746 (with **) ' 1 / 29.034 (with **) ' for PULSOUT

' -----[ Variables ]------------------------------------------------------SYMBOL SYMBOL SYMBOL rawDist inches cm = W1 = W2 = W3 ' raw measurement

Parallax, Inc. PING)))TM Ultrasonic Distance Sensor (#28015) v1.3 6/13/2006

Page 9 of 13

' -----[ Program Code ]---------------------------------------------------Main: GOSUB Get_Sonar inches = rawDist ** RawToIn cm = rawDist ** RawToCm DEBUG DEBUG DEBUG DEBUG CLS "Time (uS)..... ", #rawDist, CR "Inches........ ", #inches, CR "Centimeters... ", #cm

' get sensor value ' convert to inches ' convert to centimeters ' report

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 PULSOUT Ping, Trigger PULSIN Ping, IsHigh, rawDist rawDist = rawDist * Scale rawDist = rawDist / 2 RETURN

' ' ' ' '

make trigger 0-1-0 activate sensor measure echo pulse convert to uS remove return trip

Parallax, Inc. PING)))TM Ultrasonic Distance Sensor (#28015) v1.3 6/13/2006

Page 10 of 13

Program Example: Javelin Stamp MicrocontrollerThis 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. * * Usage:
* * Ping range = new Ping(CPU.pin0); // trigger and echo on P0 * * * Detailed documentation for the PING))) Sensor can be found at:
* http://www.parallax.com/detail.asp?product_id=28015 * * * @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 35Laporan 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 Subhnahu wa Taala, 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 33C. Keywords Sensor Ping, Sensor LM35, Heater

iii

DAFTAR ISI HALAMAN JUDUL KATA PENGANTAR . ABSTRAK .................... DAFTAR ISI DAFTAR GAMBAR. DAFTAR TABEL . BAB I PENDAHULUAN . 1.1 1.2 1.3 1.4

i ii iii iv v v 1

Latar Belakang ....... 1 Tujuan Tugas Akhir .. 1 Pembatasan Masalah ...... 1 Sistematika Penulisan ..... 2 3 Sensor Ping.. 3 Sensor LM 35. LCD . MOC 3021.. Triac Solder. 4 Mikrokontroller ATMEGA 128 .. 5 5 LED.. .. 6 7 7 7 8

BAB II DASAR TEORI ..... 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8

BAB III PERANCANGAN ALAT ....

3.1 Perancangan Perangkat Keras ... 8 3.2 Perancangan Perangkat Lunak 9 BAB IV PENJELASAN SOURCE CODE DAN PENGUJIAN ALAT .... 11 4.1 4.2 Penjelasan Source Code.. 11 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 29C dan jarak 20 cm .................... 12 Gambar 4.3 state Heater standBy suhu 35C 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. 2. Sistem Kontrol yang digunakan merupakan kontrol On-Off Sensor yang digunakan adalah sensor ultrasonik yang diproduksi oleh Parallax ( Sensor PING Ultrasonik Range Finder).

1

2

3. 4. 5.

Range pendeteksian antara 3 cm 300 cm. Tugas akhir ini tidak membahas mengenai arsitektur mikrokontroller 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 2 Jarak=

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 33C 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; 5000mV/1023=4.89mV

//tegangan

sensor

dalam

//millivolt

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 29C dan jarak 20 cm

Pada saat sistem berada pada state heater standBy

Gambar 4.3 state Heater standBy suhu 35C 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 No Penggaris (cm) 1 2 3 4 5 6 7 8 9 10 3.00 5.00 8.00 10.00 12.00 15.00 17.00 20.00 25.00 30.00 Rata-Rata Error Hasil Pengukuran PING (cm) 3.08 5.65 8.07 10.22 12.37 15.15 16.85 19.93 24.97 30.07 Error (cm) 0.08 0.65 0.07 0.22 0.37 0.15 -0.15 -0.07 -0.03 0.07 0.14

Dari tabel 4.1 tersebut terlihat bahwa rata-rata error yang dihasilkan dari pengukuran adalah sebesar 0.14 cm.

14

Bab V KesimpulanDari 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 33C. 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%2F28015PINGv1.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 #include #include #include #include // Alphanumeric LCD Module functions #asm .equ __lcd_port=0x15 ;PORTC #endasm #include #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=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 Rocklin, California 95765, USA Office: (916) 624-8333 Fax: (916) 624-8003

General: [email protected] Technical: [email protected] Web Site: www.parallax.com 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 DefinitionsGND 5V SIG Ground (Vss) 5 VDC (Vdd) 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 CircuitThis circuit allows you to quickly connect your PING))) sensor to a BASIC Stamp 2 via the Board of Education breadboard area. The PING))) modules 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 CautionsIf 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 3-pin header. Then, use jumper wires to connect Black to Vss, Red to Vdd, and White to I/O pin P15.

Board of Education Servo Port Jumper, Set to Vdd

Parallax, Inc. PING)))TM Ultrasonic Distance Sensor (#28015) v1.3 6/13/2006

Page 2 of 13

Theory of OperationThe 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 DataThe 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: Target: 40 in. (101.6 cm) 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: Target: 40 in. (101.6 cm) 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 MicrocontrollerThe 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 generallyaccepted 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..... [email protected] ' 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. equates to 1 inch in 73.746 uS, or 1 cm in 29.034 uS). This

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 Scale CON $200 #CASE BS2SX, BS2P, BS2PX Trigger CON 13 Scale CON $0CD #CASE BS2PE Trigger CON 5 Scale CON $1E1 #ENDSELECT RawToIn RawToCm IsHigh IsLow CON CON CON CON 889 2257 1 0

' trigger pulse = 10 uS ' raw x 2.00 = uS

' raw x 0.80 = uS

' raw x 1.88 = uS

' 1 / 73.746 (with **) ' 1 / 29.034 (with **) ' for PULSOUT

Parallax, Inc. PING)))TM Ultrasonic Distance Sensor (#28015) v1.3 6/13/2006

Page 7 of 13

' -----[ Variables ]------------------------------------------------------rawDist inches cm VAR VAR VAR Word Word Word ' raw measurement

' -----[ Initialization ]-------------------------------------------------Reset: DEBUG CLS, "Parallax PING))) Sonar", "======================", CR, "Time (uS)..... ", "Inches........ ", "Centimeters... "

CR, CR, CR, CR,

' setup report screen

' -----[ Program Code ]---------------------------------------------------Main: DO GOSUB Get_Sonar inches = rawDist ** RawToIn cm = rawDist ** RawToCm DEBUG CRSRXY, 15, 3, DEC rawDist, CLREOL, CRSRXY, 15, 4, DEC inches, CLREOL, CRSRXY, 15, 5, DEC cm, CLREOL PAUSE 100 LOOP END

' get sensor value ' convert to inches ' convert to centimeters ' update report screen

' -----[ 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 PULSOUT Ping, Trigger PULSIN Ping, IsHigh, rawDist rawDist = rawDist */ Scale rawDist = rawDist / 2 RETURN

' ' ' ' '

make trigger 0-1-0 activate sensor measure echo pulse convert to uS remove return trip

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..... [email protected] ' 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. equates to 1 inch in 73.746 uS, or 1 cm in 29.034 uS). This

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 SYMBOL SYMBOL SYMBOL SYMBOL SYMBOL Trigger Scale RawToIn RawToCm IsHigh IsLow = 1 = 10 = 889 = 2257 = 1 = 0 ' 10 uS trigger pulse ' raw x 10.00 = uS ' 1 / 73.746 (with **) ' 1 / 29.034 (with **) ' for PULSOUT

' -----[ Variables ]------------------------------------------------------SYMBOL SYMBOL SYMBOL rawDist inches cm = W1 = W2 = W3 ' raw measurement

Parallax, Inc. PING)))TM Ultrasonic Distance Sensor (#28015) v1.3 6/13/2006

Page 9 of 13

' -----[ Program Code ]---------------------------------------------------Main: GOSUB Get_Sonar inches = rawDist ** RawToIn cm = rawDist ** RawToCm DEBUG DEBUG DEBUG DEBUG CLS "Time (uS)..... ", #rawDist, CR "Inches........ ", #inches, CR "Centimeters... ", #cm

' get sensor value ' convert to inches ' convert to centimeters ' report

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 PULSOUT Ping, Trigger PULSIN Ping, IsHigh, rawDist rawDist = rawDist * Scale rawDist = rawDist / 2 RETURN

' ' ' ' '

make trigger 0-1-0 activate sensor measure echo pulse convert to uS remove return trip

Parallax, Inc. PING)))TM Ultrasonic Distance Sensor (#28015) v1.3 6/13/2006

Page 10 of 13

Program Example: Javelin Stamp MicrocontrollerThis 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. * * Usage:
* * Ping range = new Ping(CPU.pin0); // trigger and echo on P0 * * * Detailed documentation for the PING))) Sensor can be found at:
* http://www.parallax.com/detail.asp?product_id=28015 * * * @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

MOTOROLA

SEMICONDUCTOR TECHNICAL DATA

Order this document by MOC3020/D

GlobalOptoisolator

6-Pin DIP Random-Phase Optoisolators Triac Driver Output(400 Volts Peak)The MOC3020 Series consists of gallium arsenide infrared emitting diodes, optically coupled to a silicon bilateral switch. To order devices that are tested and marked per VDE 0884 requirements, the suffix V must be included at end of part number. VDE 0884 is a test option. They are designed for applications requiring isolated triac triggering. Recommended for 115/240 Vac(rms) Applications: Solenoid/Valve Controls Lamp Ballasts Interfacing Microprocessors to 115 Vac Peripherals Motor Controls

MOC3021 MOC3022 MOC3023 *[IFT = 15 mA Max] [IFT = 10 mA Max] [IFT = 5 mA Max] *Motorola Preferred Device

STYLE 6 PLASTIC

Static ac Power Switch Solid State Relays Incandescent Lamp Dimmers

6

1

STANDARD THRU HOLE CASE 730A04

MAXIMUM RATINGS (TA = 25C unless otherwise noted)Rating INFRARED EMITTING DIODE Reverse Voltage Forward Current Continuous Total Power Dissipation @ TA = 25C Negligible Power in Triac Driver Derate above 25C OUTPUT DRIVER OffState Output Terminal Voltage Peak Repetitive Surge Current (PW = 1 ms, 120 pps) Total Power Dissipation @ TA = 25C Derate above 25C TOTAL DEVICE Isolation Surge Voltage(1) (Peak ac Voltage, 60 Hz, 1 Second Duration) Total Power Dissipation @ TA = 25C Derate above 25C Junction Temperature Range Ambient Operating Temperature Range(2) Storage Temperature Range(2) Soldering Temperature (10 s) VISO PD TJ TA Tstg TL 7500 330 4.4 40 to +100 40 to +85 40 to +150 260 Vac(pk) mW mW/C C C C C VDRM ITSM PD 400 1 300 4 Volts A mW mW/C VR IF PD 3 60 100 1.33 Volts mA mW mW/C 1. 2. 3. 4. 5. 5. 6. 3 Symbol Value Unit 1 2

SCHEMATIC6 5 4 ANODE CATHODE NC MAIN TERMINAL SUBSTRATE DO NOT CONNECT MAIN TERMINAL

1. Isolation surge voltage, VISO, is an internal device dielectric breakdown rating. 1. For this test, Pins 1 and 2 are common, and Pins 4, 5 and 6 are common. 2. Refer to Quality and Reliability Section in Opto Data Book for information on test conditions.Preferred devices are Motorola recommended choices for future use and best overall value.

GlobalOptoisolator is a trademark of Motorola, Inc.

REV 1

MotorolaInc. 1995 Motorola, Optoelectronics Device Data

1

MOC3021 MOC3022 MOC3023ELECTRICAL CHARACTERISTICS (TA = 25C unless otherwise noted)Characteristic INPUT LED Reverse Leakage Current (VR = 3 V) Forward Voltage (IF = 10 mA) OUTPUT DETECTOR (IF = 0 unless otherwise noted) Peak Blocking Current, Either Direction (Rated VDRM(1)) Peak OnState Voltage, Either Direction (ITM = 100 mA Peak) Critical Rate of Rise of OffState Voltage (Figure 7, Note 2) COUPLED LED Trigger Current, Current Required to Latch Output (Main Terminal Voltage = 3 V(3)) MOC3021 MOC3022 MOC3023 Holding Current, Either Direction 1. 2. 3. 3. IFT IH 8 100 15 10 5 A mA IDRM VTM dv/dt 10 1.8 10 100 3 nA Volts V/s IR VF 0.05 1.15 100 1.5 A Volts Symbol Min Typ Max Unit

Test voltage must be applied within dv/dt rating. This is static dv/dt. See Figure 7 for test circuit. Commutating dv/dt is a function of the loaddriving thyristor(s) only. All devices are guaranteed to trigger at an IF value less than or equal to max IFT. Therefore, recommended operating IF lies between max IFT (15 mA for MOC3021, 10 mA for MOC3022, 5 mA for MOC3023) and absolute max IF (60 mA).

TYPICAL ELECTRICAL CHARACTERISTICS TA = 25C2 VF, FORWARD VOLTAGE (VOLTS) 1.8 PULSE ONLY PULSE OR DC 1.6 1.4 TA = 40C 25C 85C 1 10 100 IF, LED FORWARD CURRENT (mA) 1000 ITM , ON-STATE CURRENT (mA) +800

+400

0

1.2 1

400

800 3 2 1 0 1 2 VTM, ONSTATE VOLTAGE (VOLTS) 3

Figure 1. LED Forward Voltage versus Forward Current

Figure 2. OnState Characteristics

2

Motorola Optoelectronics Device Data

MOC3021 MOC3022 MOC30231.3 IFT, NORMALIZED LED TRIGGER CURRENT IFT, TRIGGER CURRENT NORMALIZED 1.4 25 20 NORMALIZED TO: PWin 100 s 1.2 1.1 1

q

15

0.9 0.8

10

5 0 1

0.7 0.6 40 20 0 20 40 60 TA, AMBIENT TEMPERATURE (C) 80 100

2

5 10 20 PWin, LED TRIGGER WIDTH (s)

50

100

Figure 3. Trigger Current versus Temperature

Figure 4. LED Current Required to Trigger versus LED Pulse Width

12 10 dv/dt, STATIC (V/ s) 8 6 4 2 0 25 30 I DRM, LEAKAGE CURRENT (nA) 100 STATIC dv/dt CIRCUIT IN FIGURE 7

100

10

40

50 60 70 80 TA, AMBIENT TEMPERATURE (C)

90

1 40 30 20 10 0 10 20 30 40 50 60 TA, AMBIENT TEMPERATURE (C)

70

80

Figure 5. dv/dt versus Temperature

Figure 6. Leakage Current, IDRM versus Temperature

+400 Vdc

RTEST

R = 10 k

PULSE INPUT

CTEST MERCURY WETTED RELAY X100 SCOPE PROBE

D.U.T.

1. The mercury wetted relay provides a high speed repeated pulse to the D.U.T. 2. 100x scope probes are used, to allow high speeds and voltages. 3. The worstcase condition for static dv/dt is established by triggering the D.U.T. with a normal LED input current, then removing the current. The variable RTEST allows the dv/dt to be gradually increased until the D.U.T. continues to trigger in response to the applied voltage pulse, even after the LED current has been removed. The dv/dt is then decreased until the D.U.T. stops triggering. tRC is measured at this point and recorded. Vmax = 400 V

APPLIED VOLTAGE WAVEFORM

252 V dv dttRC

0 VOLTS

V + 0.63 RCmax + 252 RCt t

Figure 7. Static dv/dt Test Circuit

Motorola Optoelectronics Device Data

3

MOC3021 MOC3022 MOC3023VCC Rin 1 2 3 MOC 3021/ 3022/ 3023 6 5 4 0.01 F LOAD GROUND 360 0.05 F 470 HOT 39 240 VAC

* This optoisolator should not be used to drive a load directly. It is intended to be a trigger device only. Additional information on the use of optically coupled triac drivers is available in Application Note AN780A.

In this circuit the hot side of the line is switched and the load connected to the cold or gro