Institutional Repository | Satya Wacana Christian University: Beban Elektronik Pengujian Regulasi Catu Daya

LAMPIRAN A
SCEMATIC DIAGRAM

Gambar A.1. Skematik diagram keseluruhan

LAMPIRAN B
SOURCE CODE BEBAN ELEKTRONIK

/*****************************************************
This program was produced by the
CodeWizardAVR V2.05.3 Standard
Automatic Program Generator
© Copyright 1998-2011 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project :
Version :
Date

: 8/10/2015


Author : monica
Company :
Comments:

Chip type

: ATmega32

Program type

: Application

AVR Core Clock frequency: 11.059200 MHz
Memory model

: Small

External RAM size

:0


Data Stack size

: 512

*****************************************************/
#include
#include
#include
#include
#include

// Alphanumeric LCD functions
#include

#define a 7
#define b 3
#define ADC_VREF_TYPE 0x40

// Read the AD conversion result

unsigned int read_adc(unsigned char adc_input)
{
ADMUX=adc_input | (ADC_VREF_TYPE & 0xff);
// Delay needed for the stabilization of the ADC input voltage
delay_us(10);
// Start the AD conversion
ADCSRA|=0x40;
// Wait for the AD conversion to complete
while ((ADCSRA & 0x10)==0);
ADCSRA|=0x10;
return ADCW;
}
// Declare your global variables here
int z;
char key;
int I;
float nowCurrent, prevCurrent, current, nowTemp, prevTemp, temp;
char input[5] = {0};
char OCRO_val[3] = {0};
char arusPilih[3] = {0};

char loadCurrent[10];
char deviceTemp[10] = {0};

void bacaArus(){
nowCurrent = read_adc(0);

//nowCurrent = ((a*nowCurrent)+(b*prevCurrent))/(a+b);
//prevCurrent = nowCurrent;
current = (nowCurrent*0.04886)-25.01629;
ftoa(current,3,loadCurrent);
}

void bacaSuhu(){
nowTemp = read_adc(2);
nowTemp = ((a*nowTemp)+(b*prevTemp))/(a+b);
prevTemp = nowTemp;
temp = (nowTemp*500)/1024;
ftoa(temp,3,deviceTemp);
}


char get_keypad(){
PORTD=0xfe;
//delay_ms(40);
if(PIND.4==0)return '6';
if(PIND.5==0)return '2';
if(PIND.6==0)return '0';
if(PIND.7==0)return '8';
PORTD=0xfc;
//delay_ms(40);
if(PIND.4==0)return '5';
if(PIND.5==0)return '1';
if(PIND.6==0)return '.';
if(PIND.7==0)return '7';
PORTD=0xfb;
//delay_ms(40);
if(PIND.4==0)return '4';
if(PIND.5==0)return 'A';

if(PIND.6==0)return 'D';
if(PIND.7==0)return 'C';

PORTD=0xf7;
//delay_ms(40);
if(PIND.4==0)return 'B';
if(PIND.5==0)return '3';
if(PIND.6==0)return '#';
if(PIND.7==0)return '9';
//PORTD=0x00;
//delay_ms(1);
return (key);
}

void input_arus(){
float arus, val = 0;
int cnt = 0;
char key=0;
I = 0;
lcd_clear();
if(I255) I = 255;

while(1){

key = get_keypad();
if(key>='0' && key 0){
val = (float)atof(input);
if(val5){
lcd_clear();
lcd_putsf("INPUT SALAH !!");
delay_ms(500);
lcd_clear();
}
else{
arus = val;
ftoa(arus,2,arusPilih);
I=( arus/5 ) * 255;
itoa(I,OCRO_val);
lcd_clear();
lcd_putsf("INPUT BENAR");
delay_ms(500);
lcd_clear();
lcd_gotoxy(0,0);
lcd_putsf("


OCR0 : ");

lcd_puts(OCRO_val);
// lcd_gotoxy(17,0);
lcd_putsf(" b");
lcd_gotoxy(0,1);

lcd_putsf("SET ARUS : ");
lcd_puts(input);
// lcd_gotoxy(17,1);
lcd_putsf(" A");
lcd_gotoxy(0,2);
lcd_putsf("I LOAD : ");
lcd_puts(loadCurrent);
// lcd_gotoxy(17,2);
lcd_putsf(" A");
lcd_gotoxy(0,3);
lcd_putsf("SUHU : ");
// lcd_gotoxy(17,2);

lcd_puts(deviceTemp);
lcd_putsf(" T");
return;
}
}
lcd_clear();
lcd_gotoxy(0,0);
lcd_putsf("OCR0 : ");
lcd_puts(OCRO_val);
//lcd_gotoxy(17,0);
lcd_putsf("b");
lcd_gotoxy(0,1);
lcd_putsf("SET ARUS : ");
lcd_puts(input);
//lcd_gotoxy(17,1);
lcd_putsf(" A");
lcd_gotoxy(0,2);
lcd_putsf("I LOAD: ");
//lcd_gotoxy(17,2);


lcd_puts(loadCurrent);
lcd_putsf(" A");
lcd_gotoxy(0,3);
lcd_putsf("SUHU : ");
//lcd_gotoxy(17,3);
lcd_puts(deviceTemp);
lcd_putsf(" T");
delay_ms(200);
}
}
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTA=0x00;
DDRA=0x00;


// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=Out Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=0 State2=T State1=T State0=T
PORTB=0x00;
DDRB=0x08;

// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0x00;
DDRC=0xFF;

// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0xF0;
DDRD=0x0F;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: 10.800 kHz
// Mode: Fast PWM top=0xFF
// OC0 output: Non-Inverted PWM
TCCR0=0x6D;
TCNT0=0x00;
OCR0=0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;

// ADC initialization
// ADC Clock frequency: 691.200 kHz
// ADC Voltage Reference: AVCC pin
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0x84;

// Alphanumeric LCD initialization
// Connections are specified in the
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
// RS - PORTC Bit 0
// RD - PORTC Bit 1
// EN - PORTC Bit 2

// D4 - PORTC Bit 4
// D5 - PORTC Bit 5
// D6 - PORTC Bit 6
// D7 - PORTC Bit 7
// Characters/line: 16
lcd_init(20);
bacaArus();
bacaSuhu();
input_arus();
OCR0=I;
while (1)
{
lcd_clear();
// Place your code here
bacaArus();
bacaSuhu();
if((get_keypad()=='A')&&(OCR00)){
//OCR0-=1;
I -= 1;
OCR0 = I;
}
if(get_keypad()=='#'){
I=1;
OCR0=I;
itoa(I,OCRO_val);
z = 0;

itoa(z,input);
input_arus();
OCR0=I;
}
lcd_clear();
lcd_gotoxy(0,0);
lcd_putsf("BEBAN ELEKTRONIK");
//lcd_puts(OCRO_val);
//lcd_gotoxy(17,0);
//lcd_putsf(" b");

lcd_gotoxy(0,1);
lcd_putsf("SET ARUS : ");
lcd_puts(input);
//lcd_gotoxy(17,1);
lcd_putsf(" A");

lcd_gotoxy(0,2);
lcd_putsf("I LOAD: ");
lcd_puts(loadCurrent);
// lcd_gotoxy(17,2);
lcd_putsf(" A");

lcd_gotoxy(0,3);
lcd_putsf("SUHU : ");
lcd_puts(deviceTemp);
//lcd_gotoxy(17,3);
lcd_putsf(" C");
delay_ms(1000);
}
}

LAMPIRAN C
DOKUMENTASI ALAT

Gambar C.1 tampak depan

Gambar C.2 tampak atas