1
Universitas Sumatera Utara
2
Lampiran 1 : Skematik Rangkaian Seluruh Alat
Universitas Sumatera Utara
3
Lampiran 2 : Listing Program /******************************************************* This program was created by the CodeWizardAVR V3.12 Advanced Automatic Program Generator © Copyright 1998-2014 Pavel Haiduc, HP InfoTech s.r.l. http://www.hpinfotech.com
Project : Version : Date
: 06/01/2016
Author : Company : Comments:
Chip type
: ATmega8535
Program type
: Application
AVR Core Clock frequency: 8.000000 MHz Memory model
: Small
External RAM size
:0
Data Stack size
: 128
*******************************************************/
#include <mega8535.h> #include <delay.h> #include <stdlib.h> #define pump PORTD.0
Universitas Sumatera Utara
4
#define d1 PORTD.2 #define d2 PORTD.3 #define pb1 PINB.0 #define pb2 PINB.1 #define pb3 PINB.2
int data, data1, data2,i=150,x,u=0,counter=0; char buff[10];
// Alphanumeric LCD functions #include
// Declare your global variables here
// Voltage Reference: AREF pin #define ADC_VREF_TYPE ((0<
// Read the AD conversion result unsigned int read_adc(unsigned char adc_input) { ADMUX=adc_input | ADC_VREF_TYPE; // Delay needed for the stabilization of the ADC input voltage delay_us(10); // Start the AD conversion ADCSRA|=(1<
Universitas Sumatera Utara
5
ADCSRA|=(1<
void read_sensor(void) { data=read_adc(0); data1=read_adc(1); data2=read_adc(2); }
void main(void) { // Declare your local variables here
// Input/Output Ports initialization // Port A initialization // Function: Bit7=In Bit6=In Bit5=In Bit4=In Bit3=In Bit2=In Bit1=In Bit0=In DDRA=(0<
// Port B initialization // Function: Bit7=In Bit6=In Bit5=In Bit4=In Bit3=In Bit2=In Bit1=In Bit0=In DDRB=(0<
Universitas Sumatera Utara
6
PORTB=(0<
// Port C initialization // Function: Bit7=In Bit6=In Bit5=In Bit4=In Bit3=In Bit2=In Bit1=In Bit0=In DDRC=(0<
// Port D initialization // Function: Bit7=In Bit6=In Bit5=Out Bit4=Out Bit3=In Bit2=In Bit1=In Bit0=Out DDRD=(1<
// Timer/Counter 0 initialization // Clock source: System Clock // Clock value: Timer 0 Stopped // Mode: Normal top=0xFF // OC0 output: Disconnected TCCR0=(0<<WGM00) | (0<
// Timer/Counter 1 initialization // Clock source: System Clock
Universitas Sumatera Utara
7
// Clock value: 1000.000 kHz // Mode: Fast PWM top=0x00FF // OC1A output: Non-Inverted PWM // OC1B output: Non-Inverted PWM // Noise Canceler: Off // Input Capture on Falling Edge // Timer Period: 0.256 ms // Output Pulse(s): // OC1A Period: 0.256 ms Width: 0 us // OC1B Period: 0.256 ms Width: 0 us // Timer1 Overflow Interrupt: Off // Input Capture Interrupt: Off // Compare A Match Interrupt: Off // Compare B Match Interrupt: Off TCCR1A=(1<
// Timer/Counter 2 initialization // Clock source: System Clock
Universitas Sumatera Utara
8
// Clock value: Timer2 Stopped // Mode: Normal top=0xFF // OC2 output: Disconnected ASSR=0<
// Timer(s)/Counter(s) Interrupt(s) initialization TIMSK=(0<
// External Interrupt(s) initialization // INT0: Off // INT1: Off // INT2: Off MCUCR=(0<
// USART initialization // USART disabled UCSRB=(0<
// Analog Comparator initialization // Analog Comparator: Off // The Analog Comparator's positive input is // connected to the AIN0 pin
Universitas Sumatera Utara
9
// The Analog Comparator's negative input is // connected to the AIN1 pin ACSR=(1<
// ADC initialization // ADC Clock frequency: 1000.000 kHz // ADC Voltage Reference: AREF pin // ADC High Speed Mode: Off // ADC Auto Trigger Source: ADC Stopped ADMUX=ADC_VREF_TYPE; ADCSRA=(1<
// SPI initialization // SPI disabled SPCR=(0<<SPIE) | (0<<SPE) | (0<
// TWI initialization // TWI disabled TWCR=(0<
// Alphanumeric LCD initialization // Connections are specified in the // Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu: // RS - PORTC Bit 0 // RD - PORTC Bit 1
Universitas Sumatera Utara
10
// EN - PORTC Bit 2 // D4 - PORTC Bit 3 // D5 - PORTC Bit 4 // D6 - PORTC Bit 5 // D7 - PORTC Bit 6 // Characters/line: 16 lcd_init(16);
while (1) { u++; if(u==200){u=0;} i--; if(i<50){i=60;}
if (pb1==0){counter=0;lcd_clear();}
read_sensor();
if(data<35 && data1<35 && data2<=40) { x=0; d1=0;d2=1; OCR1B=i; OCR1A=i; lcd_gotoxy(0,1); lcd_putsf("
");
}
Universitas Sumatera Utara
11
else if(data>35 && data1<35 && data2<=40) { pump=0; d1=0;d2=1; OCR1B=i; OCR1A=i; }
else if(data>35 && data1>35 && data2>40) { pump=0; d1=0;d2=1; OCR1B=i; OCR1A=i; }
else if(data>35 && data1>35) { d1=0;d2=0; OCR1B=0; OCR1A=0; lcd_gotoxy(0,0); lcd_gotoxy(0,1); lcd_putsf("Mengisi Tabung "); if(data2<=40) { pump=1;
Universitas Sumatera Utara
12
} }
if(data>35 && x==0) { x=1; counter++; if (counter>=100) { counter=0; lcd_clear(); } }
lcd_gotoxy(0,0); lcd_putsf("Jumlah Botol= "); itoa(counter,buff); lcd_gotoxy(14,0); lcd_puts(buff);
} }
Universitas Sumatera Utara
13
Lampiran 3 : Foto Alat
(a) Gambar 3.1 (a). Foto alat kondisi konveyor jalan
(b) Gambar 3.1. (b) Foto Alat kondisi Konveyor saat sensor mendeteksi keberadaan botol. Konveyor berhenti dan pompa aktif mengisi cairan ke tabung.
Universitas Sumatera Utara
14
Lampiran 4 Gambar Dokumentasi dan Pengambilan Data
Gambar 4 (a) Foto pengambilan data tegangan sensor photodioda sebelum mendeteksi botol
Gambar 4 (b). Foto pengambilan data tegangan sensor photodioda sebelum mendeteksi botol
Universitas Sumatera Utara
15
Gambar 4 ( c ) Foto pengambilan data tegangan sensor photodioda 3 untuk deteksi botol penuh.
Universitas Sumatera Utara
16
Lampiran 5 Data Sheet ATMega 8535
Universitas Sumatera Utara
17
Universitas Sumatera Utara
18
Universitas Sumatera Utara
19
Universitas Sumatera Utara
20
Universitas Sumatera Utara
21
Universitas Sumatera Utara
22
Universitas Sumatera Utara
23
Universitas Sumatera Utara
24
Lampiran 6 Datasheet L298
Universitas Sumatera Utara
25
Universitas Sumatera Utara
26
Universitas Sumatera Utara
27
Universitas Sumatera Utara