Tugas Akhir
Oleh:
Final Project
By:
Name : IGN. Heru Wahyudi M.D.A.
Student Number: 035114050
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.
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.
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
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 :
tulisan ini.
4. A. Bayu Primawan, S.T., M.Eng. dan Djoko Untoro Suwarno, S.Si, M.T
Sanata.
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
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
Penulis
v
DAFTAR ISI
halaman
Gambar 3.1. Diagram kotak pengontrol suhu udara pada inkubator ...................... 25
Gambar 3.9. Antarmuka antara key pad dengan Mikrokontroler AT89s52 ........... 33
Gambar 3.14. Diagram alir program Penghitungan error dan d_error ...................... 40
Gambar 3.15. Diagram alir program penyulutan fungsi keanggotaan masukan .......... 42
mikrokontroler. ..................................................................................... 63
xvii
BAB I
PENDAHULUAN
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
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
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
Spesifikasi alat yang akan dibuat seperti yang telah diuraikan di atas dibatasi
pada:
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
Tujuan Penelitian ini adalah menghasilkan pengontrol suhu inkubator bayi kucing
2
3. Perancangan dan pengujian rangkaian pengendali lampu AC 100W dan
3
BAB II
DASAR TEORI
Untuk tranduser suhu secara khusus sudah tersedia dalam bentuk bahan
semikonduktor dengan bentuk fisik seperti transistor dengan tiga buah kaki.
lebar, dan mempunyai sifat yang benar-benar linier antara perubahan suhu yang
derajad. Simbol dan bentuk dari LM335 dapat dilihat pada gambar 2.1.
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
bila pada komponen ini diberi catu daya maka ia akan bekerja sebagai
adalah
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
input adc, tegangan minimal keluaran sensor diubah menjadi tegangan minimal
5
input adc dan tegangan maksimal keluaran sensor diubah menjadi tegangan
gambar 2.3.
Vo
AV = .....................................................................................................................
Vi
V −i X 1 V −oY 1
= ..................................................................................................
X 2 − X 1 Y 2 − Y1
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:
dengan keluaran sensor dan input negatif (inverting) terhubung dengan tegangan
6
a.
Penguat Beda (differential Amplifier)[2]
presisi yang membuat rangkaian menjadi stabil dan berguna ketika ketelitian
Penguat beda ini mempunyai dua masukan yaitu V1 yang terhubung dengan
masukan ini terhubung dengan sebuah tahanan, pada masukan membalik diberi
tahanan umpan balik dari keluaran dan pada masukan tidak membalik diberi
Rf
Ai n v = − ............................................................................................. 2.8
R1
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
R f + R1 R g
V Vo1=0 = u t .V2
+ ......................................................... 2.11
R 1 gR R 2
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
R g
V o= u t(V 2 −i V 1)
R1
..........................................................................................................................
2.12
Rg
∆V =
R1
..........................................................................................................................
2.13
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
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
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
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
e. INTR
f. V IN (+)
Berfungsi sebagai masukan. Pin ini merupakan jalan masuk bagi sinyal
g. V IN (-)
Berfungsi sebagai masukan. Pin ini merupakan jalan masuk bagi sinyal
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
j. D GND
k. DB7-DB0
Berfungsi sebagai keluaran. Pin ini merupakan jalan keluaran bagi data
l. CLKR
m. V CC (Or ref)
Berfungsi sebagai masukan daya. Pin ini sebagai jalan masuk untuk catu
V
r e s o =l u nms ai kVolt/step ............................................................................ (2.12)
2 −1
11
2.4
Mikrokontroler AT89S52[8]
Erasable Read Only Memory). FPEROM adalah ROM (Read Only Memory) yang
(input/output), watchdog timer, dua data pointer, tiga 16-bit timer/counter, jalur
pada gambar 2.8 dan fungsi pin dapat dilihat pada tabel 2.1.
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
dan tak langsung terletak pada alamat 30H sampai 7FH. Lokasi RAM
13
XTAL1 Masukan osilator internal
XTAL2 Keluaran osilator internal, apabila menggunakan
osilator eksternal pin tidak dihubungkan (No
Connect)
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
0 1 2 3 4 5 6 7 8 9 A B C D E F
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
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
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
Pada gambar 2.11 apabila saklar tidak ditekan, pin reset pada
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]
3) Unit basis pengetahuan (knowledge base unit), yang terdiri dari dua
bagian:
16
a. Basis data (data base), yang memuat fungsi-fungsi keanggotaan dari
kabur.
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
itu ke dalam nilai-nilai yang tegas. Nilai tegas inilah yang kemudian direalisasikan
dalam bentuk suatu tindakan yang dilaksanakan dalam proses pengendalian itu.
ini.
17
Gambar 2.12 Struktur dasar suatu sistem kendali kabur
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
(fuzzyfication function) yang akan mengubah nilai variabel masukan yang tegas
(yang biasanya dinyatakan dalam bilangan real) menjadi nilai pendekatan yang
suatu klas himpunan kabur dalam semesta ℜ (himpunan kabur dalam semesta ℜ
himpunan kabur
~
A dengan µ A~ (a) = 1 atau sekurang-kurangnya a
2) Bila nilai masukan catat karena derau, diharapkan fungsi pengaburan dapat
inferensinya.
18
Tunggal. Dalam alat ini diaplikasikan Fungsi Pengaburan Segitiga pada fungsi
yaitu
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}.
Basis pengetahuan dari suatu sistem kendali logika kabur terdiri dari basis
data dan basis kaidah. Basis data adalah himpunan fungsi-fungsi keanggotaan dari
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:
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
yang memetakan suatu himpunan kabur ke suatu bilangan real yang tegas.
Bilangan ini menentukan tindakan pengendalian yang harus dilakukan oleh sistem
itu.
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
∑x i
M = {xi ∈ X µ A~ ( xi ) = T ~
i( An) , yaitu t ( A )=
X i ∈M
anode. Common anode adalah semua kutub anode led yang terdapat pada seven
segment dijadikan satu. Pada common anode input tersambung dengan katoda
(gambar2.15)
22
Gambar 2.15. Susunan led seven segment tampak atas.
transien sistem transien kontrol terhadap masukan tangga aturan, biasanya dicari
parameter berikut:
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%.
c) Waktu puncak,t p
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
sistem.
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
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
25
BAB III
suhu udara pada inkubator, sesuai suhu yang diinginkan. Pengontrolan suhu pada
inkubator dilakukan oleh program Fuzzy Logic Control (FLC), yang dieksekusi
mengatur banyaknya lampu yang menyala dan mati atau hidupnya kipas angin.
dengan metoda fuzzy logic ini dapat digambarkan seperti gambar 3.1.
Akuator
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.
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
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
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
26
Gambar 3.2 Gambar inkubator secara keseluruhan
Untuk mendinginkan suhu udara, digunakan dua buah kipas angin yaitu
berfungsi menarik udara luar ke dalam inkubator dan kipas 3 bertugas menarik
LM335 (Is = arus sensor ) sehingga arus maksimal yang mampu mengalir dapat di
27
ditentukan adalah VCC sebesar 5V dan Is sebesar 2.5mA (yang ditunjukan oleh
5V
Rs =
2.5mA
Rs = 2kΩ
selalu melakukan konversi data. Pin R D pada ADC 0804 juga dihubungkan ke
mikrokontroler.
Tegangan masukan ADC0804 adalah tegangan keluaran span & zerro yang
150pF. Pada rangkaian ini, juga digunakan dioda zener 5,1Volt sebagai pembatas
tegangan agar saat tegangan masukan ADC0804 bernilai sama dengan tegangan
Tegangan masukan positif dibatasi sebesar 5,1Volt sesuai dengan nilai dioda
dengan tegangan maju dioda silikon. Hubungan sinyal terkondisi dengan ADC
28
Gambar 3.4. Hubungan sinyal terkondisi dengan ADC0804.
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 )
pada ADC 0804 juga dihubungkan ke ground sehingga ADC selalu membaca data
5Volt
resolusi = = 0,0196Volt/step
28 − 1
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 200C adalah sebesar
V lm335 = 3.08Volt
dan tegangan sensor 3.08 Volt merupakan tegangan maksimal yang dihasilkan
30
menujukan bahwa tegangan minimal yang mampu diterima oleh ADC sebesar
Dari table 3.1 diasumsikan V lm335 adalah X yang merupakan input dari
pengkondisi sinyal dan Vout ADC adalah Y yang merupakan output dari
persamaan 2.6)
x − 2.93 y−0
=
3.08 − 2.93 5 − 0
Y = 33.33 (x – 2.93)
Atau
Vout = 33.33 (Vin – 2.93)
beroperasi untuk menjumlahkan Vin dengan – 2.93 dan dikuatkan sebesar 33.33
gambar3.6.
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
2.10 yaitu:
10kΩ
33.333 =
R1
R1 = R2 = 300Ω
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
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:
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.
tombol terhubung dengan gerbang logika NOR, keluaran gerbang logika NOR
33
3.1.8 Tampilan Suhu
P2.0 sampai dengan P2.2 merupakan data yang akan ditampilkan pada setiap
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
Pada rangkaian 7’segment, nilai R dapat ditentukan sebagai berikut (Vcc = 5V) :
V = I.R
34
5V = 15mA.R
manusia dalam mengendalikan suatu sistem kendali. Secara umum respon fungsi
step suatu sistem kendali akan memberikan output seperti terdapat pada gambar
3.11
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
akhirnya outputnya mencapai SP. Apa yang dilakukan oleh kontroler untuk
menaikan dan menurunkan output harus sesuai dengan harga output saat itu dan
(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
µ(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.
suhu udara inkubator ( pengaturan driver lampu dan driver kipas). Prosesnya
adalah pembacaan data ADC sebagai informasi suhu, perhitugan error dan
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
fuzzy (FLC), dalam prosedur ini nilai error dan d_error akan melewati proses
37
fuzzification, inferensi dan defuzzifications. Hasil dari program FLC akan
Inis
B
Hitung
T
Y
T
TD
Y
suhu aktual pada seven segment. Setelah waktu delay tercukupi, mikrokontroler
38
melakukan proses sampling secara berulang-ulang dimulai dari pembacaan data
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.
e (t) = SP – PV
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.
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
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 (-)
40
D_error = e(t) – (- e(t-1)) atau
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
Masukan dari program FLC berupa error dan d_error, lalu diproses oleh
sistem fuzzy yang meliputi langkah fuzzifikasi, inferensi (basis data dan basis
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
41
Proses pengaburan error dilakukan dengan membandingkan nilai error
terhadap rentang nilai fungsi keanggotaan ZERRO, SMALL dan BIG (tabel 3.5).
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.
kaidah. Nilai derajad keanggotaan diproses pada program basis data, dengan
metode look up table. Sedangkan untuk mecari kaidah diproses pada program
Gambar 3.16 menunjukan diagram alir program basis data untuk error. Nilai
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
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
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
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
44
Gambar 3.17 Diagram alir program basis kaidah.
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
pada 4 bit rendah pada port 0. Jika semua 4 bit rendah telah benilai 1 maka proses
45
metoda geser kanan pada 4 bit rendah. Proses penggeseran ini dimulai nilai yang
46
3.3.3 Program penampilan suhu
keseluruhan metoda yang dipakai adalah metoda look up table, nilai yang
tersimpan pada tabel merupakan nilai–nilai hasil konversi dari data ADC (hasil
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
47
Nilai satuan dan sepersepuluh diperoleh dari tabel dengan referensi nilai PV.
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
Pada bab ini akan memberikan informasi dari data yang telah diambil,
bekerja dengan baik. Bentuk fisik alat dapat dilihat pada gambar 4.1. Dengan
Pada bab ini juga akan diperlihatkan tentang hasil unjuk kerja alat yang telah
dirancang.
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
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
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 dibuat secara sederhana, yaitu dengan cara membuat lubang kecil-kecil
menyerupai pori.
50
Kipas
Lubang pori-pori
pemanas. Lampu yang dipasang secara vertikal, di letakkan dalam sebuah kotak.
Kipas
4 buah lampu
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,
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
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.
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
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)
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)
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
pengamatan set point 28oC, sama dengan persamaan yang digunakan pada
pengamatan set point 26oC. Hasil dari penghitungan dan pengamatan pada gambar
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
jumlah lampu yang menyala, sehingga menyebabkan suhu yang dipanaskan akan
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)
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
pada pengamatan set point 32oC, sama dengan persamaan yang digunakan pada
56
pengamatan set point 26oC. Hasil dari penghitungan dan pengamatan pada gambar
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
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)
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
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
1. Suhu luar
2. Suhu awal
3. Waktu 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.
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
Tk = 34 - 25,65
= 8,35 menit
26.1
26
gangguan
suhu(oC)
waktu(menit)
23
0 4 8 12 16 20 24 28 32 36 40 44
(a)
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.
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.
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
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
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
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)
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%-
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)
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
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
detik, penentuan waktu sampling diperoleh dari pengamatan respon suhu terhadap
64
Pada program ini dilakukan looping terus menerus sebanyak nilai yang
Diawal program penghitungan error, nilai error disimpan sebagai nilai error
adalah sebuah alamat yang digunakan untuk menandai nilai error apakah negatif
sebelumnya.
Program fuzzy logic adalah program inti dari kontrol suhu berbasis
65
subrutine diantaranya adalah fuzzifation, basis data, basis kaidah dan
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
membandingkan nilai error dengan batas-batas nilai membership function big, lalu
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
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
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
67
BAB V
PENUTUP
Kesimpulan
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
3. Dengan tercapainya setiap set point maka inkubator bayi kucing ini dapat digunakan
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:
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
24.50
25.40 Max
20 11
7.00 Max
6.30
1
10
0.89 1.30
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
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.
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
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
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
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
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)
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
Philips Semiconductors Product data
A GND 8 13 D5
VREF/2 9 12 D6
FEATURES
D GND 10 11 D7
• Compatible with most microprocessors
• Differential inputs TOP VIEW
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
2002 Oct 17 2
Philips Semiconductors Product data
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
2002 Oct 17 3
Philips Semiconductors Product data
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
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.
2002 Oct 17 5
Philips Semiconductors Product data
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
2002 Oct 17 7
Philips Semiconductors Product data
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
(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
4.0
16
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)
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
2002 Oct 17 9
Philips Semiconductors Product data
t1H tOH
SL00019
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
CS tRI
RD
NOTE
DATA THREE–STATE
OUTPUTS
tACC
t1H, t0H
2002 Oct 17 10
Philips Semiconductors Product data
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
NOTE:
The VREF/2 voltage is either 1/2 the VCC voltage or is that which is forced at Pin 9.
SL00021
+5V +5V
+5V
VCC
VIN(+) +
VCC
10 µF 2 kΩ
+
VIN(+) 10 µF A/D
2 kΩ 100 Ω
A/D
VREF/2
SL00023
2002 Oct 17 11
Philips Semiconductors Product data
VCC
VIN(+) VCC
TRANSDUCER +
10µF
2 kΩ
A/D
2 kΩ
SL00024
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
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
2002 Oct 17 12
Philips Semiconductors Product data
+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
+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Ω
SL00030
2002 Oct 17 13
Philips Semiconductors Product data
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
2N3906
1N4148 TO HEATER
SL00031
2002 Oct 17 14
Philips Semiconductors Product data
SO20: plastic small outline package; 20 leads; body width 7.5 mm SOT163-1
2002 Oct 17 15
Philips Semiconductors Product data
2002 Oct 17 16
Philips Semiconductors Product data
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
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.
2002 Oct 17 18
This datasheet has been download from:
www.datasheetcatalog.com
Rev. 1919A-07/01
1
Pin Configurations
PDIP PLCC
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
2 AT89S52
AT89S52
Block Diagram
P0.0 - P0.7 P2.0 - P2.7
VCC
PORT 0 DRIVERS PORT 2 DRIVERS
GND
PROGRAM
B STACK ADDRESS
REGISTER ACC POINTER REGISTER
BUFFER
TMP2 TMP1
PC
ALU INCREMENTER
PROGRAM
PSW COUNTER
PSEN
ALE/PROG TIMING INSTRUCTION
AND REGISTER DUAL DPTR
EA / VPP CONTROL
RST
OSC
PORT 3 DRIVERS PORT 1 DRIVERS
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
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
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
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.
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
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
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
CONTROL
EXEN2
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
OSC ÷ 12 OVERFLOW
C/T2 = 0
CONTROL
TR2
C/T2 = 1 TIMER 2
INTERRUPT
T2 PIN
RCAP2H RCAP2L
COUNT
(UP COUNTING RELOAD VALUE) DIRECTION
1=UP
0=DOWN
T2EX PIN
÷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
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
14 AT89S52
AT89S52
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
(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
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
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
GND
7 6 5 4 3 2 1 0
20 AT89S52
AT89S52
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
A8
A12
A10
A9
}
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
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
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
VIH Input High Voltage (Except XTAL1, RST) 0.2 VCC+0.9 VCC+0.5 V
ILI Input Leakage Current (Port 0, EA) 0.45 < VIN < VCC ±10 µA
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
tAVIV
PSEN
tLLDV
tRLRH
tLLWL
RD tLLAX
tRLDV tRHDZ
tAVLL
tRLAZ
tRHDX
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
tAVWL
26 AT89S52
AT89S52
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)*
.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)
0.75(0.030) 0.15(0.006)
0.45(0.018) 0.05(0.002)
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
MCS-51 ® is the registered trademark of Intel Corporation. Terms and product names in this document may be
trademarks of others.
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
TO-46 SO-8
Metal Can Package* Small Outline Molded Package
DS005516-1 DS005516-21
TO-92 TO-220
Plastic Package Plastic Package*
DS005516-2
DS005516-24
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
DS005516-29
DS005516-28
DS005516-30
DS005516-32 DS005516-33
DS005516-31
5 www.national.com
LM35
Typical Performance Characteristics (Continued)
DS005516-34 DS005516-35
*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
DS005516-6
DS005516-20
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
DS005516-5
DS005516-9
7 www.national.com
LM35
Typical Applications (Continued)
DS005516-11
DS005516-10
DS005516-12
DS005516-13
FIGURE 13. Temperature To Digital Converter (Serial Output) (+128˚C Full Scale)
DS005516-14
www.national.com 8
LM35
Typical Applications (Continued)
DS005516-16
DS005516-15
9 www.national.com
LM35
Block Diagram
DS005516-23
www.national.com 10
LM35
Physical Dimensions inches (millimeters) unless otherwise noted
11 www.national.com
LM35
Physical Dimensions inches (millimeters) unless otherwise noted (Continued)
www.national.com 12
LM35 Precision Centigrade Temperature Sensors
Physical Dimensions inches (millimeters) unless otherwise noted (Continued)
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
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
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
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
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).
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 )
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.
DAFTAR PUSTAKA