BAB IV PENGUJIAN RANGKAIAN
4.1 PENGUJIAN RANGKAIAN POWER SUPPLAY ADAPTOR PSA
Pengujian rangkaian ini dengan mengukur tegangan keluaran dari power supply menggunakan multimeter digital. Setelah dilakukan pengukuran maka
diperoleh besarnya tegangan keluaran sebesar 5 volt. Setelah itu rangkaian power supply dihubungkan ke sumber arus listrik dan saklar ONOFF nya diaktifkan ke
posisi ON.
4.2 Pengujian Sistem Minimum ATMega 8535
Karena pemrograman robot menggunakan mode ISP In System Programming
mikrokontroler harus dapat diprogram langsung pada papan rangkaian dan rangkaian mikrokontroler harus dapat dikenali oleh program
downloader. Pada pengujian ini berhasil dilakukan dengan dikenalinya jenis mikrokontroler oleh program downloader yaitu ATMega8535.
4.3 Pengujian Sensor LM 35
Sensor ini bekerja dengan cukup baik, Sensor suhu LM 35 dapat mendeteksi suhu suatu ruangan tersebut. Tetapi dalam pengujian ini, sensor yang ditampilkan pada 7
segment berupa data yang tetap yang telah diatur sebelumnya dari push buttom, tetapi setelah kita hidupkan, kita masih dapat juga mengubahnya dengan mengatur push buttom
tersebut.
Universitas Sumatera Utara
4.4
Pengujian Seven LCD
Untuk menguji rangkaian LCD, maka dibuatlah rangkaian sebagai berikut ini:
Gambar 4.1 Pengujian Rangkaian LCD
Kemudian, pada mikrokontroler dimasukkan program sebagai berikut: regfile = 8535def.dat
crystal = 12000000 Config Lcd = 16 2
Config Lcdpin = Pin , Rs = Portc.1 , E = Portc.0 , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7
Cursor Off Cls
Do Locate 1 , 1
Lcd Hello World Loop
Ketika program dieksekusi oleh mikrokontroler, maka pada display LCD akan muncul tulisan “hello, world” pada layar LCD.
Universitas Sumatera Utara
• Program keseluruhan rangkaian
This program was created by the CodeWizardAVR V3.04 Standard
Automatic Program Generator © Copyright 1998-2013 Pavel Haiduc, HP InfoTech s.r.l.
http:www.hpinfotech.com Project :
Version : Date : 7112013
Author : Company :
Comments:
Chip type : ATmega8535 Program type : Application
AVR Core Clock frequency: 16.000000 MHz Memory model : Small
External RAM size : 0 Data Stack size : 128
include mega8535.h include delay.h
include delay.h include stdio.h
define t5 PIND.6 define led PORTD.4
define t2 PIND.0 define t3 PIND.1
Universitas Sumatera Utara
unsigned char buf[33]; unsigned int t, t_set;
eeprom unsigned int cnt; bit due;
unsigned char idx;
Alphanumeric LCD functions include alcd.h
Declare your global variables here External Interrupt 0 service routine
interrupt [EXT_INT0] void ext_int0_isrvoid {
Place your code here t_set++;
if t_set 99 t_set = 99; lcd_gotoxy9,1;
sprintfbuf,Set:02uC,t_set; lcd_putsbuf;
} External Interrupt 1 service routine
interrupt [EXT_INT1] void ext_int1_isrvoid {
Place your code here t_set--;
if t_set 2 t_set = 1;
Universitas Sumatera Utara
lcd_gotoxy9,1; sprintfbuf,Set:02uC,t_set;
lcd_putsbuf; }
Timer 0 overflow interrupt service routine interrupt [TIM0_OVF] void timer0_ovf_isrvoid
{ Place your code here
idx ++; if idx 10
{ idx = 0;
led = led; }
} Timer1 overflow interrupt service routine
interrupt [TIM1_OVF] void timer1_ovf_isrvoid {
Reinitialize Timer1 value TCNT1H=0xBDC 8;
TCNT1L=0xBDC 0xff; Place your code here
cnt --; if cnt 10
{ cnt = 8;
due = 1; }
} Voltage Reference: Int., cap. on AREF
Universitas Sumatera Utara
define ADC_VREF_TYPE 1REFS1 | 1REFS0 | 0ADLAR Read the AD conversion result
unsigned int read_adcunsigned char adc_input {
ADMUX=adc_input | ADC_VREF_TYPE; Delay needed for the stabilization of the ADC input voltage
delay_us10; Start the AD conversion
ADCSRA|=1ADSC; Wait for the AD conversion to complete
while ADCSRA 1ADIF==0; ADCSRA|=1ADIF;
return ADCW; }
unsigned int suhu void {
float nilai; unsigned int idx;
nilai = nilai + read_adc0; nilai = nilai2;
return nilai; }
void mainvoid {
Declare your local variables here InputOutput Ports initialization
Universitas Sumatera Utara
Port A initialization Function: Bit7=In Bit6=In Bit5=In Bit4=In Bit3=In Bit2=In
Bit1=In Bit0=In DDRA=0DDA7 | 0DDA6 | 0DDA5 | 0DDA4 | 0DDA3
| 0DDA2 | 0DDA1 | 0DDA0; State: Bit7=T Bit6=T Bit5=T Bit4=T Bit3=T Bit2=T Bit1=T
Bit0=T PORTA=0PORTA7 | 0PORTA6 | 0PORTA5 | 0PORTA4 |
0PORTA3 | 0PORTA2 | 0PORTA1 | 0PORTA0; Port B initialization
Function: Bit7=In Bit6=In Bit5=In Bit4=In Bit3=In Bit2=In Bit1=In Bit0=In
DDRB=0DDB7 | 0DDB6 | 0DDB5 | 0DDB4 | 0DDB3 | 0DDB2 | 0DDB1 | 0DDB0;
State: Bit7=T Bit6=T Bit5=T Bit4=T Bit3=T Bit2=T Bit1=T Bit0=T
PORTB=0PORTB7 | 0PORTB6 | 0PORTB5 | 0PORTB4 | 0PORTB3 | 0PORTB2 | 0PORTB1 | 0PORTB0;
Port C initialization Function: Bit7=In Bit6=In Bit5=In Bit4=In Bit3=In Bit2=In
Bit1=In Bit0=In DDRC=0DDC7 | 0DDC6 | 0DDC5 | 0DDC4 | 0DDC3
| 0DDC2 | 0DDC1 | 0DDC0; State: Bit7=T Bit6=T Bit5=T Bit4=T Bit3=T Bit2=T Bit1=T
Bit0=T PORTC=0PORTC7 | 0PORTC6 | 0PORTC5 | 0PORTC4 |
0PORTC3 | 0PORTC2 | 0PORTC1 | 0PORTC0; Port D initialization
Function: Bit7=In Bit6=In Bit5=Out Bit4=In Bit3=In Bit2=In Bit1=In Bit0=In
DDRD=0DDD7 | 0DDD6 | 0DDD5 | 1DDD4 | 0DDD3 | 0DDD2 | 0DDD1 | 0DDD0;
State: Bit7=T Bit6=T Bit5=0 Bit4=T Bit3=T Bit2=T Bit1=T Bit0=T
Universitas Sumatera Utara
PORTD=0PORTD7 | 0PORTD6 | 0PORTD5 | 0PORTD4 | 0PORTD3 | 0PORTD2 | 0PORTD1 | 0PORTD0;
TimerCounter 0 initialization Clock source: System Clock
Clock value: Timer 0 Stopped Mode: Normal top=0xFF
OC0 output: Disconnected TCCR0=0WGM00 | 0COM01 | 0COM00 | 0WGM01 |
0CS02 | 0CS01 | 0CS00; TCNT0=0x00;
OCR0=0x00; TimerCounter 1 initialization
Clock source: System Clock Clock value: 62.500 kHz
Mode: Normal top=0xFFFF OC1A output: Disconnected
OC1B output: Disconnected Noise Canceler: Off
Input Capture on Falling Edge Timer Period: 1 s
Timer1 Overflow Interrupt: On Input Capture Interrupt: Off
Compare A Match Interrupt: Off Compare B Match Interrupt: Off
TCCR1A=0COM1A1 | 0COM1A0 | 0COM1B1 | 0COM1B0 | 0WGM11 | 0WGM10;
TCCR1B=0ICNC1 | 0ICES1 | 0WGM13 | 0WGM12 | 1CS12 | 0CS11 | 0CS10;
TCNT1H=0x0B; TCNT1L=0xDC;
ICR1H=0x00; ICR1L=0x00;
OCR1AH=0x00; OCR1AL=0x00;
OCR1BH=0x00;
Universitas Sumatera Utara
OCR1BL=0x00; TimerCounter 2 initialization
Clock source: System Clock Clock value: Timer2 Stopped
Mode: Normal top=0xFF OC2 output: Disconnected
ASSR=0AS2; TCCR2=0WGM20 | 0COM21 | 0COM20 | 0WGM21 |
0CS22 | 0CS21 | 0CS20; TCNT2=0x00;
OCR2=0x00; TimersCounters Interrupts initialization
TIMSK=0OCIE2 | 0TOIE2 | 0TICIE1 | 0OCIE1A | 0OCIE1B | 1TOIE1 | 0OCIE0 | 1TOIE0;
External Interrupts initialization INT0: On
INT0 Mode: Falling Edge INT1: On
INT1 Mode: Falling Edge INT2: Off
GICR|=1INT1 | 1INT0 | 0INT2; MCUCR=1ISC11 | 0ISC10 | 1ISC01 | 0ISC00;
MCUCSR=0ISC2; GIFR=1INTF1 | 1INTF0 | 0INTF2;
USART initialization USART disabled
UCSRB=0RXCIE | 0TXCIE | 0UDRIE | 0RXEN | 0TXEN | 0UCSZ2 | 0RXB8 | 0TXB8;
Analog Comparator initialization Analog Comparator: Off
The Analog Comparators positive input is connected to the AIN0 pin
Universitas Sumatera Utara
The Analog Comparators negative input is connected to the AIN1 pin
ACSR=1ACD | 0ACBG | 0ACO | 0ACI | 0ACIE | 0ACIC | 0ACIS1 | 0ACIS0;
ADC initialization ADC Clock frequency: 125.000 kHz
ADC Voltage Reference: Int., cap. on AREF ADC High Speed Mode: Off
ADC Auto Trigger Source: ADC Stopped ADMUX=ADC_VREF_TYPE;
ADCSRA=1ADEN | 0ADSC | 0ADATE | 0ADIF | 0ADIE | 1ADPS2 | 1ADPS1 | 1ADPS0;
SFIOR=1ADHSM | 0ADTS2 | 0ADTS1 | 0ADTS0; SPI initialization
SPI disabled SPCR=0SPIE | 0SPE | 0DORD | 0MSTR | 0CPOL
| 0CPHA | 0SPR1 | 0SPR0; TWI initialization
TWI disabled TWCR=0TWEA | 0TWSTA | 0TWSTO | 0TWEN |
0TWIE; Alphanumeric LCD initialization
Connections are specified in the Project|Configure|C Compiler|Libraries|Alphanumeric LCD
menu: RS - PORTB Bit 0
RD - PORTB Bit 1 EN - PORTB Bit 2
D4 - PORTB Bit 4 D5 - PORTB Bit 5
D6 - PORTB Bit 6 D7 - PORTB Bit 7
Charactersline: 16
Universitas Sumatera Utara
lcd_init16; Global enable interrupts
asmsei
lcd_gotoxy0,0; lcd_putsf THERMO COOLER;
delay_ms2000; lcd_clear;
lcd_gotoxy0,0; lcd_putsf SIGIT D3 FIN ;
due = 0; delay_ms1000;
lcd_gotoxy0,0; lcd_putsf Tekan Tombol 5;
whilet5; t_set = 25;
lcd_gotoxy0,0; lcd_putsf SIGIT D3 FIN ;
due = 0;
while 1 {
Place your code here t = suhu;
lcd_gotoxy0,1; sprintfbuf,T: 02uC,t;
Universitas Sumatera Utara
lcd_putsbuf; lcd_gotoxy9,1;
sprintfbuf,Set:02uC,t_set; lcd_putsbuf;
if due == 1 {
lcd_gotoxy0,0; lcd_putsf Kalibrasi Ulang;
while1; }
} }
Universitas Sumatera Utara
4.5 Program Code-Vision AVR