LAMPIRAN

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

LAMPIRAN I

RANGKAIAN
KESELURUHAN
RANGKAIAN KESELURUHAN
LAMPIRAN II
LISTING PROGRAM
LISTING PROGRAM */ speedr=0;
}
#include <mega16.h> #include <delay.h>
#include <stdio.h>
#define ADC_VREF_TYPE 0x00
#define roda PINA.0
#define kipas PINA.2 // Read the AD conversion result
#define servo1 PORTB.0 unsigned int read_adc(unsigned char
#define servo2 PORTB.1 adc_input)
#define speedr PORTB.2 {
#define speedk PORTB.3 ADMUX=adc_input |
(ADC_VREF_TYPE & 0xff);
int i,count,count2; // Delay needed for the stabilization
int of the ADC input voltage
pass,pass2,flag=1,go,pwmk,pwmr,kp delay_us(10);
,kd,ki; // Start the AD conversion
char t[16]; ADCSRA|=0x40;
// Wait for the AD conversion to
// Alphanumeric LCD Module complete
functions while ((ADCSRA & 0x10)==0);
#asm ADCSRA|=0x10;
.equ __lcd_port=0x12 ;PORTD return ADCW;
#endasm }
#include <lcd.h>
int
int kaizo,s1,s2; error,error_1,integ,deriv,setpoint=50,
val_error,plus,hitung,hitung2;
// Timer 0 overflow interrupt service int
routine konstanta,konstanta2,rpmroda,rpmki
interrupt [TIM0_OVF] void pas;
timer0_ovf_isr(void) // Declare your global variables here
{
// Place your code here void read_sensor()
kaizo++; {
if(kaizo>2000) kaizo=0; for(i=0;i<600;i++)
{
if(s1>kaizo) servo1=1; if(roda==1)
else servo1=0; {
count=1;
if(s2>kaizo) servo2=1; }
else servo2=0; if(roda==0 && count==1)
/* {
if(pwmk>kaizo) speedk=1; hitung+=1;
else speedk=0; count=0;
}
if(pwmr>kaizo) speedr=1; if(kipas==1)
else {
count2=1; lcd_gotoxy(0,1);
} sprintf(t,"S1 %3d S2 %3d",s1,s2);
if(kipas==0 && count2==1) lcd_puts(t);
{ hitung=0;
hitung2+=2; hitung2=0;
count2=0; go=0;
} break;
delay_ms(1); }
}
lcd_gotoxy(0,0); case 2:
sprintf(t, "R %3d K {
%3d",hitung,hitung2); konstanta=220/60;
lcd_puts(t); konstanta2=220/30;
} rpmkipas=hitung2-30;
s1=40+(rpmkipas/konstanta);
void kerja() s2=70+(rpmkipas/konstanta2);
{
switch(go) if(s1>100) s1=100;
{ if(s1<40) s1=40;
case 0: if(s2>100) s2=100;
{ if(s2<70) s2=70;
read_sensor();
if(hitung>=hitung2) lcd_gotoxy(0,1);
{ sprintf(t,"S1 %3d S2 %3d",s1,s2);
go=1; lcd_puts(t);
break; hitung=0;
} hitung2=0;
else if(hitung2>=hitung) go=0;
{ break;
go=2; }
break; }
} }
}
void main(void)
case 1: {
{ PORTA=0x00;
konstanta=220/60; DDRA=0x00;
konstanta2=220/30;
rpmroda=hitung-30; PORTB=0x00;
s1=40+(rpmroda/konstanta); DDRB=0x0F;
s2=70+(rpmroda/konstanta2);
PORTC=0x00;
if(s1>100) s1=100; DDRC=0x00;
if(s1<40) s1=40;
if(s2>100) s2=100; PORTD=0x00;
if(s2<70) s2=70; DDRD=0x00;
TCCR1A=0x00; lcd_putsf(" SYSTEM READY ");
TCCR1B=0x00; delay_ms(500);
TCNT1H=0x00; lcd_clear();
TCNT1L=0x00;
ICR1H=0x00; while (1)
ICR1L=0x00; {
OCR1AH=0x00; kerja();
OCR1AL=0x00; };
OCR1BH=0x00; }
OCR1BL=0x00;

// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;

MCUCR=0x00;
MCUCSR=0x00;

TIMSK=0x01;

Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;

ADMUX=ADC_VREF_TYPE &
0xff;
ADCSRA=0x84;

// LCD module initialization


lcd_init(16);

// Global enable interrupts


#asm("sei")

lcd_gotoxy(0,0);
lcd_putsf(" SALITY SYSTEM ");
delay_ms(500);
lcd_gotoxy(0,1);
lcd_putsf("INITIALISATION..");
delay_ms(1000);
lcd_gotoxy(0,1);
LAMPIRAN III
DATASHEET

You might also like