STABILISASI TEMPERATURE RUANGAN MENGGUNAKAN SENSORS LM35DZ BERBASIS MIKROKONTROLER ATmega8

Posted: Juli 16, 2011 in Teknologi

JamaalHr

Proses Pembelajaran sesungguhnya.

Overview ATmega8

The ATmega8 is a low-power CMOS 8-bit microcontroller based on the AVR RISC architecture. By executing powerful instructions in a single clock cycle, the ATmega8 achieves throughputs approaching 1 MIPS per MHz, allowing the system designer to optimize power consumption versus processing speed.

Pin Configurations

Pin Descriptions

VCC   

Digital supply voltage.

GND   

Ground.

Port B (PB7..PB0) XTAL1/ XTAL2/TOSC1/TOSC2                       

Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port B output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset condition becomes active, even if the clock is not running. Depending on the clock selection fuse settings, PB6 can be used as input to the inverting Oscillator amplifier and input to the internal clock operating circuit. Depending on the clock selection fuse settings, PB7 can be used as output from the inverting Oscillator amplifier. If the Internal Calibrated RC Oscillator is used as chip clock source, PB7..6 is used as TOSC2..1 input for the Asynchronous Timer/Counter2 if the AS2 bit in ASSR is set. The various special features of Port B are elaborated in “Alternate Functions of Port B” on page 56 and “System Clock and Clock Options” on page 23.

Port C (PC5..PC0)     

Port C is an 7-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port C output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port C pins that are externally pulled low will source current if the pull-up resistors are activated. The Port C pins are tri-stated when a reset condition becomes active, even if the clock is not running.

PC6/RESET   

If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin. Note that the electrical characteristics of PC6 differ from those of the other pins of Port C. If the RSTDISBL Fuse is unprogrammed, PC6 is used as a Reset input. A low level on this pin for longer than the minimum pulse length will generate a Reset, even if the clock is not running. The minimum pulse length is given in Table 15 on page 36. Shorter pulses are not guaranteed to generate a Reset. The various special features of Port C are elaborated on page 59.

Port D (PD7..PD0)     

Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port D output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port D pins that are externally pulled low will source current if the pull-up resistors are activated. The Port D pins are tri-stated when a reset condition becomes active, even if the clock is not running. Port D also serves the functions of various special features of the ATmega8 as listed on page 61.

RESET           

Reset input. A low level on this pin for longer than the minimum pulse length will generate a reset, even if the clock is not running. The minimum pulse length is given in Table 15 on page 36. Shorter pulses are not guaranteed to generate a reset.

AVCC

AVCC is the supply voltage pin for the A/D Converter, Port C (3..0), and ADC (7..6). It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter. Note that Port C (5..4) use digital supply voltage, VCC.

AREF 

AREF is the analog reference pin for the A/D Converter

ADC7..6 (TQFP and MLF Package Only)    

In the TQFP and MLF package, ADC7..6 serve as analog inputs to the A/D converter. These pins are powered from the analog supply and serve as 10-bit ADC channels.

Sistem Minimum ATmega8

 

 

Temperature Sensors LM35DZ

LM35DZ dari National Semiconductor adalah sebuah sensor temperatur centigrade presisi, yang memiliki tegangan output analog. Memiliki jangkauan pengukuran -55ºC hingga +150ºC dengan akurasi ±0.5ºC. Tegangan output adalah 10mV/ºC. Tegangan output dapat langsung dihubungkan dengan salah satu port mikrokontroler yang memiliki kemampuan ADC, misalnya ATmega8. ADC pada ATmega8 memiliki resolusi 10-bit, yang dapat memberikan keluaran 2^10 = 1024 nilai diskrit. Bila digunakan catu 5V, resolusi yang dihasilkan adalah 5000mV/1024 = 4.8mV. Karena LM35DZ memiliki resolusi output 10mV/ºC, maka resolusi termometer yang dibuat dengan ATmega8 adalah 10mV/4.8mV ~ 0.5ºC.

 

Prinsip Kerja IC Temperature Sensors LM35DZ

Suhu lingkungan di deteksi menggunakan bagian IC yang peka terhadap suhu. Suhu lingkungan ini diubah menjadi tegangan listrik oleh rangkaian di dalam IC, dimana perubahan suhu berbanding lurus dengan perubahan tegangan output.

Pada seri LM35DZ.

Vout=10 mV/oC

Tiap perubahan 1oC akan menghasilkan perubahan tegangan output sebesar 10mV

Kelebihan dan Kelemahan IC Temperature Sensors LM35DZ

Kelebihan:

* Rentang suhu yang jauh, antara -55 sampai +150 oC.

* Low self-heating, sebesar 0.08 oC.

* Beroperasi pada tegangan 4 sampai 30 V.

* Rangkaian tidak rumit.

* Tidak memerlukan pengkondisian sinyal.

Kekurangan:

* Membutuhkan sumber tegangan untuk beroperasi.

Jenis IC Temperaturs Sensors LM35DZ yang digunakan

Gambar Rangkaian yang sudah jadi

Cara kerja Rangkaian

Rangkain stabilisasi temperature sensors LM35DZ berbasis mikrokontroller akan bekerja apabila di beri tegangan +5V DC, adapun bekerjanya suatu sensor akan secara otomatis mendeteksi temperature ruangan oleh karena itu mikro akan langsung membaca sinyal digital yang sudah di rubah oleh ADC (Analog to Digital Comperter) dan diproses secara konstan, temperature yang sudah diproses akan di tampilkan oleh LED temperature yang terdiri dari LD1-300C , LD2-310C , LD3-320C , LD4-330C , LD5-340C , LD6-350C , LD7-360C , LD1-370C ,dan 400C akan menghidupkan alarem.

