Anda di halaman 1dari 199

PENGONTROL SUHU UDARA INKUBATOR BAYI KUCING

BERBASIS MIKROKONTROLER AT89S52


DENGAN METODA FUZZY LOGIC

Tugas Akhir

Diajukan Untuk Memenuhi Salah Satu Syarat

Memperoleh Gelar Sarjana Teknik

Program Studi Teknik Elektro

Oleh:

Nama : IGN. Heru Wahyudi M.D.A.


NIM : 035114050

PROGRAM STUDI TEKNIK ELEKTRO


FAKULTAS SAINS DAN TEKNOLOGI
UNIVERSITAS SANATA DHARMA
YOGYAKARTA
2009
TEMPERATURE CONTROL FOR INCUBATOR KITTEN
BASED ON AT89S52 MICROCONTROLLER
WITH METHODE FUZZY LOGIC

Final Project

Presented as Partial Fulfillment of the Requirements


To Obtain the Sarjana Teknik Degree
In Electrical Engineering Study Program

By:
Name : IGN. Heru Wahyudi M.D.A.
Student Number: 035114050

ELECTRICAL ENGINEERING STUDY PROGRAM


FACULTY OF SCIENCE AND TECHNOLOGY
SANATA DHARMA UNIVERSITY
YOGYAKARTA
2009
III
J
600Zi5qmTd5S"[ru88us ( 'I'W 'J SltruH lrr1.\\B
#
I
ll Eurqurrqur:;
60-0[reqru-5ldd$or'1n88uel 1'yq'pmlposIrv Brul-rd
: qslo mlnpslp qulel
O9O' IIE' O:I^tr IN
'V'C'I I rynftlu/v\ruoH'NOI
:qCIlo
JI$OT AZZNT Y(IOItrI^I I{YONf,O
SISYtrUtrfl
ZSS6SIVUf,]OUINIOXOTDTITAI
3\trSrDrr^vfl uorv{flxNll Yuvofl oHns rourNrocNfd
UIIDTY SYf)OI
NYNfNIUSUf,d NIYINYTYH
v'ct'I trtpn{,{e16nreg 'u81
.H
6002 requeldes,'eu")Ie{EoI
.e1epnd,"-;;.;#ffi
;:ffffi::: ffi* {rlencel
'ure18ue;o e,{ra1 uel8eq nele e.fte1 lenrueru {epl1
rur srln1e,(esEue,(lqle se8nl e^\q€q e,{uqn8Eunsesue8uep uelelefueur uie5..
VATIY){ NYTTSYfl)TNVVIYANUf,d
PENGONTROL SUHU UDARA INKUBATOR BAYI KUCING
BERBASIS MIKROKONTROLER AT89S52
DENGAN METODA FUZZY LOGIC

Heru wahyudi
035114050

Intisari
Memelihara kucing mempunyai kepuasan tersendiri dan kebanyakan orang menjadikannya
sebagai hewan kesayangan. Sering kali pada saat melahirkan induk kucing mengalami kematian,
sehingga bayi kucing tersebut membutuhkan suhu ruangan yang nyaman. Inkubator dapat
dijadikan sebagai media untuk merawat bayi kucing, karena suhu udaranya dapat dikontrol,
sehingga suhu udaranya sesuai dengan yang diharapkan.
Mikrokontroler AT89S52 berperan sebagai pengendali suhu udara inkubator. Sistem ini
didukung dengan lampu sebagai pemanas dan kipas sebagai pendingin. Sensor suhu yang
digunakan adalah LM335. Data yang diperoleh kemudian diolah oleh mikrokontroler. Suhu yang
diinginkan mempunyai 3 pilihan yaitu 32oC untuk bayi yang berumur 0-7 hari, 28oC untuk bayi
yang berumur 8-14 hari, 26 oC untuk bayi yang berumur 15-28 hari . Suhu yang terukur
ditampilkan pada 3 digit seven segment. Metode pengendalian yang digunakan berbasis kendali
logika samar.
Piranti pengontrol suhu udara inkubator bayi kucing ini dapat diimplementasikan untuk
mengontrol suhu dengan media mikrokontroler AT89S52. Terbukti pada hasil pengujian setiap
set point tercapai dan stabil, gangguan yang diberikan tidak mempengaruhi kestabilan suhu udara
inkubator.

Kata kunci : inkubator, bayi kucing , kendali logika samar, mikrokontroler

vii
TEMPERATURE CONTROL FOR INCUBATOR KITTEN
BASED ON AT89S51 MICROCONTROLLER
WITH METHODE FUZZY LOGIC

Heru wahyudi
035114050

Abstract

Taking care a cat might give self satisfaction for most people. Mostly, when
bearing, the mother cat die which makes the kitten needs the comfortable room
temperature. Incubator could be used as the media to take care kitten, since the
temperature can be controlled as what we expect.
AT89S52 microcontroller had the role as the incubator temperature controller.
This system was supported by the lamp as the heater and the fan as the cooler. The
temperature sensor used was 1m335 then processed by the microcontroller. The
expected temperature has three options, 32oC for a 0-7 days old, 28oC for a 8-14 days
old, 26oC for a 15-28 days old kitten. The measured temperature was showed by 3
digit seven segment. Controlling method use fuzzy logic controller (FLC).
Device of Temperature controller incubator kitten could be implemented to
control the temperature by AT89S52 microcontroller as the media. It was proved on
the test result, each set point was reached and stabil, the given interference did not
influence the incubator temperature stability.

Key words : incubator, kitten, fuzzy logic controller, microcontroller.


.

viii
KATA PENGANTAR

Puji syukur penulis panjatkan kepada Tuhan Yesus Kristus, karena kasih

karunia-Nya penulis akhirnya dapat menyelesaikan tugas akhir ini dengan baik

dan lancar. Tugas akhir ini merupakan salah satu syarat untuk memperoleh gelar

Sarjana pada program studi Teknik Elektro Universitas Sanata Dharma

Yogyakarta.

Dalam proses penulisan tugas akhir ini penulis menyadari bahwa ada

begitu banyak pihak yang telah memberikan perhatian dan bantuan sehingga tugas

akhir ini dapat terselesaikan. Maka dari itu, penulis ingin mengucapkan terima

kasih kepada :

1. Yosef Agung Cahyanta S.T.,M.T, selaku Dekan Fakultas Teknik

Universitas Sanata Dharma Yogyakarta.

2. B. Wuri Harini, S.T., M.T., selaku Kaprodi Teknik Elektro Universitas

Sanata Dharma Yogyakarta dan banyak membantu dalam menyelesaikan

tulisan ini.

3. Ir. Th. Prima Ari Setyiani, M.T., selaku pembimbing I

4. A. Bayu Primawan, S.T., M.Eng. dan Djoko Untoro Suwarno, S.Si, M.T

sebagai penguji dan kepada seluruh dosen Teknik Elektro Universitas

Sanata.

5. Bapak M maryono(Alm) dan Ibu Maria Supimurtini sebagai orang tua

yang baik. I. Singgih H dan A Tri Dewi sebagai saudaraku

6. Rb. Supardiyono sekeluarga, yang telah banyak banyak membantu dalam

menyelesaikan tugas akhir ini.

iv
7. Laboran Teknik Elektro : mas Broto, mas Mardi, mas Sur, mas Hardi.

8. Dan seluruh pihak yang telah ambil bagian dalam proses penulisan tugas

akhir ini yang terlalu banyak jika disebutkan satu-persatu.

Dengan rendah hati penulis menyadari bahwa tugas akhir ini masih jauh

dari sempurna, oleh karena itu berbagai kritik dan saran untuk perbaikan tugas

akhir ini sangat diharapkan. Akhir kata, semoga tugas akhir ini dapat bermanfaat

bagi semua pihak. Terima kasih.

Yogyakarta, juni 2009

Penulis

v
DAFTAR ISI

HALAMAN JUDUL ........................................................................................ i


HALAMAN PERSETUJUAN PEMBIMBING.. ................................................. iii
HALAMAN PENGESAHAN ... ................................................................................... iv
PERNYATAAN KEASLIAN KARYA .. ............................................................v

MOTO DAN PERSEMBAHAN .. ..................................................................... vi


INTISARI .................................................................................................... vii
ABSTRACT ................................................................................................ viii
KATA PENGANTAR .....................................................................................ix
DAFTAR ISI ................................................................................................. xi
DAFTAR GAMBAR .................................................................................................. xiv
DAFTAR TABEL ......................................................................................................xvii
DAFTAR LAMPIRAN ............................................................................................ xviii
BAB I. PENDAHULUAN ................................................................................1
1.1 Latar Belakang Masalah ................................................................................... 1
1.2 Tujuan dan Manfaat Penelitian ......................................................................... 2
1.3 Batasan Masalah ................................................................................................ 2
1.4 Metodologi Penelitian ....................................................................................... 2

BAB II. DASAR TEORI ..................................................................................4


2.1 Sensor suhu ..................................................................................................... 4
2.2 Pengondisi Sinyal (Span & Zero) ................................................................... 5
a. Penguat Beda (differential Amplifier) .................................................... 7
b. Pembagi Tegangan dengan Penyangga (rangkaian pengurang). ............ 8
2.3 Pengubah Data (tegangan) Analog ke Data Digital ........................................ 9
2.4 Mikrokontroler AT89S52 ............................................................................. 11
2.4.1 Konfigurasi Pin Mikrokontroler AT89S52 ..................................... 12
2.4.2 RAM Internal .................................................................................. 12
2.4.2.1 Flash PEROM ................................................................. 14
2.4.2.2 PSW (Program Status Word ........................................... 14
2.4.3 Rangkaian Osilator Mikrokontroler ................................................ 15
2.4.4 Rangkaian Reset Mikrokotroler ...................................................... 15
2.5 Himpunan Kabur (Fuzzy Logic) ................................................................... 16
2.5.1 Fungsi Pengaburan .......................................................................... 17
2.5.2 Basis Pengetahuan .......................................................................... 19
2.5.3 Unit Penalaran Kabur ...................................................................... 20
2.5.4 Unit Penegasan................................................................................ 20
2.6 Seven segment .............................................................................................. 22
2.7 Definisi spesifikasi respon transien .............................................................. 22

a. Waktu runda (delay time) .................................................................... 23


b. Waktu naik (rise time) ......................................................................... 23
c. Waktu puncak ...................................................................................... 23
d. Lewatan maksimum (M p ).................................................................... 23
e. Waktu penetapan ................................................................................. 24

BAB III. PERANCANGAN ......................................................................................... 25


3.1 Perancangan Perangkat Keras ...................................................................... 26
3.1.1 Perancangan Inkubator (Plant............................................................... 26
3.1.2 Sensor suhu elektronis LM335 dan penyangga .................................... 27
3.1.3 Hubungan sinyal terkondisi dengan ADC0804 .................................... 28
3.1.4 Antarmuka ADC 0804 dengan Mikrokontroler AT89S52 ................... 29
3.1.5 Rangkaian Pengkondisi Isyarat Untuk Masukan ADC ......................... 29
3.1.6 Rangkaian reset mikrokontroler ............................................................ 32
3.1.7 Key Pad ................................................................................................. 33
3.1.8 Tampilan Suhu ...................................................................................... 34
3.2 Pembuatan Rules ........................................................................................... 35
3.3 Perancangan Perangkat Lunak ...................................................................... 36
3.3.1 Program Penghitungan error dan d_error ............................................ 39
3.3.2 Program Fuzzy Logic Controll (FLC) .................................................. 41
3.3.2.1 Program Fuzzifikasi ........................................................................ 41
3.3.2.2 Program Inferensi ............................................................................ 42
3.3.2.3 Program Defuzzification (penegasan) ............................................. 45
3.3.3 Program penampilan suhu..................................................................... 47

BAB IV. HASIL DAN PEMBAHASAN ..................................................................... 49


4.1 Cara kerja inkubator bayi kucing ................................................................... 51
4.2 Pengamatan dan analisa suhu inkubator ........................................................ 52
4.2.1 Hasil pengamatan pada set point 26 oC............................................. 52
4.2.2 Hasil pengamatan pada set point 28 oC ............................................. 55
4.2.3 Hasil pengamatan pada set point 32 oC .............................................. 56
4.3 Hasil pengamatan menghadapi gangguan ..................................................... 58
4.3.1 Pengujian pada set point 26oC .......................................................... 59
4.3.2 Pengujian pada set point 28oC .......................................................... 59
4.3.3 Pengujian pada set point 32oC .......................................................... 61
4.4 Program utama ............................................................................................... 63
4.4.1 Penghitungan error dan d_error ......................................................... 65
4.4.2 Program fuzzy logic ........................................................................... 65
4.4.2.1 Fuzzification ....................................................................... 66
4.4.2.2 Basis data ........................................................................... 67

BAB V KESIMPULAN DAN SARAN ................................................................... 68


5.1 Kesimpulan ................................................................................................... 68
5.2 Saran ............................................................................................................. 68
DAFTAR PUSTAKA

LAMPIRAN DATA HASIL PENGUKURAN

LAMPIRAN GAMBAR RANGKAIAN


LAMPIRAN LIST PROGRAM

LAMPIRAN DATA SHEET


DAFTAR GAMBAR

halaman

Gambar 2.1. Simbol dan bentuk IC LM335 ............................................................ 5

Gambar 2.2. Sensor suhu sederhana tanpa kalibarasi .............................................. 6

Gambar 2.3. Two-port system .................................................................................. 7

Gambar 2.4. Penguat Beda (differential amplifier) ................................................. 8

Gambar 2.5. Pembagi tegangan dengan penyangga ............................................... 9

Gambar 2.6. Diagram blok pengubah analog ke digital ........................................ 10

Gambar 2.7. Pin ADC0804 .................................................................................... 12

Gambar 2.8. Konfigurasi pin Mikrokontroler AT89S52 ....................................... 13

Gambar 2.9. Lokasi RAM Internal ........................................................................ 15

Gambar 2.10. Rangkaian osilator mikrokontroler ................................................. 16

Gambar 2.11. Rangkaian reset mikrokontroler ........................................................ 17

Gambar 2.12. Struktur dasar suatu sustem kendali kabur........................................ 18

Gambar 2.13. Nilai fungsi pengaburan segitiga....................................................... 20

Gambar 2.14. Rangakaian led common catoda ...................................................... 23

Gambar 2.15. Susunan led seven segment tampak atas ........................................... 23

Gambar 3.1. Diagram kotak pengontrol suhu udara pada inkubator ...................... 25

Gambar 3.2. Rancangan konstruksi inkubator ....................................................... 26

Gambar 3.3. Rangkain sensor LM335 .................................................................... 27

Gambar 3.4. Hubungan sinyal terkondisi dengan ADC080438 ............................. 28

Gambar 3.5. Antarmuka AT89s52 dengan ADC0804 ............................................ 38

Gambar 3.6. Diagram kotak pengkondisi sinyal .................................................... 31


Gambar 3.7. Rangkaian penguat beda .................................................................... 31

Gambar 3.8. Rangkaian reset .................................................................................. 32

Gambar 3.9. Antarmuka antara key pad dengan Mikrokontroler AT89s52 ........... 33

Gambar 3.10. Rangakaian seven segment. ................................................................ 34

Gambar 3.11. Respon sistem tipikal dan pembagian daerahnya ................................. 35

Gambar 3.12. (a) Fungsi keanggotaan error dan d_error ........................................ 36


(b) Fungsi keanggotan output ............................................................ 36
Gambar 3.13. Diagram alir program utama ……………………… ........................... 38

Gambar 3.14. Diagram alir program Penghitungan error dan d_error ...................... 40

Gambar 3.15. Diagram alir program penyulutan fungsi keanggotaan masukan .......... 42

Gambar 3.16. Diagram alir program basis data. ......................... ……………………44

Gambar 3.17. Diagram alir program basis kaidah …………………… ..................... 45

Gambar 3.18. Diagram alir program defuzzifikasi ............. …………………………46

Gambar 3.19. Diagram alir program panampilan suhu ............................................... 47

Gambar 4.1. Inkubator kucing................................................................................... 48

Gambar 4.2. Panel kontrol......................................................................................... 49

Gambar 4.3. Pendingin inkubator sederhana ........................................................... 50

Gambar 4.4. Pemanas suhu udara ............................................................................. 50

Gambar 4.5. Grafik respon transien set point 26oC................................................... 53

Gambar 4.6. Grafik respon transien set point 28oC................................................... 55

Gambar 4.7. Grafik respon transien set point 32oC................................................... 57

Gambar 4.8. Grafik pengujian ganguan set point 26oC............................................. 59

Gambar 4.9 Grafik pengujian ganguan set point 28oC............................................. 61

Gambar 4.10 Grafik pengujian ganguan set point 32oC............................................. 62


Gambar 4.11 Program utama pengontrol suhu udara inkubator berbasis

mikrokontroler. ..................................................................................... 63

Gambar 4.12 Program pengitungan error................................................................... 64

Gambar 4.13 Program fuzzification ........................................................................... 65

Gambar 4.14 Subrutine program basis data ............................................................... 66


DAFTAR LAMPIRAN

Lampiran I Perancangan Tampilan Mode F1 ……………………………. LI


Lampiran II Gambar Rangkaian ………………………………………….. LII
Lampiran III Daftar ASCII ………………………………………………... LIII
Lampiran IV Listing Program .…………………………………………....... LIV
Lampiran V Datasheet ……………………………………………………. LV

xvii
BAB I

PENDAHULUAN

1.1 Latar Belakang

Kebutuhan bayi kucing yang harus di penuhi oleh induknya diantaranya

adalah kehangatan, perlindungan, pendidikan, nutrisi dan perawatan. Kebutuhan

akan suhu yang nyaman bisa terpenuhi secara alami, diantanya adalah berasal dari

suhu tubuh induknya atau suhu tubuh anakan kucing yang lainnya.

Bayi kucing yang lahir prematur, induk kucing yang mengalami gangguan

kesehatan saat melahirkan dan jumlah bayi kucing yang banyak, menyebabkan

kurang terpenuhinya kebutuhan-kebutuhan bagi bayi kucing. Pemberian

perlindungan, nutrisi, perawatan dan pendidikan dapat dilakukan secara langsung

oleh manusia secara rutin, sedangkan kebutuhan kehangatan memerlukan

tindakan khusus untuk mendapatkan suhu yang nyaman dan stabil.

Bayi kucing yang baru dilahirkan sangat sensitive terhadap suhu ruangan.

Salah satu masalah yang akan timbul jika suhu ruangan tidak sesuai dengan

kebutuhan bayi kucing adalah mengalami hipotermi. Banyak cara yang diciptakan

untuk membuat suhu yang cocok dan nyaman untuk bayi kucing tersebut. Salah

satu cara yang dilakukan oleh pakar kesehatan adalah menempatkan bayi kucing

pada sebuah inkubator. Untuk menjaga temperatur udara yang diinginkan pada

sebuah inkubator bayi hewan khususnya kucing, sekarang ini masih dilakukan

secara manual yaitu dengan menyalakan atau mematikan lampu berdasarkan suhu

yang terukur oleh termometer ruangan atau secara prediksi.

Dari masalah yang sedang terjadi diatas, maka dalam tugas akhir ini akan

dibuat sebuah inkubator bayi kucing dengan pengendali suhunya dilakukan secara

1
otomatis dan pengontrol suhu menggunakan mikrokontroler AT89S51 dengan

metoda logika kabur (fuzzy logic control).

1.2 Pembatasan Masalah

Spesifikasi alat yang akan dibuat seperti yang telah diuraikan di atas dibatasi

pada:

1. Penggunaan inkubator dikhususkan pada bayi kucing yang berumur 0

sampai 28 hari dengan suhu yang diinginkan pada umur 0-7 hari adalah

32oC, pada umur 8-14 hari adalah 28oC sedangkan pada umur 15-28 hari

membutuhkan suhu udara 26 oC.

2. Sistem pengendali menggunakan mikrokontroler Atmel seri AT89S52 dan

program fuzzy logic controller yang tersimpan didalamnya.

3. Sebagai pemanas digunakan empat buah lampu 100 watt dan

pendinginnya menggunakan kipas.

4. Tampilan suhu aktual menggunakan seven segment 3 angka.

1.3 Tujuan Penelitian

Tujuan Penelitian ini adalah menghasilkan pengontrol suhu inkubator bayi kucing

dengan metoda fuzzy logic conroller (FLC).

1.4 Metodologi Penelitian

Merodologi penelitian yang akan digunakan dalam penelitian ini pada

pembuatan alat ini adalah sebagai berikut:

1. Perancangan dan pembuatan plant inkubator .

2. Pengujian dan pengaplikasian tranduser suhu (LM335)

2
3. Perancangan dan pengujian rangkaian pengendali lampu AC 100W dan

kipas angin 12V.

4. Perancangan dan pengujian AT89S51 untuk pengolah data yang diterima

dari tranduser suhu dan mengendalikan sistem pengendali.

5. Perancangan dan pengujian fuzzy logic controller untuk diaplikasikan

sebagai pengendali suhu udara inkubator menggunakan bahasa assembler.

3
BAB II

DASAR TEORI

2.1 Sensor Suhu

Untuk tranduser suhu secara khusus sudah tersedia dalam bentuk bahan

semikonduktor dengan bentuk fisik seperti transistor dengan tiga buah kaki.

Kemampuan bahan semikonduktor ini mempunyai jangkauan pengukuran yang

lebar, dan mempunyai sifat yang benar-benar linier antara perubahan suhu yang

diterima dan tegangan keluaran yang dihasilkannya. Contohnya adalah

semikonduktor terintegrasi berupa IC LM35 dan LM335.

Inkubator yang dibuat menggunakan semikonduktor terintegrasi berupa IC

LM335. Perubahan nilai tegangan keluaran adalah sebesar 10 mV setiap satu

derajad. Simbol dan bentuk dari LM335 dapat dilihat pada gambar 2.1.

simbol tampak bawah


Gambar 2.1. Simbol dan Bentuk IC LM335.

LM335 berupa semikonduktor yang secara fisik bentuknya sama dengan

transistor tiga kaki. Dilihat dari bawah dengan bidang yang mendatar berada di

atas maka dapat ditentukan kaki-kakinya. Kaki pertama merupakan kaki adj, kaki

kedua adalah kaki anoda dan kaki ketiga adalah kaki katoda. IC LM335

sebenarnya adalah dioda zener yang stabil. Karena itu penerapannya dalam untai

4
elektronis sama dengan dioda, secara sederhana untainya dapat digambarkan

seperti pada gambar 2.2[2].

Gambar 2.2 Sensor suhu sederhana Tanpa kalibrasi

Berikut ini adalah beberapa karakteristik dari LM335 yang mendukung

pembuatan inkubator dalam pendeteksian suhu udara:

1. LM334 mempunyai perubahan pada keluaran sebesar 10mV setiap 1oC

bila pada komponen ini diberi catu daya maka ia akan bekerja sebagai

sensor suhu yang bersifat linier.

2. Mempunyai jangkah pengukuran suhu yang besar dari –40 oC sampai

dengan 100 oC.

Tegangan yang dihasilkan sensor berdasarkan besarnya suhu dalam celcius

adalah

V lm335 = ( 273 + oC ) X 10mV ………………………………….2.1

Rentang arus untuk sensor LM335 adalah 400μA hingga 5mA. Resistor Rs adalah

hambatan untuk membatasi arus masukan. Besarnya arus yang mengalir kedalam

sensor adalah,

V cc
IRs = …………………………………………………...2.2
Rs

2.2 Pengondisi Sinyal (Span & Zero)

Pengkondisi sinyal berfungsi untuk menyesuaikan keluaran sensor dengan

input adc, tegangan minimal keluaran sensor diubah menjadi tegangan minimal

5
input adc dan tegangan maksimal keluaran sensor diubah menjadi tegangan

maksimal tegangan input adc. Diagram blok pengkondisi sinyal[2] ditunjukan

gambar 2.3.

Gambar 2.3. Two-port system

Besarnya penguatan dari pengkondisi sinyal adalah perbandingan antara

tegangan keluaran dengan tegangan input. Besarnya penguatan dapat di tulis

dalam persamaan sebagai berikut yaitu

Vo
AV = .....................................................................................................................
Vi

V −i X 1 V −oY 1
= ..................................................................................................
X 2 − X 1 Y 2 − Y1

Penyesuaian sinyal ini menggunakan penguat operasional (op-amp).

Penggunaan op-amp diperlukan karena op-amp mempunyai sifat penting salah

satunya yaitu mempunyai impedansi masukan tinggi dan impedansi keluaran

rendah, sehingga tidak perlu arus yang besar untuk mengaktifkan op-amp dan

mempunyai nilai penguatan yang tinggi. Pengkondisi sinyal ini terdiri dari dua

bagian yaitu:

1. Bagian rangkaian penguat beda

2. Bagian rangkaian pengurang

Pada rangkaian penguat beda input positif (non inverting) terhubung

dengan keluaran sensor dan input negatif (inverting) terhubung dengan tegangan

pengurang. Tegangan pengurang dihasilkan dari rangkaian pembagi tegangan.

6
a.
Penguat Beda (differential Amplifier)[2]

Penguat beda merupakan bagian dari penguat instrumentasi dalam

pengukuran. Penguat ini dirancang dengan menggunakan op-amp dan tahanan

presisi yang membuat rangkaian menjadi stabil dan berguna ketika ketelitian

menjadi suatu hal yang penting.

Penguat beda ini mempunyai dua masukan yaitu V1 yang terhubung dengan

masukan membalik dan V2 yang terhubung dengan masukan tidak membalik,

Rangkaian penguat beda ini ditunjukan pada gambar 2.4. Masing-masing

masukan ini terhubung dengan sebuah tahanan, pada masukan membalik diberi

tahanan umpan balik dari keluaran dan pada masukan tidak membalik diberi

sebuah tahanan yang terhubung dengan bumi.

Gambar 2.4. Penguat Beda (differential amplifier)

Pada masukan membalik terdapat penguatan tegangan masukan sebesar

Rf
Ai n v = − ............................................................................................. 2.8
R1

Pada masukan tak membalik terdapat penguatan tegangan masukan sebesar

 R f + R1  R g 
An = −
nn v 
 
−oi
  ................................................................ 2.9
 R1  R g + R2 
Pada saat V2 = 0 dan V1 0 maka keluaran penguat beda adalah

7
 Rf 
V oV2=u0 =t − .V1
 R1 

......... 2.10

Pada saat V1 = 0 dan V2 0 maka keluaran penguat beda adalah

 R f + R1  R g 
V Vo1=0 = u t  .V2
 +  ......................................................... 2.11
 R 1  gR R 2 

Tegangan keluaran merupakan penjumlahan dari dua keadaan tersebut

Vo u =t V o V 2u= 0 +t V o V 1=u0 t

 Rf   R + R1  R g 
Vo u =t  − .V 1 +  f  .V 2
  R  R + R 
 R1   1  g 2 

Bila Rf = RG dan R2= R1, maka

 R g
V o= u t(V 2 −i V 1)
 R1 
..........................................................................................................................

2.12

Rg
∆V =
R1
..........................................................................................................................

2.13

b. Pembagi Tegangan dengan Penyangga (rangkaian pengurang)[2].

Rangkaian ini merupakan sumber tegangan yang digunakan sebagai

tegangan pengurang,

8
Gambar 2.5. Pembagi tegangan dengan penyangga

Tegangan keluaran pada Vo1 adalah sama dengan Vpot yaitu tegangan yang

dihasilkan dari pembagi tegangan antara R1 dan (Rpot +R2), Karena penguatan

pada op-amp adalah 1.


2.3
Pengubah Data (tegangan) Analog ke Data Digital[8]

Pengubah sinyal analog menjadi sinyal digital disebut pengkode atau

encoder. Gambar 2.6 memperlihatkan diagram blok pengubah sinyal analog ke

digital. Dari gambar 2.6, masukan berupa sinyal analog akan diubah menjadi

bentuk biner pada bagian keluaran dari bit paling rendah (LSB) sampai bit yang

paling tinggi (MSB).

Gambar 2.6. Diagram blok pengubah analog ke digital.

Pengubah analog ke digital yang digunakan oleh penulis adalah ADC0804

yang dibuat untuk dapat langsung berhubungan dengan mikroprosesor baik Zilog

80, 8080, atau mikroprosesor 8 bit lainnya. Sinyal masukan maupun sinyal

keluaran dari IC ini, sesuai untuk MOS dan TTL. IC ADC0804 mempunyai waktu

pengubahan 100µS terhadap pengubahan masukan dan mengeluarkan dalam

9
bentuk biner. Beroperasi pada daya standar +5volt dan dapat menerima masukan

analog berkisar 0Volt sampai 5Volt. Macam-macam pin (kaki) yang dimiliki oleh

IC ADC0804:

a. CS

Berfungsi sebagai masukan. Pin ini sebagai chip select dari kontrol

mikroprosesor.

b. RD

Berfungsi sebagai masukan. Pin ini sebagai kontrol untuk membaca data

dari mikroprosesor.

c. WR

Berfungsi sebagai masukan. Pin ini sebagai kontrol untuk menulis data ke

mikroprosesor.

d. CLK IN

Berfungsi sebagai masukan. Pin ini sebagai pengatur detak.

e. INTR

Berfungsi sebagai keluaran. Pin ini sebagai sarana untuk memberikan

interupsi pada masukan interupsi mikroprosesor.

f. V IN (+)

Berfungsi sebagai masukan. Pin ini merupakan jalan masuk bagi sinyal

analog masukkan positif.

g. V IN (-)

Berfungsi sebagai masukan. Pin ini merupakan jalan masuk bagi sinyal

analog masukan negatif.

h. A GND

10
Berfungsi sebagai masukan daya. Pin ini sebagai pembulatan analog.

i. V REF /2

Berfungsi sebagai masukan. Pin ini merupakan jalan masuk bagi tegangan

acuan yang lain (±).

j. D GND

Berfungsi sebagai keluaran. Pin ini sebagai pembulatan digital.

k. DB7-DB0

Berfungsi sebagai keluaran. Pin ini merupakan jalan keluaran bagi data

keluaran bit7 sampai bit0.

l. CLKR

Berfungsi sebagai masukan. Pin ini sebagai pengatur detak dengan

menghubungkannya ke resistor eksternal.

m. V CC (Or ref)

Berfungsi sebagai masukan daya. Pin ini sebagai jalan masuk untuk catu

daya +5volt dan tegangan acuan primer.

Gambar 2.7 menunjukkan konfigurasi kaki pada ADC0804. Resolusi ADC

dengan jumlah bit (n) dapat dihitung dengan

V
r e s o =l u nms ai kVolt/step ............................................................................ (2.12)
2 −1

Gambar 2.7. Pin ADC0804.

11
2.4
Mikrokontroler AT89S52[8]

Mikrokontroler AT89S52 adalah mikrokontroler buatan ATMEL.

Mikrokontroler 8 bit ini sudah dilengkapi FPEROM (Flash Programmable and

Erasable Read Only Memory). FPEROM adalah ROM (Read Only Memory) yang

dapat dihapus dan ditulis kembali.

Fasilitas-fasilitas standar yang dimiliki Mikrokontroler AT89S52 adalah 8

KB FPEROM, 256 byte RAM (Random Accsess Memory), 32 jalur I/O

(input/output), watchdog timer, dua data pointer, tiga 16-bit timer/counter, jalur

komunikasi serial full duplex dan osilator internal.

2.4.1 Konfigurasi Pin Mikrokontroler AT89S52

Mikrokontroler AT89S52 memiliki 40 pin dan ada beberapa pin yang

memiliki fungsi ganda. Konfigurasi pin Mikrokontroler AT89S52 dapat dilhat

pada gambar 2.8 dan fungsi pin dapat dilihat pada tabel 2.1.

Gambar 2.8. Konfigurasi pin Mikrokontroler AT89S52.

2.4.2 RAM Internal

RAM Internal pada Mikrokontroler AT89S52 terdiri atas :

a. Register Bank. Mikrokontroler memiliki 8 buah register yang terdiri atas

R0 sampai dengan R7. Register ini dapat diubah dari bank 0 (default) ke

12
bank 1, bank 2 dan bank 3 dengan cara mengubah nilai RS0 dan RS1 pada

register PSW.

b. Bit addressable RAM. RAM yang dapat diakses secara pengalamatan bit

terletak pada alamat 20H sampai 2FH.

c. RAM serbaguna. RAM ini dapat diakses secara pengalamatan langsung

dan tak langsung terletak pada alamat 30H sampai 7FH. Lokasi RAM

Internal dapat dilihat pada gambar 2.9.

Tabel 2.1 Fungsi pin Mikrokontroler AT89S52.


Pin Fungsi
VCC Catu daya 4V – 5,5V
GND Ground
Port 0 8 bit jalur I/O dua arah
Port 1 8 bit jalur I/O dua arah
Fungsi alternatif :
P1.0 = T2 (Masukan untuk timer 2)
P1.1 = T2EX (Trigger timer 2)
P1.5 = MOSI (digunakan untuk ISP)
P1.6 = MISO (digunakan untuk ISP)
P1.7 = SCK (digunakan untuk ISP)
Port 2 8 bit jalur I/O dua arah
Port 3 8 bit jalur I/O dua arah
Fungsi alternatif :
P3.0 = RXD (masukan komunikasi serial)
P3.1 = TXD (keluaran komunikasi serial)
P3.2 = INT 0 (interupsi ekternal 0)
P3.3 = INT 1 (interupsi eksternal 1)
P3.4 = T0 (masukan timer 0)
P3.5 = T1 (masukan timer 1)
P3.6 = WR
P3.7 = RD
RST Mereset mikrokontroler apabila diberi logika ‘1’
selama 2 siklus mesin

EA /VPP Harus diberi VCC apabila ingin menjalankan


program internal

13
XTAL1 Masukan osilator internal
XTAL2 Keluaran osilator internal, apabila menggunakan
osilator eksternal pin tidak dihubungkan (No
Connect)

2.4.2.1 Flash PEROM

Mikrokontroler AT89S52 mempunyai 8 KB Flash PEROM yang dapat

ditulis dan dihapus. Flash PEROM berisikan instruksi-instruksi. Instruksi-

instruksi ini akan dieksekusi jika sistem di-reset. Bila pin EA/VPP berlogika ‘1’

maka mikrokontroler aktif berdasarkan program yang ada di Flash PEROM. Bila

pin EA/VPP berlogika ‘0’ maka mikrokontroler aktif berdasarkan program yang

ada di memori eksternal.

0 1 2 3 4 5 6 7 8 9 A B C D E F

00 BANK 0 (default) BANK 1


10 BANK 2 BANK 3
20 Bit Addressable RAM
30
40
50
60
70
80
90 RAM Serbaguna
A0
B0
C0
D0
E0
F0

Gambar 2.9. Lokasi RAM Internal

2.4.2.2 PSW (Program Status Word)

14
PSW (Program Status Word) berisikan bit-bit status yang berkaitan

dengan kondisi CPU. PSW bersifat bit-adressable artinya tiap-tipa bit dapat

dialamati satu-persatu tanpa harus merubah satu kesatuan byte. Bit-bit penyusun

PSW dapat dilihat pada tabel 2.2.

Tabel 2.2. Bit-bit penyusun PSW


Posis PSW. PSW. PSW. PSW. PSW. PSW. PSW. PSW.
i 7 6 5 4 3 2 1 0
Bit CY AC F0 RS1 RS0 OV - P

Keterangan :
CY = Menerima carry out dari bit 1
operasi aritmatik
AC = Menerima carry out dari bit 1
operasi penjumlahan
F0 = Status multiguna
RS1 = Bit 1 pemilih bank register
RS0 = Bit 0 pemilih bank register
OV = Limpahan opersai aritmatik
PSW.7 = Didefinisikan pengguna
P =Paritas genap akumulator, menjaga agar di
akumulator selalu genap
2.4.3 Rangkaian Osilator Mikrokontroler

Pada datasheet dikatakan bahwa jika menggunakan osilator kristal, maka

kapasitor yang digunakan adalah 30 pF. Rangkaian osilator dapat dilihat pada

gambar 2.10.

15
Gambar 2.10. Rangkaian osilator mikrokontroler.
2.4.4 Rangkaian Reset Mikrokontroler

Rangkaian reset digunakan untuk mereset program yang terdapat pada

mikrokontroler. Rangkain reset dapat dilihat pada gambar 2.11.

Gambar 2.11. Rangkaian reset mikrokontroler

Pada gambar 2.11 apabila saklar tidak ditekan, pin reset pada

mikrokontroler akan mendapatkan logika rendah ‘0’. Sedangkan saat saklar

ditekan pin akan mendapatkan logiga tinggi ‘1’ dan akan mereset mikrokontroler.

Lamanya waktu yang dibutuhkan untuk mereset adalah dua siklus mesin dan

memenuhi persamaan :

T = R x C ................................................................... 2.16
2.5
Himpunan Kabur (Fuzzy Logic)[4]

Pada logika fuzzy proses yang terjadi adalah

1) Unit pengaburan (Fuzzification unit)

2) Unit penalaran logika kabur (Fuzzy logic reasoning unit)

3) Unit basis pengetahuan (knowledge base unit), yang terdiri dari dua

bagian:

16
a. Basis data (data base), yang memuat fungsi-fungsi keanggotaan dari

himpunan-himpunan kabur yang terkait dengan nilai dari variabel-

variabel linguistik yang dipakai.

b. Basis kaidah (rule base), yang memuat kaidah-kaidah berupa implikasi

kabur.

4) Unit penegasan (defuzzification unit).

Satuan sistem kendasi semacam itu mula-mula mengukur nilai-nilai tegas

dari semua variabel masukan yang terkait dalam proses yang akan dikendalikan.

Nilai-nilai itu kemudian dikonversikan oleh unit pengkaburan ke nilai kabur yang

sesuai. Hasil pengukuran yang telah dikaburkan itu kemudian diproses oleh unit

penalaran, dibandingkan dengan unit basis pengetahuan, menghasilkan himpunan

(himpunan-himpunan) kabur sesuai keluarannya. Langkah terakhir dikerjakan

oleh unit penegasan, yaitu menerjemahkan himpunan-himpunan kabur keluaran

itu ke dalam nilai-nilai yang tegas. Nilai tegas inilah yang kemudian direalisasikan

dalam bentuk suatu tindakan yang dilaksanakan dalam proses pengendalian itu.

Langkah-langkah tersebut secara skematis disajikan dalam gambar 2.12 dibawah

ini.

17
Gambar 2.12 Struktur dasar suatu sistem kendali kabur

2.5.1 Fungsi Pengaburan

Karena sistem kendali logika kabur bekerja dengan kaidah dan masukan

kabur, maka langkah pertama adalah mengubah masukan yang tegas yang

diterima menjadi masukan kabur. Itulah yang dikerjakan oleh unit pengaburan

dari sistem tersebut.

Untuk masing-masing variabel masukan ditentukan suatu fungsi pengaburan

(fuzzyfication function) yang akan mengubah nilai variabel masukan yang tegas

(yang biasanya dinyatakan dalam bilangan real) menjadi nilai pendekatan yang

kabur. Jadi fungsi pengaburan adalah pemetaan f : ℜ → K , di mana K adalah

suatu klas himpunan kabur dalam semesta ℜ (himpunan kabur dalam semesta ℜ

juga disebut bilangan kabur). Fungsi pengaburan itu biasanya ditentukan

berdasarkan beberapa kriteria:

1) Fungsi pengaburan diharapkan mengubah suatu nilai tegas, ke suatu

himpunan kabur
~
A dengan µ A~ (a) = 1 atau sekurang-kurangnya a

mempunyai derajad keanggotaan yang tinggi.

2) Bila nilai masukan catat karena derau, diharapkan fungsi pengaburan dapat

menekan sejauh mungkin derau itu.

3) Fungsi pengaburan diharapkan dapat membantu menyederhanakan

komputasi yang harus dilakukan oleh sistem tersebut dalam proses

inferensinya.

Dalam proses pengaburan terdapat beberapa fungsi pengaburan yaitu Fungsi

Pengaburan Segitiga, Fungsi Pengaburan Gauss, Fungsi Pengaburan Elemen

18
Tunggal. Dalam alat ini diaplikasikan Fungsi Pengaburan Segitiga pada fungsi

masukan dan Fungsi Pengaburan element tunggal untuk fungsi keluaran.


~
a) Fungsi Pengaburan Segitiga memetakan a ∈ ℜ ke himpunan kabur A

dengan fungsi keanggotaan berbentuk segitiga samakaki (gambar 2.13),

yaitu

µ A~ ( x) = S e ( x;ga − σi, a,t a +i σ g)

di mana σ adalah suatu parameter berupa bilangan positif yang menentukan

lebarnya pendukung dari himpunan kabur tersebut.

Gambar 2.13. Nilai fungsi pengaburan segitiga

b) Fungsi Pengaburan Elemen tunggal memetakan nilai tegas a ∈ ℜ ke


~
himpunan tanggal A dengan fungsi keanggotaan

1, j i k xa= a
μ A {X}= 
0, j i k xa≠ a
~
untuk setiap x ∈ ℜ . Jadi sebenarnya himpunan kabur A ini adalah himpunan
~
tegas dengan elemen tunggal, yaitu A = {a}.

2.5.2 Basis Pengetahuan

Basis pengetahuan dari suatu sistem kendali logika kabur terdiri dari basis

data dan basis kaidah. Basis data adalah himpunan fungsi-fungsi keanggotaan dari

himpunan-himpunan kabur yang terkait dengan nilai-nilai linguistik dari variabel-

variabel yang terlibat dalam sistem itu.

19
Basis Kaidah adalah himpunan implikasi-implikasi kabur yang berlaku

sebagai kaidah dalam sistem itu. Bila sistem itu mempunyai m buah kaidah

dengan (n+1) varaibel, maka bentuk kaidah ke-i (i=1,…,m) adalah sebagai

berikut:

Bila x 1 adalah A i1 dan …dan x n adalah A in , maka y adalah Bi

Di mana x j adalah variabel linguistik dengan semesta numeris X j (j=1,…,n)

Suatu basis kaidah diharapkan memenuhi beberapa kriteria sebagai berikut:

1) Lengkap, yaitu untuk setiap ( x1 , . .xn.) ,∈ X 1 × . .X.n terdapat i ∈ {1, . . . m


,}

sedemikian sehingga µ A~ ( x j ) ≠ 0 untuk semua j ∈ {1, . . .n, } . Dengan


ij

perkataan lain, untuk setiap kali masukan terdapat sekurang-kurangnya

satu kaidah yang “tersulut”.

2) Konsisten, yaitu tidak terdapat kaidah-kaidah yang mempunyai

antesenden yang sama tetapi konsekuennya berbeda.

3) Kontinu, yaitu tidak terdapat kaida-kaidah dengan himpunan-himpunan

kabur yang terkait dalam antesenden beririsan, tetapi himpunan-himpunan

kabur yang terkait dalam konsekuennya saling asing.

2.5.3 Unit Penalaran Kabur

Masukan kabur hasil pengolahan unit pengaburan diterima oleh unit

penalaran untuk disimpulkan berdasarkan kaida-kaidah yang tersedia dalam basis

pengetahuan. Penarikan kesimpulan itu dilaksanakan berdasarkan aturan modus

ponens rampat multikondisional.

2.5.4 Unit Penegasan

Kesimpulan/keluaran dari sistem kendali kabur adalah suatu himpunan

kabur. Karena sistem tersebut hanya dapat Mengeksekusi nilai yang tegas, maka

20
diperlukan suatu mekanisme untuk mengubah nilai kabur keluaran itu menjadi

nilai yang tegas, maka diperlukan suatu mekanisme untuk mengubah nilai kabur

keluaran itu menjadi nilai yang tegas. Itulah peranan unit penegasan yang memuat

fungsi-fungsi penegasan dalam sistem itu. Fungsi Penegasan adalah suatu

pemetaan f : K → ℜ , dimana K adalah suatu klas himpunan-himpunan kabur,

yang memetakan suatu himpunan kabur ke suatu bilangan real yang tegas.

Bilangan ini menentukan tindakan pengendalian yang harus dilakukan oleh sistem

itu.

Pemilihan fungsi penegasan biasanya ditentukan oleh beberapa kriteria:


~
1) Masuk akal, artinya secara intuitif bilangan tegas t( A ) dapat diterima
~
sebagai bilangan yang mewakili himpunan kabur A ,

2) Kemudahan komputasi, yaitu diharapkan fungsi penegasan itu cukup

mudah dan sederhana dalam proses komputasinya dalam menghasilkan

bilangan tegas keluarannya.


~
3) Kontinu, artinya perubahan kecil pada A tidak akan mengakibatkan
~
perubahan besar pada t( A ).

Dalam literature dikenal beberapa fungsi penegasan, di antaranya adalah

Purata Maksimum ( Mean of Maxsimum). Pada Purata Maksimum himpunan


~ ~
kabur A dalam semesta ℜ dirubah menajadi bilangan tegas t( A ), yang

merupakan purata dari semua nilai yang mencapai nilai maksimum dalam µ A~ ,

yaitu

~
∫ xdx
t ( A) = M

∫ dx
M

21
~
dengan M = {x ∈ ℜ µ A ( x) = T i ( An)

~ a+b
Apabila M = [a,b], maka t ( A) = . Apabila himpunan kabur terdefinisi pada
2
~
semesta berhingga X={x1,x2,…,xn}, maka bilangan tegas t ( A) didefinisikan

sebagai rerata dari semua nilai dalam himpunan tegas.

∑x i
M = {xi ∈ X µ A~ ( xi ) = T ~
i( An) , yaitu t ( A )=
X i ∈M

dengan M menyatakan banyaknya banyaknya anggota dari himpunan tegas M.


2.6
Seven segment[5]

Seven segment mempunyai 2 jenis yaitu common catode dan common

anode. Common anode adalah semua kutub anode led yang terdapat pada seven

segment dijadikan satu. Pada common anode input tersambung dengan katoda

(gambar2.15)

Gambar 2.14. Rangakaian led common catoda

22
Gambar 2.15. Susunan led seven segment tampak atas.

2.7 Definisi spesifikasi respon transien

Respon transien sistem kontrol praktis sering menunjukan osilasi teredam

sebelum mencapai keadaan tunak. Dalam menentukan karakteristis respon

transien sistem transien kontrol terhadap masukan tangga aturan, biasanya dicari

parameter berikut:

a) Waktu tunda (delay time), t d

waktu tunda adalah waktu yang diperlukan responuntuk mencapai

setengah harga akhir pertama kali

b) Waktu naik (rise time),t r

Waktu naik adalah waktu yang diperlukan respon untuk naik dari 10

sampai 90%, 5 sampai 95%, atau 0 sampai 100% dari harga akhirnya. Untuk

sistem orde kedua redaman kurang, biasanya digunakan wktu naik 0-100%.

Untuk sistem redaman lebih, biasanya digunakan waktu naik 10-90%

c) Waktu puncak,t p

Waktu puncak adalah waktu yang diperlukan respon untuk mencapai

puncak lewatan yang pertamakali.

d) Lewatan maksimum (M p )

23
Lewatan maksimum adalah harga puncak maksimum dari kurva

respon yang diukur dari satu. Jika karga keadaan tunak respon tidak sama

dengan satu, maka bisa digunakan persen lewatan maksimum. Parameter ini

didefinisikan sebagai

Besarnya lewatan maksimum secara langsung menujukan kestabilan relatif

sistem.

Toleransi yang diizinkan


c(t)
mp 0,05
1 Atau
0,9 0,02

td
0,5

0,1
0
tr
tp
ts

Gambar 2.16.
Kurva respon tangga satuan yang menunjukan t d ,t r ,t p ,M p dan t s

e) Waktu penetapan,t s

waktu penetapan adalah waktu yang dibutuhkan respon untuk

mencapai dan menetap dalam daerah disekitar harga akhir yang ukurannya

ditentukan dengan persentase mutlak dari harga akhir (biasanya 5% atau 2%).

Waktu penetapan ini diaktifkan dengan konstanta waktu yang terbesar dari

24
sistem kontrol. Kriteria persentase kesalahan yang akan digunakan ditentukan

dari sasaran desain distem yang dinyatakan.

25
BAB III

PERANCANGAN PENGENDALIAN SUHU UDARA PADA INKUBATOR

BAYI KUCING BERBASIS MIKROKONTROLER AT89S52 DENGAN

METODA FUZZY LOGIC

Keadaan yang diinginkan dari kontrol inkubator adalah mempertahankan

suhu udara pada inkubator, sesuai suhu yang diinginkan. Pengontrolan suhu pada

inkubator dilakukan oleh program Fuzzy Logic Control (FLC), yang dieksekusi

oleh mikrokontroler AT89S52. Untuk menciptakan suhu yang diinginkan FLC

mengatur banyaknya lampu yang menyala dan mati atau hidupnya kipas angin.

Perancangan pengendalian suhu pada inkubator berbasis mikrokontroler

dengan metoda fuzzy logic ini dapat digambarkan seperti gambar 3.1.

Akuator

Gambar 3.1. Diagram kotak Pengontrol suhu udara pada inkubator.

Program FLC tersimpan pada memori mikrokontroler AT89S52. Input μC

adalah keypad 5 tombol dan sensor LM335. data sensor LM335 adalah data

analog yang harus dirubah ke dalam digital, pengubahan data ini dilakukan oleh

25
ADC0804. Sedangkan output dari μC adalah driver lampu, driver kipas dan

seven segment.

3.1 Perancangan Perangkat Keras.

Perangkat keras atau hardware adalah bentuk-bentuk fisik termasuk rangkaian

elektronik yang disusun agar bekerja sesuai yang diinginkan. Perancangan

perangkat keras pengendali suhu pada inkubator meliputi : plant atau inkubator,

rangkaian keypad, sensor suhu LM335, rangkaian pengubah data analog kedalam

data digital dengan menggunakan IC ADC0804 8bit, pengkondisi sinyal (span &

zerro), driver lampu dan driver kipas, mikrokontroler AT89S52 sebagai unit

pengontrol suhu udara pada inkubator dan rangkaian seven segment yang

menampilakan suhu yang terukur.

3.1.1 Perancangan Inkubator (Plant)

Ukuran inkubator dirancang agar mampu menampung 1 ekor induk kucing

dan 7 ekor bayi kucing. Dimensi inkubator berbentuk balok dengan panjang

50cm, lebar 40 cm dan tinggi 40cm. Bagian samping inkubator terbuat dari

acrylic, bagian bawah terbuat dari jaring kawat agar memudahkan kotoran turun

ke keranjang kotoran, dan bagian atas dapat dibuka dan ditutup. Bentuk dan

ukuran inkubator ini dapat dilihat pada gambar 3.2.

Lampu yang menyala akan memanaskan udara yang berada di dalam kotak

lampu. Udara panas akan dihisap kipas 2, yang bertujuan agar aliran udara yang

terjadi didalam inkubator seminimal mungkin dan penyebaran udara panas pada

inkubator cepat merata.

26
Gambar 3.2 Gambar inkubator secara keseluruhan

Untuk mendinginkan suhu udara, digunakan dua buah kipas angin yaitu

kipas 1 dan kipas 2, yang berfungsi mempercepat sirkulasi udara. Kipas 2

berfungsi menarik udara luar ke dalam inkubator dan kipas 3 bertugas menarik

udara dari dalam ke luar inkubator.

3.1.2 Sensor suhu elektronis LM335 dan penyangga[2]

Sensor suhu yang diaplikasikan adalah IC LM335 dengan untai elektronis

dapat dilihat seperti pada gambar 3.3.

Gambar 3.3 Rangkaian sensor LM335.

Hambatan Rs berfungsi untuk membatasi arus yang mengalir pada IC

LM335 (Is = arus sensor ) sehingga arus maksimal yang mampu mengalir dapat di

hitung dengan menggunakan persamaan 2.2. Nilai-nilai komponen yang

27
ditentukan adalah VCC sebesar 5V dan Is sebesar 2.5mA (yang ditunjukan oleh

data sheet rentang Is antara 400μA hingga 5mA) maka

5V
Rs =
2.5mA
Rs = 2kΩ

3.1.3 Hubungan sinyal terkondisi dengan ADC0804

Pin start conversion ADC ( C S ) dihubungkan ke ground agar ADC0804

selalu melakukan konversi data. Pin R D pada ADC 0804 juga dihubungkan ke

ground sehingga ADC selalu membaca data dari mikrokontroler. Pin WR

dihubungkan dengan P0.0 pada Mikrokontroler AT89s52 yang bertujuan agar

penulisan data dari ADC0804 menuju mikrokontroler dapat dikendalikan oleh

mikrokontroler.

Tegangan masukan ADC0804 adalah tegangan keluaran span & zerro yang

dihubungkan pada pin +IN. Berdasarkan datasheet, untuk mencapai waktu

konversi ADC0804 sebesar 100µs, dibutuhkan resistor 10KΩ dan kapasitor

150pF. Pada rangkaian ini, juga digunakan dioda zener 5,1Volt sebagai pembatas

tegangan agar saat tegangan masukan ADC0804 bernilai sama dengan tegangan

saturasi penguat operasional, tegangan tersebut tidak merusak IC ADC0804.

Tegangan masukan positif dibatasi sebesar 5,1Volt sesuai dengan nilai dioda

zener, sedangkan tegangan masukan negatif dibatasi sekitar –0,7Volt, sesuai

dengan tegangan maju dioda silikon. Hubungan sinyal terkondisi dengan ADC

ditunjukkan pada gambar 3.4.

28
Gambar 3.4. Hubungan sinyal terkondisi dengan ADC0804.

3.1.4 Antarmuka ADC 0804 dengan Mikrokontroler AT89s52

Antarmuka antara ADC0804 dengan Mikrokontroler AT89s52 ditunjukkan

pada gambar 3.5. Jalur data dari ADC0804 pada pin 18-11 dihubungkan dengan

pin Port 1 (P1) pada Mikrokontroler AT89s52. Pin start conversion ADC ( C S )

dihubungkan ke ground agar ADC0804 selalu melakukan konversi data. Pin R D

pada ADC 0804 juga dihubungkan ke ground sehingga ADC selalu membaca data

dari mikrokontroler. Pin W R dihubungkan dengan P3.0 pada Mikrokontroler

AT89s52 yang bertujuan agar penulisan data dari ADC0804 menuju

mikrokontroler dapat dikendalikan oleh mikrokontroler.

Dengan mengacu pada persamaan 2-12, resolusi pada ADC adalah

5Volt
resolusi = = 0,0196Volt/step
28 − 1

3.1.5 Rangkaian Pengkondisi Isyarat Untuk Masukan ADC

Rentang suhu yang terbaca oleh mikrokontroler dibatasi dari suhu 20oC

sampai 35oC.Tegangan yang dihasilkan sensor pada saat 200C akan dijadikan 0

volt dan tegangan yang dihasilkan sensor pada saat 350C akan dikondisikan

menjadi 5volt.

29
Gambar 3.5. Antarmuka AT89s52 dengan ADC0804.

Besar tegangan yang dihasilkan sensor pada saat 0 0C adalah sebesar

(rumus mengacu pada persamaan 2.1)

V lm335 = ( 273 + 0 ) X 10mV

V lm335 = 2,73 Volt

Besar tegangan yang dihasilkan sensor pada saat 200C adalah sebesar

V lm335 = ( 273 + 20 ) X 10mV

V lm335 = 2.93 Volt

Dan besar tegangan sensor pada saat 350C adalah sebesar

V lm335 = ( 273 + 35 ) X 10mV

V lm335 = 3.08Volt

Tegangan sensor sebesar 2,93Volt merupakan tegangan minimum sensor

dan tegangan sensor 3.08 Volt merupakan tegangan maksimal yang dihasilkan

sensor. Pada ADC0804 mempunyai tegangan referensi sebesar 5Volt, ini

30
menujukan bahwa tegangan minimal yang mampu diterima oleh ADC sebesar

0Volt dan tegangan maksimalnya adalah 5 Volt.

Table 3.1 perumusan karakterisik pengkondisi sinyal


V lm335 (Volt) Vout ADC (Volt)
Suhu ( 0C)
(input pengkondisi sinyal) (Output pengkondisi sinyal)
20 2.93 0
35 3.08 5

Dari table 3.1 diasumsikan V lm335 adalah X yang merupakan input dari

pengkondisi sinyal dan Vout ADC adalah Y yang merupakan output dari

pengkondisi sinyal. Dapat dinyatakan dalam persamaan (mengacu pada

persamaan 2.6)

x − 2.93 y−0
=
3.08 − 2.93 5 − 0

Penyelesainnya sebagai berikut:

Y = 33.33 (x – 2.93)
Atau
Vout = 33.33 (Vin – 2.93)

Dari hasil perhitungan ini dapat diuraikan bahwa pengkondisi sinyal

beroperasi untuk menjumlahkan Vin dengan – 2.93 dan dikuatkan sebesar 33.33

kali. Gambar diagram kotak rangkaian pengkondisi sinyal ditunjukan pada

gambar3.6.

Gambar 3.6 Diagram kotak pengkondisi sinyal

31
Rangkaian penguat beda bertujuan untuk menjumlahkan tegangan sensor

dengan tegangan pengurang dengan penguatan sebesar 33.33 kali. Rangkaian ini

terdiri dari IC LM741 dan resistor yang dirangkai menjadi penguat beda seperti

terlihat pada gambar 3.7.

Pada perancangan rangkaian penguat beda nilai hambatan Rf = Rg = 10KΩ

dan R1 = R2. Untuk mencari nilai hambatan R2 dan R1 menggunakan persamaan

2.10 yaitu:

10kΩ
33.333 =
R1

R1 = R2 = 300Ω

Gambar 3.7 Rangkaian penguat beda.

3.1.6 Rangkaian reset mikrokontroler

Reset digunakan untuk mengembalikan keseluruhan sistem (program) ke

awal. Reset terjadi dengan adanya logika 1 selama minimal 2 cycle (2μ detik)

pada kaki reset (pin 9) berdasarkan data sheet (gambar 3.10). Pada perancangan,

waktu pengosongan dipilih sebesar 100 ms dengan asumsi waktu reset telah lebih

dari 2µs, sesuai dengan persamaan 2.16. Bila nilai kapasitor dipilih 10 μF, maka

nilai R adalah:

100mS = R × 10 µF

R = 10 KΩ

32
Gambar 3.8 Rangkaian reset
3.1.7 Key Pad

Key pad dirancang untuk masukan mikrokontroler untuk memilih setting

point (SP) suhu udara inkubator berdasarkan usia kitten dan on/off plant. Key pad

Setting point terdiri dari 3 tombol (gambar 3.11), dengan fungsi setiap tombol

sebagai berikut:

1. SP 32oC untuk bayi kucing (kitten) yang berumur 0 sampai 5 hari.

2. SP 28oC untuk bayi kucing (kitten) yang berumur 6 sampai 14 hari.

3. SP 26oF untuk Bayi kucing (kitten) yang berumur 15 sampai 28 hari.

Antarmuka antara key pad dengan Mikrokontroler AT89s52 ditunjukkan pada

gambar 3.11. Tombol yang dipergunakan untuk memberikan seting point

terhubung dengan P3.4 sampai dengan p3.6, sedangkan untuk tombol terhubung

dengan p3.3.

Gambar 3.9
Antarmuka antara key pad dengan Mikrokontroler AT89s52.

Mikrokontroler membaca key pad jika terjadi interupsi external. Semua

tombol terhubung dengan gerbang logika NOR, keluaran gerbang logika NOR

terhubung dengan P2.2 ( INT 0 ).

33
3.1.8 Tampilan Suhu

Untuk mengetahui hasil pengukuran suhu aktual oleh mikrokontroler

ditampilkan pada 3 buah seven segment, nilai yang ditampilkan akan

dibandingkan dengan hasil pengukuran termometer ruangan. Gambar 3.11

menunjukan antarmuka antara mikrokontroler dengan rangkaian seven segment,

P2.0 sampai dengan P2.2 merupakan data yang akan ditampilkan pada setiap

seven segment melalui proses dekoder oleh IC74ls47.

Gambar 3.10 Rangkaian seven segment.

Pengiriman data setiap seven segment dilakukan secara bergantian sehingga

diperlukan selektor. P2.5 sampai dengan P2.7 merupakan port yang digunakan

sebagai data pengontrol selektor. Seven segment yang dipergunakan adalah tipe

common anode, sehingga untuk memilih seven segment yang aktif, keluaran

selektor dikontrol agar bernilai 1.

Pada rangkaian 7’segment, nilai R dapat ditentukan sebagai berikut (Vcc = 5V) :

I = 15mA (LED pada seven segment sudah memenuhi arus

minimal yang diperlukan agar LED menyala)

V = I.R

34
5V = 15mA.R

R = 333,33Ω dibulatkan menjadi 330Ω

3.2 Pembuatan Rules

Proses pembuatan rules dilakukan dengan menerapkan kemampuan

manusia dalam mengendalikan suatu sistem kendali. Secara umum respon fungsi

step suatu sistem kendali akan memberikan output seperti terdapat pada gambar

3.11

Gambar 3.11 Respon sistem tipikal dan pembagian daerahnya

Pada saat sistem diaktifkan (output=0 dan waktu=0), output akan naik

dengan cepat menuju seting point (SP), bahkan jauh melebihi SP. Output ini oleh

komputer akan diturunkan menuju SP, tetapi proses punurunan ini juga

mengalami kelebihan sehingga outputnya akan berisolasi disekitar SP, hingga

akhirnya outputnya mencapai SP. Apa yang dilakukan oleh kontroler untuk

menaikan dan menurunkan output harus sesuai dengan harga output saat itu dan

sebelumnya (tergantung dari error dan d_error), sehingga kontroler dapat

mengambil tindakan yang tepat untuk menyesuaikan outputnya.

Fungsi keanggotaan yang direncanankan untuk input error dan d_error

(kesalahan dan perubahan kesalahan) terdiri dari lima label yaitu NB (Negatif

35
Big), NS (Negatif Small), Z (Zero), PS ( Positive Small), PB (Positive Big).

Sedangkan fungsi output yang berupa garis (singleton) mempunyai label yang

sama dengan error dan d_error.

µ(x)

domain
(a)

µ(x)

domain
b)
Gambar 3.12 (a) Fungsi keanggotaan error dan d_error,
(b) Fungsi keanggotan output.

Dari gambar 3.12 terlihat jika error (SP-PV) adalah positif besar, dan

D_error adalah nol, maka output yang harus dikeluarkan adalah positif dan besar

(point a), atau bila dituliskan dalam bentuk rule base yaitu:

IF error e(t) is Positif Big (PB) AND d_error De(t) is Zerro (Z) THEN

Output u(t) is Positif Big (PB), untuk lebih jelasnya perhatikan tabel 3.2 dan 3.3.

3.3 Perancangan Perangkat Lunak

Perangakat lunak pada mikrokontroler mempunyai tugas mengendalikan

suhu udara inkubator ( pengaturan driver lampu dan driver kipas). Prosesnya

adalah pembacaan data ADC sebagai informasi suhu, perhitugan error dan

d_error serta melakukan prosedur fuzzy.

36
Tabel 3.2 rules base
Rule – rule Fuzzy Control Dasar
Rule No Error D_error Result Ref. Point
1. PB Z PB A
2. Z NB NB B
3. NB Z NB C
4. Z PB PB D
5. PS Z PS E
6. Z NS NS F
7. NS Z NS G
8. Z PS PS H
9. Z Z Z Set point

Tabel 3.3
Rule-rule Fuzzy Control Tambahan
Rule No Error D_error Result Ref. Point
10. PB NS PS A-B
11. PB NB Z A-B
12. PS NB NS A-B
13. NS NS NS B-C
14. NB PS NS C-D
15. NB PB Z C-D
16. NS PS Z C-D
17. NS PB PS C-D
18. PS PS PS D-E
19. PS NS Z E-F
20. NB NB NB B-C
21. NB NS NB B-C
22. PS PB NB D-E
23. PB PB PB D-E
24. PB PS PB D-E
25. NS NB PB F-G

Alur program utama perangkat lunak terlihat seperti pada gambar 3.13.

program akan menunggu intrupsi dari rangkaian keypad, jika salah satu keypad

ditekan maka program mengiterupsi untuk membaca key pad yang dipilih dan

menterjemahkan menjadi sebuah data. Setelah selesai mikrokontroler akan

menghitung error dan d_error. Proses selanjutnya adalah melakukan prosedur

fuzzy (FLC), dalam prosedur ini nilai error dan d_error akan melewati proses

37
fuzzification, inferensi dan defuzzifications. Hasil dari program FLC akan

digunakan sebagai pengontrol lampu dan kipas.

Inis
B

Hitung

T
Y
T
TD
Y

Gambar 3.13. Diagram alir program utama.

Untuk mendapatkan respon yang baik maka waktu proses sampling

diberikan waktu delay. Pemanfaatan delay digunakan untuk program penampilan

suhu aktual pada seven segment. Setelah waktu delay tercukupi, mikrokontroler

38
melakukan proses sampling secara berulang-ulang dimulai dari pembacaan data

ADC hingga tombol reset di tekan.

3.3.1 Program Penghitungan error dan d_error

Program ini akan menghitung perbedaan nilai Set Point (SP) dan nilai yang

terjadi sekarang (PV) yang disebut error dan menghitung besarnya perubahan

error yang disebut d_error. Hasil perhitungan ini merupakan input untuk

program FLC.

Harga Error dan D_error ditentukan dari persamaan:

e (t) = SP – PV

D_error = e(t) – e(t-1)

Keterangan :
SP = Nilai seting point
PV = Nilai output pada saat t
e (t) = Nilai error pada saat t
e (t-1) = Nilai error sebelumnya (t-1)

Nilai error akan bernilai posif pada saat SP lebih besar dari PV dan error

akan bernilai negatif pada saat SP lebih kecil dari PV (suhu udara inkubator lebih

panas dari suhu yang diinginkan). Nilai d_error akan sama halnya dengan nilai

error, bernilai positif jika errornya menurun dan nilai error akan negatif jika

error bertambah.

Dalam program subrutine perhitungan error (gambar 3.14), e(t-1) adalah

nilai error sebelumnya, sedangkan e(t) adalah error sekarang. Diawal program

nilai error (e(t)) sekarang disimpan sebagai nilai error sebelumnya (e(t-1)),

kemudian program akan menghitung besar error. Besarnya error )adalah selisih

antara Set Point dan Present Value (SP- PV), jika hasil pengurangan nilai e(t)

39
lebih dari nol maka tanda e(t) adalah positif jika sebaliknya maka tanda e(t) adalah

negatif (-) dan besarnya e(t) = PV – SP.

Gambar 3.14 Diagram alir program Penghitungan error dan d_error.

Pada perhitungan error tanda (+ atau -) sangat berpengaruh pada nilai

d_error. Pada tabel 3.4 menujukan besarnya d_error berdasarkan tanda yang

dimiliki e(t) dan e(t-1). Jika e(t) bertanda positif (+) dan e(t-1) bertanda negatif (-)

maka besarnya d_error adalah

40
D_error = e(t) – (- e(t-1)) atau

D_error = e(t) + e(t-1)

Tabel 3.4. Persamaan nilai d_error berdasarkan tanda e(t) dan e(t-1)
Tanda e(t) Tanda e(t-1) D_error =
Positif Positif e(t)-e(t-1)
Positif Negatif e(t)+e(t-1)
Negatif Positif -(e(t)+e(t-1)
Negatif Negatif e(t-1)-e(t)

Tanda d_error adalah positif jika hasil perhitungan d_error bernilai positif

(d_error > 0), jika hasil perhitungan d_error bernilai negatif (d_error < 0)

pengurangan akan ditukar. Nilai positif atau negatif berpengaruh pada proses

inferensi (basis kaidah), jika nilai tersebut negatif maka fungsi keanggotaan yang

berlaku adalah NB, NS dan Z. Sedangakan jika hasil tersebut posif maka fungsi

keanggotaan yang berlaku adalah PB, PS dan Z.

3.3.2 Program Fuzzy Logic Controll (FLC)

Masukan dari program FLC berupa error dan d_error, lalu diproses oleh

sistem fuzzy yang meliputi langkah fuzzifikasi, inferensi (basis data dan basis

kaidah ), dan defuzifikasi.

3.3.2.1 Program Fuzzifikasi

Program fuzzifikasi bertujuan untuk merubah nilai yang tegas menjadi nilai

kabur. Masukan untuk program ini adalah nilai error dan d_error, dimana nilai

tersebut akan menyulut fungsi keanggotaan input (crips input error dan crips

input d_error), tanda (+/-) tidak berpengaruh sehingga diabaikan.

Tabel 3.5. Batas minimal dan maksimal fungsi keanggotaan


Fungsi Keanggotaan Min Max
ZERRO 0 42
SMALL 0 170
BIG 85 255

41
Proses pengaburan error dilakukan dengan membandingkan nilai error

terhadap rentang nilai fungsi keanggotaan ZERRO, SMALL dan BIG (tabel 3.5).

pengaburan untuk nilai d_error sama dengan proses pengaburan error.

Gambar 3.15 menunjukan diagram alir program fuuzzification, setiap fungsi

keanggotaan yang tersulut akan disimpan sebagai bilangan kabur pada alamat

register, Jika nilai error atau d_error berada diantara 2 fungsi keanggotaan maka

memerlukan 2 register.

3.3.2.2 Program Inferensi

Program inferensi bertujuan untuk mencari nilai derajad keanggotaan dan

kaidah. Nilai derajad keanggotaan diproses pada program basis data, dengan

metode look up table. Sedangkan untuk mecari kaidah diproses pada program

basis kaidah menggunakan metoda if then.

Gambar 3.16 menunjukan diagram alir program basis data untuk error. Nilai

derajat keanggotaan setiap fungsi keanggotaan telah tersimpan pada memori

mikrokontroler berupa tebel-tabel. Pada memori mikrokotroler terdapat 3 tabel

yakni tabel zerro, tabel small dan tabel big. Data yang tersimpan pada setiap tabel

terdapat 255 data, data tersebut menggambarkan bentuk dari fungsi keanggotaan

(gambar 3.12 (a)). Nilai maksimal derajat keanggotaan dari fungsi keanggotan

adalah FFh dan nilai minimalnya adalah 00h.

Proses alur program basis data untuk d_error sama halnya dengan alur

program basis data error (gambar 3.16). Hanya saja, untuk proses d_error

pengecekan nilai kabur diganti dengan pengecekan kabur d_error.

42
Gambar 3.15. Diagram alir program penyulutan fungsi
keanggotaan masukan (Fuzzification)

Gambar 3.17 menujukan program basis kaidah. Basis kaidah dibagi menjadi

4 bagian yaitu basis kaidah untuk nilai kabur error dan nilai kabur d_error positif

( Z, PS dan PB), basis kaidah untuk nilai kabur error positif dan nilai kabur

d_error negatif (Z, NS dan NB), basis kaidah untuk nilai kabur error negatif dan

nilai kabur d_error positif, dan yang terakhir adalah basis kaidah untuk nilai

kabur error dan d_error negatif.

43
Gambar 3.16. Diagram alir program basis data.

Setiap menemukan kaidah akan dicari nilai derajat keanggotaan yang paling

kecil, antara nilai derajad keanggotaan error dan derajat keanggotaan d_error.

Nilai ini dihitung setelah menemukan kaidah dan disimpan pada register derajat

kaidah. Setiap nilai derajat kaidah akan dibandingkan dan diambil nilai derajad

keanggotaan yang terbesar. Kesimpulan dari proses inference kaidah adalah

kaidah yang mempunyai derajat keanggotaan yang terbesar.

44
Gambar 3.17 Diagram alir program basis kaidah.

3.3.2.3 Program Defuzzification (penegasan)

Keluaran program fuzzy merupakan bilangan kabur, untuk mengontrol kipas

dan lampu dibutuhkan nilai yang tegas (riil), peraturan pengubahan bilangan

kabur menjadi bilangan tegas ditunjukan pada tabel 3.6. Jika keluaran program

fuzzy adalah PB maka jumlah lampu yang menyala akan ditambah 2, dan kipas

off dan seterusnya.

Penambahan jumlah lampu yang menyala menggunakan metoda geser kiri

pada 4 bit rendah pada port 0. Jika semua 4 bit rendah telah benilai 1 maka proses

penggeseran dihentikan. Pengurangan jumlah lampu yang menyala menggunakan

45
metoda geser kanan pada 4 bit rendah. Proses penggeseran ini dimulai nilai yang

terjadi pada P0.0 sampai P0.3.

Tabel 3.6.Pengontrolan lampu dan kipas berdasarkan bilangan kabur


No Bilangan kabur Kontrol lampu Kontrrol kipas
1. PB Hidupkan 2 buah lampu Off
2. PS Hidupkan 1 buah lampu Off
3. Z Tetap Tetap
4. NS Matikan 1 buah lampu On
5. NB Matikan 2 buah lampu On

Gambar 3.18. Diagram alir program defuzzifikasi

46
3.3.3 Program penampilan suhu

Penampilan pada 7’segment bertugas menampilkan nilai suhu yang terukur,

gambar 3.19 merupakan diagram alir program penampilan suhu. Secara

keseluruhan metoda yang dipakai adalah metoda look up table, nilai yang

tersimpan pada tabel merupakan nilai–nilai hasil konversi dari data ADC (hasil

konversi analog ke digital) kedalam satuan suhu.

Penampilan suhu menggunakan 3 digit yang terdiri dari satuan, puluhan dan

sepersepuluh. Rentang suhu yang terukur adalah dari 20oC hingga 35oC dan nilai

heksanya adalah 00h-FFh, sehingga diperoleh nilai heksa untuk batasan antara 2

puluhan dan 3 puluhan.

Gambar 3.19. Diagram alir program panampilan suhu

47
Nilai satuan dan sepersepuluh diperoleh dari tabel dengan referensi nilai PV.

Proses pengiriman data ke seven segment dilakukan secara bergantian, jika

mengirim data puluhan maka 7’segment digit puluhan diberi logika 1 dan digit

lainya berlogika 0. Begitu juga pada proses penampilan data untuk satuan dan

sepersepuluhan.

Delay pada akhir program berfungsi sebagai penentu waktu sampling (time

sampling) waktu ini dimanfaatkan untuk menampilkan suhu aktual secara terus

menerus.

48
BAB IV

HASIL DAN PEMBAHASAN

Pada bab ini akan memberikan informasi dari data yang telah diambil,

beserta pembahasan yang akan memperlihatkan bahwa alat yang dirancang

bekerja dengan baik. Bentuk fisik alat dapat dilihat pada gambar 4.1. Dengan

mengetahui perbandingan antara perancangan dan realisasi alat, maka diharapkan

dapat mengetahui letak kesalahan maupun karakteristik komponen sesungguhnya.

Pada bab ini juga akan diperlihatkan tentang hasil unjuk kerja alat yang telah

dirancang.

Gambar 4.1 Bentuk fisik inkubator kucing

49
Panel kontrol ditunjukan Gambar 4.2, terdapat 5 tombol, 2 buah indikator

lampu dan 7’segment 3 digit. Tombol “C” digunakan untuk mengubah suhu yang

diinginkan, tombol “SP1, SP2, SP3 merupakan tombol yang digunakan untuk

memilih set point (suhu yang diinginkan). Lampu bagian kanan merupakan

indikator power, sedangkan lampu kiri merupakan indikator untuk menujukkan

suhu yang berada di dalam inkubator telah mencapai suhu yang diinginkan.

Penampil
suhu aktual
stabil power
Suhu aktual Tombol
C Sp3 Sp2 Sp1
set point

Gambar 4.2 panel kontrol

Jika suhu dalam inkubator lebih panas dari suhu yang diinginkan maka

suhu inkubator harus diturunkan. Proses pendinginan suhu udara adalah dengan

cara menambahkan udara ruangan. Pendingin udara ditunjukkan pada gambar 4.3.

Udara yang masuk ke dalam inkubator tidak hanya dihembuskan langsung ke

dalam inkubator, akan tetapi melalui proses pendinginan. Proses pendinginan

udara dibuat secara sederhana, yaitu dengan cara membuat lubang kecil-kecil

menyerupai pori.

50
Kipas

Lubang pori-pori

Gambar 4.3 Pendingin inkubator sederhana

Pada perancangan bab 3 telah dijelaskan mengenai pemanas suhu udara,

yaitu menggunakan 4 buah lampu. Gambar 4.4 menunjukkan konstruksi

pemanas. Lampu yang dipasang secara vertikal, di letakkan dalam sebuah kotak.

Suhu yang telah dipanaskan ditarik oleh sebuah kipas

Kipas

4 buah lampu

Gambar 4.4. Pemanas suhu udara

4.1 Cara Kerja Inkubator Bayi Kucing

Cara kerja dari alat ini dibuat sesuai dengan alur program yang dirancang di

bab 3. Yang perlu diamati pada saat pertama kali alat ini dihidupkan adalah lampu

indikator power suplay menyala, jika sudah menyala display akan menampilkan

angka nol. Setelah itu memilih set point dengan cara menekan tombol yang

tersedia. Nilai suhu yang terpilih akan ditampilkan. Setelah memilih set point,

selanjutnya mikrokontroler akan mengatur suhu inkubator sesuai dengan suhu

yang dipilih.

51
Bayi kucing dimasukkan setelah inkubator dalam keadaan stabil. Untuk

mengubah suhu yang diinginkan tombol “C” harus ditekan terlebih dahulu.

Setelah angka pada penampil berubah dilanjutkan dengan memeilih set point yang

sesuai dengan suhu yang diinginkan.

4.2 Pengamatan dan analisa suhu inkubator

Yang diamati dari inkubator bayi kucing adalah suhu udara inkubator dan

suhu udara ruangan sehingga set point dapat tercapai. Suhu ruangan harus lebih

dingin dari pada suhu udara inkubator, karena tidak terdapat komponen pendingin

udara.

Pengamatan untuk setiap set point adalah:

1. Suhu udara ruangan

2. Suhu udara inkubator awal

3. Waktu tunda (Td)

4. Waktu naik (Tr)

5. Waktu lonjakan maksimum (Tp)

6. Lonjakan maksimum (Mp) %

4.2.1 Hasil pengamatan pada set point 26 oC

Suhu awal yang terukur pada pengamatan set point ini adalah 23.7 oC. Suhu

ini lebih rendah dari suhu yang diinginkan, sehingga pengontrol mampu untuk

menciptakan suhu sesuai dengan yang diinginkan. Tabel 4.1 menunjukkan hasil

yang diperoleh dari pengamatan pada gambar 4.5. Waktu naik adalah waktu yang

ditempuh pada saat suhu inkubator mencapai 10% hingga 90% menuju set point.

Diketahui perbedaan antara suhu awal dan set point adalah 2,3oC, sehingga

52
T 10% = 23,7oC + (0,1 X 2,3oC)
= 23,93oC
Dan
T 90% = 23,7oC + (0,9 X 2,3oC)
= 25,77oC
Dari pengamatan pada gambar 4.5 suhu 23,93oC tercapai pada waktu 0,5

menit dan suhu 25,77 oC tercapai pada waktu 1,3 menit. Jadi waktu naik yang

dibutuhkan untuk mencapai set point adalah 0,8 menit. Setelah suhu mencapai

90%, gradien kenaikan suhu menjadi lebih landai, ini pengaruh dari sistem kontrol

yang dimaksudkan untuk mengurangi besar lonjakan.

Tabel 4.1 Pengamatan set point 26 oC


Respon Hasil
Suhu awal 23,7 oC
10% 23.9 oC
50% 24.85 oC
90% 25.77 oC
Tr 0.8 Menit
Td 0.9 Menit
Tp 2.7 Menit
Mp 1,15 %
Waktu tunda adalah waktu yang tercapai pada saat kenaikan suhu telah

mencapai 50%, suhu tersebut adalah

T 50% = 23,7oC + (0,5 X 2,3oC)


= 24,85oC
Jadi waktu tundanya adalah 0,9 menit, sedangkan lonjakan maksimal sebesar

26,3oC atau

53
SP=26oC suhu awal 23.7oC

26,2
26
25,7
suhu (oC)

23.7
Ts
23 waktu (menit)
0 6 12 18 24 30 36 42
(a)

tanggapan trasien set point 26oC

Mp
26
25.7

Td
24.8
suhu (oC)

23.9
23.7
Tr
Tp waktu (menit)
23
0 1 2 3 4 5

(b)

Gambar 4.5 Grafik respon transien set point 26oC


(a) Waktu pengamatan hingga kondisi stabil
(b) Pengamatan pada respon transien

Lonjakan maksimal tersebut terjadi pada saat menit ke 2,7. Pada

pengamatan ini, daerah osilasi setelah terjadinya lonjakan maksimal adalah 25,8oC

hingga 26,2oC atau sekitar 0,7%. Kondisi ini terjadi setelah menit ke 13.

54
4.2.2 Hasil pengamatan pada set point 28 oC

Metoda perhitungan untuk mendapatkan nilai yang dicari pada

pengamatan set point 28oC, sama dengan persamaan yang digunakan pada

pengamatan set point 26oC. Hasil dari penghitungan dan pengamatan pada gambar

4.6 ditampilkan pada tabel 4.2.

Tabel 4.2 pengamatan set point 28 oC


Respon Hasil
Suhu awal 24,7 oC
10% 25.03 oC
50% 26.35 oC
90% 27.67 oC
Td 2.2 Menit
Tr 2.6 Menit
Tp 4 Menit
Mp 2,86%

Pengamatan pada gambar 4.6 (b) daerah osilasi setelah terjadi lonjakan

maksimal adalah 27,7oC sampai 28,4oC atau 0,14% dan dimulai menit ke5. Nilai

ini lebih besar jika dibandingkan dengan set point 26oC. Kondisi ini disebabkan

keadaan banyaknya lampu yang menyala setelah mencapai 90%. Telihat jelas

pada gambar tersebut bahwa pada saat mencapai set point pertama kali, keadaan

suhu langsung menurun hingga 27,6oC. Karena nilai error negatif dan nilai d_error

negatif maka kemungkinan besar fuzzy logic controller akan menambahkan

jumlah lampu yang menyala, sehingga menyebabkan suhu yang dipanaskan akan

melebihi set point dan terjadi lonjakan suhu.

55
SP=28oC dengan suhu awal =24.7oC

28,4

28
27,7

26
suhu(oC)

Ts waktu(menit)
24
0 8 16 24 32 40 48

(a)

respon transien set point 28oC

Mp
28
27.6
suhu(oC)

Td
26.3

25.0
24.7
Tr
Tp waktu(menit)
24
0 1 2 3 4 5 6
(b)
Gambar 4.6 Grafik respon transien set point 28oC
(a) waktu pengamatan hingga kondisi stabil
(b) pengamatan pada respon transien

4.2.3 Hasil pengamatan pada set point 32 oC

Persamaan-persamaan yang dipakai untuk mendapatkan nilai yang dicari

pada pengamatan set point 32oC, sama dengan persamaan yang digunakan pada

56
pengamatan set point 26oC. Hasil dari penghitungan dan pengamatan pada gambar

4.7 ditampilkan pada tabel 4.3.

Perbedaan suhu set point dengan suhu awal cukup besar yaitu 7,5oC.

Perbedaan ini menyebabkan nilai error menjadi besar sehingga kenaikan suhu

awal tidak stabil. Suhu udara inkubator setelah mencapai set point yaitu menit ke

8,5 menit, tidak mengalami lonjakan yang besar. Lonjakan maksimum terjadi

pada menit ke 12,3 menit sebesar 32,5oC atau 1,56% dari set point

Osilasi yang terjadi setelah lonjakan maksimum menjadi lebih kecil yakni

antara 31,8oC hingga 32,2oC atau sebesar 0,62%, nilai ini menujukan daerah

kesetabilan untuk set point 32oC, dimulai dari menit ke 18,5.

Tabel 4.3 Suhu set point 32 oC


Respon Hasil
Suhu awal 24,5 Menit
10% 25.25 oC
50% 28.25 oC
90% 31.25 oC
Td 3.3 Menit
Tr 5.3 Menit
Tp 12.2 Menit
Mp 1,56%

57
SP=32oC dengan suhu awal 24,5oC
34

31,4
32
31,7

30

28
suhu oC

26
24.5
24
Ts
waktu(menit)
22
0 5 10 15 20 25 30 35 40 45

(a)

respon transien SP=32oC

32
31.25

Td
28.25
suhu (oC)

25.25
24.5
Tr
Tp
22 waktu(menit)
0 1 2 3 4 5 6 7 8 9 10 11 12 13
(b)
Gambar 4.7 Grafik pengamatan set point 32oC
(a) waktu pengamatan hingga kondisi stabil
(b) pengamatan pada respon transien

4.3 Hasil pengamatan tes terhadap gangguan

Langkah-langkah penggunaan inkubator ini telah diterangkan pada sub bab

langkah kerja di atas. Kucing tidak boleh dimasukkan sebelum suhu udara

inkubator stabil, pada saat memasukkan kucing pintu inkubator terbuka sehingga

58
udara yang berada di luar akan masuk begitu juga udara yang ada didalam

inkubator akan keluar. Sehingga udara dalam inkubator tidak lagi sesuai dengan

suhu yang diinginkan. Pada pengujian ini gangguan yang diberikan berupa udara

ruangan yang dibiarkan masuk melalui pintu inkubator yang terbuka lebar selama

20 detik (Tg), sehingga diharapkan suhu yang telah sesuai dengan set point

terganggu (suhu udara inkubator menjadi lebih dingin). Pengujian ini bertujuan

untuk mengetahui waktu yang dibutuhkan untuk kembali ke keadaan steady state

dan stabil kembali.

Pada pengujian inkubator kucing terhadap gangguan, yang diamati adalah:

1. Suhu luar

2. Suhu awal

3. Waktu gangguan

4. Waktu suhu udara kembali normal

4.3.1 Pengujian pada set point 26 oC

Data hasil percobaan ini ditampilkan gambar 4.8. Pemberian gangguan

pada menit ke 25,2 menit(gambar 4.8(b)), karena pada menit ke 5 dan seterusnya

suhu udara inkubator hanya berosilasi di daerah set point, jadi dianggap sudah

stabil. Pada gambar tersebut dapat diamati bahwa setelah gangguan dihentikan,

suhu udara pada inkubator langsung meningkat. Disebabkan karena saat terjadi

gangguan, lampu yang menyala terus ditambah agar mampu mengejar set point.

Untuk mendapatkan waktu kembali normal setelah diberikan gangguan,

maka diperlukan titik normal. Pada gambar 4.8 (a) terdapat garis putus-putus yang

bernilai 26,1oC, nilai ini didapat dari daerah osilasi terkecil sebelum diberikan

59
ganguan atau bisa dikatan osilasi pada keadaan stabil. Lamanya waktu untuk

kembali normal pada set point 26oC adalah

Tk = 34 - 25,65

= 8,35 menit

Tes menghadapi gangguan untuk Sp= 26 oC

26.1
26

gangguan
suhu(oC)

waktu(menit)
23
0 4 8 12 16 20 24 28 32 36 40 44

(a)

tanggapan transien SP=26oC

26.1
26
suhu(oC)

23.5
Tg Tk
23
waktu (menit)
24 25 26 27 28 29 30 31 32 33 34 35 36
(b)
Gambar 4.8 Grafik pengujian ganguan set point 26oC
(a) Grafik pengujian secara lengkap
(b) Grafik pengujian pada waktu terjadi gangguan

60
4.3.2 Pengujian pada set point 28oC

Data hasil pengujian untuk set point 28oC ditampilkan pada gambar 4.9.

Pemberian gangguan diberikan pada saat menit ke 29,3 hingga menit ke 29,6.

diamati bahwa meskipun gangguan dihentikan, suhu udara inkubator tetap

menurun hingga 26,7oC. Kondisi ini disebabkan karena suhu udara yang berada di

dalam pemanas tidak mampu untuk menciptakan suhu 28oC, sehingga butuh

waktu (Ta) untuk memanaskan udara inkubator yaitu selama 1,4 menit.

Lonjakan maksimum (Mp) setelah gangguan sebesar 28,4oC atau 1,4%.

Keadaan ini tidak terlalu berpengaruh pada keadaan kucing karena masih dalam

rentang toleransi. Waktu yang dibutuhkan untuk kembali pada keadaan normal

adalah

Tk = 33,5-29,7
= 3,8 menit

4.3.3 Pengujian pada set point 32oC

Data hasil pengujian untuk set point 32oC ditampilkan gambar 4.10.

Gangguan terjadi saat menit ke 98 hingga menit ke 99. Pada gambar tersebut

dapat diamati bahwa meskipun gangguan dihentikan, suhu udara inkubator tetap

menurun hingga 29,1oC dengan waktu turun 2 menit.

Lonjakan maksimum setelah melewati gangguan tersebut adalah sebesar

32,3oC atau 0,93%. Garis putus-putus pada suhu 32,3oC merupakan batas atas

daerah stabil, garis ini akan digunakan sebagai referensi dalam menghitung waktu

yang dibutuhkan untuk kembali normal. Dari referensi tersebut maka

Tk = 37-33
=4 menit

61
Tes menghadapi gangguan untuk SP = 28oC

28.1
28
27.6

gangguan
suhu (oC)

26.1

waktu (menit)
25
0 5 10 15 20 25 30 35 40

(a)

tanggapan transien Sp=28oC

28.1 Mp
28
suhu (oC)

26.7
Ta
26.1
Tk
Tg
waktu (menit)
25
28 29 30 31 32 33 34 35 36

(b)

Gambar 4.9
Grafik pengujian ganguan terhadap set point 28oC. (a) grafik
pengujian secara lengkap (b) grafik pengujian pada waktu terjadi
ganguan

Jika dilihat dari kebutuhan bayi kucing untuk mendapatkan suhu yang

diinginkan, 4 menit merupakan waktu yang lama. Akan tetapi jika dilihat dari

ketentuan tanggapan respon yang berlaku, waktu tercapainya keadaan stabil (2%-

5%) kurang dari 4 menit.

62
Tes menghadapi gangguan SP =32oC

32,3
32

gangguan
suhu (oC)

29,1
28,8

waktu (suhu)
28
0 6 12 18 24 30 36 42 48

(a)

Tanggapan transien SP =32oC


32,3
32
suhu (oC)

29,1
28,8
Tg Tk waktu (suhu)
28
32 34 36 38 40

(b)

Gambar 4.10
Grafik pengujian ganguan set point 32oC. (a) grafik pengujian secara
lengkap, (b) grafik pengujian pada waktu terjadi ganguan

4.4. Program utama

Program utama pengontrolan suhu ditunjukkan pada gambar 4.11. Program

dimulai dengan proses inisialisasi. Baris 1 sampai dengan baris 4 adalah perintah

untuk memasukkan rentang nilai dari setiap fungsi keanggotaan. Baris pertama

63
merupakan batas minimal rentang nilai dari fungsi keanggotaan PB dan NB, baris

ke-2 dan ke-3 untuk rentang nilai fungsi keanggotaan NS dan PS, baris ke-4 untuk

rentang nilai fungsi keanggotaan ZERRO. Output mikro diatur agar bernilai nol

pada saat program mulai dijalankan. Baris ke-5 merupakan perintah untuk

menampilkan angka nol untuk semua seven segment. Sedangkan baris ke 6

bertujuan untuk membuat lampu dan kipas dalam keadaan mati.

Waktu sampling dihitung dari mulai membaca sensor sampai kembali ke

program pembacaan sensor lagi. Waktu sampling yang dibutuhkan adalah 20

detik, penentuan waktu sampling diperoleh dari pengamatan respon suhu terhadap

pemanas. Pengaturan waktu sampling dilakukan pada program subroutine display,

Gambar 4.11 Program utama pengontrol suhu udara inkubator berbasis


mikrokontroler.

64
Pada program ini dilakukan looping terus menerus sebanyak nilai yang

terdapat dalam register 6, pengisian nilai R6 dilakukan sebelum program

subroutine display dijalankan.

4.4.1. Penghitungan error dan d_error

Diawal program penghitungan error, nilai error disimpan sebagai nilai error

sebelumnya (e(t-1)). Pada bab 3 telah dijelaskan mengenai operasi penghitungan

error. Pembuatan programnya ditampilkan pada gambar 4.12. TANDA_ERR

adalah sebuah alamat yang digunakan untuk menandai nilai error apakah negatif

atau positif, ERR_BEFORE adalah alamat untuk menyimpan nilai error

sebelumnya.

Gambar 4.12 Program pengitungan error

Pembuatan program d_error hampir sama dengan program penghitungan

nilai error. Perbedaannya hanya pada pengecekan tanda (+/-) error.

4.4.2. Program fuzzy logic

Program fuzzy logic adalah program inti dari kontrol suhu berbasis

mikrokontroler ini. Pembuatan program FLC akan dibagi dalam beberapa

65
subrutine diantaranya adalah fuzzifation, basis data, basis kaidah dan

defuzzification. Penjelasan setiap subrutin adalah sebagi berikut:

4.4.2.1. Fuzzification

Tugas dari program ini adalah merubah nilai error dan d_error menjadi

bilangan kabur. Metode yang digunakan adalah membandingkan nilai error atau

d_error dengan batas-batas dari setiap membership function. Program

fuzzification ditunjukkan pada gambar 4.13. Program diawali dengan

membandingkan nilai error dengan batas-batas nilai membership function big, lalu

small dan yang terakhir adalah dengan himpunan zerro.

Gambar 4.13 Program fuzzification

Setiap fungsi keanggotaan mempunyai alamat memori masing-masing dan

alamat untuk bilangan kabur error dipisahkan dengan alamat kabur d_error.

Alamat memori fungsi keanggotaan akan berisi data 0FFh jika nilai error dan

66
d_error termasuk ke dalam himpunan tersebut. Jika tidak maka alamat tersebut

akan berisi data 00h.

4.4.2.2. Basis data

Program ini bertugas untuk mencari tingkat derajad fungsi keanggotaan

yang terpilih. Gambar 4.14 menunjukkan sebagian list program untuk mencari

nilai derajad zerro. Pada awal program terdapat perintah untuk mengecek apakah

alamat zerro mempunyai data 0ffH. Jika tidak maka lompat ke program

selanjutnya yaitu mengecek fungsi keanggotaan yang lain. Proses pengambilan

data berdasarkan nilai dari error atau d_err, alamat awal untuk tabel derajad fungsi

keanggotaan zerro disalin ke DPTR dan nilai error disimpan di accumulator lalu

diperintahkan untuk mengambil data di alamat (A+DPTR) pada memori external .

Gambar 4.14 Subrutine program basis data

67
BAB V

PENUTUP

Kesimpulan

Berdasarkan perancangan dan pengamatan yang telah dilakukan, maka diperoleh

beberapa kesimpulan sebagai berikut :

1. Program fuzzy logic telah berhasil diterapkan pada IC atmel seri AT89S52 dengan

bahasa assembley.

2. Setiap set point tercapai dengan baik dan mampu dipertahankan secara stabil, set

point 26oC dengan suhu awal 23,7 oC stabil pada menit ke 13, mempunyai toleransi

0,7%, set point 28oC stabil pada menit ke 5, mempunyai toleransi 0,14% dan set

point 32oC stabil pada menit 18,5 dengan toleransi 0,62%.

3. Dengan tercapainya setiap set point maka inkubator bayi kucing ini dapat digunakan

untuk merawat bayi kucing dari umur 0-28 hari.

4. Incubator bayi kucing ini mampu menghadapi gangguan (membuka pintu inkubator),

pada set point 26oC membutuhkan 8,3 menit untuk kembali ke keadaan semula. set

point 28oC membutuhkan 3,8 menit dan set point 32oC membutuhkan waktu 4 menit.

Saran
Apabila penelitian ini ingin diteruskan maka penulis menyarankan agar:

1. Memperhatikan faktor keamanan, kenyamanan dan kesehatan bagi pengguna (kucing)

2. Menambahkan komponen yang mampu mendinginkan suhu udara, agar inkubator

dapat digunakan pada saat suhu ruangan lebih panas dari set point.

68
DAFTAR PUSTAKA

[1] Wardhana, Lingga. 2006. Belajar Sendiri Mikrokontroler AVR Seri ATMega8535.
Penerbit Andi: Yogyakarta.
[2] Pratomo, Andi. 2005. Panduan Praktis Pemrograman AVR Microkontroler
AT90S2313. Penerbit Andi: Yogyakarta.
[3] Grob, Bernard. 1984. Basic Television and Video Systems, fifth edition. McGraw-
Hill Inc.
[4] Kadir, Abdul. 2003. Pemrograman C++. Penerbit Andi: Yogyakarta.
[5] Hartono, Jogiyanto. 2003. Konsep Dasar Pemrograman Bahasa C. Penerbit Andi:
Yogyakarta.
[5] http://instruct1.cit.cornell.edu/cources/ee476/video/index.html, tanggal akses 19
Januari 2007.
[6] http://instruct1.cit.cornell.edu/cources/ee476/video/oldindex.html, tanggal akses 19
Januari 2007.
[7] http://www.stanford.edu/class/ee281/handouts/lab4.pdf, tanggal akses 22 Febuari
2007
[8] http://www.Atmel.com, tanggal akses 29 Januari 2007
[9] http://www.hpinfotech.ro, tanggal akses 9 Febuari 2007
[10] http://www.lancos.com, tanggal akses 27 September 2006

74
Set point = 26oC Set point = 28oC
waktu suhu waktu suhu waktu suhu waktu suhu waktu suhu waktu suhu waktu suhu waktu suhu
0.3 23.70 12.3 25.80 24.3 25.90 36.3 25.90 0.3 24.70 12.3 27.70 24.3 28.30 36.3 27.90
0.7 24.20 12.7 26.00 24.7 26.00 36.7 26.00 0.7 25.10 12.7 27.70 24.7 27.70 36.7 27.80
1.0 25.10 13.0 26.30 25.0 26.00 37.0 26.00 1.0 25.40 13.0 28.40 25.0 27.70 37.0 27.80
1.3 25.80 13.3 26.10 25.3 25.80 37.3 26.10 1.3 25.60 13.3 28.00 25.3 27.80 37.3 28.00
1.7 25.90 13.7 26.10 25.7 26.00 37.7 26.00 1.7 26.10 13.7 27.70 25.7 28.00 37.7 28.00
2.0 26.10 14.0 25.90 26.0 25.80 38.0 26.00 2.0 26.20 14.0 27.80 26.0 28.10 38.0 27.80
2.3 26.20 14.3 26.00 26.3 25.70 38.3 26.00 2.3 26.50 14.3 28.00 26.3 28.20 38.3 27.80
2.7 26.30 14.7 26.10 26.7 25.80 38.7 26.10 2.7 26.90 14.7 28.10 26.7 27.80 38.7 27.90
3.0 26.20 15.0 26.00 27.0 26.00 39.0 26.00 3.0 27.30 15.0 28.30 27.0 28.20 39.0 28.00
3.3 26.20 15.3 26.00 27.3 25.80 39.3 26.00 3.3 28.00 15.3 28.10 27.3 28.20 39.3 27.90
3.7 26.20 15.7 26.10 27.7 25.70 39.7 26.00 3.7 27.70 15.7 27.70 27.7 28.00 39.7 28.00
4.0 26.00 16.0 26.00 28.0 25.70 40.0 26.00 4.0 28.80 16.0 27.80 28.0 28.20 40.0 27.80
4.3 26.00 16.3 25.90 28.3 25.80 40.3 25.90 4.3 28.00 16.3 27.80 28.3 28.20 40.3 28.10
4.7 25.80 16.7 26.00 28.7 25.70 40.7 26.00 4.7 28.40 16.7 28.20 28.7 28.00 40.7 27.80
5.0 25.70 17.0 26.00 29.0 25.80 41.0 25.90 5.0 28.20 17.0 28.20 29.0 27.90 41.0 27.90
5.3 25.60 17.3 25.80 29.3 25.70 41.3 26.00 5.3 27.90 17.3 27.70 29.3 27.80 41.3 28.00
5.7 25.70 17.7 26.00 29.7 25.70 41.7 26.10 5.7 28.00 17.7 27.90 29.7 27.80 41.7 28.10
6.0 25.70 18.0 25.80 30.0 25.90 42.0 26.00 6.0 27.80 18.0 28.00 30.0 27.90 42.0 28.10
6.3 26.00 18.3 25.70 30.3 26.00 42.3 26.10 6.3 28.00 18.3 28.20 30.3 28.00 42.3 28.00
6.7 26.00 18.7 25.80 30.7 25.80 42.7 26.00 6.7 27.80 18.7 28.20 30.7 27.90 42.7 28.00
7.0 25.80 19.0 26.00 31.0 25.90 43.0 26.10 7.0 27.70 19.0 28.00 31.0 28.00 43.0 27.90
7.3 25.70 19.3 25.80 31.3 26.00 43.3 26.10 7.3 27.70 19.3 27.70 31.3 28.10 43.3 27.90
7.7 25.70 19.7 25.70 31.7 26.10 43.7 26.00 7.7 27.70 19.7 27.70 31.7 28.20 43.7 28.00
8.0 26.00 20.0 25.70 32.0 26.10 44.0 26.10 8.0 28.10 20.0 28.00 32.0 27.80 44.0 27.90
8.3 26.20 20.3 25.80 32.3 26.10 44.3 26.10 8.3 28.20 20.3 27.90 32.3 28.00 44.3 27.80
8.7 26.30 20.7 25.70 32.7 26.00 44.7 26.00 8.7 28.00 20.7 27.90 32.7 28.10 44.7 27.80
9.0 26.10 21.0 25.70 33.0 25.90 45.0 26.00 9.0 27.70 21.0 27.90 33.0 27.80 45.0 28.00
9.3 25.90 21.3 25.90 33.3 26.00 45.3 25.90 9.3 28.10 21.3 27.90 33.3 27.90 45.3 28.10
9.7 25.80 21.7 26.00 33.7 26.00 45.7 25.90 9.7 28.20 21.7 27.70 33.7 28.00 45.7 28.20
10.0 26.20 22.0 25.80 34.0 25.80 46.0 26.00 10.0 28.00 22.0 27.70 34.0 28.00 46.0 28.20
10.3 26.30 22.3 25.90 34.3 26.00 46.3 26.00 10.3 27.70 22.3 28.40 34.3 28.10 46.3 28.10
10.7 26.10 22.7 26.00 34.7 26.10 46.7 25.80 10.7 28.00 22.7 28.00 34.7 27.90 46.7 28.00
11.0 25.90 23.0 26.10 35.0 26.00 47.0 26.10 11.0 27.90 23.0 27.70 35.0 28.00 47.0 28.00
11.3 25.90 23.3 26.20 35.3 26.00 47.3 26.10 11.3 27.90 23.3 27.80 35.3 27.80 47.3 28.20
11.7 26.00 23.7 26.10 35.7 25.80 47.7 26.00 11.7 27.90 23.7 28.00 35.7 28.10 47.7 28.20
12.0 25.60 24.0 26.00 36.0 25.90 143 12.0 27.90 24.0 28.10 36.0 28.00 143
tes menghadapi gangguan sp=26oC tes menghadapi gangguan sp=28oC
waktu suhu waktu suhu waktu suhu waktu suhu waktu suhu waktu suhu waktu suhu waktu suhu
0.3 23.5 12.3 26 24.3 26 36.3 26 0.3 26.1 12.3 27.7 24.3 27.9 36.3 28
0.7 23.8 12.7 26 24.7 25.9 36.7 25.9 0.7 26.2 12.7 27.4 24.7 28 36.7 27.8
1.0 23.8 13.0 25.9 25.0 26 37.0 26 1.0 26.3 13.0 28 25.0 27.7 37.0 28.2
1.3 24.2 13.3 25.9 25.3 25.9 37.3 25.9 1.3 26.6 13.3 27.7 25.3 27.7 37.3 27.7
1.7 24.3 13.7 26 25.7 25.2 37.7 26 1.7 27 13.7 28 25.7 28 37.7 27.9
2.0 24.2 14.0 26 26.0 25.3 38.0 26.1 2.0 27.3 14.0 28 26.0 28.1 38.0 28
2.3 24.4 14.3 25.8 26.3 25.4 38.3 26 2.3 27.6 14.3 27.7 26.3 27.7 38.3 28.2
2.7 24.8 14.7 26.1 26.7 25.4 38.7 26.1 2.7 27.8 14.7 28 26.7 27.6 38.7 28.2
3.0 25.4 15.0 26.1 27.0 25.7 39.0 26 3.0 27.8 15.0 28.5 27.0 27.7 39.0 28
3.3 25.6 15.3 26 27.3 26.1 39.3 26.1 3.3 27.5 15.3 28.3 27.3 27.9 39.3 27.7
3.7 25.9 15.7 26 27.7 26.2 39.7 26.1 3.7 27.4 15.7 28.1 27.7 27.7 39.7 27.8
4.0 26.2 16.0 26 28.0 26.4 40.0 26 4.0 28 16.0 27.9 28.0 28 40.0 27.8
4.3 26.5 16.3 25.9 28.3 26.3 40.3 25.9 4.3 27.7 16.3 28.2 28.3 28 40.3 27.9
4.7 26.4 16.7 26 28.7 26.4 40.7 26 4.7 27.7 16.7 27.7 28.7 27.7 40.7 28
5.0 26 17.0 25.9 29.0 26.5 41.0 25.9 5.0 27.7 17.0 27.7 29.0 28 41.0 27.9
5.3 26 17.3 26 29.3 26.3 41.3 25.9 5.3 27.8 17.3 27.5 29.3 27.7 41.3 28
5.7 25.9 17.7 26.1 29.7 26.3 41.7 26 5.7 27.7 17.7 28 29.7 27.3 41.7 27.8
6.0 25.8 18.0 26 30.0 26.1 42.0 25.9 6.0 27.8 18.0 27.8 30.0 27 42.0 28.2
6.3 25.7 18.3 26.1 30.3 26.2 42.3 26 6.3 28 18.3 27.7 30.3 27 42.3 28.2
6.7 25.7 18.7 26 30.7 26.1 42.7 26.1 6.7 27.9 18.7 27.6 30.7 26.9 42.7 27.7
7.0 26 19.0 26.1 31.0 26.1 43.0 26 7.0 28.2 19.0 27.7 31.0 26.7 43.0 27.9
7.3 26 19.3 26.1 31.3 26.1 7.3 28.2 19.3 27.8 31.3 26.8
7.7 26 19.7 26 31.7 26.1 7.7 27.8 19.7 27.6 31.7 28.4
8.0 25.9 20.0 26 32.0 26.2 8.0 28.4 20.0 28 32.0 28.4
8.3 26 20.3 25.9 32.3 26 8.3 28.3 20.3 27.8 32.3 28.4
8.7 25.9 20.7 25.9 32.7 26.1 8.7 27.8 20.7 27.5 32.7 28.3
9.0 26 21.0 26 33.0 26.1 9.0 28.2 21.0 27.9 33.0 28.1
9.3 26.1 21.3 26.1 33.3 26.2 9.3 28 21.3 28 33.3 28.1
9.7 26 21.7 25.9 33.7 26.2 9.7 27.7 21.7 28.1 33.7 28
10.0 26.1 22.0 26 34.0 26.1 10.0 27.4 22.0 28 34.0 28
10.3 26 22.3 26 34.3 26.1 10.3 27.5 22.3 27.8 34.3 28
10.7 26.1 22.7 25.8 34.7 26 10.7 28 22.7 27.7 34.7 27.8
11.0 26.1 23.0 26.1 35.0 26.1 11.0 27.9 23.0 27.9 35.0 27.8
11.3 26 23.3 26.1 35.3 26 11.3 27.6 23.3 27.8 35.3 27.9
11.7 26.1 23.7 26 35.7 26 11.7 28 23.7 27.7 35.7 27.8
12.0 26.1 24.0 26 36.0 26 12.0 27.9 24.0 27.8 36.0 27.8
Set point = 32oC
waktu suhu waktu suhu waktu suhu waktu suhu
0.3 23.70 12.3 25.80 24.3 25.90 36.3 25.90
0.7 24.20 12.7 26.00 24.7 26.00 36.7 26.00
1.0 25.10 13.0 26.30 25.0 26.00 37.0 26.00
1.3 25.80 13.3 26.10 25.3 25.80 37.3 26.10
1.7 25.90 13.7 26.10 25.7 26.00 37.7 26.00
2.0 26.10 14.0 25.90 26.0 25.80 38.0 26.00
2.3 26.20 14.3 26.00 26.3 25.70 38.3 26.00
2.7 26.30 14.7 26.10 26.7 25.80 38.7 26.10
3.0 26.20 15.0 26.00 27.0 26.00 39.0 26.00
3.3 26.20 15.3 26.00 27.3 25.80 39.3 26.00
3.7 26.20 15.7 26.10 27.7 25.70 39.7 26.00
4.0 26.00 16.0 26.00 28.0 25.70 40.0 26.00
4.3 26.00 16.3 25.90 28.3 25.80 40.3 25.90
4.7 25.80 16.7 26.00 28.7 25.70 40.7 26.00
5.0 25.70 17.0 26.00 29.0 25.80 41.0 25.90
5.3 25.60 17.3 25.80 29.3 25.70 41.3 26.00
5.7 25.70 17.7 26.00 29.7 25.70 41.7 26.10
6.0 25.70 18.0 25.80 30.0 25.90 42.0 26.00
6.3 26.00 18.3 25.70 30.3 26.00 42.3 26.10
6.7 26.00 18.7 25.80 30.7 25.80 42.7 26.00
7.0 25.80 19.0 26.00 31.0 25.90 43.0 26.10
7.3 25.70 19.3 25.80 31.3 26.00 43.3 26.10
7.7 25.70 19.7 25.70 31.7 26.10 43.7 26.00
8.0 26.00 20.0 25.70 32.0 26.10 44.0 26.10
8.3 26.20 20.3 25.80 32.3 26.10 44.3 26.10
8.7 26.30 20.7 25.70 32.7 26.00 44.7 26.00
9.0 26.10 21.0 25.70 33.0 25.90 45.0 26.00
9.3 25.90 21.3 25.90 33.3 26.00 45.3 25.90
9.7 25.80 21.7 26.00 33.7 26.00 45.7 25.90
10.0 26.20 22.0 25.80 34.0 25.80 46.0 26.00
10.3 26.30 22.3 25.90 34.3 26.00 46.3 26.00
10.7 26.10 22.7 26.00 34.7 26.10 46.7 25.80
11.0 25.90 23.0 26.10 35.0 26.00 47.0 26.10
11.3 25.90 23.3 26.20 35.3 26.00 47.3 26.10
11.7 26.00 23.7 26.10 35.7 25.80 47.7 26.00
12.0 25.60 24.0 26.00 36.0 25.90 143
tes menghadapi gangguan sp=32oC
waktu suhu waktu suhu waktu suhu waktu suhu
0.3 28.8 12.3 31.7 24.3 31.8 36.3 32.1
0.7 29.1 12.7 32.1 24.7 31.3 36.7 32.5
1.0 29.7 13.0 32 25.0 31.9 37.0 32.4
1.3 30.1 13.3 31.7 25.3 32 37.3 32
1.7 30.3 13.7 32.2 25.7 31.7 37.7 32.3
2.0 30.8 14.0 31.7 26.0 31.5 38.0 32.1
2.3 31 14.3 32.1 26.3 32 38.3 31.9
2.7 31.4 14.7 32.1 26.7 31.7 38.7 31.7
3.0 31.6 15.0 32.1 27.0 31.4 39.0 31.8
3.3 31.8 15.3 32.7 27.3 31.9 39.3 31.7
3.7 31.8 15.7 32 27.7 31.8 39.7 32.2
4.0 32.1 16.0 31.8 28.0 31.4 40.0 32.1
4.3 31.8 16.3 32.1 28.3 31.7 40.3 32.1
4.7 31.6 16.7 32 28.7 31.7 40.7 31.7
5.0 32.2 17.0 31.7 29.0 32 41.0 32
5.3 31.9 17.3 32.1 29.3 31.8 41.3 31.7
5.7 31.8 17.7 31.8 29.7 31.9 41.7 32.1
6.0 32.2 18.0 31.5 30.0 31.7 42.0 31.8
6.3 32.4 18.3 32 30.3 31.5 42.3 32.2
6.7 32 18.7 32.5 30.7 32 42.7 32.1
7.0 32.1 19.0 32.1 31.0 31.8 43.0 32.2
7.3 31.8 19.3 31.8 31.3 31.9
7.7 32.1 19.7 31.6 31.7 31.7
8.0 31.8 20.0 32 32.0 31.5
8.3 31.8 20.3 31.5 32.3 32
8.7 31.5 20.7 31.7 32.7 31.7
9.0 31.4 21.0 32.1 33.0 30.8
9.3 31.6 21.3 31.7 33.3 30.8
9.7 31.5 21.7 32.2 33.7 30.2
10.0 31.7 22.0 31.8 34.0 30.1
10.3 32.2 22.3 32.4 34.3 29.8
10.7 31.9 22.7 32 34.7 29.4
11.0 32.2 23.0 32.2 35.0 29.1
11.3 32 23.3 32 35.3 31.1
11.7 32.2 23.7 31.7 35.7 31
12.0 32.2 24.0 31.4 36.0 31.7
1 0000 ;**********************************************************
2 0000 ;**------------------------------------------------------**
3 0000 ;** PROGRAM PENGONTRRROL SUHU PADA INKUBATOR **
4 0000 ;** BERBASIS MIKROKONTRORLER AT89S51 **
5 0000 ;** DENGAN METODA FUZZY LOGIC **
6 0000 ;**------------------------------------------------------**
7 0000 ;**********************************************************
8 0000 ; by:ignasius heru wahyudi

10 0000 ;INISIALISASI
11 0000 org 00h
12 0000 ;INPUT MIKRO
13 0000 PV EQU 30H;
14 0000 SET_POINT EQU 31H;
15 0000 POWER EQU 90H;
16 0000 ;------------------------ ;
17 0000 intr equ P0.7 ;INTR signal P0.6
18 0000 wr equ P2.7 ;Write signal P1.7
19 0000 rd equ P1.7 ;Read signal P0.5
20 0000 adc_port equ P3 ;ADC data pins P3
21 0000 lampu equ p2.6
22 0000 ;INPUT FUZZY
24 0000 TANDA_ERR EQU 40H
25 0000 ERR EQU 41H
26 0000 TANDA_ERR_BEFORE EQU 32H
27 0000 ERR_BEFORE EQU 33H
28 0000 TANDA_DERR EQU 42H
29 0000 D_ERR EQU 43H
30 0000 ;------------------------
31 0000 ;FUZZIFICATION
32 0000 KABUR_ERR_Z EQU 50H
33 0000 KABUR_ERR_S EQU 51H
34 0000 KABUR_ERR_B EQU 52H
35 0000 KABUR_DERR_Z EQU 53H
36 0000 KABUR_DERR_S EQU 54H
37 0000 KABUR_DERR_B EQU 55H
38 0000 ;------------------------
39 0000 ;BASIS DATA
40 0000 DERAJAT_ERR_Z EQU 60H
41 0000 DERAJAT_ERR_S EQU 61H
42 0000 DERAJAT_ERR_B EQU 62H
43 0000 DERAJAT_DERR_Z EQU 63H
44 0000 DERAJAT_DERR_S EQU 64H
45 0000 DERAJAT_DERR_B EQU 65H
46 0000 ;------------------------
47 0000 ;BASIS KAIDAH
48 0000 KAIDAH EQU 56H
49 0000 ;------------------------
50 0000 DERAJAT_KAIDAH EQU 66H
51 0000 ;OUT FUZZY
52 0000 OUT_DEFUZZI EQU 5AH
53 0000 ;------------------------
54 0000 ;OUTPUT MIKRO
55 0000 PULUHAN EQU 7CH
56 0000 SATUAN EQU 7DH
57 0000 SEPULUH EQU 7EH
58 0000 REG_TAMP EQU 7FH
59 0000 ;------------------------
60 0000 ;SUBB FUZZIFICATION
61 0000 IN_FUZZIFICATION EQU 4CH
62 0000 KABUR_BIG EQU 4DH ; FUZZIFICATION UNTUK BIG
63 0000 KABUR_SMALL EQU 4EH ; FUZZIFICATION UNTUK SMALL
64 0000 KABUR_ZERRO EQU 4FH ; FUZZIFICATION UNTUK ZERRO
65 0000 ;------------------------
66 0000 ;SUBB BASIS DATA
67 0000 IN_BASIS_DATA EQU 5CH
68 0000 DERAJAT_BIG EQU 5DH
69 0000 DERAJAT_SMALL EQU 5EH
70 0000 DERAJAT_ZERRO EQU 5FH
71 0000 ;------------------------
72 0000 MIN_BIG EQU 3CH
73 0000 MIN_SMALL EQU 3DH
74 0000 MAX_SMALL EQU 3EH
75 0000 MAX_ZERRO EQU 3FH
76 0000
77 0000
78 0000 ;***********PROGRAM UTAMA*****
79 0000
80 0000 ORG 00H
81 0000 MOV MIN_BIG,#55H
82 0003 MOV MIN_SMALL,#00H
83 0006 MOV MAX_SMALL,#0AAH
84 0009 MOV MAX_ZERRO,#02AH
85 000C mov p1,#70h ;agar nilai out bernilai nol
86 000F mov p2,#00h ;P2 DAN P1 => OUTPUT
88 0012 acall baca_tombol ;1 membaca nilai set point
89 0014 acall delay_bentar
91 0016 START:
93 0016 ACALL BACA_SENSOR ;2 pembacaan ADC (nilai PV)
94 0018 ACALL HITUNG_ERROR ;3 dan d_error
95 001A ACALL HITUNG_D_ERROR
96 001C ACALL FLC ;4 program fuzzy logic controller
97 001E ACALL PENGATURAN_LAMPU&KIPAS ;5 memanaskan/mendinginkan
98 0020 MOV R6,#0AH ; time sampling 20 dtk
99 0022 ACALL DISPLAY ;6 program untuk menampilakan
101 0024 SJMP START
102 0026 ;*************END OF PROGRAM UTAMA*************************
105 0026
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
106 0026 ;1 ----------------*****BACA SETPOINT*****--------------------
107 0026 baca_tombol:
109 0026 jnb p0.0,u1
110 0029 MOV SET_POINT,#217 ; 32.516 derajat celcius
111 002C mov p1,#41h
112 002F sjmp oi
113 0031 u1:
114 0031 jnb p0.1,u2
115 0034 mov SET_POINT,#116 ; 28.531 derajat celcius
116 0037 mov p1,#42h
117 003A sjmp oi
118 003C u2:
119 003C jnb p0.2,baca_tombol
120 003F mov SET_POINT,#64 ; 26.500 derajat celcius
121 0042 mov p1,#43h
122 0045 oi:
124 0045 RET ; kembali keselanjutnya
126 0046 ;2 -----------*****BACA SENSOR*****---------------------------
128 0046 BACA_SENSOR: ;Start of Program
129 0046 acall conv ;Start ADC conversion
130 0048 acall read ;Read converted value
131 004A RET ;Do it again
132 004B conv: ;Start of Conversion
133 004B setb wr
134 004D acall lay
135 004F clr wr
136 0051 jnb intr,$ ;Wait for INTR signal p1.7=1 ?
137 0054 ret ;Conversion done
138 0055 read: ;Read ADC value
139 0055 setb rd ;Make RD Low
140 0057 acall lay
141 0059 mov a,adc_port ;Read the converted value
142 005B mov PV,a ;Store it in local variable
143 005D clr rd ;Make RD High
145 005F ret ;Reading done
148 0060 ;3 ----------------*****MENGHITUNG ERROR*****----------------
149 0060 HITUNG_ERROR:
150 0060 MOV TANDA_ERR_BEFORE,TANDA_ERR
151 0063 MOV ERR_BEFORE,ERR ; SIMPAN ERR SEKARANG DAN TANDA
152 0066 MOV A,SET_POINT
153 0068 ACALL RESET
154 006A SUBB A,PV ; KURANGI (SP-PV)
155 006C MOV TANDA_ERR,#00H ; TANDA_ERR DIISI DENGAN 00H
156 006F JNC TANDA_ERROR ; CEK HASIL(+/-)
157 0071 MOV TANDA_ERR,#0FFH ; TANDA_ERR DIISI DENGAN FFH
158 0074 MOV A,PV ; KURANGI (PV-SP)
159 0076 ACALL RESET
160 0078 SUBB A,SET_POINT
161 007A ;--------------------------------------------------
162 007A TANDA_ERROR:
163 007A MOV ERR,A ; SIMPAN HASIL ERROR => [e(t1)]
164 007C RET
166 007D ;---------*****MENGHITUNG D_ERROR*****------------------
167 007D HITUNG_D_ERROR:
169 007D MOV A,TANDA_ERROR
170 007F CJNE A,#00H,e_negaitf ; JIKA D_ERR (-) LOMPAT
171 0082 MOV A,TANDA_ERR_BEFORE
172 0084 CJNE A,#00H,d_negatif ; JIKA ERR BEFORE (-)
173 0087 ACALL RESET
174 0089 MOV A,ERR ;[e(t)-e(t-1)]
175 008B SUBB A,ERR_BEFORE
176 008D MOV TANDA_DERR,#00H ; TANDA_DERR DIISI DENGAN 00H
177 0090 JNC TANDA_DERROR
178 0092 MOV TANDA_DERR,#0FFH ; TANDA_DERR DISI DENGAN FFH
179 0095 ACALL RESET
180 0097 MOV A,ERR_BEFORE
181 0099 SUBB A,ERR ;[e(t-1)-e(t)]
182 009B SJMP TANDA_DERROR
184 009D d_negatif:
185 009D ACALL RESET
186 009F MOV A,ERR ;[e(t)+e(t-1)]
187 00A1 ADD A,ERR_BEFORE
188 00A3 MOV TANDA_DERR,#00H ; TANDA_DERR DIISI DENGAN 00H
189 00A6 SJMP TANDA_DERROR
190 00A8 e_negaitf:
191 00A8 MOV A,TANDA_ERR_BEFORE
192 00AA CJNE A,#00H,d_enegatif ; JIKA ERR BEFORE (-) LOMPAT
193 00AD ACALL RESET
194 00AF MOV A,ERR_BEFORE ;[e(t)+e(t-1)]
195 00B1 ADD A,ERR
196 00B3 MOV TANDA_DERR,#0FFH ; TANDA_DERR DIISI DENGAN 00H
197 00B6 SJMP TANDA_DERROR
199 00B8 d_enegatif:
200 00B8 ACALL RESET
201 00BA MOV A,ERR_BEFORE ;[e(t-1)-e(t)]
202 00BC SUBB A,ERR
203 00BE MOV TANDA_DERR,#00H ; TANDA_DERR DIISI DENGAN 00H
204 00C1 JNC TANDA_DERROR
205 00C3 MOV TANDA_DERR,#0FFH ; TANDA_DERR DISI DENGAN FFH
206 00C6 ACALL RESET
207 00C8 MOV A,ERR
208 00CA SUBB A,ERR_BEFORE ;[e(t)-e(t-1)]
209 00CC SJMP TANDA_DERROR
212 00CE TANDA_DERROR:
213 00CE mov b,#2 ; nilai d_error dikali 2
214 00D1 mul ab
215 00D2 mov D_ERR,A ; SIMAN DERR SEKARANG
216 00D4 RET
219 00D5 ;###########SUBB RUTINE FLC################
222 00D5 ;4 -------*****FUZZIFICATION*****-------------------
224 00D5 FLC:
226 00D5 MOV IN_FUZZIFICATION,ERR ; _____________
227 00D8 ACALL FUZZIFICATION ;4.1 | program |
228 00DA MOV KABUR_ERR_Z,KABUR_ZERRO ; in|fuzzification|out
229 00DD MOV KABUR_ERR_S,KABUR_SMALL ; |_____________|
230 00E0 MOV KABUR_ERR_B,KABUR_BIG ; program pengkaburan error
231 00E3 ;---------------------------------------
233 00E3 MOV IN_FUZZIFICATION,D_ERR ;program penkaburan d_err
234 00E6 ACALL FUZZIFICATION ;4.1
235 00E8 MOV KABUR_DERR_Z,KABUR_ZERRO
236 00EB MOV KABUR_DERR_S,KABUR_SMALL
237 00EE MOV KABUR_DERR_B,KABUR_BIG
238 00F1 ;----------------------------------------
240 00F1 ;---------*****BASIS DATA*****----------------------
241 00F1 ;BASIS DATA ERROR
242 00F1 MOV IN_BASIS_DATA,ERR ; memasukan nilai error
243 00F4 MOV R4,KABUR_ERR_Z ; tanda (00h/0ffh) zerro
244 00F6 MOV R5,KABUR_ERR_S ; tanda (00h/0ffh) small
245 00F8 MOV R6,KABUR_ERR_B ; tanda (00h/0ffh) big
246 00FA ACALL BASIS_DATA ;4.2
247 00FC MOV DERAJAT_ERR_Z,DERAJAT_ZERRO ;
248 00FF MOV DERAJAT_ERR_S,DERAJAT_SMALL
249 0102 MOV DERAJAT_ERR_B,DERAJAT_BIG
250 0105 ;----------------------------------------
251 0105 ;BASIS DATA D_ERROR
252 0105 MOV IN_BASIS_DATA,D_ERR ; memasukan nilai d_err
253 0108 MOV R4,KABUR_DERR_Z
254 010A MOV R5,KABUR_DERR_S
255 010C MOV R6,KABUR_DERR_B
256 010E ACALL BASIS_DATA ;4.2
257 0110 MOV IN_BASIS_DATA,D_ERR
258 0113 MOV DERAJAT_DERR_Z,DERAJAT_ZERRO
259 0116 MOV DERAJAT_DERR_S,DERAJAT_SMALL
260 0119 MOV DERAJAT_DERR_B,DERAJAT_BIG
261 011C ;----------------------------------------
263 011C SJMP BASIS_KAIDAH ; 4.3
264 011E RET
266 011F ;4.1 ------------*********FUZZIFICATION***********-----------
268 011F FUZZIFICATION:
269 011F MOV A,MIN_BIG ; MASUKAN NILAI MINIMAL DARI FUNGSI BIG
270 0121 ACALL RESET
271 0123 SUBB A,IN_FUZZIFICATION ; CARI YANG LEBIH MINIMAL
272 0125 MOV KABUR_BIG,#00H ; SET TERLEBIH DAHULU OUT_BIG
273 0128 JNC FICATION_SMALL
274 012A MOV KABUR_BIG,#0FFH ; JIKA INPUT BESAR MAKA = FF
275 012D FICATION_SMALL:
276 012D MOV A,IN_FUZZIFICATION ; MASUKAN NILAI MINIMAL DARI BIG
277 012F ACALL RESET
278 0131 SUBB A,MAX_SMALL ; CARI YANG LEBIH MINIMAL
279 0133 MOV KABUR_SMALL,#00H ; SET TERLEBIH DAHULU OUT_BIG
280 0136 JNC FICATION_ZERRO ; JIKA INPUT KECIL MAKA LOMPAT
281 0138 MOV KABUR_SMALL,#0FFH 282 013B FICATION_ZERRO:
283 013B MOV A,MAX_ZERRO ; MASUKAN NILAI MINIMAL DARI BIG
284 013D SUBB A,IN_FUZZIFICATION ; CARI YANG LEBIH MINIMAL
285 013F MOV KABUR_ZERRO,#00H
286 0142 JC FICATION_END
287 0144 MOV KABUR_ZERRO,#0FFH
289 0147 FICATION_END: RET
290 0148 ;******************SUBB RESET****************
291 0148 RESET:
293 0148 CLR CY
294 014A CLR AC
295 014C CLR OV
296 014E RET
297 014F ;4.2 -------------********BASIS DATA**********----------------
299 014F BASIS_DATA:
300 014F CLR A
301 0150 MOV DERAJAT_ZERRO,#00H
302 0153 CJNE R4,#0FFH,DATA_SMALL
303 0156 MOV DPTR,#TABEL_ZERRO ; jika error termasuk zerro maka akan
304 0159 MOV A,IN_BASIS_DATA ; dicari derajat keanggotaanya
305 015B MOVC A,@A+DPTR
306 015C MOV DERAJAT_ZERRO,A
307 015E DATA_SMALL:
308 015E CLR A
309 015F MOV DERAJAT_SMALL,#00H
310 0162 CJNE R5,#0FFH,DATA_BIG
311 0165 MOV DPTR,#TABEL_SMALL ; jika error termasuk zerro maka akan
312 0168 MOV A,IN_BASIS_DATA ; dicari derajat keanggotaanya
313 016A MOVC A,@A+DPTR
314 016B MOV DERAJAT_SMALL,A
315 016D DATA_BIG:
316 016D CLR A
317 016E MOV DERAJAT_BIG,#00H
318 0171 CJNE R6,#0FFH,DATA_END
319 0174 MOV DPTR,#TABEL_BIG ; jika error termasuk zerro maka
320 0177 MOV A,IN_BASIS_DATA
321 0179 MOVC A,@A+DPTR
322 017A MOV DERAJAT_BIG,A
323 017C DATA_END: RET
325 017D ;4.3 -----------********BASIS KAIDAH**********-------------
327 017D ;|---------------
328 017D ;| KODE UNTUK OUTPUT
329 017D ;|------+-------|
330 017D ;| KODE | ARTI |
331 017D ;|------+-------|
332 017D ;| 01 | ZERRO |
333 017D ;| 02 | PS |
334 017D ;| 03 | PB |
335 017D ;| 04 | NS |
336 017D ;| 05 | NB |
337 017D ;|------+-------|
339 017D BASIS_KAIDAH:
340 017D MOV R1,#KAIDAH
341 017F MOV R0,#DERAJAT_KAIDAH
342 0181 MOV A,TANDA_ERR
343 0183 CJNE A,#0FFH,CEK_DEEROR
344 0186 LJMP KAIDAH_ERMIN ;jump jika tanda error minus
345 0189 CEK_DEEROR:
346 0189 MOV R2,TANDA_DERR
347 018B CJNE R2,#0FFH,CEK_ZERRO
348 018E LJMP KAIDAH_DERMIN ; jump jika tanda d_error minus
349 0191 CEK_ZERRO:
350 0191 MOV R3,KABUR_ERR_Z
351 0193 CJNE R3,#0FFH,KAIDAH_ERS ;jump jika error notZ
352 0196 MOV R4,KABUR_DERR_Z
353 0198 CJNE R4,#0FFH,NEXTZ1
354 019B MOV @R1,#01H
355 019D INC R1
356 019E MOV A,DERAJAT_ERR_Z
357 01A0 ACALL RESET
358 01A2 SUBB A,DERAJAT_DERR_Z
359 01A4 MOV @R0,DERAJAT_DERR_Z
360 01A6 JNC NEXTZ1a
361 01A8 MOV @R0,DERAJAT_ERR_Z
362 01AA NEXTZ1a: INC R0

363 01AB ;-------------------------------------------------


364 01AB NEXTZ1:
365 01AB MOV R4,KABUR_DERR_S
366 01AD CJNE R4,#0FFH,NEXTZ2
367 01B0 MOV @R1,#02H
368 01B2 INC R1
369 01B3 MOV A,DERAJAT_ERR_Z
370 01B5 ACALL RESET
371 01B7 SUBB A,DERAJAT_DERR_S
372 01B9 MOV @R0,DERAJAT_DERR_S
373 01BB JNC NEXTZ2b
374 01BD MOV @R0,DERAJAT_ERR_Z
375 01BF NEXTZ2b: INC R0
376 01C0 ;-----------------------------------------------------
377 01C0 NEXTZ2:
378 01C0 MOV R4,KABUR_DERR_B
379 01C2 CJNER4,#0FFH,KAIDAH_ERS ;Err = Z And d_err = PB => out=PB
380 01C5 MOV @R1,#03H
381 01C7 INC R1
382 01C8 MOV A,DERAJAT_ERR_Z
383 01CA ACALL RESET
384 01CC SUBB A,DERAJAT_DERR_B
385 01CE MOV @R0,DERAJAT_DERR_B
386 01D0 JNC KAIDAH_ERSc
387 01D2 MOV @R0,DERAJAT_ERR_Z
388 01D4 KAIDAH_ERSc: INC R0
389 01D5 ;-----------------------------------------------
390 01D5 KAIDAH_ERS:; jika error tidak termasuk SMALL lompat
391 01D5 MOV R3,KABUR_ERR_S
392 01D7 CJNE R3,#0FFH,KAIDAH_ERB
393 01DA MOV R4,KABUR_DERR_Z
394 01DC CJNE R4,#0FFH,NEXTS1 ;Err = PS and d_err = Z => out=PS
395 01DF MOV @R1,#02H
396 01E1 INC R1
397 01E2 MOV A,DERAJAT_ERR_S
398 01E4 ACALL RESET
399 01E6 SUBB A,DERAJAT_DERR_Z
400 01E8 MOV @R0,DERAJAT_DERR_Z
401 01EA JNC NEXTS1a
402 01EC MOV @R0,DERAJAT_ERR_S
403 01EE NEXTS1a: INC R0
404 01EF ;----------------------------------------------
405 01EF NEXTS1:
406 01EF MOV R4,KABUR_DERR_S
407 01F1 CJNE R4,#0FFH,NEXTS2 ;Err = PS and d_err = PS => out=PS
408 01F4 MOV @R1,#02H
409 01F6 INC R1
410 01F7 MOV A,DERAJAT_ERR_S
411 01F9 ACALL RESET
412 01FB SUBB A,DERAJAT_DERR_S
413 01FD MOV @R0,DERAJAT_DERR_S
414 01FF JNC NEXTS2b
415 0201 MOV @R0,DERAJAT_ERR_S
416 0203 NEXTS2b: INC R0
417 0204 ;----------------------------------------------
418 0204 NEXTS2:
419 0204 MOV R4,KABUR_DERR_B
420 0206 CJNE R4,#0FFH,KAIDAH_ERB ;Err = PS and d_err = PB => out=NB
421 0209 MOV @R1,#05H
422 020B INC R1
423 020C MOV A,DERAJAT_ERR_S
424 020E ACALL RESET
425 0210 SUBB A,DERAJAT_DERR_S
426 0212 MOV @R0,DERAJAT_DERR_S
427 0214 JNC KAIDAH_ERBa
428 0216 MOV @R0,DERAJAT_ERR_S
429 0218 KAIDAH_ERBa: INC R0
430 0219 ;---------------------------------------------------------
431 0219 KAIDAH_ERB:; jika error tidak termasuk BIG lompat
432 0219 MOV R3,KABUR_ERR_B
433 021B CJNE R3,#0FFH,KELUARA
434 021E MOV R4,KABUR_DERR_Z
435 0220 CJNE R4,#0FFH,NEXTB1 ;Err = PB and d_err = Z => out=PB
436 0223 MOV @R1,#03H
437 0225 INC R1
438 0226 MOV A,DERAJAT_ERR_B
439 0228 ACALL RESET
440 022A SUBB A,DERAJAT_DERR_Z
441 022C MOV @R0,DERAJAT_DERR_Z
442 022E JNC NEXTB1a
443 0230 MOV @R0,DERAJAT_ERR_B
444 0232 NEXTB1a: INC R0
445 0233 ;----------------------------------------------------------
446 0233 NEXTB1:
447 0233 MOV R4,KABUR_DERR_S
448 0235 CJNE R4,#0FFH,NEXTB2 ;Err = PB and d_err = PS => out=PB
449 0238 MOV @R1,#03H
450 023A INC R1
451 023B MOV A,DERAJAT_ERR_B
452 023D ACALL RESET
453 023F SUBB A,DERAJAT_DERR_S
454 0241 MOV @R0,DERAJAT_DERR_S
455 0243 JNC NEXTB2b
456 0245 MOV @R0,DERAJAT_ERR_B
457 0247 NEXTB2b: INC R0
458 0248 ;----------------------------------------------------------
459 0248 NEXTB2:
460 0248 MOV R4,KABUR_DERR_B
461 024A CJNE R4,#0FFH,KELUARA ;Err = PB and d_err = PB => out=PB
462 024D MOV @R1,#03H
463 024F INC R1
464 0250 MOV A,DERAJAT_ERR_B
465 0252 ACALL RESET
466 0254 SUBB A,DERAJAT_DERR_B
467 0256 MOV @R0,DERAJAT_DERR_B
468 0258 JNC KELUARAa
469 025A MOV @R0,DERAJAT_ERR_B
470 025C KELUARAa: INC R0
471 025D KELUARA: LJMP KELUAR
472 0260 ;----------------------------------------------------------
473 0260 KAIDAH_DERMIN:
474 0260 MOV R3,KABUR_ERR_Z
475 0262 CJNE R3,#0FFH,KAIDAH_ERSM
476 0265 MOV R4,KABUR_DERR_Z
477 0267 CJNE R4,#0FFH,NEXTZ1M ;Err = Z and d_err = Z => out=Z
478 026A MOV @R1,#01H
479 026C INC R1
480 026D MOV A,DERAJAT_ERR_Z
481 026F ACALL RESET
482 0271 SUBB A,DERAJAT_DERR_Z
483 0273 MOV @R0,DERAJAT_DERR_Z
484 0275 JNC NEXTZ1Ma
485 0277 MOV @R0,DERAJAT_ERR_Z
486 0279 NEXTZ1Ma: INC R0
487 027A ;----------------------------------------------------------
488 027A NEXTZ1M:
489 027A MOV R4,KABUR_DERR_S
490 027C CJNE R4,#0FFH,NEXTZ2M ;Err = Z and d_err = NS => out=NS
491 027F MOV @R1,#04H
492 0281 INC R1
493 0282 MOV A,DERAJAT_ERR_Z
494 0284 ACALL RESET
495 0286 SUBB A,DERAJAT_DERR_S
496 0288 MOV @R0,DERAJAT_DERR_S
497 028A JNC NEXTZ2Mb
498 028C MOV @R0,DERAJAT_ERR_Z
499 028E NEXTZ2Mb: INC R0
500 028F ;----------------------------------------------------------
501 028F NEXTZ2M:
502 028F MOV R4,KABUR_DERR_B
503 0291 CJNE R4,#0FFH,KAIDAH_ERSM ;Err = Z and d_err = NB => out=NB
504 0294 MOV @R1,#05H
505 0296 INC R1
506 0297 MOV A,DERAJAT_ERR_Z
507 0299 ACALL RESET
508 029B SUBB A,DERAJAT_DERR_B
509 029D MOV @R0,DERAJAT_DERR_B
510 029F JNC KAIDAH_ERSMc
511 02A1 MOV @R0,DERAJAT_ERR_Z
512 02A3 KAIDAH_ERSMc: INC R0
513 02A4 ;----------------------------------------------------------
514 02A4 KAIDAH_ERSM:
515 02A4 MOV R3,KABUR_ERR_S
516 02A6 CJNE R3,#0FFH,KAIDAH_ERBM
517 02A9 MOV R4,KABUR_DERR_Z
518 02AB CJNE R4,#0FFH,NEXTS1M ;Err = PS and d_err = Z => out=PS
519 02AE MOV @R1,#02H
520 02B0 INC R1
521 02B1 MOV A,DERAJAT_ERR_S
522 02B3 ACALL RESET
523 02B5 SUBB A,DERAJAT_DERR_Z
524 02B7 MOV @R0,DERAJAT_DERR_Z
525 02B9 JNC NEXTS1Ma
526 02BB MOV @R0,DERAJAT_ERR_S
527 02BD NEXTS1Ma: INC R0
528 02BE ;----------------------------------------------------------
529 02BE NEXTS1M:
530 02BE MOV R4,KABUR_DERR_S
531 02C0 CJNE R4,#0FFH,NEXTS2M ;Err = PS and d_err = NS => out=Z
532 02C3 MOV @R1,#01H
533 02C5 INC R1
534 02C6 MOV A,DERAJAT_ERR_S
535 02C8 ACALL RESET
536 02CA SUBB A,DERAJAT_DERR_S
537 02CC MOV @R0,DERAJAT_DERR_S
538 02CE JNC NEXTS2Mb
539 02D0 MOV @R0,DERAJAT_ERR_S
540 02D2 NEXTS2Mb: INC R0
541 02D3 ;----------------------------------------------------------
542 02D3 NEXTS2M:
543 02D3 MOV R4,KABUR_DERR_B
544 02D5 CJNE R4,#0FFH,KAIDAH_ERBM ;Err = PS and d_err= NB => out=NS
545 02D8 MOV @R1,#04H
546 02DA INC R1
547 02DB MOV A,DERAJAT_ERR_S
548 02DD ACALL RESET
549 02DF SUBB A,DERAJAT_DERR_B
550 02E1 MOV @R0,DERAJAT_DERR_B
551 02E3 JNC KAIDAH_ERBMc
552 02E5 MOV @R0,DERAJAT_ERR_S
553 02E7 KAIDAH_ERBMc: INC R0
554 02E8 ;----------------------------------------------------------
555 02E8 KAIDAH_ERBM:
556 02E8 MOV R3,KABUR_ERR_B
557 02EA CJNE R3,#0FFH,KELUARB
558 02ED MOV R4,KABUR_DERR_Z
559 02EF CJNE R4,#0FFH,NEXTB1M ;Err = PB and d_err = Z => out=PB
560 02F2 MOV @R1,#03H
561 02F4 INC R1
562 02F5 MOV A,DERAJAT_ERR_B
563 02F7 ACALL RESET
564 02F9 SUBB A,DERAJAT_DERR_Z
565 02FB MOV @R0,DERAJAT_DERR_Z
566 02FD JNC NEXTB1Ma
567 02FF MOV @R0,DERAJAT_ERR_B
568 0301 NEXTB1Ma: INC R0
569 0302 ;----------------------------------------------------------
570 0302 NEXTB1M:
571 0302 MOV R4,KABUR_DERR_S
572 0304 CJNE R4,#0FFH,NEXTB2M ;Err = PB and d_err = NS => out=PS
573 0307 MOV @R1,#02H
574 0309 INC R1
575 030A MOV A,DERAJAT_ERR_B
576 030C ACALL RESET
577 030E SUBB A,DERAJAT_DERR_S
578 0310 MOV @R0,DERAJAT_DERR_S
579 0312 JNC NEXTB2Mb
580 0314 MOV @R0,DERAJAT_ERR_B
581 0316 NEXTB2Mb: INC R0
582 0317 ;------------------------------------------------
----------
583 0317 NEXTB2M:
584 0317 MOV R4,KABUR_DERR_B
585 0319 CJNE R4,#0FFH,KELUARB ;Err = PB and d_err = NB => out=Z
586 031C MOV @R1,#01H
587 031E INC R1
588 031F MOV A,DERAJAT_ERR_B
589 0321 ACALL RESET
590 0323 SUBB A,DERAJAT_DERR_B
591 0325 MOV @R0,DERAJAT_DERR_B
592 0327 JNC KELUARBc
593 0329 MOV @R0,DERAJAT_ERR_B
594 032B KELUARBc: INC R0
595 032C KELUARB: LJMP KELUAR
596 032F ;minminminminmnminminminminminminminminminminminminminin
597 032F ;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
598 032F KAIDAH_ERMIN:
599 032F MOV R2,TANDA_DERR
600 0331 CJNE R2,#0FFH,CEK_ZERROA
601 0334 LJMP KAIDAH_DERMIN_EM
602 0337 CEK_ZERROA:
603 0337 MOV R3,KABUR_ERR_Z
604 0339 CJNE R3,#0FFH,KAIDAH_ERS_EM
605 033C MOV R4,KABUR_DERR_Z
606 033E CJNE R4,#0FFH,NEXTZ1_EM ;Err = Z and d_err = Z => out=Z
607 0341 MOV @R1,#01H
608 0343 INC R1
609 0344 MOV A,DERAJAT_ERR_Z
610 0346 ACALL RESET
611 0348 SUBB A,DERAJAT_DERR_Z
612 034A MOV @R0,DERAJAT_DERR_Z
613 034C JNC NEXTZ1_EMa
614 034E MOV @R0,DERAJAT_ERR_Z
615 0350 NEXTZ1_EMa: INC R0
616 0351 ;----------------------------------------------------------
617 0351 NEXTZ1_EM:
618 0351 MOV R4,KABUR_DERR_S
619 0353 CJNE R4,#0FFH,NEXTZ2_EM ;Err = Z and d_err = PS => out=PS
620 0356 MOV @R1,#02H
621 0358 INC R1
622 0359 MOV A,DERAJAT_ERR_Z
623 035B ACALL RESET
624 035D SUBB A,DERAJAT_DERR_S
625 035F MOV @R0,DERAJAT_DERR_S
626 0361 JNC NEXTZ2_EMb
627 0363 MOV @R0,DERAJAT_ERR_Z
628 0365 NEXTZ2_EMb: INC R0
629 0366 ;----------------------------------------------------------
630 0366 NEXTZ2_EM:
631 0366 MOV R4,KABUR_DERR_B
632 0368 CJNE R4,#0FFH,KAIDAH_ERS_EM ;Err = Z and d_err = PB => out=PB
633 036B MOV @R1,#03H
634 036D INC R1
635 036E MOV A,DERAJAT_ERR_Z
636 0370 ACALL RESET
637 0372 SUBB A,DERAJAT_DERR_B
638 0374 MOV @R0,DERAJAT_DERR_B
639 0376 JNC KAIDAH_ERS_EMc
640 0378 MOV @R0,DERAJAT_ERR_Z
641 037A KAIDAH_ERS_EMc: INC R0
642 037B ;--------------------------------------------------------
643 037B KAIDAH_ERS_EM:
644 037B MOV R3,KABUR_ERR_S
645 037D CJNE R3,#0FFH,KAIDAH_ERB_EM
646 0380 MOV R4,KABUR_DERR_Z
647 0382 CJNE R4,#0FFH,NEXTS1_EM ;Err = NS and d_err = Z => out=NS
648 0385 MOV @R1,#04H
649 0387 INC R1
650 0388 MOV A,DERAJAT_ERR_S
651 038A ACALL RESET
652 038C SUBB A,DERAJAT_DERR_Z
653 038E MOV @R0,DERAJAT_DERR_Z
654 0390 JNC NEXTS1_EMa
655 0392 MOV @R0,DERAJAT_ERR_S
656 0394 NEXTS1_EMa: INC R0
657 0395;------------4444444$$$$$$$$$$$$$$$$$$$$$$$$$$$$$901>>>>>>>>>02
658 0395 NEXTS1_EM:
659 0395 MOV R4,KABUR_DERR_S
660 0397 CJNE R4,#0FFH,NEXTS2_EM ;Err = NS and d_err = PS => out=PS
661 039A MOV @R1,#02H
662 039C INC R1
663 039D MOV A,DERAJAT_ERR_S
664 039F ACALL RESET
665 03A1 SUBB A,DERAJAT_DERR_S
666 03A3 MOV @R0,DERAJAT_DERR_S
667 03A5 JNC NEXTS2_EMb
668 03A7 MOV @R0,DERAJAT_ERR_S
669 03A9 NEXTS2_EMb: INC R0
670 03AA ;-------------------------------------------------------
671 03AA NEXTS2_EM:
672 03AA MOV R4,KABUR_DERR_B
673 03AC CJNE R4,#0FFH,KAIDAH_ERB_EM ;Err = NS and d_err= PB => out=PS
674 03AF MOV @R1,#02H
675 03B1 INC R1
676 03B2 MOV A,DERAJAT_ERR_S
677 03B4 ACALL RESET
678 03B6 SUBB A,DERAJAT_DERR_S
679 03B8 MOV @R0,DERAJAT_DERR_S
680 03BA JNC KAIDAH_ERB_EMa
681 03BC MOV @R0,DERAJAT_ERR_S
682 03BE KAIDAH_ERB_EMa: INC R0
683 03BF ;----------------------------------------------------------
684 03BF KAIDAH_ERB_EM:
685 03BF MOV R3,KABUR_ERR_B
686 03C1 CJNE R3,#0FFH,KELUARC
687 03C4 MOV R4,KABUR_DERR_Z
688 03C6 CJNE R4,#0FFH,NEXTB1_EM ;Err = NB and d_err = Z => out=NB
689 03C9 MOV @R1,#05H
690 03CB INC R1
691 03CC MOV A,DERAJAT_ERR_B
692 03CE ACALL RESET
693 03D0 SUBB A,DERAJAT_DERR_Z
694 03D2 MOV @R0,DERAJAT_DERR_Z
695 03D4 JNC NEXTB1_EMa
696 03D6 MOV @R0,DERAJAT_ERR_B
697 03D8 NEXTB1_EMa: INC R0
698 03D9 ;----------------------------------------------------------
699 03D9 NEXTB1_EM:
700 03D9 MOV R4,KABUR_DERR_S
701 03DB CJNE R4,#0FFH,NEXTB2_EM ;Err = NB and d_err = PS => out=NB
702 03DE MOV @R1,#05H
703 03E0 INC R1
704 03E1 MOV A,DERAJAT_ERR_B
705 03E3 ACALL RESET
706 03E5 SUBB A,DERAJAT_DERR_S
707 03E7 MOV @R0,DERAJAT_DERR_S
708 03E9 JNC NEXTB2_EMb
709 03EB MOV @R0,DERAJAT_ERR_B
710 03ED NEXTB2_EMb: INC R0
711 03EE ;----------------------------------------------------------
712 03EE NEXTB2_EM:
713 03EE MOV R4,KABUR_DERR_B
714 03F0 CJNE R4,#0FFH,KELUARC ;Err = NB and d_err = PB => out=NS
715 03F3 MOV @R1,#05
716 03F5 INC R1
717 03F6 MOV A,DERAJAT_ERR_B
718 03F8 ACALL RESET
719 03FA SUBB A,DERAJAT_DERR_B
720 03FC MOV @R0,DERAJAT_DERR_B
721 03FE JNC KELUARCa
722 0400 MOV @R0,DERAJAT_ERR_B
723 0402 KELUARCa: INC R0
724 0403 KELUARC: LJMP KELUAR
725 0406 ;----------------------------------------------------------
726 0406 KAIDAH_DERMIN_EM:
727 0406 MOV R3,KABUR_ERR_Z
728 0408 CJNE R3,#0FFH,KAIDAH_ERSM_EM
729 040B MOV R4,KABUR_DERR_Z
730 040D CJNE R4,#0FFH,NEXTZ1M_EM ;Err = Z and d_err = Z => out=Z
731 0410 MOV @R1,#01H
732 0412 INC R1
733 0413 MOV A,DERAJAT_ERR_Z
734 0415 ACALL RESET
735 0417 SUBB A,DERAJAT_DERR_Z
736 0419 MOV @R0,DERAJAT_DERR_Z
737 041B JNC NEXTZ1M_EMa
738 041D MOV @R0,DERAJAT_ERR_Z
739 041F NEXTZ1M_EMa: INC R0
740 0420
741 0420 NEXTZ1M_EM:
742 0420 MOV R4,KABUR_DERR_S
743 0422 CJNE R4,#0FFH,NEXTZ2M_EM ;Err = Z and d_err = NS => out=NS
744 0425 MOV @R1,#04H
745 0427 INC R1
746 0428 MOV A,DERAJAT_ERR_Z
747 042A ACALL RESET
748 042C SUBB A,DERAJAT_DERR_S
749 042E MOV @R0,DERAJAT_DERR_S
750 0430 JNC NEXTZ2M_EMb
751 0432 MOV @R0,DERAJAT_ERR_Z
752 0434 NEXTZ2M_EMb: INC R0
753 0435 ;----------------------------------------------------------
754 0435 NEXTZ2M_EM:
755 0435 MOV R4,KABUR_DERR_B
756 0437 CJNE R4,#0FFH,KAIDAH_ERSM_EM ;Err = Z and d_err = NB => out=NB
757 043A MOV @R1,#05H
758 043C INC R1
759 043D MOV A,DERAJAT_ERR_Z
760 043F ACALL RESET
761 0441 SUBB A,DERAJAT_DERR_B
762 0443 MOV @R0,DERAJAT_DERR_B
763 0445 JNC NEXTZ1M_EMc
764 0447 MOV @R0,DERAJAT_ERR_Z
765 0449 NEXTZ1M_EMc: INC R0
766 044A ;----------------------------------------------------------
767 044A KAIDAH_ERSM_EM:
768 044A MOV R3,KABUR_ERR_S
769 044C CJNE R3,#0FFH,KAIDAH_ERBM_EM
770 044F MOV R4,KABUR_DERR_Z
771 0451 CJNE R4,#0FFH,NEXTS1M_EM ;Err = NS and d_err = Z => out=NS
772 0454 MOV @R1,#04H
773 0456 INC R1
774 0457 MOV A,DERAJAT_ERR_S
775 0459 ACALL RESET
776 045B SUBB A,DERAJAT_DERR_Z
777 045D MOV @R0,DERAJAT_DERR_Z
778 045F JNC NEXTS1M_EMa
779 0461 MOV @R0,DERAJAT_ERR_S
780 0463 NEXTS1M_EMa: INC R0
781 0464 ;----------------------------------------------------------
782 0464 NEXTS1M_EM:
783 0464 MOV R4,KABUR_DERR_S
784 0466 CJNE R4,#0FFH,NEXTS2M_EM ;Err = NS and d_err = NS => out=NS
785 0469 MOV @R1,#04H
786 046B INC R1
787 046C MOV A,DERAJAT_ERR_S
788 046E ACALL RESET
789 0470 SUBB A,DERAJAT_DERR_S
790 0472 MOV @R0,DERAJAT_DERR_S
791 0474 JNC NEXTS2M_EMb
792 0476 MOV @R0,DERAJAT_ERR_S
793 0478 NEXTS2M_EMb: INC R0
794 0479 ;---------------------------------------------------------
795 0479 NEXTS2M_EM:
796 0479 MOV R4,KABUR_DERR_B
797 047B CJNE R4,#0FFH,KAIDAH_ERBM_EM ;Err = NS and d_err = NB => out=NS
798 047E MOV @R1,#04H
799 0480 INC R1
800 0481 MOV A,DERAJAT_ERR_S
801 0483 ACALL RESET
802 0485 SUBB A,DERAJAT_DERR_B
803 0487 MOV @R0,DERAJAT_DERR_B
804 0489 JNC KAIDAH_ERBM_EMa
805 048B MOV @R0,DERAJAT_ERR_S
806 048D KAIDAH_ERBM_EMa: INC R0
807 048E ;----------------------------------------------------------
808 048E KAIDAH_ERBM_EM:
809 048E MOV R3,KABUR_ERR_B
810 0490 CJNE R3,#0FFH,KELUAR
811 0493 MOV R4,KABUR_DERR_Z
812 0495 CJNE R4,#0FFH,NEXTB1M_EM ;Err = NB and d_err = Z => out=NB
813 0498 MOV @R1,#05H
814 049A INC R1
815 049B MOV A,DERAJAT_ERR_B
816 049D ACALL RESET
817 049F SUBB A,DERAJAT_DERR_Z
818 04A1 MOV @R0,DERAJAT_DERR_Z
819 04A3 JNC NEXTB1M_EMa
820 04A5 MOV @R0,DERAJAT_ERR_B
821 04A7 NEXTB1M_EMa: INC R0
822 04A8 ;----------------------------------------------------------
823 04A8 NEXTB1M_EM:
824 04A8 MOV R4,KABUR_DERR_S
825 04AA CJNE R4,#0FFH,NEXTB2M_EM ;Err = NB and d_err = NS => out=NB
826 04AD MOV @R1,#05H
827 04AF INC R1
828 04B0 MOV A,DERAJAT_ERR_B
829 04B2 ACALL RESET
830 04B4 SUBB A,DERAJAT_DERR_S
831 04B6 MOV @R0,DERAJAT_DERR_S
832 04B8 JNC NEXTB2M_EMb
833 04BA MOV @R0,DERAJAT_ERR_B
834 04BC NEXTB2M_EMb: INC R0
835 04BD ;-------------------------------------------------------
836 04BD NEXTB2M_EM:
837 04BD MOV R4,KABUR_DERR_B
838 04BF CJNE R4,#0FFH,KELUAR ;Err = NB and d_err = NB => out=NB
839 04C2 MOV @R1,#05H
840 04C4 INC R1
841 04C5 MOV A,DERAJAT_ERR_B
842 04C7 ACALL RESET
843 04C9 SUBB A,DERAJAT_DERR_B
844 04CB MOV @R0,DERAJAT_DERR_B
845 04CD JNC KELUARf
846 04CF MOV @R0,DERAJAT_ERR_B
847 04D1 KELUARf: INC R0
848 04D2 SJMP KELUAR
849 04D4 ;----------------------------------------------------------
850 04D4 KELUAR:
852 04D4 ;4.4 ----------*********DEFUZZIFICATION***********----------
----------------
853 04D4 DEFUZZIFICATION:
854 04D4 MOV R0,#DERAJAT_KAIDAH
855 04D6 MOV R1,#KAIDAH
856 04D8 MOV R2,#04H
857 04DA mov 5Ah,#00h
858 04DD YM:
859 04DD ACALL RESET
860 04DF MOV A,@R0
861 04E0 SUBB A,5Ah
862 04E2 MOV 5AH,5AH
863 04E5 MOV 5BH,5BH
864 04E8 JC YO
865 04EA MOV 5AH,@R0
866 04EC MOV 5BH,@R1
867 04EE YO:
868 04EE INC R0
869 04EF INC R1
870 04F0 DJNZ R2,YM
871 04F2 ret
872 04F3 ;*******************************END OF FUZZY
PROCESS****************************
875 04F3 ;5 --------------**********PENGATURAN LAMPU DAN
KIPAS***********----------------
877 04F3 PENGATURAN_LAMPU&KIPAS:
878 04F3 ;|---------------
879 04F3 ;| KODE UNTUK OUTPUT
880 04F3 ;|------+-------|
881 04F3 ;| KODE | ARTI |
882 04F3 ;|------+-------|
883 04F3 ;| 01 | ZERRO |
884 04F3 ;| 02 | PS |
885 04F3 ;| 03 | PB |
886 04F3 ;| 04 | NS |
887 04F3 ;| 05 | NB |
888 04F3 ;|------+-------|
889 04F3 ;01=>TETAP
890 04F3 mov PV,34h
891 04F6 CLR A
892 04F7 MOV R0,#77H
893 04F9 MOV @R0,P2
894 04FB MOV R2,5BH
895 04FD CJNE R2,#01H,TAMBAH_SATU
896 0500 MOV R7,#02
897 0502 MOV R6,#00
898 0504 MOV P2,@R0
899 0506 clr p2.4
900 0508 LJMP BALIK
901 050B ;----------------------------------------
902 050B ;02=>JUMLAH LAMPU YG MENYALA TAMBAH SATU
903 050B TAMBAH_SATU:
904 050B XCHD a,@r0
905 050C CJNE R2,#02H,TAMBAH_DUA
907 050F CJNE A,#0FH,NYALA_3N1
908 0512 MOV A,#0FH ;NYALA 4 => NYALA 4
909 0514 XCHD A,@R0
910 0515 MOV P2,@R0
911 0517 SETB p2.4
912 0519 LJMP BALIK
913 051C NYALA_3N1:
914 051C CJNE A,#07H,NYALA_2N1
915 051F MOV A,#0FH ;NYALA 3 => NYALA 4
916 0521 XCHD A,@R0
917 0522 MOV P2,@R0
918 0524 SETB p2.4
919 0526 LJMP BALIK
920 0529 NYALA_2N1:
921 0529 CJNE A,#03H,NYALA_1N1
922 052C MOV A,#07H ;NYALA 2 => NYALA 3
923 052E XCHD A,@R0
924 052F MOV P2,@R0
925 0531 clr p2.4
926 0533 LJMP BALIK
927 0536 NYALA_1N1:
928 0536 CJNE A,#01H,NYALA_0N1
929 0539 MOV A,#03H ;NYALA 1 => NYALA 2
930 053B XCHD A,@R0
931 053C MOV P2,@R0
932 053E clr p2.4
933 0540 LJMP BALIK
934 0543 NYALA_0N1:
935 0543 MOV A,#01H ;NYALA 0 => NYALA 1
936 0545 XCHD A,@R0
937 0546 MOV P2,@R0
938 0548 clr p2.4
939 054A LJMP BALIK
940 054D ;----------------------------------------
941 054D ;03=>JUMLAH LAMPU YG MENYALA TAMBAH DUA
942 054D TAMBAH_DUA:
943 054D CJNE R2,#03H,KURANG_SATU
945 0550 CJNE A,#0FH,NYALA_3N2
946 0553 MOV A,#0FH ;NYALA 4 => NYALA 4
947 0555 XCHD A,@R0
948 0556 MOV P2,@R0
949 0558 clr p2.4
950 055A LJMP BALIK
951 055D NYALA_3N2:
952 055D CJNE A,#07H,NYALA_2N2
953 0560 MOV A,#0FH ;NYALA 3 => NYALA 4
954 0562 XCHD A,@R0
955 0563 MOV P2,@R0
956 0565 clr p2.4
957 0567 LJMP BALIK
958 056A NYALA_2N2:
959 056A CJNE A,#03H,NYALA_1N2
960 056D MOV A,#0FH ;NYALA 2 => NYALA 4
961 056F XCHD A,@R0
962 0570 MOV P2,@R0
963 0572 clr p2.4
964 0574 LJMP BALIK
965 0577 NYALA_1N2:
966 0577 CJNE A,#01H,NYALA_0N2
967 057A MOV A,#07H ;NYALA 1 => NYALA 3
968 057C XCHD A,@R0
969 057D MOV P2,@R0
970 057F clr p2.4
971 0581 LJMP BALIK
972 0584 NYALA_0N2:
973 0584 MOV A,#03H ;NYALA 0 => NYALA 2
974 0586 XCHD A,@R0
975 0587 MOV P2,@R0
976 0589 clr p2.4
977 058B LJMP BALIK
978 058E ;-----------------------------------
979 058E ;04=>JUMLAH LAMPU YG MENYALA KURANGI SATU
980 058E KURANG_SATU:
981 058E CJNE R2,#04H,KURANG_DUA
983 0591 CJNE A,#0FH,NYALA_3K1
984 0594 MOV A,#07H ;NYALA 4 => NYALA 3
985 0596 XCHD A,@R0
986 0597 MOV P2,@R0
987 0599 setb p2.4
988 059B LJMP BALIK
989 059E NYALA_3K1:
990 059E CJNE A,#07H,NYALA_2K1
991 05A1 MOV A,#03H ;NYALA 3 => NYALA 2
992 05A3 XCHD A,@R0
993 05A4 MOV P2,@R0
994 05A6 setb p2.4
995 05A8 LJMP BALIK
996 05AB NYALA_2K1:
997 05AB CJNE A,#03H,NYALA_1K1
998 05AE MOV A,#01H ;NYALA 2 => NYALA 1
999 05B0 XCHD A,@R0
1000 05B1 MOV P2,@R0
1001 05B3 setb p2.4
1002 05B5 SJMP BALIK
1003 05B7 NYALA_1K1:
1004 05B7 CJNE A,#01H,NYALA_0K1
1005 05BA MOV A,#00H ;NYALA 1 => NYALA 0
1006 05BC XCHD A,@R0
1007 05BD MOV P2,@R0
1008 05BF setb p2.4
1009 05C1 SJMP BALIK
1010 05C3 NYALA_0K1:
1011 05C3 MOV A,#00H ;NYALA 0 => NYALA 0
1012 05C5 XCHD A,@R0
1013 05C6 MOV P2,@R0
1014 05C8 setb p2.4
1015 05CA SJMP BALIK
1016 05CC ;-----------------------------------------------------
1017 05CC ;05=>JUMLAH LAMPU YG MENYALA KURANGI DUA
1018 05CC KURANG_DUA:
1019 05CC CJNE A,#0FH,NYALA_3K2
1020 05CF MOV A,#03H ;NYALA 4 => NYALA 2
1021 05D1 XCHD A,@R0
1022 05D2 MOV P2,@R0
1023 05D4 setb p2.4
1024 05D6 SJMP BALIK
1025 05D8 NYALA_3K2:
1026 05D8 CJNE A,#07H,NYALA_2K2
1027 05DB MOV A,#01H ;NYALA 3 => NYALA 1
1028 05DD XCHD A,@R0
1029 05DE MOV P2,@R0
1030 05E0 setb p2.4
1031 05E2 SJMP BALIK
1032 05E4 NYALA_2K2:
1033 05E4 CJNE A,#03H,NYALA_1K2
1034 05E7 MOV A,#00H ;NYALA 2 => NYALA 0
1035 05E9 XCHD A,@R0
1036 05EA MOV P2,@R0
1037 05EC setb p2.4
1038 05EE SJMP BALIK
1039 05F0 NYALA_1K2:
1040 05F0 CJNE A,#01H,NYALA_0K2
1041 05F3 MOV A,#00H ;NYALA 1 => NYALA 0
1042 05F5 XCHD A,@R0
1043 05F6 MOV P2,@R0
1044 05F8 setb p2.4
1045 05FA SJMP BALIK
1046 05FC NYALA_0K2:
1047 05FC MOV A,#00H ;NYALA 0 => NYALA 0
1048 05FE XCHD A,@R0
1049 05FF MOV P2,@R0
1050 0601 setb p2.4
1051 0603 SJMP BALIK
1052 0605 BALIK:
1053 0605 MOV A,R7
1054 0606 ADD A,PV
1055 0608 MOV R5,A
1056 0609 ACALL RESET
1057 060B SUBB A,35H
1058 060D JC LAGX
1059 060F ACALL RESET
1060 0611 MOV A,R5
1061 0612 SUBB A,R6
1062 0613 MOV R5,A
1064 0614 LAGX:
1065 0614 MOV 34h,R5
1067 0616 RET
1069 0617
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%
1071 0617 ;6 --------------*********SUBRUTINE PENAMPILAN************----
------------------
1073 0617 DISPLAY:
1074 0617 mov a,#153 ; BATAS ANGKA PULUHAN ANTARA 2 DAN 3 BERADA
DI 0AAh
1075 0619 cjne a,PV,jo
1076 061C sjmp tiga
1077 061E jo:
1078 061E subb a,PV
1079 0620 jnc dua ; JIKA PV KURANG DARI 0AAh MAKA SUHU
KUTRANGB DARI 30
1080 0622 tiga:
1082 0622 ;--------TIGA PULUHAN-------------
1084 0622 ;-----------PULUHAN---------------
1085 0622 MOV PULUHAN,#03H
1087 0625 ;-----------SATUAN----------------
1088 0625 MOV R0,#00h
1089 0627 MOV R1,#06
1090 0629 mov A,PV
1091 062B cjne A,#0ffh,loop
1092 062E sjmp ffo
1094 0630 dua: ; SUBB RUTINE UNTUK ANGKA DUA PULUHAN
1095 0630 ; -------DUA PULUHAN--------------
1097 0630 ;|---------PULUHAN----------------|
1098 0630 MOV PULUHAN,#02H
1100 0633 ;-----------SATUAN----------------
1101 0633 MOV R0,#04h ; NILAI SUHU PERTAMA ADALAH 24 JADI
SATUANNYA ADALAH 4
1102 0635 MOV R1,#00H ; ALAMAT AWAL UNTUK DATA ANGKA 2
1103 0637 loop:
1104 0637 MOV A,R1
1105 0638 MOV DPTR,#TABEL_PENAMPIL2
1106 063B MOVC A,@A+DPTR
1107 063C mov r2,a ; DATA INI DISIMPAN UNTUK MENETUKAN
1108 063D subb a,PV ; NILAI SEPERSEPULUH
1109 063F jnc loop1 ; LANSUNG CARI NOURUT
1110 0641 inc r1
1111 0642 inc r0
1112 0643 mov a,R1
1113 0644 sjmp loop
1114 0646 loop1:
1115 0646 mov SATUAN,r0
1116 0648 ;-------------------
1117 0648 ;----SEPERSEPULUH--- ; NILAI UNTUK SEPERSEPULUH
DIDAPAT DARI TABEL
1118 0648 MOV R3,#26 ; NILAI ALAMAT PALING BELAKANG
1119 064A GO1:
1120 064A MOV A,R2 ; NILAI R2 ADALAH NILAI URUT MAKSIMAL
SATUAN
1121 064B CJNE A,PV,go
1122 064E MOV DPTR,#TABEL_PENAMPIL1
1123 0651 MOV A,R3
1124 0652 MOVC A,@A+DPTR
1125 0653 MOV SEPULUH,A
1126 0655 JMP TAMPILKAN
1127 0658 go:
1128 0658 DEC R3
1129 0659 DEC R2
1130 065A JMP GO1
1131 065D ffo: mov SEPULUH,#00H
1132 0660 mov SATUAN,#04H
1133 0663 ;----------------------selesae-----
1135 0663
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
1137 0663 ;7 ------------------------tampilan---------------------------
------------
1139 0663 TAMPILKAN:
1140 0663 ;untuk trasfer data ke seven segment
1141 0663 lagi:
1142 0663 clr p1.4
1143 0665 clr p1.5
1144 0667 clr p1.6
1145 0669 mov r5,#05h ;harusnya 5 juga cukup
1146 066B again1:
1147 066B mov r7,#0ffh
1148 066D again:
1150 066D ;--penampilan puluhan-----------
1151 066D mov a,p1
1152 066F mov REG_TAMP,PULUHAN
1153 0672 mov r0,#REG_TAMP
1154 0674 xchd a,@r0
1155 0675 MOV P1,A
1156 0677 clr p1.6
1157 0679 setb p1.4
1158 067B acall lay
1159 067D ;-------------------------------
1160 067D ;----penampilan satuan----------
1161 067D mov a,p1
1162 067F mov REG_TAMP,SATUAN
1163 0682 mov r0,#REG_TAMP
1164 0684 xchd a,@r0
1165 0685 MOV P1,A
1166 0687 clr p1.4
1167 0689 setb p1.5
1168 068B acall lay
1169 068D ;------------------------------
1170 068D ;----penampilan sepersepuluan--
1171 068D mov a,p1
1172 068F mov REG_TAMP,SEPULUH
1173 0692 mov r0,#REG_TAMP
1174 0694 xchd a,@r0
1175 0695 MOV P1,A
1176 0697 clr p1.5
1177 0699 setb p1.6
1178 069B acall lay
1179 069D djnz r7,again
1180 069F djnz r5,again1
1181 06A1 ;------------------------------
1182 06A1 DJNZ R6,TAMPILKAN
1183 06A3 RET
1186 06A4 ;&&&&&&&&&&&&&&&&&&& DELAY SUBRUTINE
&&&&&&&&&&&&&&&&&&&&&&&&&&
1187 06A4 delay_bentar: ;$$$
1188 06A4 mov r7,#90 ;$$$
1189 06A6 tunda_b: ;$$$
1190 06A6 mov r6,#100 ;$$$
1191 06A8 again_b: ;$$$
1192 06A8 mov r5,#20 ;$$$
1193 06AA djnz r5,$ ;$$$
1194 06AC djnz r6,again_b ;$$$
1195 06AE djnz r7,tunda_b ;$$$
1196 06B0 RET ;$$$
1197 06B1
;==========================================================;$$$

1198 06B1 lay: ;$$$


1199 06B1 mov r3,#0ffh ;$$$
1200 06B3 djnz r3,$ ;$$$
1201 06B5 ret ;$$$
1202 06B6
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
1207 06B6 ;|----------------------------|@|<<<<<<$$>>>>>>|@|------------
--------------------|
1208 06B6 ;|@@@@@@@@@@@@@@@@@@@@@@@@@@@ |@|END OF PROGRAM|@|
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
1209 06B6 ;|----------------------------|@|<<<<<<$$>>>>>>|@|------------
--------------------|
1214 06B6
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$
1215 06B6
;$$$$$$$$$$$$$$$$$$>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>$$$$$$$$$$$$$$$$
$$$$
1216 06B6 ;$$$$$$$$$$>>>>>>---->>>>>>TABEL DATA BASE>>>>>----
>>>>>>>>>>$$$$$$$$$$
1217 06B6
;$$$$$$$$$$$$$$$$$$>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>$$$$$$$$$$$$$$$$
$$$$
1218 06B6
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$
1221 06B6 ORG 1C01H
1222 1C01 TABEL_ZERRO:
1224 1C01 DB
0FFH,0F6H,0F0H,0EAH,0E4H,0DEH,0D8H,0D2H,0CCH,0C6H,0C0H,0BAH,0B4H,0A
EH,0A8H,0A2H
1225 1C11 DB
09CH,096H,090H,08AH,084H,082H,07EH,078H,072H,06CH,066H,060H,05AH,05
4H,04EH,048H
1226 1C21 DB 042H,03CH,036H,030H,02AH,024H,01EH,018H,012H,00CH,000H
1227 1C2C ;------------------------------------------------------------
----------------------
1229 1C2C ORG 1D00H
1230 1D00 TABEL_SMALL:
1232 1D00 DB
000H,003H,006H,009H,00CH,00FH,012H,015H,018H,01BH,01EH,021H,024H,02
7H,02AH,02DH ;1
1233 1D10 DB
030H,033H,036H,039H,03CH,03FH,042H,045H,048H,04BH,04EH,051H,054H,05
7H,05AH,05DH ;2
1234 1D20 DB
060H,063H,066H,069H,06CH,06FH,072H,075H,078H,07BH,07EH,081H,084H,08
7H,08AH,08DH ;3
1235 1D30 DB
090H,093H,096H,099H,09CH,09FH,0A2H,0A5H,0A8H,0ABH,0AEH,0B1H,0B4H,0B
7H,0BAH,0BDH ;4
1236 1D40 DB
0C0H,0C3H,0C6H,0C9H,0CCH,0CFH,0D2H,0D5H,0D8H,0DBH,0DEH,0E1H,0E4H,0E
7H,0EAH,0EDH ;5
1237 1D50 DB
0F0H,0F3H,0F6H,0F9H,0FCH,0FFH,0FCH,0F9H,0F6H,0F3H,0F0H,0EDH,0EAH,0E
7H,0E4H,0E1H ;6
1238 1D60 DB
0DEH,0DBH,0D8H,0D5H,0D2H,0CFH,0CCH,0C9H,0C6H,0C3H,0C0H,0BDH,0BAH,0B
7H,0B4H,0B1H ;7
1239 1D70 DB
0AEH,0ABH,0A8H,0A5H,0A2H,09FH,09CH,099H,096H,093H,090H,08DH,08AH,08
7H,084H,081H ;8
1240 1D80 DB
07EH,07BH,078H,075H,072H,06FH,06CH,069H,066H,063H,060H,05DH,05AH,05
7H,054H,051H ;9
1241 1D90 DB
04EH,04BH,048H,045H,042H,03FH,03CH,039H,036H,033H,030H,02DH,02AH,02
7H,024H,021H ;10
1242 1DA0 DB 01EH,01BH,018H,015H,012H,00FH,00CH,009H,006H,003H,000H
;11
1243 1DAB ;-------------------------------------------------------------
-------------------------
1245 1DAB ORG 1E00H
1246 1E00 TABEL_BIG:
1248 1E00 DB
000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,00
0H,000H,000H
1249 1E10 DB
000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,00
0H,000H,000H
1250 1E20 DB
000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,00
0H,000H,000H
1251 1E30 DB
000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,00
0H,000H,000H
1252 1E40 DB
000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,00
0H,000H,000H
1253 1E50 DB 000H,000H,000H,000H,000H
1254 1E55 DB
000H,003H,006H,009H,00CH,00FH,012H,015H,018H,01BH,01EH,021H,024H,02
7H,02AH,02DH ;1
1255 1E65 DB
030H,033H,036H,039H,03CH,03FH,042H,045H,048H,04BH,04EH,051H,054H,05
7H,05AH,05DH ;2
1256 1E75 DB
060H,063H,066H,069H,06CH,06FH,072H,075H,078H,07BH,07EH,081H,084H,08
7H,08AH,08DH ;3
1257 1E85 DB
090H,093H,096H,099H,09CH,09FH,0A2H,0A5H,0A8H,0ABH,0AEH,0B1H,0B4H,0B
7H,0BAH,0BDH ;4
1258 1E95 DB
0C0H,0C3H,0C6H,0C9H,0CCH,0CFH,0D2H,0D5H,0D8H,0DBH,0DEH,0E1H,0E4H,0E
7H,0EAH,0EDH ;5
1259 1EA5 DB
0F0H,0F3H,0F6H,0F9H,0FCH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0F
FH,0FFH,0FFH ;6
1260 1EB5 DB
0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0F
FH,0FFH,0FFH ;7
1261 1EC5 DB
0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0F
FH,0FFH,0FFH ;8
1262 1ED5 DB
0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0F
FH,0FFH,0FFH ;9
1263 1EE5 DB
0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0F
FH,0FFH,0FFH ;10 DB
0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0F
FH,0FFH,0FFH
1264 1EF5 DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
;11
1265 1F00 ;-------------------------------------------------------------
--------------------------
1267 1F00 ORG 1F00h
1268 1F00 TABEL_PENAMPIL1:
1270 1F00 DB
000H,000H,000H,001H,001H,001H,002H,002H,003H,003H,003H,004H,004H,005H,005
H,005H,006H,006H
1271 1F12 DB 007H,007H,007H,008H,008H,008H,009H,009H
1272 1F1A ;-------------------------------------------------------------
---------------------------
1274 1F1A ORG 1F30h
1275 1F30 TABEL_PENAMPIL2:
1277 1F30 DB 019H,033H,04CH,066H,07FH,099H,0B3H,0CBH,0E5H,0FEH,0FFH
1278 1F3B ;--------------------------------------------------------------
---------------------------
Unit: mm

24.50
25.40 Max
20 11

7.00 Max
6.30
1
10
0.89 1.30

1.27 Max 7.62

2.54 Min 5.08 Max


0.51 Min
+ 0.11
0.25 – 0.05
2.54 ± 0.25 0.48 ± 0.10
0° – 15°
Hitachi Code DP-20N
JEDEC —
EIAJ Conforms
Weight (reference value) 1.26 g
Unit: mm
12.6
13 Max

20 11

5.5
1 10
7.80 +– 0.30
0.20

*0.22 ± 0.05
0.20 ± 0.04
2.20 Max
0.80 Max 1.15

0° – 8°
1.27 0.10 ± 0.10 0.70 ± 0.20

*0.42 ± 0.08
0.40 ± 0.06
0.15

0.12 M
Hitachi Code FP-20DA
JEDEC —
*Dimension including the plating thickness EIAJ Conforms
Base material dimension Weight (reference value) 0.31 g
Unit: mm
12.8
13.2 Max

20 11

7.50
1 10
10.40 +– 0.40
0.25

2.65 Max

*0.27 ± 0.05
0.25 ± 0.04
0.935 Max 1.45

0° – 8°
0.20 ± 0.10
1.27 0.70 +– 0.30
0.57

*0.42 ± 0.08
0.40 ± 0.06
0.15

0.12 M Hitachi Code FP-20DB


JEDEC Conforms
*Dimension including the plating thickness EIAJ —
Base material dimension Weight (reference value) 0.52 g
Cautions

1. Hitachi neither warrants nor grants licenses of any rights of Hitachi’s or any third party’s patent,
copyright, trademark, or other intellectual property rights for information contained in this document.
Hitachi bears no responsibility for problems that may arise with third party’s rights, including
intellectual property rights, in connection with use of the information contained in this document.
2. Products and product specifications may be subject to change without notice. Confirm that you have
received the latest product standards or specifications before final design, purchase or use.
3. Hitachi makes every attempt to ensure that its products are of high quality and reliability. However,
contact Hitachi’s sales office before using the product in an application that demands especially high
quality and reliability or where its failure or malfunction may directly threaten human life or cause risk
of bodily injury, such as aerospace, aeronautics, nuclear power, combustion control, transportation,
traffic, safety equipment or medical equipment for life support.
4. Design your application so that the product is used within the ranges guaranteed by Hitachi particularly
for maximum rating, operating supply voltage range, heat radiation characteristics, installation
conditions and other characteristics. Hitachi bears no responsibility for failure or damage when used
beyond the guaranteed ranges. Even within the guaranteed ranges, consider normally foreseeable
failure rates or failure modes in semiconductor devices and employ systemic measures such as fail-
safes, so that the equipment incorporating Hitachi product does not cause bodily injury, fire or other
consequential damage due to operation of the Hitachi product.
5. This product is not designed to be radiation resistant.
6. No one is permitted to reproduce or duplicate, in any form, the whole or part of this document without
written approval from Hitachi.
7. Contact Hitachi’s sales office for any questions regarding this document or Hitachi semiconductor
products.

Hitachi, Ltd.
Semiconductor & Integrated Circuits.
Nippon Bldg., 2-6-2, Ohte-machi, Chiyoda-ku, Tokyo 100-0004, Japan
Tel: Tokyo (03) 3270-2111 Fax: (03) 3270-5109
URL NorthAmerica : http:semiconductor.hitachi.com/
Europe : http://www.hitachi-eu.com/hel/ecg
Asia (Singapore) : http://www.has.hitachi.com.sg/grp3/sicd/index.htm
Asia (Taiwan) : http://www.hitachi.com.tw/E/Product/SICD_Frame.htm
Asia (HongKong) : http://www.hitachi.com.hk/eng/bo/grp3/index.htm
Japan : http://www.hitachi.co.jp/Sicd/indx.htm
For further information write to:
Hitachi Semiconductor Hitachi Europe GmbH Hitachi Asia Pte. Ltd. Hitachi Asia (Hong Kong) Ltd.
(America) Inc. Electronic components Group 16 Collyer Quay #20-00 Group III (Electronic Components)
179 East Tasman Drive, Dornacher Stra§e 3 Hitachi Tower 7/F., North Tower, World Finance Centre,
San Jose,CA 95134 D-85622 Feldkirchen, Munich Singapore 049318 Harbour City, Canton Road, Tsim Sha Tsui,
Tel: <1> (408) 433-1990 Germany Tel: 535-2100 Kowloon, Hong Kong
Fax: <1>(408) 433-0223 Tel: <49> (89) 9 9180-0 Fax: 535-1533 Tel: <852> (2) 735 9218
Fax: <49> (89) 9 29 30 00 Fax: <852> (2) 730 0281
Hitachi Europe Ltd. Hitachi Asia Ltd. Telex: 40815 HITEC HX
Electronic Components Group. Taipei Branch Office
Whitebrook Park 3F, Hung Kuo Building. No.167,
Lower Cookham Road Tun-Hwa North Road, Taipei (105)
Maidenhead Tel: <886> (2) 2718-3666
Berkshire SL6 8YA, United Kingdom Fax: <886> (2) 2718-8180
Tel: <44> (1628) 585000
Fax: <44> (1628) 778322
Copyright ' Hitachi, Ltd., 1999. All rights reserved. Printed in Japan.
DM74LS47 BCD to 7-Segment Decoder/Driver with Open-Collector Outputs
October 1988
Revised March 2000

DM74LS47
BCD to 7-Segment Decoder/Driver with
Open-Collector Outputs
General Description Features
The DM74LS47 accepts four lines of BCD (8421) input ■ Open-collector outputs
data, generates their complements internally and decodes ■ Drive indicator segments directly
the data with seven AND/OR gates having open-collector
■ Cascadable zero-suppression capability
outputs to drive indicator segments directly. Each segment
output is guaranteed to sink 24 mA in the ON (LOW) state ■ Lamp test input
and withstand 15V in the OFF (HIGH) state with a maxi-
mum leakage current of 250 µA. Auxiliary inputs provided
blanking, lamp test and cascadable zero-suppression func-
tions.

Ordering Code:
Order Number Package Number Package Description
DM74LS47M M16A 16-Lead Small Outline Integrated Circuit (SOIC), JEDEC MS-012, 0.150 Narrow
DM74LS47N N16E 16-Lead Plastic Dual-In-Line Package (PDIP), JEDEC MS-001, 0.300 Wide
Devices also available in Tape and Reel. Specify by appending the suffix letter “X” to the ordering code.

Logic Symbol Connection Diagram

VCC = Pin 16
GND = Pin 8

Pin Descriptions
Pin Names Description
A0–A3 BCD Inputs
RBI Ripple Blanking Input (Active LOW)
LT Lamp Test Input (Active LOW)
BI/RBO Blanking Input (Active LOW) or
Ripple Blanking Output (Active LOW)
a –g Segment Outputs (Active LOW) (Note 1)
Note 1: OC—Open Collector

© 2000 Fairchild Semiconductor Corporation DS009817 www.fairchildsemi.com


DM74LS47
Truth Table
Decimal
Inputs Outputs
or Note
Function LT RBI A3 A2 A1 A0 BI/RBO a b c d e f g
0 H H L L L L H L L L L L L H (Note 2)
1 H X L L L H H H L L H H H H (Note 2)
2 H X L L H L H L L H L L H L
3 H X L L H H H L L L L H H L

4 H X L H L L H H L L H H L L
5 H X L H L H H L H L L H L L
6 H X L H H L H H H L L L L L
7 H X L H H H H L L L H H H H
8 H X H L L L H L L L L L L L

9 H X H L L H H L L L H H L L
10 H X H L H L H H H H L L H L
11 H X H L H H H H H L L H H L
12 H X H H L L H H L H H H L L
13 H X H H L H H L H H L H L L

14 H X H H H L H H H H L L L L
15 H X H H H H H H H H H H H H
BI X X X X X X L H H H H H H H (Note 3)
RBI H L L L L L L H H H H H H H (Note 4)
LT L X X X X X H L L L L L L L (Note 5)
Note 2: BI/RBO is wire-AND logic serving as blanking input (BI) and/or ripple-blanking output (RBO). The blanking out (BI) must be open or held at a HIGH
level when output functions 0 through 15 are desired, and ripple-blanking input (RBI) must be open or at a HIGH level if blanking or a decimal 0 is not
desired. X = input may be HIGH or LOW.
Note 3: When a LOW level is applied to the blanking input (forced condition) all segment outputs go to a HIGH level regardless of the state of any other input
condition.
Note 4: When ripple-blanking input (RBI) and inputs A0, A1, A2 and A3 are LOW level, with the lamp test input at HIGH level, all segment outputs go to a
HIGH level and the ripple-blanking output (RBO) goes to a LOW level (response condition).
Note 5: When the blanking input/ripple-blanking output (BI/RBO) is OPEN or held at a HIGH level, and a LOW level is applied to lamp test input, all segment
outputs go to a LOW level.

Functional Description
The DM74LS47 decodes the input data in the pattern indi- intermediate decoder from an OR gate whose inputs are
cated in the Truth Table and the segment identification BI/RBO of the next highest and lowest order decoders. BI/
illustration. If the input data is decimal zero, a LOW signal RBO also serves as an unconditional blanking input. The
applied to the RBI blanks the display and causes a multi- internal NAND gate that generates the RBO signal has a
digit display. For example, by grounding the RBI of the resistive pull-up, as opposed to a totem pole, and thus BI/
highest order decoder and connecting its BI/RBO to RBI of RBO can be forced LOW by external means, using wired-
the next lowest order decoder, etc., leading zeros will be collector logic. A LOW signal thus applied to BI/RBO turns
suppressed. Similarly, by grounding RBI of the lowest order off all segment outputs. This blanking feature can be used
decoder and connecting its BI/RBO to RBI of the next high- to control display intensity by varying the duty cycle of the
est order decoder, etc., trailing zeros will be suppressed. blanking signal. A LOW signal applied to LT turns on all
Leading and trailing zeros can be suppressed simulta- segment outputs, provided that BI/RBO is not forced LOW.
neously by using external gates, i.e.: by driving RBI of a

www.fairchildsemi.com 2
DM74LS47
Logic Diagram

Numerical Designations—Resultant Displays

3 www.fairchildsemi.com
DM74LS47
Absolute Maximum Ratings(Note 6)
Note 6: The “Absolute Maximum Ratings” are those values beyond which
Supply Voltage 7V the safety of the device cannot be guaranteed. The device should not be
operated at these limits. The parametric values defined in the Electrical
Input Voltage 7V Characteristics tables are not guaranteed at the absolute maximum ratings.
Operating Free Air Temperature Range 0°C to +70°C The “Recommended Operating Conditions” table will define the conditions
for actual device operation.
Storage Temperature Range −65°C to +150°C

Recommended Operating Conditions


Symbol Parameter Min Nom Max Units
VCC Supply Voltage 4.75 5 5.25 V
VIH HIGH Level Input Voltage 2 V
VIL LOW Level Input Voltage 0.8 V
IOH HIGH Level Output Current
−250 µA
a − g @ 15V = VOH (Note 7)
IOH HIGH Level Output Current BI /RBO −50 µA
IOL LOW Level Output Current 24 mA
TA Free Air Operating Temperature 0 70 °C
Note 7: OFF-State at a–g.

Electrical Characteristics
Over recommended operating free air temperature range (unless otherwise noted)
Typ
Symbol Parameter Conditions Min Max Units
(Note 8)
VI Input Clamp Voltage VCC = Min, II = −18 mA −1.5 V
VOH HIGH Level VCC = Min, IOH = Max,
2.7 3.4 V
Output Voltage VIL = Max, BI /RBO
IOFF Output HIGH Current Segment Outputs VCC = 5.5V, VO = 15V a − g 250 µA
VOL LOW Level VCC = Min, IOL = Max,
0.35 0.5
Output Voltage VIH = Min, a − g
IOL = 3.2 mA, BI /RBO 0.5 V
IOL = 12 mA, a –g 0.25 0.4
IOL = 1.6 mA, BI /RBO 0.4
II Input Current @ Max VCC = Max, VI = 7V
100 µA
Input Voltage VCC = Max, VI = 10V
IIH HIGH Level Input Current VCC = Max, VI = 2.7V 20 µA
IIL LOW Level Input Current VCC = Max, VI = 0.4V −0.4 mA
IOS Short Circuit VCC = Max (Note 9),
mA
Output Current IOS at BI/RBO −0.3 −2.0
ICC Supply Current VCC = Max 13 mA
Note 8: All typicals are at VCC = 5V, TA = 25°C.
Note 9: Not more than one output should be shorted at a time, and the duration should not exceed one second.

Switching Characteristics
at VCC = +5.0V, TA = +25°C
RL = 665Ω
Symbol Parameter Conditions CL = 15 pF Units
Min Max
tPLH Propagation Delay 100
ns
tPHL An to a –g 100
tPLH Propagation Delay 100
ns
tPHL RBI to a –g (Note 10) 100

Note 10: LT = HIGH, A0–A3 = LOW

www.fairchildsemi.com 4
DM74LS47
Physical Dimensions inches (millimeters) unless otherwise noted

16-Lead Small Outline Integrated Circuit (SOIC), JEDEC MS-012, 0.150 Narrow
Package Number M16A

5 www.fairchildsemi.com
DM74LS47 BCD to 7-Segment Decoder/Driver with Open-Collector Outputs
Physical Dimensions inches (millimeters) unless otherwise noted (Continued)

16-Lead Plastic Dual-In-Line Package (PDIP), JEDEC MS-001, 0.300 Wide


Package Number N16E

Fairchild does not assume any responsibility for use of any circuitry described, no circuit patent licenses are implied and
Fairchild reserves the right at any time without notice to change said circuitry and specifications.
LIFE SUPPORT POLICY

FAIRCHILD’S PRODUCTS ARE NOT AUTHORIZED FOR USE AS CRITICAL COMPONENTS IN LIFE SUPPORT
DEVICES OR SYSTEMS WITHOUT THE EXPRESS WRITTEN APPROVAL OF THE PRESIDENT OF FAIRCHILD
SEMICONDUCTOR CORPORATION. As used herein:
1. Life support devices or systems are devices or systems 2. A critical component in any component of a life support
which, (a) are intended for surgical implant into the device or system whose failure to perform can be rea-
body, or (b) support or sustain life, and (c) whose failure sonably expected to cause the failure of the life support
to perform when properly used in accordance with device or system, or to affect its safety or effectiveness.
instructions for use provided in the labeling, can be rea-
sonably expected to result in a significant injury to the www.fairchildsemi.com
user.

www.fairchildsemi.com 6
INTEGRATED CIRCUITS

ADC0803/0804
CMOS 8-bit A/D converters

Product data 2002 Oct 17


Supersedes data of 2001 Aug 03





Philips Semiconductors Product data

CMOS 8-bit A/D converters ADC0803/0804

DESCRIPTION PIN CONFIGURATION


The ADC0803 family is a series of three CMOS 8-bit successive
approximation A/D converters using a resistive ladder and D, N PACKAGES
capacitive array together with an auto-zero comparator. These
CS 1 20 VCC
converters are designed to operate with microprocessor-controlled
buses using a minimum of external circuitry. The 3-State output data RD 2 19 CLK R
lines can be connected directly to the data bus. WR 3 18 D0

The differential analog voltage input allows for increased CLK IN 4 17 D1


common-mode rejection and provides a means to adjust the INTR 5 16 D2
zero-scale offset. Additionally, the voltage reference input provides a
VIN(+) 6 15 D3
means of encoding small analog voltages to the full 8 bits of
resolution. VIN(–) 7 14 D4

A GND 8 13 D5

VREF/2 9 12 D6
FEATURES
D GND 10 11 D7
• Compatible with most microprocessors
• Differential inputs TOP VIEW

• 3-State outputs SL00016

• Logic levels TTL and MOS compatible Figure 1. Pin configuration

• Can be used with internal or external clock


• Analog input range 0 V to VCC APPLICATIONS
• Transducer-to-microprocessor interface
• Single 5 V supply
• Digital thermometer
• Guaranteed specification with 1 MHz clock
• Digitally-controlled thermostat
• Microprocessor-based monitoring and control systems

ORDERING INFORMATION
TEMPERATURE
DESCRIPTION ORDER CODE TOPSIDE MARKING DWG #
RANGE
20-pin plastic small outline (SO) package 0 to 70 °C ADC0803CD, ADC0804CD ADC0803-1CD, ADC0804-1CD SOT163-1
20-pin plastic small outline (SO) package –40 to 85 °C ADC0803LCD, ADC0804LCD ADC0803-1LCD, ADC0804-1LCD SOT163-1
20-pin plastic dual in-line package (DIP) 0 to 70 °C ADC0803CN, ADC0804CN ADC0803-1CN, ADC0804-1CN SOT146-1
20-pin plastic dual in-line package (DIP) –40 to +85 °C ADC0803LCN, ADC0804LCN ADC0803-1LCN, ADC0804-1LCN SOT146-1

ABSOLUTE MAXIMUM RATINGS


SYMBOL PARAMETER CONDITIONS RATING UNIT
VCC Supply voltage 6.5 V
Logic control input voltages –0.3 to +16 V
All other input voltages –0.3 to (VCC +0.3) V
Tamb Operating temperature range
ADC0803LCD/ADC0804LCD –40 to +85 °C
ADC0803LCN/ADC0804LCN –40 to +85 °C
ADC0803CD/ADC0804CD 0 to +70 °C
ADC0803CN/ADC0804CN 0 to +70 °C
Tstg Storage temperature –65 to +150 °C
Tsld Lead soldering temperature (10 seconds) 230 °C
PD Maximum power dissipation1 Tamb = 25 °C (still air)
N package 1690 mW
D package 1390 mW
NOTE:
1. Derate above 25 °C, at the following rates: N package at 13.5 mW/°C; D package at 11.1 mW/°C.

2002 Oct 17 2
Philips Semiconductors Product data

CMOS 8-bit A/D converters ADC0803/0804

BLOCK DIAGRAM
VIN (+) VIN (–)
6 7

+ –

M
9 +
VREF/2
LADDER AND AUTO ZERO
DECODER COMPARATOR
8
A GND

20 D7 (MSB) (11)
VCC
D6 (12)
D5 (13)
OUTPUT D4 (14)
LATCHES D3 (15)
D2 (16)
SAR
D1 (17)
D0 (LSB) (18)
10
D GND
LE OE

3
WR 8–BIT CLOCK
SHIFT REGISTER

1
CS
S

INTR
FF
R Q
2
RD

5 4 19

INTR CLK IN CLK R


SL00017

Figure 2. Block diagram

2002 Oct 17 3
Philips Semiconductors Product data

CMOS 8-bit A/D converters ADC0803/0804

DC ELECTRICAL CHARACTERISTICS
VCC = 5.0 V, fCLK = 1 MHz, Tmin ≤ Tamb ≤ Tmax, unless otherwise specified.
LIMITS
SYMBOL PARAMETER TEST CONDITIONS UNIT
Min Typ Max
ADC0803 relative accuracy error (adjusted) Full-Scale adjusted 0.50 LSB
ADC0804 relative accuracy error (unadjusted) VREF/2 = 2.500 VDC 1 LSB
RIN VREF/2 input resistance3 VCC = 0 V2 400 680 Ω
Analog input voltage range3 –0.05 VCC+0.05 V
DC common-mode error Over analog input voltage range 1/16 1/8 LSB
Power supply sensitivity VCC = 5V ±10%1 1/16 LSB
Control inputs
VIH Logical “1” input voltage VCC = 5.25 VDC 2.0 15 VDC
VIL Logical “0” input voltage VCC = 4.75 VDC 0.8 VDC
IIH Logical “1” input current VIN = 5 VDC 0.005 1 µADC
IIL Logical “0” input current VIN = 0 VDC –1 –0.005 µADC
Clock in and clock R
VT+ Clock in positive-going threshold voltage 2.7 3.1 3.5 VDC
VT– Clock in negative-going threshold voltage 1.5 1.8 2.1 VDC
VH Clock in hysteresis (VT+)–(VT–) 0.6 1.3 2.0 VDC
VOL Logical “0” clock R output voltage IOL = 360 µA, VCC = 4.75 VDC 0.4 VDC
VOH Logical “1” clock R output voltage IOH = –360 µA, VCC = 4.75 VDC 2.4 VDC
Data output and INTR
VOL Logical “0” output voltage
Data outputs IOL = 1.6 mA, VCC = 4.75 VDC 0.4 VDC
INTR outputs IOL = 1.0 mA, VCC = 4.75 VDC 0.4 VDC
IOH = –360 µA, VCC = 4.75 VDC 2.4
VOH
O Logical “1” output voltage VDC
C
IOH = –10 µA, VCC = 4.75 VDC 4.5
IOZL 3-State output leakage VOUT = 0 VDC, CS = logical “1” –3 µADC
IOZH 3-State output leakage VOUT = 5 VDC, CS = logical “1” 3 µADC
ISC +Output short-circuit current VOUT = 0 V, Tamb = 25 °C 4.5 12 mADC
ISC –Output short-circuit current VOUT = VCC, Tamb = 25 °C 9.0 30 mADC
fCLK = 1 MHz, VREF/2 = OPEN,
ICC Power supply current 3.0 3.5 mA
CS = Logical “1”, Tamb = 25 °C
NOTES:
1. Analog inputs must remain within the range: –0.05 ≤ VIN ≤ VCC + 0.05 V.
2. See typical performance characteristics for input resistance at VCC = 5 V.
3. VREF/2 and VIN must be applied after the VCC has been turned on to prevent the possibility of latching.

2002 Oct 17 4
Philips Semiconductors Product data

CMOS 8-bit A/D converters ADC0803/0804

AC ELECTRICAL CHARACTERISTICS
LIMITS
SYMBOL PARAMETER TO FROM TEST CONDITIONS UNIT
Min Typ Max
Conversion time fCLK = 1 MHz1 66 73 µs
fCLK Clock frequency1 0.1 1.0 3.0 MHz
Clock duty cycle1 40 60 %
CS = 0, fCLK = 1 MHz
CR Free-running conversion rate 13690 conv/s
INTR tied to WR
tW(WR)L Start pulse width CS = 0 30 ns
tACC Access time Output RD CS = 0, CL = 100 pF 75 100 ns
CL = 10 pF, RL = 10 kΩ
t1H, t0H 3-State control Output RD 70 100 ns
See 3-State test circuit
WD
tW1, tR1 INTR delay INTR 100 150 ns
or RD
CIN Logic input=capacitance 5 7.5 pF
COUT 3-State output capacitance 5 7.5 pF
NOTE:
1. Accuracy is guaranteed at fCLK = 1 MHz. Accuracy may degrade at higher clock frequencies.

FUNCTIONAL DESCRIPTION ANALOG OPERATION


These devices operate on the Successive Approximation principle.
Analog switches are closed sequentially by successive Analog Input Current
approximation logic until the input to the auto-zero comparator The analog comparisons are performed by a capacitive charge
[ VIN(+)–VIN(–) ] matches the voltage from the decoder. After all bits summing circuit. The input capacitor is switched between VIN(+)4
are tested and determined, the 8-bit binary code corresponding to and VIN(–), while reference capacitors are switched between taps on
the input voltage is transferred to an output latch. Conversion begins the reference voltage divider string. The net charge corresponds to
with the arrival of a pulse at the WR input if the CS input is low. On the weighted difference between the input and the most recent total
the High-to-Low transition of the signal at the WR or the CS input, value set by the successive approximation register.
the SAR is initialized, the shift register is reset, and the INTR output The internal switching action causes displacement currents to flow
is set high. The A/D will remain in the reset state as long as the CS at the analog inputs. The voltage on the on-chip capacitance is
and WR inputs remain low. Conversion will start from one to eight switched through the analog differential input voltage, resulting in
clock periods after one or both of these inputs makes a Low-to-High proportional currents entering the VIN(+) input and leaving the VIN(–)
transition. After the conversion is complete, the INTR pin will make a input. These transient currents occur at the leading edge of the
High-to-Low transition. This can be used to interrupt a processor, or internal clock pulses. They decay rapidly so do not inherently cause
otherwise signal the availability of a new conversion result. A read errors as the on-chip comparator is strobed at the end of the clock
(RD) operation (with CS low) will clear the INTR line and enable the period.
output latches. The device may be run in the free-running mode as
described later. A conversion in progress can be interrupted by Input Bypass Capacitors and Source Resistance
issuing another start command. Bypass capacitors at the input will average the charges mentioned
above, causing a DC and an AC current to flow through the output
Digital Control Inputs resistance of the analog signal sources. This charge pumping action
The digital control inputs (CS, WR, RD) are compatible with is worse for continuous conversions with the VIN(+) input at full
standard TTL logic voltage levels. The required signals at these scale. This current can be a few microamps, so bypass capacitors
inputs correspond to Chip Select, START Conversion, and Output should NOT be used at the analog inputs of the VREF/2 input for
Enable control signals, respectively. They are active-Low for easy high resistance sources (> 1 kΩ). If input bypass capacitors are
interface to microprocessor and microcontroller control buses. For desired for noise filtering and a high source resistance is desired to
applications not using microprocessors, the CS input (Pin 1) can be minimize capacitor size, detrimental effects of the voltage drop
grounded and the A/D START function is achieved by a across the input resistance can be eliminated by adjusting the full
negative-going pulse to the WR input (Pin 3). The Output Enable scale with both the input resistance and the input bypass capacitor
function is achieved by a logic low signal at the RD input (Pin 2), in place. This is possible because the magnitude of the input current
which may be grounded to constantly have the latest conversion is a precise linear function of the differential voltage.
present at the output.

2002 Oct 17 5
Philips Semiconductors Product data

CMOS 8-bit A/D converters ADC0803/0804

Large values of source resistance where an input bypass capacitor Reference Voltage Span Adjust
is not used will not cause errors as the input currents settle out prior Note that the Pin 9 (VREF/2) voltage is either 1/2 the voltage applied
to the comparison time. If a low pass filter is required in the system, to the VCC supply pin, or is equal to the voltage which is externally
use a low valued series resistor (< 1 kΩ) for a passive RC section or forced at the VREF/2 pin. In addition to allowing for flexible
add an op amp active filter (low pass). For applications with source references and full span voltages, this also allows for a ratiometric
resistances at or below 1 kΩ, a 0.1 µF bypass capacitor at the inputs voltage reference. The internal gain of the VREF/2 input is 2, making
will prevent pickup due to series lead inductance or a long wire. A the full-scale differential input voltage twice the voltage at Pin 9.
100 Ω series resistor can be used to isolate this capacitor (both the
For example, a dynamic voltage range of the analog input voltage
resistor and capacitor should be placed out of the feedback loop)
that extends from 0 to 4 V gives a span of 4 V (4–0), so the VREF/2
from the output of the op amp, if used.
voltage can be made equal to 2 V (half of the 4 V span) and full
Analog Differential Voltage Inputs and scale output would correspond to 4 V at the input.
Common-Mode Rejection On the other hand, if the dynamic input voltage had a range of
These A/D converters have additional flexibility due to the analog 0.5 to 3.5 V, the span or dynamic input range is 3 V (3.5–0.5). To
differential voltage input. The VIN(–) input (Pin 7) can be used to encode this 3 V span with 0.5 V yielding a code of zero, the
subtract a fixed voltage from the input reading (tare correction). This minimum expected input (0.5 V, in this case) is applied to the VIN(–)
is also useful in a 4/20 mA current loop conversion. Common-mode pin to account for the offset, and the VREF/2 pin is set to 1/2 the 3 V
noise can also be reduced by the use of the differential input. span, or 1.5 V. The A/D converter will now encode the VIN(+) signal
between 0.5 and 3.5 V with 0.5 V at the input corresponding to a
The time interval between sampling VIN(+) and VIN(–) is 4.5 clock
code of zero and 3.5 V at the input producing a full scale output
periods. The maximum error due to this time difference is given by: code. The full 8 bits of resolution are thus applied over this reduced
V(max) = (VP) (2fCM) (4.5/fCLK), input voltage range. The required connections are shown in
Figure 7.
where:
V = error voltage due to sampling delay Operating Mode
These converters can be operated in two modes:
VP = peak value of common-mode voltage
1) absolute mode
fCM = common mode frequency 2) ratiometric mode
For example, with a 60 Hz common-mode frequency, fcm, and a In absolute mode applications, both the initial accuracy and the
1 MHz A/D clock, fCLK, keeping this error to 1/4 LSB (about 5 mV) temperature stability of the reference voltage are important factors in
would allow a common-mode voltage, VP, which is given by: the accuracy of the conversion. For VREF/2 voltages of 2.5 V, initial
errors of ±10 mV will cause conversion errors of ±1 LSB due to the
[V(max) (f CLK)
VP + gain of 2 at the VREF/2 input. In reduced span applications, the initial
(2f CM)(4.5) value and stability of the VREF/2 input voltage become even more
or important as the same error is a larger percentage of the VREF/2
nominal value. See Figure 8.
(5 x 10 *3) (10 4)
VP + + 2.95V In ratiometric converter applications, the magnitude of the reference
(6.28) (60) (4.5)
voltage is a factor in both the output of the source transducer and
The allowed range of analog input voltages usually places more the output of the A/D converter, and, therefore, cancels out in the
severe restrictions on input common-mode voltage levels than this, final digital code. See Figure 9.
however. Generally, the reference voltage will require an initial adjustment.
An analog input span less than the full 5 V capability of the device, Errors due to an improper reference voltage value appear as
together with a relatively large zero offset, can be easily handled by full-scale errors in the A/D transfer function.
use of the differential input. (See Reference Voltage Span Adjust).
ERRORS AND INPUT SPAN ADJUSTMENTS
Noise and Stray Pickup There are many sources of error in any data converter, some of
The leads of the analog inputs (Pins 6 and 7) should be kept as which can be adjusted out. Inherent errors, such as relative
short as possible to minimize input noise coupling and stray signal accuracy, cannot be eliminated, but such errors as full-scale and
pick-up. Both EMI and undesired digital signal coupling to these zero scale offset errors can be eliminated quite easily. See Figure 7.
inputs can cause system errors. The source resistance for these
inputs should generally be below 5 kΩ to help avoid undesired noise
Zero Scale Error
pickup. Input bypass capacitors at the analog inputs can create Zero scale error of an A/D is the difference of potential between the
errors as described previously. Full scale adjustment with any input ideal 1/2 LSB value (9.8 mV for VREF/2=2.500 V) and that input
voltage which just causes an output transition from code 0000 0000
bypass capacitors in place will eliminate these errors.
to a code of 0000 0001.
Reference Voltage If the minimum input value is not ground potential, a zero offset can
For application flexibility, these A/D converters have been designed be made. The converter can be made to output a digital code of
to accommodate fixed reference voltages of 5V to Pin 20 or 2.5 V to 0000 0000 for the minimum expected input voltage by biasing the
Pin 9, or an adjusted reference voltage at Pin 9. The reference can VIN(–) input to that minimum value expected at the VIN(–) input to
be set by forcing it at VREF/2 input, or can be determined by the that minimum value expected at the VIN(+) input. This uses the
supply voltage (Pin 20). Figure 6 indicates how this is accomplished. differential mode of the converter. Any offset adjustment should be
done prior to full scale adjustment.

2002 Oct 17 6
Philips Semiconductors Product data

CMOS 8-bit A/D converters ADC0803/0804

Full Scale Adjustment DRIVING THE DATA BUS


Full scale gain is adjusted by applying any desired offset voltage to This CMOS A/D converter, like MOS microprocessors and
VIN(–), then applying the VIN(+) a voltage that is 1-1/2 LSB less than memories, will require a bus driver when the total capacitance of the
the desired analog full-scale voltage range and then adjusting the data bus gets large. Other circuitry tied to the data bus will add to
magnitude of VREF/2 input voltage (or the VCC supply if there is no the total capacitive loading, even in the high impedance mode.
VREF/2 input connection) for a digital output code which just
There are alternatives in handling this problem. The capacitive
changes from 1111 1110 to 1111 1111. The ideal VIN(+) voltage for
loading of the data bus slows down the response time, although DC
this full-scale adjustment is given by:
specifications are still met. For systems with a relatively low CPU
V MAX * V MIN clock frequency, more time is available in which to establish proper
V IN()) + V IN(*) * 1.5 x
255 logic levels on the bus, allowing higher capacitive loads to be driven
(see Typical Performance Characteristics).
where:
At higher CPU clock frequencies, time can be extended for I/O
VMAX = high end of analog input range (ground referenced) reads (and/or writes) by inserting wait states (8880) or using
VMIN = low end (zero offset) of analog input (ground referenced) clock-extending circuits (6800, 8035).
Finally, if time is critical and capacitive loading is high, external bus
drivers must be used. These can be 3-State buffers (low power
CLOCKING OPTION Schottky is recommended, such as the N74LS240 series) or special
The clock signal for these A/Ds can be derived from external higher current drive products designed as bus drivers. High current
sources, such as a system clock, or self-clocking can be bipolar bus drivers with PNP inputs are recommended as the PNP
accomplished by adding an external resistor and capacitor, as input offers low loading of the A/D output, allowing better response
shown in Figure 11. time.
Heavy capacitive or DC loading of the CLK R pin should be avoided
POWER SUPPLIES
as this will disturb normal converter operation. Loads less than 50pF
Noise spikes on the VCC line can cause conversion errors as the
are allowed. This permits driving up to seven A/D converter CLK IN
internal comparator will respond to them. A low inductance filter
pins of this family from a single CLK R pin of one converter. For
capacitor should be used close to the converter VCC pin and values
larger loading of the clock line, a CMOS or low power TTL buffer or
of 1 µF or greater are recommended. A separate 5 V regulator for
PNP input logic should be used to minimize the loading on the CLK
the converter (and other 5 V linear circuitry) will greatly reduce
R pin.
digital noise on the VCC supply and the attendant problems.
Restart During a Conversion
WIRING AND LAYOUT PRECAUTIONS
A conversion in process can be halted and a new conversion began
Digital wire-wrap sockets and connections are not satisfactory for
by bringing the CS and WR inputs low and allowing at least one of
breadboarding this (or any) A/D converter. Sockets on PC boards
them to go high again. The output data latch is not updated if the
can be used. All logic signal wires and leads should be grouped or
conversion in progress is not completed; the data from the
kept as far as possible from the analog signal leads. Single wire
previously completed conversion will remain in the output data
analog input leads may pick up undesired hum and noise, requiring
latches until a subsequent conversion is completed.
the use of shielded leads to the analog inputs in many applications.
Continuous Conversion A single-point analog ground separate from the logic or digital
To provide continuous conversion of input data, the CS and RD ground points should be used. The power supply bypass capacitor
inputs are grounded and INTR output is tied to the WR input. This and the self-clocking capacitor, if used, should be returned to digital
INTR/WR connection should be momentarily forced to a logic low ground. Any VREF/2 bypass capacitor, analog input filter capacitors,
upon power-up to insure circuit operation. See Figure 10 for one and any input shielding should be returned to the analog ground
way to accomplish this. point. Proper grounding will minimize zero-scale errors which are
present in every code. Zero-scale errors can usually be traced to
improper board layout and wiring.

2002 Oct 17 7
Philips Semiconductors Product data

CMOS 8-bit A/D converters ADC0803/0804

APPLICATIONS the NE5521 data sheet for a complete description of the operation of
that part.
Microprocessor Interfacing
This family of A/D converters was designed for easy microprocessor Circuit Adjustment
interfacing. These converters can be memory mapped with To adjust the full scale and zero scale of the A/D, determine the range
appropriate memory address decoding for CS (read) input. The of voltages that the transducer interface output will take on. Set the
active-Low write pulse from the processor is then connected to the LVDT core for null and set the Zero Scale Scale Adjust Potentiometer
WR input of the A/D converter, while the processor active-Low read for a digital output from the A/D of 1000 000. Set the LVDT core for
pulse is fed to the converter RD input to read the converted data. If maximum voltage from the interface and set the Full Scale Adjust
the clock signal is derived from the microprocessor system clock, potentiometer so the A/D output is just barely 1111 1111.
the designer/programmer should be sure that there is no attempt to
A Digital Thermostat
read the converter until 74 converter clock pulses after the start
pulse goes high. Alternatively, the INTR pin may be used to interrupt Circuit Description
the processor to cause reading of the converted data. Of course, the The schematic of a Digital Thermostat is shown in Figure 16. The
converter can be connected and addressed as a peripheral (in I/O A/D digitizes the output of the LM35, a temperature transducer IC
space), as shown in Figure 12. A bus driver should be used as a with an output of 10 mV per °C. With VREF/2 set for 2.56 V, this
buffer to the A/D output in large microprocessor systems where the 10 mV corresponds to 1/2 LSB and the circuit resolution is 2 °C.
data leaves the PC board and/or must drive capacitive loads in Reducing VREF/2 to 1.28 yields a resolution of 1 °C. Of course, the
excess of 100 pF. See Figure 14. lower VREF/2 is, the more sensitive the A/D will be to noise.
Interfacing the SCN8048 microcomputer family is pretty simple, as The desired temperature is set by holding either of the set buttons
shown in Figure 13. Since the SCN8048 family has 24 I/O lines, one closed. The SCC80C451 programming could cause the desired
of these (shown here as bit 0 or port 1) can be used as the chip (set) temperature to be displayed while either button is depressed
select signal to the converter, eliminating the need for an address and for a short time after it is released. At other times the ambient
decoder. The RD and WR signals are generated by reading from temperature could be displayed.
and writing to a dummy address.
The set temperature is stored in an SCN8051 internal register. The
Digitizing a Transducer Interface Output A/D conversion is started by writing anything at all to the A/D with
port pin P10 set high. The desired temperature is compared with the
Circuit Description digitized actual temperature, and the heater is turned on or off by
Figure 15 shows an example of digitizing transducer interface output clearing setting port pin P12. If desired, another port pin could be
voltage. In this case, the transducer interface is the NE5521, an used to turn on or off an air conditioner.
LVDT (Linear Variable Differential Transformer) Signal Conditioner.
The diode at the A/D input is used to insure that the input to the A/D The display drivers are NE587s if common anode LED displays are
does not go excessively beyond the supply voltage of the A/D. See used. Of course, it is possible to interface to LCD displays as well.

2002 Oct 17 8
Philips Semiconductors Product data

CMOS 8-bit A/D converters ADC0803/0804

TYPICAL PERFORMANCE CHARACTERISTICS


Power Supply Current vs Clock Frequency vs Input Current vs
Temperature Clock Capacitor Applied Voltage at VREF/2 Pin
3.2 10.0 5
8.0 VCC = 5.0 V
POWER SUPPLY CURRENT (mA)

3.0 fCLK = 1 MHz 6.0 4 Tamb = 25 oC


CS = H 4.0 3
2.8

CLOCK FRQ (MHz)


2
2.0
MAX. 1

(mA)
2.6
5.5 V
1.0 0

REF/2
2.4 0.8
0.6 –1
5.0 V

f
0.4 –2
2.2 TYP.
–3
2.0 4.5 V 0.2
–4
MIN.
1.8 0.1 –5
–50 –25 0 25 50 75 100 125 10 20 40 60 80100 200 400 600 1000 0 1 2 3 4 5

AMBIENT TEMPERATURE (°C) CLOCK CAP (pF) APPLIED VREF/2 (V)

Logic Input Threshold CLK–IN Threshold Voltage vs Output Current vs


Voltage vs Supply Voltage Supply Voltage Temperature
4.5 18
–55 °C ≤ Tamb ≤ 125 °C
1.70 –55 °C VCC = 5.0 V
CLK–IN THRESHOLD VOLTAGE (V)

4.0
16

OUTPUT CURRENT (mA)


3.5
1.60 +25 °C VT+ 14
LOGIC INPUT (V)

3.0
+125 °C
12 VO = 2.5 V
1.50 2.5

VT 10
2.0
1.40 VO = 0.4 V
1.5 8

1.30 6
1.0
4.50 4.75 5.00 5.25 5.50 4.50 4.75 5.00 5.25 5.50 –50 –25 0 25 50 75 100 125

VCC SUPPLY VOLTAGE (V) VCC SUPPLY VOLTAGE (V) AMBIENT TEMPERATURE (oC)

Delay From RD Falling


Full Scale Error vs Edge to Data Valid vs
Conversion Time Load Capacitance
4 350
VCC = 5.0 V VCC = 5.0 V
300
VREF/2 = 2.5 V Tamb = 25 oC
3 250
ERROR (LSB)

200
DEALY (ns)

2
150

100
1
50

0 0
0 20 40 60 80 100 120 0 200 400 600 800 1000
CONVERSION TIME (µs) LOAD CAPACITANCE (pF) SL00018

Figure 3. Typical Performance Characteristics

2002 Oct 17 9
Philips Semiconductors Product data

CMOS 8-bit A/D converters ADC0803/0804

3-STATE TEST CIRCUITS AND WAVEFORMS (ADC0801-1)


20ns
VCC VCC VCC
tr tr
VCC VCC
90% 90%
RD 50% RD 50%
RD DATA
CS GND 10% 10 kΩ GND 10%
OUTPUT
t1H t0H
RD DATA
CL 10 kΩ VOH CS VOH
90% OUTPUT
10 pF DATA DATA
OUTPUT GND CL 10 pF OUTPUT GND 10%

t1H tOH
SL00019

Figure 4. 3-State Test Circuits and Waveforms (ADC0801-1)

TIMING DIAGRAMS (All timing is measured from the 50% voltage points)
START
CONVERSION
CS

WR

tWI
tW(WR)L

”BUSY”

DATA IS VALID IN
ACTUAL INTERNAL ”NOT BUSY” OUTPUT LATCHES
STATUS OF THE
CONVERTER 1 TO 8 X 1/fCLK INTERNAL TC
(LAST DATA WAS READ)
INTR
(LAST DATA WAS NOT READ) INT ASSERTED
1/2 TCLK

INTR INTR RESET

CS tRI

RD

NOTE

DATA THREE–STATE
OUTPUTS

tACC
t1H, t0H

Output Enable and Reset INTR


NOTE:
Read strobe must occur 8 clock periods (8/fCLK) after assertion of interrupt to guarantee reset of INTR. SL00020

Figure 5. Timing Diagrams

2002 Oct 17 10
Philips Semiconductors Product data

CMOS 8-bit A/D converters ADC0803/0804

VCC
(5V)
20 VREF VREF

VREF/2 9 –
330 Ω
TO VREF/2
FS
OFFSET + 0.1 µF
ADJUST
DIGITAL
CIRCUITS

ZS
R ANALOG OFFSET TO VIN(–)
CIRCUITS ADJUST

SL00022

Figure 7. Offsetting the Zero Scale and Adjusting the Input


Range (Span)
8 10

NOTE:
The VREF/2 voltage is either 1/2 the VCC voltage or is that which is forced at Pin 9.

SL00021

Figure 6. Internal Reference Design

+5V +5V
+5V
VCC
VIN(+) +
VCC
10 µF 2 kΩ
+
VIN(+) 10 µF A/D

2 kΩ 100 Ω
A/D
VREF/2

VREF/2 VOLTAGE VIN(–)


REFERENCE 2 kΩ 2 kΩ
VIN(–) VREF/2

a. Fixed Reference b. Fixed Reference Derived from VCC


c. Optional Full
Scale Adjustment

SL00023

Figure 8. Absolute Mode of Operation

2002 Oct 17 11
Philips Semiconductors Product data

CMOS 8-bit A/D converters ADC0803/0804

VCC

VIN(+) VCC
TRANSDUCER +
10µF
2 kΩ
A/D

VREF/2 FULL SCALE


VIN(–) OPTIONAL
100 Ω

2 kΩ

SL00024

Figure 9. Ratiometric Mode of Operation with Optional Full


Scale Adjustment

10k +5 V
+5 V
CS 1 20 VCC
RD 2 19 CLK R
WR 3 18 D0
DB0
10 kΩ 2.7 kΩ CLK IN 4 17 D1
DB1
INTR 5 16 D2
DB2
A/D
VIN(+) 6 15 D3
10 kΩ 47 µF TO DB3
VIN(–) 7 14 D4
100 µF DB4
56 pF A GND 8 13 D5
DB5
VREF/2 9 12 D6
DB6
D GND 10 11 D7
DB7

SL00025

Figure 10. Connection for Continuous Conversion

INT
CLK R 19 I/O WR
I/O RD
R
CLK IN 4 10 kΩ +5 V
CLK
C fCLK = 1/1.7 R C
R = 10 kΩ CS 1 20 VCC
A/D RD 2 19 CLK R
SL00026 WR 3 18 D0
DB0
17 D1
Figure 11. Self-Clocking the Converter CLK IN 4 DB1
INTR 5 16 D2
DB2
VIN(+) 6 A/D 15 D3
ANALOG DB3
VIN(–) 7 14 D4
INPUTS DB4
A GND 8 13 D5
DB5
56 pF VREF/2 9 12 D6
DB6
D GND 10 11 D7
DB7

ADDRESS
DECODE
LOGIC

SL00027

Figure 12. Interfacing to 8080A Microprocessor

2002 Oct 17 12
Philips Semiconductors Product data

CMOS 8-bit A/D converters ADC0803/0804

+5 V
18 D0
17 D1
16 D2
VCC VCC 8–BIT
40 20 15 D3
19 CLK R BUFFER DATA
1 P1.0 D0 18 14 D4 BUS
2 P1.1 D1 17 A/D 13 D5 N74LS241
3 P1.2 D2 16 10 kΩ N74LS244
12 D6
4 CLK IN N74LS541
4 P1.3 D3 15 11 D7
5 P1.4 D4 14 56 pF
6 P1.5 D5 13
SCN8051 7 P1.6 D6 12 OE
OR A/D
6 VIN(+)
SCN80C51 8 P1.7 D7 11 SL00029
ANALOG
INPUTS
17 RD RD 2 7 VREF/2 Figure 14. Buffering the A/D Output to Drive High Capacitance
16 WR WR 3
Loads and for Driving Off-Board Loads
12 INTO INTR 5 12 A GND
39 P0.0 CS 1 11 D GND

SL00028

Figure 13. SCN8051 Interfacing

+5 V

Ct

18 kΩ
4.7 kΩ
1.5 kΩ 820 Ω LVDT
NE5521

1µF

4.7 kΩ 0.47 µF 22 kΩ

+5 V
470 Ω
IN4148

VCC
VIN(+)

3.3 kΩ
2 kΩ
A/D

2 kΩ VIN(–) VREF/2 FULL SCALE


100 Ω ADJUST

2 kΩ

SL00030

Figure 15. Digitizing a Transducer Interface Output

2002 Oct 17 13
Philips Semiconductors Product data

CMOS 8-bit A/D converters ADC0803/0804

RBI 5
6
2
1 7
NE587
1/4 7
HEF4071
3 8

RBO 4
10 kΩ
RBI 5
6
2
1 7
NE587
1/4 7
HEF4071
3 8

10 kΩ
LOWER
13 14
P15
18 DB0 D0 18
+5 V
RAISE 17 DB1 D1 17
P16 20 VCC
16 DB2 D2 16
+
15 DB3 D3 15 10 µF
14 DB4 D4 14 19 CLK R

13 DB5 D5 13
SCC80C51 10 kΩ
12 DB6 D6 12 A/D
11 DB7 D7 11 4
CLK IN
56 pF
8 RD RD 2
10 WR WR 3
6 VIN(+)
6 INT INTR 5 LM35
7 VIN(–)
27 P10 CS 1

29 P12 20 GND D GND 10 8 A GND


+V

2N3906

1N4148 TO HEATER

SL00031

Figure 16. Digital Thermostat

2002 Oct 17 14
Philips Semiconductors Product data

CMOS 8-bit A/D converters ADC0803/0804

SO20: plastic small outline package; 20 leads; body width 7.5 mm SOT163-1

2002 Oct 17 15
Philips Semiconductors Product data

CMOS 8-bit A/D converters ADC0803/0804

DIP20: plastic dual in-line package; 20 leads (300 mil) SOT146-1

2002 Oct 17 16
Philips Semiconductors Product data

CMOS 8-bit A/D converters ADC0803/0804

REVISION HISTORY
Rev Date Description
_3 20021017 Product data; third version; supersedes data of 2001 Aug 03.
Engineering Change Notice 853–0034 28949 (date: 20020916).
Modifications:
• Add “Topside Marking” column to Ordering Information table.
_2 20010803 Product data; second version (9397 750 08926).
Engineering Change Notice 853–0034 26832 (date: 20010803).
_1 19940831 Product data; initial version.
Engineering Change Notice 853–0034 13721 (date: 19940831).

2002 Oct 17 17
Philips Semiconductors Product data

CMOS 8-bit A/D converters ADC0803/0804

Data sheet status


Product Definitions
Level Data sheet status [1]
status [2] [3]
I Objective data Development This data sheet contains data from the objective specification for product development.
Philips Semiconductors reserves the right to change the specification in any manner without notice.

II Preliminary data Qualification This data sheet contains data from the preliminary specification. Supplementary data will be published
at a later date. Philips Semiconductors reserves the right to change the specification without notice, in
order to improve the design and supply the best possible product.

III Product data Production This data sheet contains data from the product specification. Philips Semiconductors reserves the
right to make changes at any time in order to improve the design, manufacturing and supply. Relevant
changes will be communicated via a Customer Product/Process Change Notification (CPCN).
[1] Please consult the most recently issued data sheet before initiating or completing a design.
[2] The product status of the device(s) described in this data sheet may have changed since this data sheet was published. The latest information is available on the Internet at URL
http://www.semiconductors.philips.com.
[3] For data sheets describing multiple type numbers, the highest-level product status determines the data sheet status.

Definitions
Short-form specification — The data in a short-form specification is extracted from a full data sheet with the same type number and title. For detailed information see
the relevant data sheet or data handbook.
Limiting values definition — Limiting values given are in accordance with the Absolute Maximum Rating System (IEC 60134). Stress above one or more of the limiting
values may cause permanent damage to the device. These are stress ratings only and operation of the device at these or at any other conditions above those given
in the Characteristics sections of the specification is not implied. Exposure to limiting values for extended periods may affect device reliability.
Application information — Applications that are described herein for any of these products are for illustrative purposes only. Philips Semiconductors make no
representation or warranty that such applications will be suitable for the specified use without further testing or modification.

Disclaimers
Life support — These products are not designed for use in life support appliances, devices, or systems where malfunction of these products can reasonably be
expected to result in personal injury. Philips Semiconductors customers using or selling these products for use in such applications do so at their own risk and agree
to fully indemnify Philips Semiconductors for any damages resulting from such application.
Right to make changes — Philips Semiconductors reserves the right to make changes in the products—including circuits, standard cells, and/or software—described
or contained herein in order to improve design and/or performance. When the product is in full production (status ‘Production’), relevant changes will be communicated
via a Customer Product/Process Change Notification (CPCN). Philips Semiconductors assumes no responsibility or liability for the use of any of these products, conveys
no license or title under any patent, copyright, or mask work right to these products, and makes no representations or warranties that these products are free from patent,
copyright, or mask work right infringement, unless otherwise specified.

Contact information  Koninklijke Philips Electronics N.V. 2002


For additional information please visit All rights reserved. Printed in U.S.A.
http://www.semiconductors.philips.com. Fax: +31 40 27 24825
Date of release: 10-02
For sales offices addresses send e-mail to:
sales.addresses@www.semiconductors.philips.com. Document order number: 9397 750 10538





2002 Oct 17 18
This datasheet has been download from:

www.datasheetcatalog.com

Datasheets for electronics components.


Features
• Compatible with MCS-51® Products
• 8K Bytes of In-System Programmable (ISP) Flash Memory
– Endurance: 1000 Write/Erase Cycles
• 4.0V to 5.5V Operating Range
• Fully Static Operation: 0 Hz to 33 MHz
• Three-level Program Memory Lock
• 256 x 8-bit Internal RAM
• 32 Programmable I/O Lines
• Three 16-bit Timer/Counters


Eight Interrupt Sources
Full Duplex UART Serial Channel
8-bit


Low-power Idle and Power-down Modes
Interrupt Recovery from Power-down Mode
Microcontroller
• Watchdog Timer
• Dual Data Pointer with 8K Bytes
• Power-off Flag
In-System
Description Programmable
The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K
bytes of in-system programmable Flash memory. The device is manufactured using Flash
Atmel’s high-density nonvolatile memory technology and is compatible with the indus-
try-standard 80C51 instruction set and pinout. The on-chip Flash allows the program
memory to be reprogrammed in-system or by a conventional nonvolatile memory pro-
grammer. By combining a versatile 8-bit CPU with in-system programmable Flash on
AT89S52
a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which provides a
highly-flexible and cost-effective solution to many embedded control applications.
The AT89S52 provides the following standard features: 8K bytes of Flash, 256 bytes
of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters, a
six-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator,
and clock circuitry. In addition, the AT89S52 is designed with static logic for operation
down to zero frequency and supports two software selectable power saving modes.
The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and
interrupt system to continue functioning. The Power-down mode saves the RAM con-
tents but freezes the oscillator, disabling all other chip functions until the next interrupt
or hardware reset.

Rev. 1919A-07/01

1
Pin Configurations
PDIP PLCC

P1.1 (T2 EX)

P0.0 (AD0)
P0.1 (AD1)
P0.2 (AD2)
P0.3 (AD3)
(T2) P1.0 1 40 VCC

P1.0 (T2)
(T2 EX) P1.1 2 39 P0.0 (AD0)

VCC
P1.4
P1.3
P1.2
P1.2 3 38 P0.1 (AD1)

NC
P1.3 4 37 P0.2 (AD2)
P1.4 5 36 P0.3 (AD3)

6
5
4
3
2
1
44
43
42
41
40
(MOSI) P1.5 6 35 P0.4 (AD4) (MOSI) P1.5 7 39 P0.4 (AD4)
(MISO) P1.6 7 34 P0.5 (AD5) (MISO) P1.6 8 38 P0.5 (AD5)
(SCK) P1.7 8 33 P0.6 (AD6) (SCK) P1.7 9 37 P0.6 (AD6)
RST 9 32 P0.7 (AD7) RST 10 36 P0.7 (AD7)
(RXD) P3.0 10 31 EA/VPP (RXD) P3.0 11 35 EA/VPP
(TXD) P3.1 11 30 ALE/PROG NC 12 34 NC
(INT0) P3.2 12 29 PSEN (TXD) P3.1 13 33 ALE/PROG
(INT1) P3.3 13 28 P2.7 (A15) (INT0) P3.2 14 32 PSEN
(T0) P3.4 14 27 P2.6 (A14) (INT1) P3.3 15 31 P2.7 (A15)
(T1) P3.5 15 26 P2.5 (A13) (T0) P3.4 16 30 P2.6 (A14)
(WR) P3.6 16 25 P2.4 (A12) (T1) P3.5 17 29 P2.5 (A13)

18
19
20
21
22
23
24
25
26
27
28
(RD) P3.7 17 24 P2.3 (A11)
XTAL2 18 23 P2.2 (A10)

(WR) P3.6
(RD) P3.7
XTAL2
XTAL1
GND
NC
(A8) P2.0
(A9) P2.1
(A10) P2.2
(A11) P2.3
(A12) P2.4
XTAL1 19 22 P2.1 (A9)
GND 20 21 P2.0 (A8)

TQFP
P1.1 (T2 EX)

P0.0 (AD0)
P0.1 (AD1)
P0.2 (AD2)
P0.3 (AD3)
P1.0 (T2)

VCC
P1.4
P1.3
P1.2

NC
44
43
42
41
40
39
38
37
36
35
34

(MOSI) P1.5 1 33 P0.4 (AD4)


(MISO) P1.6 2 32 P0.5 (AD5)
(SCK) P1.7 3 31 P0.6 (AD6)
RST 4 30 P0.7 (AD7)
(RXD) P3.0 5 29 EA/VPP
NC 6 28 NC
(TXD) P3.1 7 27 ALE/PROG
(INT0) P3.2 8 26 PSEN
(INT1) P3.3 9 25 P2.7 (A15)
(T0) P3.4 10 24 P2.6 (A14)
(T1) P3.5 11 23 P2.5 (A13)
12
13
14
15
16
17
18
19
20
21
22
(WR) P3.6
(RD) P3.7
XTAL2
XTAL1
GND
GND
(A8) P2.0
(A9) P2.1
(A10) P2.2
(A11) P2.3
(A12) P2.4

2 AT89S52
AT89S52

Block Diagram
P0.0 - P0.7 P2.0 - P2.7

VCC
PORT 0 DRIVERS PORT 2 DRIVERS

GND

RAM ADDR. PORT 0 PORT 2


REGISTER RAM LATCH LATCH FLASH

PROGRAM
B STACK ADDRESS
REGISTER ACC POINTER REGISTER

BUFFER
TMP2 TMP1

PC
ALU INCREMENTER

INTERRUPT, SERIAL PORT,


AND TIMER BLOCKS

PROGRAM
PSW COUNTER

PSEN
ALE/PROG TIMING INSTRUCTION
AND REGISTER DUAL DPTR
EA / VPP CONTROL
RST

WATCH PORT 3 PORT 1 ISP PROGRAM


DOG LATCH LATCH PORT LOGIC

OSC
PORT 3 DRIVERS PORT 1 DRIVERS

P3.0 - P3.7 P1.0 - P1.7

3
Pin Description external data memory that use 16-bit addresses (MOVX @
DPTR). In this application, Port 2 uses strong internal pul-
VCC lups when emitting 1s. During accesses to external data
Supply voltage. memory that use 8-bit addresses (MOVX @ RI), Port 2
GND emits the contents of the P2 Special Function Register.
Ground. Port 2 also receives the high-order address bits and some
Port 0 control signals during Flash programming and verification.
Port 0 is an 8-bit open drain bidirectional I/O port. As an Port 3
output port, each pin can sink eight TTL inputs. When 1s Port 3 is an 8-bit bidirectional I/O port with internal pullups.
are written to port 0 pins, the pins can be used as high- The Port 3 output buffers can sink/source four TTL inputs.
impedance inputs. When 1s are written to Port 3 pins, they are pulled high by
Port 0 can also be configured to be the multiplexed low- the internal pullups and can be used as inputs. As inputs,
order address/data bus during accesses to external Port 3 pins that are externally being pulled low will source
program and data memory. In this mode, P0 has internal current (IIL) because of the pullups.
pullups. Port 3 also serves the functions of various special features
Port 0 also receives the code bytes during Flash program- of the AT89S52, as shown in the following table.
ming and outputs the code bytes during program verifica- Port 3 also receives some control signals for Flash pro-
tion. External pullups are required during program gramming and verification.
verification.
Port Pin Alternate Functions
Port 1
Port 1 is an 8-bit bidirectional I/O port with internal pullups. P3.0 RXD (serial input port)
The Port 1 output buffers can sink/source four TTL inputs. P3.1 TXD (serial output port)
When 1s are written to Port 1 pins, they are pulled high by
the internal pullups and can be used as inputs. As inputs, P3.2 INT0 (external interrupt 0)
Port 1 pins that are externally being pulled low will source P3.3 INT1 (external interrupt 1)
current (IIL) because of the internal pullups.
P3.4 T0 (timer 0 external input)
In addition, P1.0 and P1.1 can be configured to be the
timer/counter 2 external count input (P1.0/T2) and the P3.5 T1 (timer 1 external input)
timer/counter 2 trigger input (P1.1/T2EX), respectively, as P3.6 WR (external data memory write strobe)
shown in the following table.
P3.7 RD (external data memory read strobe)
Port 1 also receives the low-order address bytes during
Flash programming and verification.
RST
Port Pin Alternate Functions Reset input. A high on this pin for two machine cycles while
the oscillator is running resets the device. This pin drives
P1.0 T2 (external count input to Timer/Counter 2), High for 96 oscillator periods after the Watchdog times out.
clock-out
The DISRTO bit in SFR AUXR (address 8EH) can be used
P1.1 T2EX (Timer/Counter 2 capture/reload trigger to disable this feature. In the default state of bit DISRTO,
and direction control) the RESET HIGH out feature is enabled.
P1.5 MOSI (used for In-System Programming) ALE/PROG
P1.6 MISO (used for In-System Programming)
Address Latch Enable (ALE) is an output pulse for latching
the low byte of the address during accesses to external
P1.7 SCK (used for In-System Programming) memory. This pin is also the program pulse input (PROG)
during Flash programming.
Port 2 In normal operation, ALE is emitted at a constant rate of
Port 2 is an 8-bit bidirectional I/O port with internal pullups. 1/6 the oscillator frequency and may be used for external
The Port 2 output buffers can sink/source four TTL inputs. timing or clocking purposes. Note, however, that one
When 1s are written to Port 2 pins, they are pulled high by ALE pulse is skipped during each access to external data
the internal pullups and can be used as inputs. As inputs, memory.
Port 2 pins that are externally being pulled low will source
current (IIL) because of the internal pullups. If desired, ALE operation can be disabled by setting bit 0 of
SFR location 8EH. With the bit set, ALE is active only dur-
Port 2 emits the high-order address byte during fetches ing a MOVX or MOVC instruction. Otherwise, the pin is
from external program memory and during accesses to

4 AT89S52
AT89S52

weakly pulled high. Setting the ALE-disable bit has no Note, however, that if lock bit 1 is programmed, EA will be
effect if the microcontroller is in external execution mode. internally latched on reset.
PSEN EA should be strapped to VCC for internal program execu-
Program Store Enable (PSEN) is the read strobe to exter- tions.
nal program memory. This pin also receives the 12-volt programming enable volt-
When the AT89S52 is executing code from external pro- age (VPP) during Flash programming.
gram memory, PSEN is activated twice each machine XTAL1
cycle, except that two PSEN activations are skipped during Input to the inverting oscillator amplifier and input to the
each access to external data memory. internal clock operating circuit.
EA/VPP XTAL2
External Access Enable. EA must be strapped to GND in Output from the inverting oscillator amplifier.
order to enable the device to fetch code from external pro-
gram memory locations starting at 0000H up to FFFFH.
Table 1. AT89S52 SFR Map and Reset Values

0F8H 0FFH

B
0F0H 0F7H
00000000

0E8H 0EFH

ACC
0E0H 0E7H
00000000

0D8H 0DFH

PSW
0D0H 0D7H
00000000

T2CON T2MOD RCAP2L RCAP2H TL2 TH2


0C8H 0CFH
00000000 XXXXXX00 00000000 00000000 00000000 00000000

0C0H 0C7H

IP
0B8H 0BFH
XX000000

P3
0B0H 0B7H
11111111

IE
0A8H 0AFH
0X000000

P2 AUXR1 WDTRST
0A0H 0A7H
11111111 XXXXXXX0 XXXXXXXX

SCON SBUF
98H 9FH
00000000 XXXXXXXX

P1
90H 97H
11111111

TCON TMOD TL0 TL1 TH0 TH1 AUXR


88H 8FH
00000000 00000000 00000000 00000000 00000000 00000000 XXX00XX0

P0 SP DP0L DP0H DP1L DP1H PCON


80H 87H
11111111 00000111 00000000 00000000 00000000 00000000 0XXX0000

5
Special Function Registers
A map of the on-chip memory area called the Special Func- new features. In that case, the reset or inactive values of
tion Register (SFR) space is shown in Table 1. the new bits will always be 0.
Note that not all of the addresses are occupied, and unoc- Timer 2 Registers: Control and status bits are contained in
cupied addresses may not be implemented on the chip. registers T2CON (shown in Table 2) and T2MOD (shown in
Read accesses to these addresses will in general return Table 3) for Timer 2. The register pair (RCAP2H, RCAP2L)
random data, and write accesses will have an indetermi- are the Capture/Reload registers for Timer 2 in 16-bit cap-
nate effect. ture mode or 16-bit auto-reload mode.
User software should not write 1s to these unlisted loca- Interrupt Registers: The individual interrupt enable bits
tions, since they may be used in future products to invoke are in the IE register. Two priorities can be set for each of
the six interrupt sources in the IP register.
Table 2. T2CON – Timer/Counter 2 Control Register
T2CON Address = 0C8H Reset Value = 0000 0000B
Bit Addressable
Bit TF2 EXF2 RCLK TCLK EXEN2 TR2 C/T2 CP/RL2
7 6 5 4 3 2 1 0

Symbol Function
TF2 Timer 2 overflow flag set by a Timer 2 overflow and must be cleared by software. TF2 will not be set when either RCLK = 1
or TCLK = 1.
EXF2 Timer 2 external flag set when either a capture or reload is caused by a negative transition on T2EX and EXEN2 = 1.
When Timer 2 interrupt is enabled, EXF2 = 1 will cause the CPU to vector to the Timer 2 interrupt routine. EXF2 must be
cleared by software. EXF2 does not cause an interrupt in up/down counter mode (DCEN = 1).
RCLK Receive clock enable. When set, causes the serial port to use Timer 2 overflow pulses for its receive clock in serial port
Modes 1 and 3. RCLK = 0 causes Timer 1 overflow to be used for the receive clock.
TCLK Transmit clock enable. When set, causes the serial port to use Timer 2 overflow pulses for its transmit clock in serial port
Modes 1 and 3. TCLK = 0 causes Timer 1 overflows to be used for the transmit clock.
EXEN2 Timer 2 external enable. When set, allows a capture or reload to occur as a result of a negative transition on T2EX if Timer
2 is not being used to clock the serial port. EXEN2 = 0 causes Timer 2 to ignore events at T2EX.
TR2 Start/Stop control for Timer 2. TR2 = 1 starts the timer.
C/T2 Timer or counter select for Timer 2. C/T2 = 0 for timer function. C/T2 = 1 for external event counter (falling edge triggered).
CP/RL2 Capture/Reload select. CP/RL2 = 1 causes captures to occur on negative transitions at T2EX if EXEN2 = 1. CP/RL2 = 0
causes automatic reloads to occur when Timer 2 overflows or negative transitions occur at T2EX when EXEN2 = 1. When
either RCLK or TCLK = 1, this bit is ignored and the timer is forced to auto-reload on Timer 2 overflow.

6 AT89S52
AT89S52

Table 3a. AUXR: Auxiliary Register


AUXR Address = 8EH Reset Value = XXX00XX0B
Not Bit Addressable
– – – WDIDLE DISRTO – – DISALE
Bit 7 6 5 4 3 2 1 0

– Reserved for future expansion


DISALE Disable/Enable ALE
DISALE Operating Mode
0 ALE is emitted at a constant rate of 1/6 the oscillator frequency
1 ALE is active only during a MOVX or MOVC instruction
DISRTO Disable/Enable Reset out
DISRTO
0 Reset pin is driven High after WDT times out
1 Reset pin is input only
WDIDLE Disable/Enable WDT in IDLE mode
WDIDLE
0 WDT continues to count in IDLE mode
1 WDT halts counting in IDLE mode

Dual Data Pointer Registers: To facilitate accessing both appropriate value before accessing the respective Data
internal and external data memory, two banks of 16-bit Pointer Register.
Data Pointer Registers are provided: DP0 at SFR address Power Off Flag: The Power Off Flag (POF) is located at bit
locations 82H-83H and DP1 at 84H-85H. Bit DPS = 0 4 (PCON.4) in the PCON SFR. POF is set to “1” during
in SFR AUXR1 selects DP0 and DPS = 1 selects DP1. power up. It can be set and rest under software control and
The user should always initialize the DPS bit to the is not affected by reset.

Table 3b. AUXR1: Auxiliary Register 1


AUXR1 Address = A2H Reset Value = XXXXXXX0B
Not Bit Addressable
– – – – – – – DPS
Bit 7 6 5 4 3 2 1 0

– Reserved for future expansion


DPS Data Pointer Register Select
DPS
0 Selects DPTR Registers DP0L, DP0H
1 Selects DPTR Registers DP1L, DP1H

7
Memory Organization
MCS-51 devices have a separate address space for Pro- When an instruction accesses an internal location above
gram and Data Memory. Up to 64K bytes each of external address 7FH, the address mode used in the instruction
Program and Data Memory can be addressed. specifies whether the CPU accesses the upper 128 bytes
of RAM or the SFR space. Instructions which use direct
Program Memory addressing access of the SFR space.
If the EA pin is connected to GND, all program fetches are
For example, the following direct addressing instruction
directed to external memory.
accesses the SFR at location 0A0H (which is P2).
On the AT89S52, if EA is connected to V CC , program
MOV 0A0H, #data
fetches to addresses 0000H through 1FFFH are directed to
internal memory and fetches to addresses 2000H through Instructions that use indirect addressing access the upper
FFFFH are to external memory. 128 bytes of RAM. For example, the following indirect
addressing instruction, where R0 contains 0A0H, accesses
Data Memory the data byte at address 0A0H, rather than P2 (whose
The AT89S52 implements 256 bytes of on-chip RAM. The address is 0A0H).
upper 128 bytes occupy a parallel address space to the MOV @R0, #data
Special Function Registers. This means that the upper 128 Note that stack operations are examples of indirect
bytes have the same addresses as the SFR space but are addressing, so the upper 128 bytes of data RAM are avail-
physically separate from SFR space. able as stack space.

8 AT89S52
AT89S52

Watchdog Timer To ensure that the WDT does not overflow within a few
(One-time Enabled with Reset-out) states of exiting Power-down, it is best to reset the WDT
just before entering Power-down mode.
The WDT is intended as a recovery method in situations
Before going into the IDLE mode, the WDIDLE bit in SFR
where the CPU may be subjected to software upsets. The
AUXR is used to determine whether the WDT continues to
WDT consists of a 13-bit counter and the Watchdog Timer
count if enabled. The WDT keeps counting during IDLE
Reset (WDTRST) SFR. The WDT is defaulted to disable
(WDIDLE bit = 0) as the default state. To prevent the WDT
from exiting reset. To enable the WDT, a user must write
from resetting the AT89S52 while in IDLE mode, the user
01EH and 0E1H in sequence to the WDTRST register
should always set up a timer that will periodically exit IDLE,
(SFR location 0A6H). When the WDT is enabled, it will
service the WDT, and reenter IDLE mode.
increment every machine cycle while the oscillator is run-
ning. The WDT timeout period is dependent on the external With WDIDLE bit enabled, the WDT will stop to count in
clock frequency. There is no way to disable the WDT IDLE mode and resumes the count upon exit from IDLE.
except through reset (either hardware reset or WDT over-
flow reset). When WDT overflows, it will drive an output UART
RESET HIGH pulse at the RST pin. The UART in the AT89S52 operates the same way as the
UART in the AT89C51 and AT89C52. For further informa-
Using the WDT tion on the UART operation, refer to the ATMEL Web site
(http://www.atmel.com). From the home page, select ‘Prod-
To enable the WDT, a user must write 01EH and 0E1H in
ucts’, then ‘8051-Architecture Flash Microcontroller’, then
sequence to the WDTRST register (SFR location 0A6H).
‘Product Overview’.
When the WDT is enabled, the user needs to service it by
writing 01EH and 0E1H to WDTRST to avoid a WDT over-
flow. The 13-bit counter overflows when it reaches 8191 Timer 0 and 1
(1FFFH), and this will reset the device. When the WDT is Timer 0 and Timer 1 in the AT89S52 operate the same way
enabled, it will increment every machine cycle while the as Timer 0 and Timer 1 in the AT89C51 and AT89C52. For
oscillator is running. This means the user must reset the further information on the timers’ operation, refer to the
WDT at least every 8191 machine cycles. To reset the ATMEL Web site (http://www.atmel.com). From the home
WDT the user must write 01EH and 0E1H to WDTRST. page, select ‘Products’, then ‘8051-Architecture Flash
WDTRST is a write-only register. The WDT counter cannot Microcontroller’, then ‘Product Overview’.
be read or written. When WDT overflows, it will generate an
output RESET pulse at the RST pin. The RESET pulse
duration is 96xTOSC, where TOSC=1/FOSC. To make the
Timer 2
best use of the WDT, it should be serviced in those sec- Timer 2 is a 16-bit Timer/Counter that can operate as either
tions of code that will periodically be executed within the a timer or an event counter. The type of operation is
time required to prevent a WDT reset. selected by bit C/T2 in the SFR T2CON (shown in Table 2).
Timer 2 has three operating modes: capture, auto-reload
(up or down counting), and baud rate generator. The
WDT During Power-down and Idle modes are selected by bits in T2CON, as shown in Table 3.
In Power-down mode the oscillator stops, which means the Timer 2 consists of two 8-bit registers, TH2 and TL2. In the
WDT also stops. While in Power-down mode, the user Timer function, the TL2 register is incremented every
does not need to service the WDT. There are two methods machine cycle. Since a machine cycle consists of 12 oscil-
of exiting Power-down mode: by a hardware reset or via a lator periods, the count rate is 1/12 of the oscillator
level-activated external interrupt which is enabled prior to frequency.
entering Power-down mode. When Power-down is exited
Table 3. Timer 2 Operating Modes
with hardware reset, servicing the WDT should occur as it
normally does whenever the AT89S52 is reset. Exiting RCLK +TCLK CP/RL2 TR2 MODE
Power-down with an interrupt is significantly different. The
interrupt is held low long enough for the oscillator to stabi- 0 0 1 16-bit Auto-reload
lize. When the interrupt is brought high, the interrupt is 0 1 1 16-bit Capture
serviced. To prevent the WDT from resetting the device
1 X 1 Baud Rate Generator
while the interrupt pin is held low, the WDT is not started
until the interrupt is pulled high. It is suggested that the X X 0 (Off)
WDT be reset during the interrupt service for the interrupt
used to exit Power-down mode.

9
In the Counter function, the register is incremented in This bit can then be used to generate an interrupt. If
response to a 1-to-0 transition at its corresponding external EXEN2 = 1, Timer 2 performs the same operation, but a 1-
input pin, T2. In this function, the external input is sampled to-0 transition at external input T2EX also causes the
during S5P2 of every machine cycle. When the samples current value in TH2 and TL2 to be captured into RCAP2H
show a high in one cycle and a low in the next cycle, the and RCAP2L, respectively. In addition, the transition at
count is incremented. The new count value appears in the T2EX causes bit EXF2 in T2CON to be set. The EXF2 bit,
register during S3P1 of the cycle following the one in which like TF2, can generate an interrupt. The capture mode is
the transition was detected. Since two machine cycles (24 illustrated in Figure 5.
oscillator periods) are required to recognize a 1-to-0 transi-
tion, the maximum count rate is 1/24 of the oscillator fre- Auto-reload (Up or Down Counter)
quency. To ensure that a given level is sampled at least Timer 2 can be programmed to count up or down when
once before it changes, the level should be held for at least configured in its 16-bit auto-reload mode. This feature is
one full machine cycle. invoked by the DCEN (Down Counter Enable) bit located in
the SFR T2MOD (see Table 4). Upon reset, the DCEN bit
Capture Mode is set to 0 so that timer 2 will default to count up. When
In the capture mode, two options are selected by bit DCEN is set, Timer 2 can count up or down, depending on
EXEN2 in T2CON. If EXEN2 = 0, Timer 2 is a 16-bit timer the value of the T2EX pin.
or counter which upon overflow sets bit TF2 in T2CON.
Figure 5. Timer in Capture Mode

OSC ÷12
C/T2 = 0

TH2 TL2 TF2

OVERFLOW
CONTROL
TR2
C/T2 = 1

T2 PIN CAPTURE

RCAP2H RCAP2L
TRANSITION
DETECTOR TIMER 2
INTERRUPT
T2EX PIN EXF2

CONTROL
EXEN2

Figure 6 shows Timer 2 automatically counting up when the direction of the count. A logic 1 at T2EX makes Timer 2
DCEN=0. In this mode, two options are selected by bit count up. The timer will overflow at 0FFFFH and set the
EXEN2 in T2CON. If EXEN2 = 0, Timer 2 counts up to TF2 bit. This overflow also causes the 16-bit value in
0FFFFH and then sets the TF2 bit upon overflow. The RCAP2H and RCAP2L to be reloaded into the timer regis-
overflow also causes the timer registers to be reloaded with ters, TH2 and TL2, respectively.
the 16-bit value in RCAP2H and RCAP2L. The values in A logic 0 at T2EX makes Timer 2 count down. The timer
Timer in Capture ModeRCAP2H and RCAP2L are preset underflows when TH2 and TL2 equal the values stored in
by software. If EXEN2 = 1, a 16-bit reload can be triggered RCAP2H and RCAP2L. The underflow sets the TF2 bit and
either by an overflow or by a 1-to-0 transition at external causes 0FFFFH to be reloaded into the timer registers.
input T2EX. This transition also sets the EXF2 bit. Both the
The EXF2 bit toggles whenever Timer 2 overflows or
TF2 and EXF2 bits can generate an interrupt if enabled.
underflows and can be used as a 17th bit of resolution. In
Setting the DCEN bit enables Timer 2 to count up or down, this operating mode, EXF2 does not flag an interrupt.
as shown in Figure 6. In this mode, the T2EX pin controls

10 AT89S52
AT89S52

Figure 6. Timer 2 Auto Reload Mode (DCEN = 0)

OSC ÷12
C/T2 = 0

TH2 TL2

CONTR OL OVERFLOW
TR2
C/T2 = 1
RELO AD
T2 PIN TIMER 2
RCAP2H RCAP2L INTERRUPT

TF2
TRANSITION
DETECTOR

T2EX PIN EXF2

CONTROL
EXEN2

Table 4. T2MOD – Timer 2 Mode Control Register

T2MOD Address = 0C9H Reset Value = XXXX XX00B


Not Bit Addressable
– – – – – – T2OE DCEN
Bit 7 6 5 4 3 2 1 0

Symbol Function
– Not implemented, reserved for future
T2OE Timer 2 Output Enable bit
DCEN When set, this bit allows Timer 2 to be configured as an up/down counter

11
Figure 7. Timer 2 Auto Reload Mode (DCEN = 1)
(DOWN COUNTING RELOAD VALUE) TOGGLE

0FFH 0FFH EXF2

OSC ÷ 12 OVERFLOW
C/T2 = 0

TH2 TL2 TF2

CONTROL
TR2
C/T2 = 1 TIMER 2
INTERRUPT
T2 PIN
RCAP2H RCAP2L
COUNT
(UP COUNTING RELOAD VALUE) DIRECTION
1=UP
0=DOWN

T2EX PIN

Figure 8. Timer 2 in Baud Rate Generator Mode


TIMER 1 OVERFLOW

÷2
"0" "1"
NOTE: OSC. FREQ. IS DIVIDED BY 2, NOT 12
SMOD1

OSC ÷2
C/T2 = 0
"1" "0"
TH2 TL2
RCLK
Rx
CONTROL CLOCK
TR2
÷ 16
C/T2 = 1
"1" "0"
T2 PIN
TCLK
RCAP2H RCAP2L Tx
CLOCK
TRANSITION ÷ 16
DETECTOR

TIMER 2
T2EX PIN EXF2 INTERRUPT

CONTROL
EXEN2

12 AT89S52
AT89S52

Baud Rate Generator


Timer 2 is selected as the baud rate generator by setting increments every state time (at 1/2 the oscillator fre-
TCLK and/or RCLK in T2CON (Table 2). Note that the quency). The baud rate formula is given below.
baud rates for transmit and receive can be different if Timer
2 is used for the receiver or transmitter and Timer 1 is used
for the other function. Setting RCLK and/or TCLK puts Modes 1 and 3 Oscillator Frequency
--------------------------------------- = --------------------------------------------------------------------------------------
Timer 2 into its baud rate generator mode, as shown in Fig- Baud Rate 32 x [65536-RCAP2H,RCAP2L)]
ure 8.
The baud rate generator mode is similar to the auto-reload
mode, in that a rollover in TH2 causes the Timer 2 registers where (RCAP2H, RCAP2L) is the content of RCAP2H and
to be reloaded with the 16-bit value in registers RCAP2H RCAP2L taken as a 16-bit unsigned integer.
and RCAP2L, which are preset by software. Timer 2 as a baud rate generator is shown in Figure 8. This
The baud rates in Modes 1 and 3 are determined by Timer figure is valid only if RCLK or TCLK = 1 in T2CON. Note
2’s overflow rate according to the following equation. that a rollover in TH2 does not set TF2 and will not gener-
ate an interrupt. Note too, that if EXEN2 is set, a 1-to-0
transition in T2EX will set EXF2 but will not cause a reload
Timer 2 Overflow Rate from (RCAP2H, RCAP2L) to (TH2, TL2). Thus, when Timer
Modes 1 and 3 Baud Rates = ------------------------------------------------------------
16 2 is in use as a baud rate generator, T2EX can be used as
an extra external interrupt.
Note that when Timer 2 is running (TR2 = 1) as a timer in
The Timer can be configured for either timer or counter the baud rate generator mode, TH2 or TL2 should not be
operation. In most applications, it is configured for timer read from or written to. Under these conditions, the Timer is
operation (CP/T2 = 0). The timer operation is different for incremented every state time, and the results of a read or
Timer 2 when it is used as a baud rate generator. Normally, write may not be accurate. The RCAP2 registers may be
as a timer, it increments every machine cycle (at 1/12 the read but should not be written to, because a write might
oscillator frequency). As a baud rate generator, however, it overlap a reload and cause write and/or reload errors. The
timer should be turned off (clear TR2) before accessing the
Timer 2 or RCAP2 registers.
Figure 9. Timer 2 in Clock-Out Mode

TL2 TH2
OSC ÷2
(8-BITS) (8-BITS)

TR2

RCAP2L RCAP2H
C/T2 BIT

P1.0
÷2
(T2)

T2OE (T2MOD.1)

TRANSITION
DETECTOR

P1.1 TIMER 2
(T2EX) EXF2
INTERRUPT

EXEN2

13
Programmable Clock Out
A 50% duty cycle clock can be programmed to come out on Table 5. Interrupt Enable (IE) Register
P1.0, as shown in Figure 9. This pin, besides being a regu-
(MSB) (LSB)
lar I/O pin, has two alternate functions. It can be pro-
grammed to input the external clock for Timer/Counter 2 or EA – ET2 ES ET1 EX1 ET0 EX0
to output a 50% duty cycle clock ranging from 61 Hz to 4 Enable Bit = 1 enables the interrupt.
MHz at a 16 MHz operating frequency.
Enable Bit = 0 disables the interrupt.
To configure the Timer/Counter 2 as a clock generator, bit
C/T2 (T2CON.1) must be cleared and bit T2OE (T2MOD.1)
must be set. Bit TR2 (T2CON.2) starts and stops the timer. Symbol Position Function
The clock-out frequency depends on the oscillator fre- EA IE.7 Disables all interrupts. If EA = 0,
quency and the reload value of Timer 2 capture registers no interrupt is acknowledged. If
(RCAP2H, RCAP2L), as shown in the following equation. EA = 1, each interrupt source is
individually enabled or disabled
by setting or clearing its enable
Oscillator Frequency bit.
Clock-Out Frequency = -------------------------------------------------------------------------------------
4 x [65536-(RCAP2H,RCAP2L)] – IE.6 Reserved.
ET2 IE.5 Timer 2 interrupt enable bit.
ES IE.4 Serial Port interrupt enable bit.
In the clock-out mode, Timer 2 roll-overs will not generate
an interrupt. This behavior is similar to when Timer 2 is ET1 IE.3 Timer 1 interrupt enable bit.
used as a baud-rate generator. It is possible to use Timer 2
EX1 IE.2 External interrupt 1 enable bit.
as a baud-rate generator and a clock generator simulta-
neously. Note, however, that the baud-rate and clock-out ET0 IE.1 Timer 0 interrupt enable bit.
frequencies cannot be determined independently from one EX0 IE.0 External interrupt 0 enable bit.
another since they both use RCAP2H and RCAP2L.
User software should never write 1s to unimplemented bits,
because they may be used in future AT89 products.
Interrupts
The AT89S52 has a total of six interrupt vectors: two exter- Figure 10. Interrupt Sources
nal interrupts (INT0 and INT1), three timer interrupts (Tim-
ers 0, 1, and 2), and the serial port interrupt. These
interrupts are all shown in Figure 10. 0
Each of these interrupt sources can be individually enabled INT0
1
IE0

or disabled by setting or clearing a bit in Special Function


Register IE. IE also contains a global disable bit, EA, which
disables all interrupts at once.
Note that Table 5 shows that bit position IE.6 is unimple- TF0
mented. In the AT89S52, bit position IE.5 is also unimple-
mented. User software should not write 1s to these bit
positions, since they may be used in future AT89 products. 0
Timer 2 interrupt is generated by the logical OR of bits TF2 INT1 IE1
1
and EXF2 in register T2CON. Neither of these flags is
cleared by hardware when the service routine is vectored
to. In fact, the service routine may have to determine
whether it was TF2 or EXF2 that generated the interrupt, TF1
and that bit will have to be cleared in software.
The Timer 0 and Timer 1 flags, TF0 and TF1, are set at TI
RI
S5P2 of the cycle in which the timers overflow. The values
are then polled by the circuitry in the next cycle. However, TF2
EXF2
the Timer 2 flag, TF2, is set at S2P2 and is polled in the
same cycle in which the timer overflows.

14 AT89S52
AT89S52

Oscillator Characteristics active long enough to allow the oscillator to restart


and stabilize.
XTAL1 and XTAL2 are the input and output, respectively,
of an inverting amplifier that can be configured for use as Figure 11. Oscillator Connections
an on-chip oscillator, as shown in Figure 11. Either a quartz
crystal or ceramic resonator may be used. To drive the C2
device from an external clock source, XTAL2 should be left XTAL2
unconnected while XTAL1 is driven, as shown in Figure 12.
There are no requirements on the duty cycle of the external
clock signal, since the input to the internal clocking circuitry
C1
is through a divide-by-two flip-flop, but minimum and maxi- XTAL1
mum voltage high and low time specifications must be
observed.

Idle Mode GND


In idle mode, the CPU puts itself to sleep while all the on-
chip peripherals remain active. The mode is invoked by
software. The content of the on-chip RAM and all the spe-
cial functions registers remain unchanged during this
mode. The idle mode can be terminated by any enabled Note: C1, C2 = 30 pF ± 10 pF for Crystals
interrupt or by a hardware reset. = 40 pF ± 10 pF for Ceramic Resonators
Note that when idle mode is terminated by a hardware Figure 12. External Clock Drive Configuration
reset, the device normally resumes program execution
from where it left off, up to two machine cycles before the
internal reset algorithm takes control. On-chip hardware NC XTAL2
inhibits access to internal RAM in this event, but access to
the port pins is not inhibited. To eliminate the possibility of
an unexpected write to a port pin when idle mode is termi-
nated by a reset, the instruction following the one that
EXTERNAL
invokes idle mode should not write to a port pin or to exter- OSCILLATOR XTAL1
nal memory. SIGNAL

Power-down Mode GND


In the Power-down mode, the oscillator is stopped, and the
instruction that invokes Power-down is the last instruction
executed. The on-chip RAM and Special Function Regis-
ters retain their values until the Power-down mode is termi-
nated. Exit from Power-down mode can be initiated either
by a hardware reset or by an enabled external interrupt.
Reset redefines the SFRs but does not change the on-chip
RAM. The reset should not be activated before V CC is
restored to its normal operating level and must be held

Table 6. Status of External Pins During Idle and Power-down Modes


Mode Program Memory ALE PSEN PORT0 PORT1 PORT2 PORT3
Idle Internal 1 1 Data Data Data Data
Idle External 1 1 Float Data Address Data
Power-down Internal 0 0 Data Data Data Data
Power-down External 0 0 Float Data Data Data

15
Program Memory Lock Bits Repeat steps 1 through 5, changing the address
and data for the entire array or until the end of the
The AT89S52 has three lock bits that can be left unpro-
object file is reached.
grammed (U) or can be programmed (P) to obtain the addi-
tional features listed in the following table. Data Polling: The AT89S52 features Data Polling to indi-
cate the end of a byte write cycle. During a write cycle, an
Table 7. Lock Bit Protection Modes
attempted read of the last byte written will result in the com-
Program Lock Bits plement of the written data on P0.7. Once the write cycle
has been completed, true data is valid on all outputs, and
LB1 LB2 LB3 Protection Type
the next cycle may begin. Data Polling may begin any time
1 U U U No program lock features after a write cycle has been initiated.
2 P U U MOVC instructions executed Ready/Busy: The progress of byte programming can also
from external program be monitored by the RDY/BSY output signal. P3.0 is pulled
memory are disabled from low after ALE goes high during programming to indicate
fetching code bytes from BUSY. P3.0 is pulled high again when programming is
internal memory, EA is done to indicate READY.
sampled and latched on reset,
Program Verify: If lock bits LB1 and LB2 have not been
and further programming of
the Flash memory is disabled
programmed, the programmed code data can be read back
via the address and data lines for verification. The status of
3 P P U Same as mode 2, but verify is the individual lock bits can be verified directly by reading
also disabled them back.
4 P P P Same as mode 3, but external Reading the Signature Bytes: The signature bytes are
execution is also disabled read by the same procedure as a normal verification of
locations 000H, 100H, and 200H, except that P3.6 and
When lock bit 1 is programmed, the logic level at the EA pin P3.7 must be pulled to a logic low. The values returned are
is sampled and latched during reset. If the device is pow- as follows.
ered up without a reset, the latch initializes to a random (000H) = 1EH indicates manufactured by Atmel
value and holds that value until reset is activated. The (100H) = 52H indicates 89S52
latched value of EA must agree with the current logic level (200H) = 06H
at that pin in order for the device to function properly.
Chip Erase: In the parallel programming mode, a chip
erase operation is initiated by using the proper combination
Programming the Flash – Parallel Mode of control signals and by pulsing ALE/PROG low for a dura-
The AT89S52 is shipped with the on-chip Flash memory tion of 200 ns - 500 ns.
array ready to be programmed. The programming interface In the serial programming mode, a chip erase operation is
needs a high-voltage (12-volt) program enable signal and initiated by issuing the Chip Erase instruction. In this mode,
is compatible with conventional third-party Flash or chip erase is self-timed and takes about 500 ms.
EPROM programmers.
During chip erase, a serial read from any address location
The AT89S52 code memory array is programmed byte-by- will return 00H at the data output.
byte.
Programming Algorithm: Before programming the
AT89S52, the address, data, and control signals should be Programming the Flash – Serial Mode
set up according to the Flash programming mode table and The Code memory array can be programmed using the
Figures 13 and 14. To program the AT89S52, take the fol- serial ISP interface while RST is pulled to VCC. The serial
lowing steps: interface consists of pins SCK, MOSI (input) and MISO
1. Input the desired memory location on the address (output). After RST is set high, the Programming Enable
lines. instruction needs to be executed first before other opera-
2. Input the appropriate data byte on the data lines. tions can be executed. Before a reprogramming sequence
can occur, a Chip Erase operation is required.
3. Activate the correct combination of control signals.
4. Raise EA/VPP to 12V. The Chip Erase operation turns the content of every mem-
ory location in the Code array into FFH.
5. Pulse ALE/PROG once to program a byte in the
Flash array or the lock bits. The byte-write cycle is Either an external system clock can be supplied at pin
self-timed and typically takes no more than 50 µs. XTAL1 or a crystal needs to be connected across pins
XTAL1 and XTAL2. The maximum serial clock (SCK)

16 AT89S52
AT89S52

frequency should be less than 1/16 of the crystal fre- appropriate Write instruction. The write cycle is self-
quency. With a 33 MHz oscillator clock, the maximum SCK timed and typically takes less than 1 ms at 5V.
frequency is 2 MHz. 4. Any memory location can be verified by using the
Read instruction which returns the content at the
Serial Programming Algorithm selected address at serial output MISO/P1.6.
To program and verify the AT89S52 in the serial program- 5. At the end of a programming session, RST can be
ming mode, the following sequence is recommended: set low to commence normal device operation.
1. Power-up sequence: Power-off sequence (if needed):
Apply power between VCC and GND pins. Set XTAL1 to “L” (if a crystal is not used).
Set RST pin to “H”. Set RST to “L”.
If a crystal is not connected across pins XTAL1 and Turn VCC power off.
XTAL2, apply a 3 MHz to 33 MHz clock to XTAL1 pin Data Polling: The Data Polling feature is also available in
and wait for at least 10 milliseconds. the serial mode. In this mode, during a write cycle an
2. Enable serial programming by sending the Pro- attempted read of the last byte written will result in the com-
gramming Enable serial instruction to pin plement of the MSB of the serial output byte on MISO.
MOSI/P1.5. The frequency of the shift clock sup-
plied at pin SCK/P1.7 needs to be less than the Serial Programming Instruction Set
CPU clock at XTAL1 divided by 16.
The Instruction Set for Serial Programming follows a 4-byte
3. The Code array is programmed one byte at a time protocol and is shown in Table 10.
by supplying the address and data together with the

17
Programming Interface – Parallel Mode
Every code byte in the Flash array can be programmed by All major programming vendors offer worldwide support for
using the appropriate combination of control signals. The the Atmel microcontroller series. Please contact your local
write operation cycle is self-timed and once initiated, will programming vendor for the appropriate software revision.
automatically time itself to completion.
Table 8. Flash Programming Modes
P2.4-0 P1.7-0
ALE/ EA/ P0.7-0
Mode VCC RST PSEN PROG VPP P2.6 P2.7 P3.3 P3.6 P3.7 Data Address
(2)
Write Code Data 5V H L 12V L H H H H DIN A12-8 A7-0

Read Code Data 5V H L H H L L L H H DOUT A12-8 A7-0


(3)
Write Lock Bit 1 5V H L 12V H H H H H X X X

(3)
Write Lock Bit 2 5V H L 12V H H H L L X X X

(3)
Write Lock Bit 3 5V H L 12V H L H H L X X X

P0.2,
Read Lock Bits
5V H L H H H H L H L P0.3, X X
1, 2, 3
P0.4
(1)
Chip Erase 5V H L 12V H L H L L X X X

Read Atmel ID 5V H L H H L L L L L 1EH X 0000 00H

Read Device ID 5V H L H H L L L L L 52H X 0001 00H

Read Device ID 5V H L H H L L L L L 06H X 0010 00H


Notes: 1. Each PROG pulse is 200 ns - 500 ns for Chip Erase.
2. Each PROG pulse is 200 ns - 500 ns for Write Code Data.
3. Each PROG pulse is 200 ns - 500 ns for Write Lock Bits.
4. RDY/BSY signal is output on P3.0 during programming.
5. X = don’t care.
Figure 13. Programming the Flash Memory Figure 14. Verifying the Flash Memory (Parallel Mode)
(Parallel Mode) VCC
VCC AT89S52
AT89S52 A0 - A7 VCC
ADDR. P1.0-P1.7
A0 - A7 VCC 0000H/1FFFH PGM DATA
ADDR. P1.0-P1.7 P2.0 - P2.4 P0
A8 - A12 (USE 10K
0000H/1FFFH PGM
P2.0 - P2.4 P0 PULLUPS)
A8 - A12 DATA P2.6
P2.6 SEE FLASH P2.7 ALE
P2.7 PROGRAMMING P3.3
SEE FLASH ALE PROG
PROGRAMMING P3.3 MODES TABLE P3.6
VIH
MODES TABLE P3.6 P3.7
P3.7 XTAL 2 EA
XTAL2 EA VIH/VPP
3-33 MHz
3-33 MHz
RDY/
P3.0
BSY

XTAL1 RST VIH


XTAL1 RST VIH GND PSEN
GND PSEN

18 AT89S52
AT89S52
Flash Programming and Verification Characteristics (Parallel Mode)
TA = 20°C to 30°C, VCC = 4.5 to 5.5V
Symbol Parameter Min Max Units
VPP Programming Supply Voltage 11.5 12.5 V
IPP Programming Supply Current 10 mA
ICC VCC Supply Current 30 mA
1/tCLCL Oscillator Frequency 3 33 MHz
tAVGL Address Setup to PROG Low 48tCLCL
tGHAX Address Hold After PROG 48tCLCL
tDVGL Data Setup to PROG Low 48tCLCL
tGHDX Data Hold After PROG 48tCLCL
tEHSH P2.7 (ENABLE) High to VPP 48tCLCL
tSHGL VPP Setup to PROG Low 10 µs
tGHSL VPP Hold After PROG 10 µs
tGLGH PROG Width 0.2 1 µs
tAVQV Address to Data Valid 48tCLCL
tELQV ENABLE Low to Data Valid 48tCLCL
tEHQZ Data Float After ENABLE 0 48tCLCL
tGHBL PROG High to BUSY Low 1.0 µs
tWC Byte Write Cycle Time 50 µs

Figure 15. Flash Programming and Verification Waveforms – Parallel Mode


PROGRAMMING VERIFICATION
P1.0 - P1.7
ADDRESS ADDRESS
P2.0 - P2.5
P3.4 tAVQV
PORT 0 DATA IN DATA OUT
tDVGL tGHDX
tAVGL tGHAX
ALE/PROG
tSHGL tGHSL
tGLGH
VPP LOGIC 1
EA/VPP LOGIC 0

tEHSH tEHQZ
tELQV
P2.7
(ENABLE)
tGHBL
P3.0
(RDY/BSY) BUSY READY
tWC

19
Figure 16. Flash Memory Serial Downloading
VCC
AT89S52
VCC

INSTRUCTION
INPUT P1.5/MOSI
DATA OUTPUT P1.6/MISO

CLOCK IN P1.7/SCK

XTAL2

3-33 MHz

XTAL1 RST VIH

GND

Flash Programming and Verification Waveforms – Serial Mode


Figure 17. Serial Programming Waveforms

7 6 5 4 3 2 1 0

20 AT89S52
AT89S52

Table 9. Serial Programming Instruction Set


Instruction
Format
Instruction Byte 1 Byte 2 Byte 3 Byte 4 Operation
Programming Enable 1010 1100 0101 0011 xxxx xxxx xxxx xxxx Enable Serial Programming
0110 1001 while RST is high
(Output)
Chip Erase 1010 1100 100x xxxx xxxx xxxx xxxx xxxx Chip Erase Flash memory
array
Read Program Memory 0010 0000 xxx Read data from Program

A11

A1
A8
A12

A10
A9

A5

A3
A2
A6
A4

A0

D7
A7

D6
D5
D4
D3

D0
D2
D1
(Byte Mode) memory in the byte mode
Write Program Memory 0100 0000 xxx Write data to Program

A1

D7
D6
A5

D5

D3

D0
A3

D4

D1
A11

A6
A4

A2
A0

D2
A7
A10
A8
A12

A9
(Byte Mode) memory in the byte mode
Write Lock Bits(2)
B2
B1
1010 1100 1110 00 xxxx xxxx xxxx xxxx Write Lock bits. See Note (2).
Read Lock Bits 0010 0100 xxxx xxxx xxxx xxxx xx xx Read back current status of

LB1
LB2
LB3
the lock bits (a programmed
lock bit reads back as a ‘1’)
Read Signature Bytes(1) 0010 1000 xxx xxx xxxx Signature Byte Read Signature Byte
A5
A4
A3
A2
A1
A0

Read Program Memory 0011 0000 xxx Byte 0 Byte 1... Read data from Program
A11

A8
A12

A10
A9

(Page Mode) Byte 255 memory in the Page Mode


(256 bytes)
Write Program Memory 0101 0000 xxx Byte 0 Byte 1... Write data to Program
A11

A8
A12

A10
A9

(Page Mode) Byte 255 memory in the Page Mode


(256 bytes)
Notes: 1. The signature bytes are not readable in Lock Bit Modes 3 and 4.

}
2. B1 = 0, B2 = 0 ---> Mode 1, no lock protection
B1 = 0, B2 = 1 ---> Mode 2, lock bit 1 activated Each of the lock bits needs to be activated sequentially before
B1 = 1, B2 = 0 ---> Mode 3, lock bit 2 activated Mode 4 can be executed.
B1 = 1, B1 = 1 ---> Mode 4, lock bit 3 activated
After Reset signal is high, SCK should be low for at least 64 For Page Read/Write, the data always starts from byte 0 to
system clocks before it goes high to clock in the enable 255. After the command byte and upper address byte are
data bytes. No pulsing of Reset signal is necessary. SCK latched, each byte thereafter is treated as data until all 256
should be no faster than 1/16 of the system clock at bytes are shifted in/out. Then the next instruction will be
XTAL1. ready to be decoded.

21
Serial Programming Characteristics

Figure 18. Serial Programming Timing

MOSI
tOVSH tSHOX tSLSH

SCK
tSHSL

MISO
tSLIV

Table 10. Serial Programming Characteristics, TA = -40° C to 85° C, VCC = 4.0 - 5.5V (Unless otherwise noted)
Symbol Parameter Min Typ Max Units
1/tCLCL Oscillator Frequency 0 33 MHz
tCLCL Oscillator Period 30 ns
tSHSL SCK Pulse Width High 2 tCLCL ns
tSLSH SCK Pulse Width Low 2 tCLCL ns
tOVSH MOSI Setup to SCK High tCLCL ns
tSHOX MOSI Hold after SCK High 2 tCLCL ns
tSLIV SCK Low to MISO Valid 10 16 32 ns
tERASE Chip Erase Instruction Cycle Time 500 ms
tSWC Serial Byte Write Cycle Time 64 tCLCL + 400 µs

22 AT89S52
AT89S52

Absolute Maximum Ratings*


Operating Temperature.................................. -55°C to +125°C *NOTICE: Stresses beyond those listed under “Absolute
Maximum Ratings” may cause permanent dam-
Storage Temperature ..................................... -65°C to +150°C age to the device. This is a stress rating only and
functional operation of the device at these or any
Voltage on Any Pin other conditions beyond those indicated in the
with Respect to Ground .....................................-1.0V to +7.0V operational sections of this specification is not
implied. Exposure to absolute maximum rating
Maximum Operating Voltage ............................................ 6.6V conditions for extended periods may affect
device reliability.
DC Output Current...................................................... 15.0 mA

DC Characteristics
The values shown in this table are valid for TA = -40°C to 85°C and VCC = 4.0V to 5.5V, unless otherwise noted.
Symbol Parameter Condition Min Max Units

VIL Input Low Voltage (Except EA) -0.5 0.2 VCC-0.1 V

VIL1 Input Low Voltage (EA) -0.5 0.2 VCC-0.3 V

VIH Input High Voltage (Except XTAL1, RST) 0.2 VCC+0.9 VCC+0.5 V

VIH1 Input High Voltage (XTAL1, RST) 0.7 VCC VCC+0.5 V


(1)
VOL Output Low Voltage (Ports 1,2,3) IOL = 1.6 mA 0.45 V
(1)
Output Low Voltage
VOL1 IOL = 3.2 mA 0.45 V
(Port 0, ALE, PSEN)

IOH = -60 µA, VCC = 5V ± 10% 2.4 V


Output High Voltage
VOH IOH = -25 µA 0.75 VCC V
(Ports 1,2,3, ALE, PSEN)
IOH = -10 µA 0.9 VCC V

IOH = -800 µA, VCC = 5V ± 10% 2.4 V


Output High Voltage
VOH1 IOH = -300 µA 0.75 VCC V
(Port 0 in External Bus Mode)
IOH = -80 µA 0.9 VCC V

IIL Logical 0 Input Current (Ports 1,2,3) VIN = 0.45V -50 µA

Logical 1 to 0 Transition Current


ITL VIN = 2V, VCC = 5V ± 10% -650 µA
(Ports 1,2,3)

ILI Input Leakage Current (Port 0, EA) 0.45 < VIN < VCC ±10 µA

RRST Reset Pulldown Resistor 10 30 KΩ

CIO Pin Capacitance Test Freq. = 1 MHz, TA = 25°C 10 pF

Active Mode, 12 MHz 25 mA


Power Supply Current
ICC Idle Mode, 12 MHz 6.5 mA
(1)
Power-down Mode VCC = 5.5V 50 µA
Notes: 1. Under steady state (non-transient) conditions, IOL must be externally limited as follows:
Maximum IOL per port pin: 10 mA
Maximum IOL per 8-bit port:
Port 0: 26 mA Ports 1, 2, 3: 15 mA
Maximum total IOL for all output pins: 71 mA
If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not guaranteed to sink current greater
than the listed test conditions.
2. Minimum VCC for Power-down is 2V.

23
AC Characteristics
Under operating conditions, load capacitance for Port 0, ALE/PROG, and PSEN = 100 pF; load capacitance for all other
outputs = 80 pF.
External Program and Data Memory Characteristics
12 MHz Oscillator Variable Oscillator
Symbol Parameter Min Max Min Max Units
1/tCLCL Oscillator Frequency 0 33 MHz
tLHLL ALE Pulse Width 127 2tCLCL-40 ns
tAVLL Address Valid to ALE Low 43 tCLCL-25 ns
tLLAX Address Hold After ALE Low 48 tCLCL-25 ns
tLLIV ALE Low to Valid Instruction In 233 4tCLCL-65 ns
tLLPL ALE Low to PSEN Low 43 tCLCL-25 ns
tPLPH PSEN Pulse Width 205 3tCLCL-45 ns
tPLIV PSEN Low to Valid Instruction In 145 3tCLCL-60 ns
tPXIX Input Instruction Hold After PSEN 0 0 ns
tPXIZ Input Instruction Float After PSEN 59 tCLCL-25 ns
tPXAV PSEN to Address Valid 75 tCLCL-8 ns
tAVIV Address to Valid Instruction In 312 5tCLCL-80 ns
tPLAZ PSEN Low to Address Float 10 10 ns
tRLRH RD Pulse Width 400 6tCLCL-100 ns
tWLWH WR Pulse Width 400 6tCLCL-100 ns
tRLDV RD Low to Valid Data In 252 5tCLCL-90 ns
tRHDX Data Hold After RD 0 0 ns
tRHDZ Data Float After RD 97 2tCLCL-28 ns
tLLDV ALE Low to Valid Data In 517 8tCLCL-150 ns
tAVDV Address to Valid Data In 585 9tCLCL-165 ns
tLLWL ALE Low to RD or WR Low 200 300 3tCLCL-50 3tCLCL+50 ns
tAVWL Address to RD or WR Low 203 4tCLCL-75 ns
tQVWX Data Valid to WR Transition 23 tCLCL-30 ns
tQVWH Data Valid to WR High 433 7tCLCL-130 ns
tWHQX Data Hold After WR 33 tCLCL-25 ns
tRLAZ RD Low to Address Float 0 0 ns
tWHLH RD or WR High to ALE High 43 123 tCLCL-25 tCLCL+25 ns

24 AT89S52
AT89S52

External Program Memory Read Cycle


tLHLL
ALE
tPLPH
tAVLL tLLIV
tLLPL
PSEN tPLIV
tPXAV
tPLAZ
tPXIZ
tLLAX
tPXIX
PORT 0 A0 - A7 INSTR IN A0 - A7

tAVIV

PORT 2 A8 - A15 A8 - A15

External Data Memory Read Cycle


tLHLL
ALE
tWHLH

PSEN
tLLDV
tRLRH
tLLWL

RD tLLAX
tRLDV tRHDZ
tAVLL
tRLAZ
tRHDX

PORT 0 A0 - A7 FROM RI OR DPL DATA IN A0 - A7 FROM PCL INSTR IN

tAVWL
tAVDV
PORT 2 P2.0 - P2.7 OR A8 - A15 FROM DPH A8 - A15 FROM PCH

25
External Data Memory Write Cycle
tLHLL
ALE
tWHLH

PSEN
tLLWL tWLWH

WR tLLAX
tAVLL tQVWX tWHQX
tQVWH

PORT 0 A0 - A7 FROM RI OR DPL DATA OUT A0 - A7 FROM PCL INSTR IN

tAVWL

PORT 2 P2.0 - P2.7 OR A8 - A15 FROM DPH A8 - A15 FROM PCH

External Clock Drive Waveforms


tCHCX
tCHCX tCLCH tCHCL
VCC - 0.5V
0.7 VCC

0.2 VCC - 0.1V


0.45V
tCLCX
tCLCL

External Clock Drive


Symbol Parameter Min Max Units
1/tCLCL Oscillator Frequency 0 33 MHz
tCLCL Clock Period 30 ns
tCHCX High Time 12 ns
tCLCX Low Time 12 ns
tCLCH Rise Time 5 ns
tCHCL Fall Time 5 ns

26 AT89S52
AT89S52

Serial Port Timing: Shift Register Mode Test Conditions


The values in this table are valid for VCC = 4.0V to 5.5V and Load Capacitance = 80 pF.
12 MHz Osc Variable Oscillator
Symbol Parameter Min Max Min Max Units
tXLXL Serial Port Clock Cycle Time 1.0 12tCLCL µs
tQVXH Output Data Setup to Clock Rising Edge 700 10tCLCL-133 ns
tXHQX Output Data Hold After Clock Rising Edge 50 2tCLCL-80 ns
tXHDX Input Data Hold After Clock Rising Edge 0 0 ns
tXHDV Clock Rising Edge to Input Data Valid 700 10tCLCL-133 ns

Shift Register Mode Timing Waveforms


INSTRUCTION 0 1 2 3 4 5 6 7 8
ALE
tXLXL
CLOCK
tQVXH
tXHQX
WRITE TO SBUF 0 1 2 3 4 5 6 7
tXHDX
OUTPUT DATA tXHDV SET TI
CLEAR RI VALID VALID VALID VALID VALID VALID VALID VALID

INPUT DATA SET RI

AC Testing Input/Output Waveforms(1) Float Waveforms(1)


VCC - 0.5V V LOAD+ 0.1V V OL - 0.1V
0.2 VCC + 0.9V
TEST POINTS V LOAD Timing Reference
Points
0.2 VCC - 0.1V V LOAD - 0.1V V OL + 0.1V
0.45V

Note: 1. AC Inputs during testing are driven at VCC - 0.5V Note: 1. For timing purposes, a port pin is no longer floating
for a logic 1 and 0.45V for a logic 0. Timing mea- when a 100 mV change from load voltage occurs. A
surements are made at VIH min. for a logic 1 and VIL port pin begins to float when a 100 mV change from
max. for a logic 0. the loaded VOH/VOL level occurs.

27
Ordering Information
Speed Power
(MHz) Supply Ordering Code Package Operation Range
24 4.0V to 5.5V AT89S52-24AC 44A Commercial
AT89S52-24JC 44J (0° C to 70° C)
AT89S52-24PC 40P6
AT89S52-24AI 44A Industrial
AT89S52-24JI 44J (-40° C to 85° C)
AT89S52-24PI 40P6
33 4.5V to 5.5V AT89S52-33AC 44A Commercial
AT89S52-33JC 44J (0° C to 70° C)
AT89S52-33PC 40P6

= Preliminary Availability

Package Type
44A 44-lead, Thin Plastic Gull Wing Quad Flatpack (TQFP)
44J 44-lead, Plastic J-leaded Chip Carrier (PLCC)
40P6 40-pin, 0.600" Wide, Plastic Dual Inline Package (PDIP)

28 AT89S52
Packaging Information
44A, 44-lead, Thin (1.0 mm) Plastic Gull Wing Quad 44J, 44-lead, Plastic J-leaded Chip Carrier (PLCC)
Flat Package (TQFP) Dimensions in Inches and (Millimeters)
Dimensions in Millimeters and (Inches)*

.045(1.14) X 45° PIN NO. 1 .045(1.14) X 30° - 45° .012(.305)


12.21(0.478) IDENTIFY .008(.203)
PIN 1 ID SQ
11.75(0.458)

.656(16.7) .630(16.0)
SQ
.650(16.5) .590(15.0)
0.45(0.018) .032(.813) .021(.533)
0.80(0.031) BSC 0.30(0.012) .695(17.7)
.026(.660) SQ .013(.330)
.685(17.4)

.050(1.27) TYP .043(1.09)


.500(12.7) REF SQ .020(.508)
.120(3.05)
.090(2.29)
.180(4.57)
10.10(0.394) .165(4.19)
SQ
9.90(0.386)
1.20(0.047) MAX
0
0.20(.008) 7
0.09(.003) .022(.559) X 45° MAX (3X)

0.75(0.030) 0.15(0.006)
0.45(0.018) 0.05(0.002)

*Controlling dimension: millimeters

40P6, 40-pin, 0.600" Wide, Plastic Dual Inline


Package (PDIP)
Dimensions in Inches and (Millimeters)
JEDEC STANDARD MS-011 AC

2.07(52.6)
2.04(51.8) PIN
1

.566(14.4)
.530(13.5)

.090(2.29)
1.900(48.26) REF MAX
.220(5.59) .005(.127)
MAX MIN

SEATING
PLANE
.065(1.65)
.161(4.09) .015(.381)
.125(3.18)
.022(.559)
.065(1.65) .014(.356)
.110(2.79) .041(1.04)
.090(2.29)
.630(16.0)
.590(15.0)
0 REF
.012(.305) 15
.008(.203)
.690(17.5)
.610(15.5)

29 AT89S52
Atmel Headquarters Atmel Product Operations
Corporate Headquarters Atmel Colorado Springs
2325 Orchard Parkway 1150 E. Cheyenne Mtn. Blvd.
San Jose, CA 95131 Colorado Springs, CO 80906
TEL (408) 441-0311 TEL (719) 576-3300
FAX (408) 487-2600 FAX (719) 540-1759
Europe Atmel Grenoble
Atmel SarL Avenue de Rochepleine
Route des Arsenaux 41 BP 123
Casa Postale 80 38521 Saint-Egreve Cedex, France
CH-1705 Fribourg TEL (33) 4-7658-3000
Switzerland FAX (33) 4-7658-3480
TEL (41) 26-426-5555
FAX (41) 26-426-5500 Atmel Heilbronn
Theresienstrasse 2
Asia POB 3535
Atmel Asia, Ltd. D-74025 Heilbronn, Germany
Room 1219 TEL (49) 71 31 67 25 94
Chinachem Golden Plaza FAX (49) 71 31 67 24 23
77 Mody Road Tsimhatsui
East Kowloon Atmel Nantes
Hong Kong La Chantrerie
TEL (852) 2721-9778 BP 70602
FAX (852) 2722-1369 44306 Nantes Cedex 3, France
TEL (33) 0 2 40 18 18 18
Japan FAX (33) 0 2 40 18 19 60
Atmel Japan K.K.
9F, Tonetsu Shinkawa Bldg. Atmel Rousset
1-24-8 Shinkawa Zone Industrielle
Chuo-ku, Tokyo 104-0033 13106 Rousset Cedex, France
Japan TEL (33) 4-4253-6000
TEL (81) 3-3523-3551 FAX (33) 4-4253-6001
FAX (81) 3-3523-7581
Atmel Smart Card ICs
Scottish Enterprise Technology Park
East Kilbride, Scotland G75 0QR
TEL (44) 1355-357-000
FAX (44) 1355-242-743

Fax-on-Demand e-mail
North America: literature@atmel.com
1-(800) 292-8635
International: Web Site
http://www.atmel.com
1-(408) 441-0732
BBS
1-(408) 436-4309

© Atmel Corporation 2001.


Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Company’s standard warranty
which is detailed in Atmel’s Terms and Conditions located on the Company’s web site. The Company assumes no responsibility for any errors
which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does
not make any commitment to update the information contained herein. No licenses to patents or other intellectual property of Atmel are granted
by the Company in connection with the sale of Atmel products, expressly or by implication. Atmel’s products are not authorized for use as critical
components in life support devices or systems.

ATMEL ® is the registered trademark of Atmel.

MCS-51 ® is the registered trademark of Intel Corporation. Terms and product names in this document may be
trademarks of others.

Printed on recycled paper.

Rev.1919A-07/01/xM
LM35 Precision Centigrade Temperature Sensors
November 2000

LM35
Precision Centigrade Temperature Sensors
General Description aged in hermetic TO-46 transistor packages, while the
LM35C, LM35CA, and LM35D are also available in the
The LM35 series are precision integrated-circuit temperature plastic TO-92 transistor package. The LM35D is also avail-
sensors, whose output voltage is linearly proportional to the able in an 8-lead surface mount small outline package and a
Celsius (Centigrade) temperature. The LM35 thus has an plastic TO-220 package.
advantage over linear temperature sensors calibrated in
˚ Kelvin, as the user is not required to subtract a large
constant voltage from its output to obtain convenient Centi- Features
grade scaling. The LM35 does not require any external n Calibrated directly in ˚ Celsius (Centigrade)
calibration or trimming to provide typical accuracies of ± 1⁄4˚C n Linear + 10.0 mV/˚C scale factor
at room temperature and ± 3⁄4˚C over a full −55 to +150˚C n 0.5˚C accuracy guaranteeable (at +25˚C)
temperature range. Low cost is assured by trimming and n Rated for full −55˚ to +150˚C range
calibration at the wafer level. The LM35’s low output imped- n Suitable for remote applications
ance, linear output, and precise inherent calibration make n Low cost due to wafer-level trimming
interfacing to readout or control circuitry especially easy. It
n Operates from 4 to 30 volts
can be used with single power supplies, or with plus and
minus supplies. As it draws only 60 µA from its supply, it has n Less than 60 µA current drain
very low self-heating, less than 0.1˚C in still air. The LM35 is n Low self-heating, 0.08˚C in still air
rated to operate over a −55˚ to +150˚C temperature range, n Nonlinearity only ± 1⁄4˚C typical
while the LM35C is rated for a −40˚ to +110˚C range (−10˚ n Low impedance output, 0.1 Ω for 1 mA load
with improved accuracy). The LM35 series is available pack-

Typical Applications

DS005516-4

DS005516-3 Choose R1 = −VS/50 µA


FIGURE 1. Basic Centigrade Temperature Sensor V OUT =+1,500 mV at +150˚C
= +250 mV at +25˚C
(+2˚C to +150˚C)
= −550 mV at −55˚C
FIGURE 2. Full-Range Centigrade Temperature Sensor

© 2000 National Semiconductor Corporation DS005516 www.national.com


LM35
Connection Diagrams

TO-46 SO-8
Metal Can Package* Small Outline Molded Package

DS005516-1 DS005516-21

*Case is connected to negative pin (GND) N.C. = No Connection


Order Number LM35H, LM35AH, LM35CH, LM35CAH or Top View
LM35DH Order Number LM35DM
See NS Package Number H03H See NS Package Number M08A

TO-92 TO-220
Plastic Package Plastic Package*

DS005516-2

Order Number LM35CZ,


LM35CAZ or LM35DZ
See NS Package Number Z03A

DS005516-24

*Tab is connected to the negative pin (GND).


Note: The LM35DT pinout is different than the discontinued LM35DP.
Order Number LM35DT
See NS Package Number TA03F

www.national.com 2
LM35
Absolute Maximum Ratings (Note 10) TO-92 and TO-220 Package,
(Soldering, 10 seconds) 260˚C
If Military/Aerospace specified devices are required,
please contact the National Semiconductor Sales Office/ SO Package (Note 12)
Distributors for availability and specifications. Vapor Phase (60 seconds) 215˚C
Infrared (15 seconds) 220˚C
Supply Voltage +35V to −0.2V
ESD Susceptibility (Note 11) 2500V
Output Voltage +6V to −1.0V
Specified Operating Temperature Range: TMIN to T MAX
Output Current 10 mA (Note 2)
Storage Temp.; LM35, LM35A −55˚C to +150˚C
TO-46 Package, −60˚C to +180˚C LM35C, LM35CA −40˚C to +110˚C
TO-92 Package, −60˚C to +150˚C LM35D 0˚C to +100˚C
SO-8 Package, −65˚C to +150˚C
TO-220 Package, −65˚C to +150˚C
Lead Temp.:
TO-46 Package,
(Soldering, 10 seconds) 300˚C

Electrical Characteristics
(Notes 1, 6)
LM35A LM35CA
Parameter Conditions Tested Design Tested Design Units
Typical Limit Limit Typical Limit Limit (Max.)
(Note 4) (Note 5) (Note 4) (Note 5)
Accuracy T A =+25˚C ± 0.2 ± 0.5 ± 0.2 ± 0.5 ˚C
(Note 7) T A =−10˚C ± 0.3 ± 0.3 ± 1.0 ˚C
T A =TMAX ± 0.4 ± 1.0 ± 0.4 ± 1.0 ˚C
T A =TMIN ± 0.4 ± 1.0 ± 0.4 ± 1.5 ˚C
Nonlinearity T MIN≤TA≤TMAX ± 0.18 ± 0.35 ± 0.15 ± 0.3 ˚C
(Note 8)
Sensor Gain T MIN≤TA≤TMAX +10.0 +9.9, +10.0 +9.9, mV/˚C
(Average Slope) +10.1 +10.1
Load Regulation T A =+25˚C ± 0.4 ± 1.0 ± 0.4 ± 1.0 mV/mA
(Note 3) 0≤IL≤1 mA T MIN≤TA≤TMAX ± 0.5 ± 3.0 ± 0.5 ± 3.0 mV/mA
Line Regulation T A =+25˚C ± 0.01 ± 0.05 ± 0.01 ± 0.05 mV/V
(Note 3) 4V≤V S≤30V ± 0.02 ± 0.1 ± 0.02 ± 0.1 mV/V
Quiescent Current V S =+5V, +25˚C 56 67 56 67 µA
(Note 9) V S =+5V 105 131 91 114 µA
V S =+30V, +25˚C 56.2 68 56.2 68 µA
V S =+30V 105.5 133 91.5 116 µA
Change of 4V≤VS≤30V, +25˚C 0.2 1.0 0.2 1.0 µA
Quiescent Current 4V≤V S≤30V 0.5 2.0 0.5 2.0 µA
(Note 3)
Temperature +0.39 +0.5 +0.39 +0.5 µA/˚C
Coefficient of
Quiescent Current
Minimum Temperature In circuit of +1.5 +2.0 +1.5 +2.0 ˚C
for Rated Accuracy Figure 1, IL =0
Long Term Stability T J =TMAX, for ± 0.08 ± 0.08 ˚C
1000 hours

3 www.national.com
LM35
Electrical Characteristics
(Notes 1, 6)
LM35 LM35C, LM35D
Parameter Conditions Tested Design Tested Design Units
Typical Limit Limit Typical Limit Limit (Max.)
(Note 4) (Note 5) (Note 4) (Note 5)
Accuracy, T A =+25˚C ± 0.4 ± 1.0 ± 0.4 ± 1.0 ˚C
LM35, LM35C T A =−10˚C ± 0.5 ± 0.5 ± 1.5 ˚C
(Note 7) T A =TMAX ± 0.8 ± 1.5 ± 0.8 ± 1.5 ˚C
T A =TMIN ± 0.8 ± 1.5 ± 0.8 ± 2.0 ˚C
Accuracy, LM35D T A =+25˚C ± 0.6 ± 1.5 ˚C
(Note 7) TA =TMAX ± 0.9 ± 2.0 ˚C
TA =TMIN ± 0.9 ± 2.0 ˚C
Nonlinearity T MIN≤TA≤TMAX ± 0.3 ± 0.5 ± 0.2 ± 0.5 ˚C
(Note 8)
Sensor Gain T MIN≤TA≤TMAX +10.0 +9.8, +10.0 +9.8, mV/˚C
(Average Slope) +10.2 +10.2
Load Regulation T A =+25˚C ± 0.4 ± 2.0 ± 0.4 ± 2.0 mV/mA
(Note 3) 0≤IL≤1 mA T MIN≤TA≤TMAX ± 0.5 ± 5.0 ± 0.5 ± 5.0 mV/mA
Line Regulation T A =+25˚C ± 0.01 ± 0.1 ± 0.01 ± 0.1 mV/V
(Note 3) 4V≤V S≤30V ± 0.02 ± 0.2 ± 0.02 ± 0.2 mV/V
Quiescent Current V S =+5V, +25˚C 56 80 56 80 µA
(Note 9) V S =+5V 105 158 91 138 µA
V S =+30V, +25˚C 56.2 82 56.2 82 µA
V S =+30V 105.5 161 91.5 141 µA
Change of 4V≤VS≤30V, +25˚C 0.2 2.0 0.2 2.0 µA
Quiescent Current 4V≤V S≤30V 0.5 3.0 0.5 3.0 µA
(Note 3)
Temperature +0.39 +0.7 +0.39 +0.7 µA/˚C
Coefficient of
Quiescent Current
Minimum Temperature In circuit of +1.5 +2.0 +1.5 +2.0 ˚C
for Rated Accuracy Figure 1, IL =0
Long Term Stability T J =TMAX, for ± 0.08 ± 0.08 ˚C
1000 hours
Note 1: Unless otherwise noted, these specifications apply: −55˚C≤TJ≤+150˚C for the LM35 and LM35A; −40˚≤TJ≤+110˚C for the LM35C and LM35CA; and
0˚≤TJ≤+100˚C for the LM35D. VS =+5Vdc and ILOAD =50 µA, in the circuit of Figure 2. These specifications also apply from +2˚C to TMAX in the circuit of Figure 1.
Specifications in boldface apply over the full rated temperature range.
Note 2: Thermal resistance of the TO-46 package is 400˚C/W, junction to ambient, and 24˚C/W junction to case. Thermal resistance of the TO-92 package is
180˚C/W junction to ambient. Thermal resistance of the small outline molded package is 220˚C/W junction to ambient. Thermal resistance of the TO-220 package
is 90˚C/W junction to ambient. For additional thermal resistance information see table in the Applications section.
Note 3: Regulation is measured at constant junction temperature, using pulse testing with a low duty cycle. Changes in output due to heating effects can be
computed by multiplying the internal dissipation by the thermal resistance.
Note 4: Tested Limits are guaranteed and 100% tested in production.
Note 5: Design Limits are guaranteed (but not 100% production tested) over the indicated temperature and supply voltage ranges. These limits are not used to
calculate outgoing quality levels.
Note 6: Specifications in boldface apply over the full rated temperature range.
Note 7: Accuracy is defined as the error between the output voltage and 10mv/˚C times the device’s case temperature, at specified conditions of voltage, current,
and temperature (expressed in ˚C).
Note 8: Nonlinearity is defined as the deviation of the output-voltage-versus-temperature curve from the best-fit straight line, over the device’s rated temperature
range.
Note 9: Quiescent current is defined in the circuit of Figure 1.
Note 10: Absolute Maximum Ratings indicate limits beyond which damage to the device may occur. DC and AC electrical specifications do not apply when operating
the device beyond its rated operating conditions. See Note 1.
Note 11: Human body model, 100 pF discharged through a 1.5 kΩ resistor.
Note 12: See AN-450 “Surface Mounting Methods and Their Effect on Product Reliability” or the section titled “Surface Mount” found in a current National
Semiconductor Linear Data Book for other methods of soldering surface mount devices.

www.national.com 4
LM35
Typical Performance Characteristics
Thermal Resistance Thermal Time Constant Thermal Response
Junction to Air in Still Air

DS005516-26
DS005516-25 DS005516-27

Thermal Response in Minimum Supply Quiescent Current


Stirred Oil Bath Voltage vs. Temperature vs. Temperature
(In Circuit of Figure 1.)

DS005516-29
DS005516-28

DS005516-30

Quiescent Current Accuracy vs. Temperature Accuracy vs. Temperature


vs. Temperature (Guaranteed) (Guaranteed)
(In Circuit of Figure 2.)

DS005516-32 DS005516-33

DS005516-31

5 www.national.com
LM35
Typical Performance Characteristics (Continued)

Noise Voltage Start-Up Response

DS005516-34 DS005516-35

Applications The TO-46 metal package can also be soldered to a metal


surface or pipe without damage. Of course, in that case the
The LM35 can be applied easily in the same way as other V− terminal of the circuit will be grounded to that metal.
integrated-circuit temperature sensors. It can be glued or Alternatively, the LM35 can be mounted inside a sealed-end
cemented to a surface and its temperature will be within metal tube, and can then be dipped into a bath or screwed
about 0.01˚C of the surface temperature. into a threaded hole in a tank. As with any IC, the LM35 and
This presumes that the ambient air temperature is almost the accompanying wiring and circuits must be kept insulated and
same as the surface temperature; if the air temperature were dry, to avoid leakage and corrosion. This is especially true if
much higher or lower than the surface temperature, the the circuit may operate at cold temperatures where conden-
actual temperature of the LM35 die would be at an interme- sation can occur. Printed-circuit coatings and varnishes such
diate temperature between the surface temperature and the as Humiseal and epoxy paints or dips are often used to
air temperature. This is expecially true for the TO-92 plastic insure that moisture cannot corrode the LM35 or its connec-
package, where the copper leads are the principal thermal tions.
path to carry heat into the device, so its temperature might These devices are sometimes soldered to a small
be closer to the air temperature than to the surface tempera- light-weight heat fin, to decrease the thermal time constant
ture. and speed up the response in slowly-moving air. On the
To minimize this problem, be sure that the wiring to the other hand, a small thermal mass may be added to the
LM35, as it leaves the device, is held at the same tempera- sensor, to give the steadiest reading despite small deviations
ture as the surface of interest. The easiest way to do this is in the air temperature.
to cover up these wires with a bead of epoxy which will
insure that the leads and wires are all at the same tempera-
ture as the surface, and that the LM35 die’s temperature will
not be affected by the air temperature.

Temperature Rise of LM35 Due To Self-heating (Thermal Resistance,θJA)


TO-46, TO-46*, TO-92, TO-92**, SO-8 SO-8** TO-220
no heat small heat fin no heat small heat fin no heat small heat fin no heat
sink sink sink sink
Still air 400˚C/W 100˚C/W 180˚C/W 140˚C/W 220˚C/W 110˚C/W 90˚C/W
Moving air 100˚C/W 40˚C/W 90˚C/W 70˚C/W 105˚C/W 90˚C/W 26˚C/W
Still oil 100˚C/W 40˚C/W 90˚C/W 70˚C/W
Stirred oil 50˚C/W 30˚C/W 45˚C/W 40˚C/W
(Clamped to metal,
Infinite heat sink) (24˚C/W) (55˚C/W)

*Wakefield type 201, or 1" disc of 0.020" sheet brass, soldered to case, or similar.
**TO-92 and SO-8 packages glued and leads soldered to 1" square of 1/16" printed circuit board with 2 oz. foil or similar.

www.national.com 6
LM35
Typical Applications

DS005516-19

FIGURE 3. LM35 with Decoupling from Capacitive Load

DS005516-6

FIGURE 6. Two-Wire Remote Temperature Sensor


(Output Referred to Ground)

DS005516-20

FIGURE 4. LM35 with R-C Damper

CAPACITIVE LOADS
Like most micropower circuits, the LM35 has a limited ability
to drive heavy capacitive loads. The LM35 by itself is able to
drive 50 pf without special precautions. If heavier loads are
anticipated, it is easy to isolate or decouple the load with a
resistor; see Figure 3. Or you can improve the tolerance of
capacitance with a series R-C damper from output to
ground; see Figure 4.
When the LM35 is applied with a 200Ω load resistor as DS005516-7

shown in Figure 5, Figure 6 or Figure 8 it is relatively immune FIGURE 7. Temperature Sensor, Single Supply, −55˚ to
to wiring capacitance because the capacitance forms a by- +150˚C
pass from ground to input, not on the output. However, as
with any linear circuit connected to wires in a hostile envi-
ronment, its performance can be affected adversely by in-
tense electromagnetic sources such as relays, radio trans-
mitters, motors with arcing brushes, SCR transients, etc, as
its wiring can act as a receiving antenna and its internal
junctions can act as rectifiers. For best results in such cases,
a bypass capacitor from VIN to ground and a series R-C
damper such as 75Ω in series with 0.2 or 1 µF from output to
ground are often useful. These are shown in Figure 13,
Figure 14, and Figure 16.

DS005516-8

FIGURE 8. Two-Wire Remote Temperature Sensor


(Output Referred to Ground)

DS005516-5

FIGURE 5. Two-Wire Remote Temperature Sensor


(Grounded Sensor)

DS005516-9

FIGURE 9. 4-To-20 mA Current Source (0˚C to +100˚C)

7 www.national.com
LM35
Typical Applications (Continued)

DS005516-11

FIGURE 11. Centigrade Thermometer (Analog Meter)

DS005516-10

FIGURE 10. Fahrenheit Thermometer

DS005516-12

FIGURE 12. Fahrenheit ThermometerExpanded Scale


Thermometer
(50˚ to 80˚ Fahrenheit, for Example Shown)

DS005516-13

FIGURE 13. Temperature To Digital Converter (Serial Output) (+128˚C Full Scale)

DS005516-14

FIGURE 14. Temperature To Digital Converter (Parallel TRI-STATE™ Outputs for


Standard Data Bus to µP Interface) (128˚C Full Scale)

www.national.com 8
LM35
Typical Applications (Continued)

DS005516-16

* =1% or 2% film resistor


Trim RB for VB =3.075V
Trim RC for VC =1.955V
Trim RA for VA =0.075V + 100mV/˚C x Tambient
Example, VA =2.275V at 22˚C

FIGURE 15. Bar-Graph Temperature Display (Dot Mode)

DS005516-15

FIGURE 16. LM35 With Voltage-To-Frequency Converter And Isolated Output


(2˚C to +150˚C; 20 Hz to 1500 Hz)

9 www.national.com
LM35
Block Diagram

DS005516-23

www.national.com 10
LM35
Physical Dimensions inches (millimeters) unless otherwise noted

TO-46 Metal Can Package (H)


Order Number LM35H, LM35AH, LM35CH,
LM35CAH, or LM35DH
NS Package Number H03H

SO-8 Molded Small Outline Package (M)


Order Number LM35DM
NS Package Number M08A

11 www.national.com
LM35
Physical Dimensions inches (millimeters) unless otherwise noted (Continued)

Power Package TO-220 (T)


Order Number LM35DT
NS Package Number TA03F

www.national.com 12
LM35 Precision Centigrade Temperature Sensors
Physical Dimensions inches (millimeters) unless otherwise noted (Continued)

TO-92 Plastic Package (Z)


Order Number LM35CZ, LM35CAZ or LM35DZ
NS Package Number Z03A

LIFE SUPPORT POLICY


NATIONAL’S PRODUCTS ARE NOT AUTHORIZED FOR USE AS CRITICAL COMPONENTS IN LIFE SUPPORT
DEVICES OR SYSTEMS WITHOUT THE EXPRESS WRITTEN APPROVAL OF THE PRESIDENT AND GENERAL
COUNSEL OF NATIONAL SEMICONDUCTOR CORPORATION. As used herein:
1. Life support devices or systems are devices or 2. A critical component is any component of a life
systems which, (a) are intended for surgical implant support device or system whose failure to perform
into the body, or (b) support or sustain life, and can be reasonably expected to cause the failure of
whose failure to perform when properly used in the life support device or system, or to affect its
accordance with instructions for use provided in the safety or effectiveness.
labeling, can be reasonably expected to result in a
significant injury to the user.
National Semiconductor National Semiconductor National Semiconductor National Semiconductor
Corporation Europe Asia Pacific Customer Japan Ltd.
Americas Fax: +49 (0) 180-530 85 86 Response Group Tel: 81-3-5639-7560
Tel: 1-800-272-9959 Email: europe.support@nsc.com Tel: 65-2544466 Fax: 81-3-5639-7507
Fax: 1-800-737-7018 Deutsch Tel: +49 (0) 69 9508 6208 Fax: 65-2504466
Email: support@nsc.com English Tel: +44 (0) 870 24 0 2171 Email: ap.support@nsc.com
www.national.com Français Tel: +33 (0) 1 41 91 8790

National does not assume any responsibility for use of any circuitry described, no circuit patent licenses are implied and National reserves the right at any time without notice to change said circuitry and specifications.
PROTOTIPE SISTEM KENDALI TEMPERATUR
BERBASIS FUZZY LOGIC PADA SEBUAH INKUBATOR
Anies Hannawati, Thiang, Resmana
JURUSAN TEKNIK ELEKTRO
UNIVERSISTAS KRISTEN PETRA

Abstrak

Makalah ini menyajikan framework teknik perancangan kendali temperatur berbasis


fuzzy logic yang diaplikasikan pada sebuah inkubator. Dengan fuzzy logic memungkinkan dibuat
sistem kendali cerdas yang mengemulasikan kepandaian seorang pakar dalam mengendalikan
temperatur. Pengetahuan seorang pakar kendali diekstrak (knowledge acquisition) dan
ditransformasikan ke dalam bentuk membership function dan fuzzy if-then rules yang selanjutnya
diproses untuk menghasilkan aksi kendali.
Penekanan utama makalah ini terletak pada metodologi perancangan kendali fuzzy yang
terdiri dari pemahaman sistem plant yang akan dikendalikan, identifikasi input/output,
penentuan membership function dan pembentukan fuzzy if-then rules. Pada proses perancangan
ini penulis dibantu dengan program PetraFuz, yaitu sistem pengembangan kendali fuzzy logic
dengan menggunakan sistem mikrokontroler MCS51 yang dikembangkan pada institusi penulis.
Proses kendali fuzzy dilakukan oleh sistem mikrokontroler MCS51 yang dilengkapi
dengan interface digital dan analog. Sebuah sensor temperatur LM335 dan aktuator pemanas
berupa bola lampu digunakan disini. Percobaan menunjukan bahwa kendali fuzzy logic relatif
mudah dan fleksibel dirancang, dengan tidak melibatkan model matematik rumit dari sistem
yang akan dikendalikan.Untuk mencapai setting point 57°dibutuhkan waktu dua menit dengan
steady state error 3°. Pemberian disturbance dapat ditangani dengan cukup baik tanpa diikuti
degradasi respon kendali yang berarti. Penggunaan tools PetraFuz pada prototipe ini sangat
membantu proses rancang bangun sistem kendali fuzzy. Respon kendali secara langsung bisa
diamati pada layar monitor PC dan secara interaktif proses penalaan membership function dan
if-then rules dapat dilakukan untuk mencapai respon yang optimum.

Kata Kunci: fuzzy logic controller, temperature control, microcontroller MCS51

1. PENDAHULUAN 2. METODE PERANCANGAN SISTEM

Penggunaan teknik kendali Fuzzy Logic telah cukup Perancangan prototipe sistem kendali temperatur
meluas pada berbagai aplikasi mulai dari kendali proses inkubator ini diawali dengan pemahaman plant yang
industri, elektronika rumah tangga, kendali robot dan akan dikendalikan. Di sini digunakan sebuah kotak
lain-lain(1) . Dalam makalah ini diberi suatu contoh inkubator berukuran 25 cm x 50 cm x 30 cm yang terbuat
aplikasi sederhana yang menggunakan kendali fuzzy, dari kaca. Sebagai pemanas digunakan empat buah bola
yaitu sistem pengaturan temperatur udara pada sebuah lampu masing-masing 100 Watt. Plant juga dilengkapi
inkubator. Dimana nantinya sistem ini dapat diterapkan dengan pendingin berupa kipas. Sebagai sensor suhu
pada berbagai aplikasi kendali bidang pertanian, digunakan sebuah solid state temperatur sensor LM335.
misalnya: inkubator, penetasan anak ayam, cold/hot Agar dapat diamati pengaruh pemberian gangguan dari
storage dan sebagainya. Sistem kendali bidang pertanian luar, plant ini dilengkapi dengan sumber disturbance
saat ini sudah melewati perkembangan yang pesat, akan berupa empat buah lampu masing-masing 100 Watt dan
tetapi kendali fuzzy di bidang pertanian belum banyak sebuah kipas.
dikembangkan. Padahal proses kendali ini relatif mudah Langkah berikutnya, dilanjutkan dengan identifikasi
dan fleksibel dirancang, dengan tidak melibatkan model input/output bagi kendali Fuzzy. Di sini digunakan dua
matematik rumit dari sistem yang akan dikendalikan. input yaitu sinyal Error, yaitu berupa selisih antara
Penggunaan tools PetraFuz pada prototipe ini sangat Setting Point dan Present Value dan sinyal D_error yang
membantu proses rancang bangun sistem kendali fuzzy. merupakan kecepatan perubahan sinyal Error. Untuk
Respon kendali secara langsung bisa diamati pada layar output digunakan dua buah yaitu output lampu yang
monitor PC. merupakan langkah perubahan penyalaan lampu serta
output kipas (on atau off).
DISTURBANCE
SAKLAR

SAKLAR

RELAY

MICROCONTROLLER
SENSOR SPAN & ZERO ADC
8031
RELAY

PLANT : INKUBATOR

Gambar 1 Blok Diagram Perangkat Keras

Setelah I/O fuzzy teridentifikasi, langkah selanjutnya mengontrol suhu, yaitu dengan menyalakan atau
adalah membangun I/O membership function dan fuzzy mematikan kipas atau lampu. Penyalaan kipas dan lampu
if-then rules dengan bantuan program Petra Fuz yang dilakukan melalui relay. Setting Point (SP), Present
akan dijelaskan kemudian. Selanjutnya PetraFuz Value (PV), error, d_error sistem akan dimonitor oleh
membentuk program bahasa assembly MCS51 yang akan program PetraFuz pada PC. Sistem juga dilengkapi
digabungkan dengan user program, lalu dicompile dan dengan gangguan dari luar (disturbance) yaitu berupa
didownload menuju target sistem Mikrokontroler empat buah lampu dan satu kipas yang dapat dinyalakan
MCS51. atau dimatikan sewaktu-waktu melalui saklar, sistem
kendali temperatur berbasis fuzzy dapat dilihat pada
2.1Perangkat Keras gambar 2.
Saat SP diinputkan ke dalam sistem, maka
Blok diagram perangkat keras yang dibuat seperti sistem akan menghitung error dan d_error. Kedua
pada gambar 1 di atas. Sensor yang digunakan adalah variabel ini menjadi input akan dalam Fuzzy Logic
sensor suhu LM335, dimana range output tegangan yang Controller yang berupa perangkat lunak sistem.Output
didapat adalah 0-2,5 Volt. Untuk menyesuaikan dengan dari FLC memberikan aksi kendali pada plant, dalam hal
range ADC 0-5 Volt maka digunakan rangkaian Span ini mengaktifkan relay-relay untuk mematikan atau
and Zero. Output ADC berupa data 8 bit yang diinputkan menyalakan kipas/lampu. Temperatur output plant akan
pada Mikrokontroller 8031. Dalam Mikrokontroler diumpanbalikkan guna menghitung sinyal error dan
terdapat program fuzzy yang digunakan untuk d_error.

SP e(n) HEATER
+
FUZZY LOGIC
OUTPUT TEMP.
- de(n) CONTROLLER COOLER PLANT

Gambar 2 Blok Diagram Plant Dan Sistem Kendali Fuzzy


2.2 Perang kat Lunak
Batasan-batasan yang digunakan untuk input
2.1.1 Pembuatan Membership Function (MF) membership function dapat dilihat di tabel 1.

Pembuatan perangkat lunak FLC diawali dengan Tabel 1 Batasan Input Membership Function
membentuk membership function dari crisp input dan
output. Pada plant yang kami gunakan, terdapat dua buah Label Point 1 Point 2 Point 3 Point 4
crisp input dan dua buah crisp output. Crisp input yang NB -255.00 -255.00 -170.00 -85.00
digunakan yaitu Error dan D_error sedangkan crisp NS -170.00 -85.00 -85.00 0.00
output yang digunakan yaitu Lampu dan Kipas. Z -85.00 0.00 0.00 85.00
Tidak seperti kontroler konvensional yang membutuhkan PS 0.00 85.00 85.00 170.00
batasan yang tepat dari input dan outputnya, FLC PB 85.00 170.00 255.00 255.00
menggunakan pendekatan secara lebih sederhana yaitu

•Output Lampu
dengan menggunakan batasan-batasan negatif, nol dan
positif. Pada desain ini, digunakan segitiga dan trapesium
untuk MF input dan bentuk singleton untuk MF output. Jumlah output membership function yang digunakan
Alasan digunakan bentuk singleton pada MF output yaitu untuk Lampu adalah lima buah yaitu yaitu dengan label
untuk memudahkan perhitungan COG (Center of Negative Big (NB), Negative Small (NS), Zero (Z),
Gravity) dari output. Positive Small (PS), dan Positive Big (PB), dalam bentuk
singleton.

•Input Error
Jumlah label membership function yang digunakan
untuk error adalah lima buah yaitu dengan label Negative
Big (NB), Negative Small (NS), Zero (Z), Positive Small
(PS), dan Positive Big (PB), dengan batasan 00H-FFH.
Bentuk membership function yang digunakan yaitu
trapesium dan segitiga (lihat gambar 3).
Gambar 5 Output Membership Function Lampu

Batasan yang digunakan untuk output membership


function dari lampu dapat dilihat di tabel 2.

Tabel 2 Batasan Output Membership Function Lampu

Label Point Arti


NB -2.00 Matikan dua buah lampu
NS -1.00 Matikan satu buah lampu
Gambar 3 Input Error Membership Function
Z 0.00 Tetap pada kondisi terakhir
PS 1.00 Nyalakan satu buah lampu
•Input D_error PB 2.00 Nyalakan dua buah lampu
Untuk crisp input d_error, membership function yang
digunakan sama dengan crisp input error, yaitu Negative
Big (NB), Negative Small (NS), Zero (Z), Positive Small •Output Kipas
(PS), dan Positive Big (PB). Untuk lebih jelasnya lihat Untuk output Kipas digunakan dua buah membership
gambar 4. function yaitu Negative (N) dan Positive (P) dalam
bentuk singleton dengan batasan Negative (N) = -1.00
yang artinya matikan kipas dan Positive (P) = 1.00 yang
artinya nyalakan kipas.

Gambar 4 Input D_error Membership Function


Gambar 6 Output Membership Function Kipas
SP

Gambar 7 Grafik Respon Output terhadap Waktu

dikeluarkan adalah positif dan besar (point a), atau bila


(2)
2.1.2 Pembuatan Rules dituliskan dalam bentuk rule yaitu :
IF error e(n) is Positive Big (PB) AND d_error
Setelah selesai membuat input dan output De(n) is Zero (Z) THEN Output u(n) is Positive Big
membership function, langkah selanjutnya yaitu (PB), untuk lebih jelasnya perhatikan tabel 3.
membuat rules. Proses pembuatan rules dilakukan
dengan menerapkan kemampuan manusia dalam Tabel 3 Rules
mengendalikan suatu sistem kendali. Secara umum
respon fungsi step suatu sistem kendali akan memberikan RULE e(n) De(n) u(n) POINT
output seperti yang terlihat pada gambar 7. Pada saat
1. PB Z PB A
sistem diaktifkan (output=0 dan waktu=0), output akan
2. Z NB NB B
naik dengan cepat menuju setting point (SP), bahkan
3. NB Z NB C
jauh melebihi SP. Output ini oleh kontroler akan
diturunkan menuju SP, tetapi proses penurunan ini juga 4. Z PB PB D
mengalami kelebihan sehingga outputnya akan berosilasi 5. PS Z PS E
di sekitar SP, hingga akhirnya outputnya mencapai SP. 6. Z NS NS F
Apa yang dilakukan oleh kontroler untuk menaikkan dan 7. NS Z NS G
menurunkan output harus sesuai dengan harga output 8. Z PS PS H
saat itu dan sebelumnya (tergantung dari error dan 9. Z Z Z SP
d_error), sehingga kontroler dapat mengambil tindakan 10. PB NS PS A-B
yang tepat untuk menyesuaikan outputnya. 11. PB NB Z A-B
Harga Error dan D_error ditentukan dari persamaan : 12. PS NB NS A-B
Error = SP – PV (1) 13. NS NS NS B-C
D_error = e(n) – e(n-1) (2)
14. NB PS NS C-D
Keterangan :
15. NB PB Z C-D
SP = Harga Setting Point
16. NS PS Z C-D
PV = Harga Output pada saat t
e(n) = Harga error pada saat t 17. NS PB PS C-D
e(n-1) = Harga error pada saat t-1 18. PS PS PS D-F
19. PS NS Z E-F
Dari gambar 7, terlihat jika Error adalah positif besar,
dan D_error adalah nol, maka output yang harus
Gambar 8 Rules untuk Output Lampu

Untuk lebih memudahkan penyusunan rules, maka respon sistem atau memonitor harga SP, PV, error dan
sering kali digunakan sistem matrix seperti terlihat pada d_error beserta hasil defuzzification maka data-data
gambar 8 dan gambar 9. Pada plant yang dirancang, tersebut perlu ditransfer ke PC melalui serial RS 232
digunakan dua buah output yaitu lampu dan kipas agar dapat diakuisisi oleh program PetraFuz. Kegiatan
sehingga rules yang ada terbagi dua yaitu masing-masing ini dilakukan terus-menerus dengan selang waktu T
untuk output lampu dan kipas. Untuk output lampu kami merupakan periode sampling. Di sini digunakan T = 0,5
menggunakan 19 buah rules seperti terlihat pada gambar detik. Program utama dapat dilihat pada gambar 11.
8, dengan memperhatikan input error dan d_error.
Sedangkan untuk output kipas, kami menggunakan lima START
buah rules yang hanya memperhatikan input error (lihat
gambar 9).

INISIALISASI SET POINT = SP

BACA SENSOR ( PV )
HITUNG ERROR = SP-PV
HITUNG DERROR=e(n)-e(n-1)

CALL FIS
T = SAMPLING
TIME
Gambar 9 Rules untuk Output Kipas

OUTPUT AKTUATOR
2.1.3 Pembuatan Program Assembly ( HEATER, COOLER )

Secara singkat diagram alir dari program yang


dibuat seperti pada gambar 10. Pada saat awal dilakukan
inisialisasi dengan memasukkan harga SP. Kemudian TRANSFER DATA KE
AKUISISI KE PC
program akan dilanjutkan dengan membaca keadaan
suhu saat itu dari sistem (PV), melakukan perhitungan
error dan d_error. Setelah harga-harga Error dan D_error
siap, program akan memanggil prosedur fuzzy (LCALL
DELAY
FIS). Prosedur fuzzy ini terdapat dalam Kernel System
target yang berada pada alamat 40A H. Dalam prosedur
ini harga error dan d_error akan melalui proses
fuzzification, rules evaluation dan defuzzification. END
Kemudian dari hasil defuzzification digunakan untuk
menentukan tindakan yang akan dilakukan, yaitu
mematikan atau menyalakan kipas/lampu. Untuk melihat Gambar 10 Diagram Alir Program
Gambar 11 Potongan Program Utama

3. HASIL-HASIL PV terhadap waktu. Garis lurus menunjukkan SP dari


sistem. Dari grafik ini terlihat bahwa sistem kendali
Eksperimen dilakukan dengan memanfaatkan tools bekerja cukup baik. Harga PV mendekati harga SP
yang disediakan oleh sistem PetraFuz sehingga respon dengan sedikit osilasi. Respon sistem untuk mencapai
dari sistem kendali temperatur udara dapat dimonitor harga yang diinginkan dapat dilakukan dengan cepat dan
secara terus-menerus melalui PC. Berikut ini adalah baik. Untuk SP 57°dapat dicapai dalam 2 menit dengan
beberapa gambar hasil akuisi data dari eksperimen yang steady state error 3°.
dilakukan. Gambar 12 adalah grafik respon sistem
kendali temperatur udara yang telah dirancang yaitu nilai

Gambar 12 Grafik SP dan PV

Gambar 12 Grafik Respon Sistem PV dan SP terhadap Waktu


Gambar 13 Grafik Error terhadap Waktu

Gambar 13 merupakan grafik error terhadap waktu. Pada saat awal harga d_error adalah nol kemudian untuk
Terlihat bahwa pada saat awal harga error bernilai positif beberapa saat selalu negatif baru kemudian harga d_error
sangat besar. Hal ini terjadi karena pada saat pertama berubah-ubah dari nilai negatif ke positif kembali ke
kali harga PV jauh di bawah harga SP. Beberapa saat negatif demikian seterusnya. Saat d_error negatif berarti
kemudian sistem kendali dapat berjalan dengan baik dan sistem kendali sedang berusaha menaikkan suhu aktual
berhasil menurunkan error mendekati nol. Garis lurus (PV) menuju ke SP. Sedangkan saat d_error positif
adalah posisi pada saat nilai error nol. berarti sistem kendali sedang menurunkan suhu menuju
Gambar 14 menunjukkan grafik d_error terhadap ke SP.
waktu. Garis lurus menunjukkan nilai nol dari d_error.

Gambar 14 Grafik D_error terhadap Waktu


Titik Awal Pemberian Disturbance

Gambar 15 Grafik Respon Sistem dengan Gangguan Dua Lampu

Eksperimen selanjutnya dilakukan dengan dengan menambahkan gangguan sehingga sistem


memberikan gangguan pada sistem yang dikendalikan. mendapatkan gangguan yang lebih besar. Dalam hal ini
Gangguan tersebut berupa panas dari luar sistem yang gangguan berupa empat lampu yang dinyalakan. Gambar
disimulasikan dengan menyalakan lampu disturbance. 16 menunjukkan grafik respon sistem bila sistem diberi
Gambar 15 merupakan grafik respon sistem (nilai PV gangguan dari luar berupa empat buah lampu dinyalakan
terhadap waktu) jika sistem diberi gangguan berupa dua bersama-sama. Dari grafik tersebut terlihat bahwa respon
lampu yang dinyalakan bersama-sama. sistem kendali masih dapat dikatakan bekerja dengan
Dari gambar terlihat bahwa sistem kendali yang baik karena sistem kendali dapat mempertahankan harga
dirancang bekerja cukup baik dalam mengatasi gangguan PV selalu mendekati SP. Bila dibandingkan dengan
yang timbul dari luar sistem. Eksperimen selanjutnya gangguan dua lampu, tentu hasilnya lebih buruk.

Titik Awal Pemberian Disturbance

Gambar 16 Grafik Sistem dengan Gangguan Empat Lampu


4. KESIMPULAN System Laboratory, Petra Christian University,
1998.
Dari hasil hasil eksperimen yang sudah dilakukan
terdapat beberapa hal yang perlu dicatat antara lain:
• Proses ekperimen menunjukkan bawah teknik KONTAK PERSON
kendali fuzzy logic relatif mudah untuk dirancang.
Anies Hannawati, S.T. ; Thiang, S.T. ; Ir. Resmana,
Dengan menerapkan asas-asas atau logika umum,
fuzzy rules dapat dibentuk dengan mudah. M.Eng.
Laboratorium Sistem Kontrol
• Penggunaan sistem pengembangan fuzzy logic Jurusan Teknik Elektro
PetraFuz cukup membantu dalam melakukan Universitas Kristen Petra
perancangan dan implementasi kendali temperatur Siwalankerto 121-131, Surabaya
inkubator ini. Proses kendali dapat diamati secara Telp. (031) 8439040
online dimana hal ini sangat dibutuhkan dalam Fax. (031) 8436418
penalaan fuzzy. E-mail: thiang@peter.petra.ac.id
• Dari hasil pengujian tampak bahwa kendali fuzzy anies@peter.petra.ac.id
mampu mengatasi gangguan dari luar dengan resmana@peter.petra.ac.id
degradasi respon kendali yang tidak terlalu
signifikan.
• Penelitian ini terbuka luas untuk pengembangan
lebih lanjut, terutama pada aplikasi kendali
temperatur pada bidang pertanian. Aturan fuzzy
dapat disesuaikan dengan respon kendali yang
dikehendaki sesuai dengan plant yang hendak
dikendalikan.

UCAPAN TERIMA KASIH

Pada kesempatan ini penulis ingin mengucapkan terima


kasih kepada asisten laboratorium Sistem Kontrol
jurusan Teknik Elektro Universitas Kristen Petra yaitu
Ban Eng, Jaury Adi Wijaya, Silviya, Kardy Antolis,
Darwin, Eric PS atas dukungan dan kerja samanya
selama proyek ini dikerjakan sehingga proyek ini bisa
diselesaikan. Tak lupa juga ucapan terima kasih kepada
laboran laboratorium Sistem Kontrol, bapak Heri
Soehartono atas dukungan dan bantuan yang diberikan
selama pengerjaan proyek ini. Serta terima kasih kami
tujukan kepada teman-teman dosen Jurusan Teknik
Elektro atas dukungan membangun sehingga proyek ini
terlaksana.

DAFTAR PUSTAKA

1. Klir, George J, “Fuzzy Sets and Fuzzy Logics :


Theory and Applications”, NJ : Prentice Hall, 1995.
2. Wang, Paul P. & Dai, Jing, “Design of Fuzzy
Controller According to the Parameters of A
Feedback System”, Technical Report Electrical
Engineering Department, Duke University, 1994.
3. Advanced Micro Device, “Microcontrollers
Handbook”, California : Advanced Micro Device,
1988.
4. Thiang, Anies Hannawati, Resmana, “Pembuatan
Program Kernel Fuzzy Logic PetraFuz untuk
Microcontroller MCS51”, Technical Report Control

Anda mungkin juga menyukai