Alat dan Bahan

  1. Mikrokontroller ATmega8.
  2. Sensors Temperature LM35DZ.
  3. Resistor 220, 1k.   
  4. Capasitor 22pf, 14pf.
  5. Pin header.
  6. Kabel.
  7. LED.
  8. PCB hole.
  9. Soket IC, pin header.
  10. Transistor BD139

Program

//Program sesnsor suhu lm35, ATmega8

#include<iom8v.h>

#include<macros.h>

#pragma interrupt_handler serv_adc:15

// channel ADC pada chanel 0

#define ADC_CH0                               0

#define N_MAX_SAMPLES    480

#define conv     0.25

#define LED0                           (1<<0)

#define LED0_mati()    (PORTB&=~LED0)

#define LED0_nyala()  (PORTB|=LED0)

#define LED0_ddr()      (DDRB|=LED0)

#define LED1                           (1<<1)

#define LED1_mati()    (PORTB&=~LED1)

#define LED1_nyala()  (PORTB|=LED1)

#define LED1_ddr()      (DDRB|=LED1)

#define LED2                           (1<<2)

#define LED2_mati()    (PORTB&=~LED2)

#define LED2_nyala()  (PORTB|=LED2)

#define LED2_ddr()      (DDRB|=LED2)

#define LED3                           (1<<3)

#define LED3_mati()    (PORTB&=~LED3)

#define LED3_nyala()  (PORTB|=LED3)

#define LED3_ddr()      (DDRB|=LED3)

#define LED4                           (1<<4)

#define LED4_mati()    (PORTB&=~LED4)

#define LED4_nyala()  (PORTB|=LED4)

#define LED4_ddr()      (DDRB|=LED4)

#define LED5                           (1<<5)

#define LED5_mati()    (PORTB&=~LED5)

#define LED5_nyala()  (PORTB|=LED5)

#define LED5_ddr()      (DDRB|=LED5)

#define LED6                           (1<<0)

#define LED6_mati()    (PORTD&=~LED6)

#define LED6_nyala()  (PORTD|=LED6)

#define LED6_ddr()      (DDRD|=LED6)

#define LED7                           (1<<1)

#define LED7_mati()    (PORTD&=~LED7)

#define LED7_nyala()  (PORTD|=LED7)

#define LED7_ddr()      (DDRD|=LED7)

#define LED8                           (1<<2)

#define LED8_mati()    (PORTD&=~LED8)

#define LED8_nyala()  (PORTD|=LED8)

#define LED8_ddr()      (DDRD|=LED8)

unsigned int data[N_MAX_SAMPLES];

unsigned int data_idx;

unsigned int get_data;

unsigned int get_adc_single_conversion(unsigned char);

void inisialisasi(void);

void serv_adc(void);

void heater_control(void);

// pembacaan adc

void serv_adc()

{

unsigned int res;

res=ADCL;

res+=ADCH*256;

data[data_idx]=res;

data_idx++;

if(data_idx>N_MAX_SAMPLES-1){

ADCSRA = 0x00;         // adc off

data_idx=0;

}

}

/* Inisialisasi  */

void inisialisasi(void)

{

PORTB =0x00;

PORTC =0x00;

PORTD =0x00;

DDRB =0;

DDRC =0;

DDRD =0;

SREG = 0x80;

LED0_mati();

LED0_ddr();

LED1_mati();

LED1_ddr();

LED2_mati();

LED2_ddr();

LED3_mati();

LED3_ddr();

LED4_mati();

LED4_ddr();

LED5_mati();

LED5_ddr();

LED6_mati();

LED6_ddr();

LED7_mati();

LED7_ddr();

LED8_mati();

LED8_ddr();

}

/* Main Program  */

void main()

{

inisialisasi();

while(1)

{

heater_control();

}

}

void heater_control()

{

//cel = (get_adc*2.56/256)*100

get_data = get_adc_single_conversion(ADC_CH0);

get_data = conv * get_data;

if(get_data>=30)LED0_nyala();

if(get_data<30)LED0_mati();

if(get_data>=31)LED1_nyala();

if(get_data<31)LED1_mati();

if(get_data>=32)LED2_nyala();

if(get_data<32)LED2_mati();

if(get_data>=33)LED3_nyala();

if(get_data<33)LED3_mati();

if(get_data>=34)LED4_nyala();

if(get_data<34)LED4_mati();

if(get_data>=35)LED5_nyala();

if(get_data<35)LED5_mati();

if(get_data>=36)LED6_nyala();

if(get_data<36)LED6_mati();

if(get_data>=37)LED7_nyala();

if(get_data<37)LED7_mati();

if(get_data>=40)LED8_nyala();

if(get_data<40)LED8_mati();

}

//===================================================

//—————————————-

unsigned int get_adc_single_conversion(unsigned char chn)

{

unsigned int res;

ADCSRA = 0x86;                                 // adc on, prescaler division 64

ADMUX = 0xc0 | chn;                      // ref 2.56V

//ADMUX = 0x40 | chn;                        // ref 5.0V

ADCSRA |= BIT(ADSC);         // start conversion

while (ADCSRA&(1<

res=ADCL;

res+=(ADCH*256);

ADCSRA = 0x00;                     // adc off

return res;

}

Selesai sudah program ini selanjutnya di download ke mikro ATmega8.

beress…. :)

 

About these ads

Berikan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Logout / Ubah )

Twitter picture

You are commenting using your Twitter account. Logout / Ubah )

Facebook photo

You are commenting using your Facebook account. Logout / Ubah )

Google+ photo

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s