unsigned float adcval,adcval1,V1;
unsigned float Is,I,I1,Is1,w1,e;
char val[7];char val1[7];
char val2[7],val3[7];
void main()
{
e=0;
w1=0;
TRISA=0XFF;
TRISD=0X00;
ADCON1=0X80;
lcd_init(&PORTD);
lcd_cmd(lcd_clear);
lcd_cmd(lcd_cursor_off);
while(1)
{
adcval=Adc_Read(0)*.0048;
Is=adcval/100;
I=Is/2.5;
V1=I*5000;
floattostr(V1,val);
val[5]='\0';
adcval1=Adc_Read(1)*.0048;
Is1=adcval1/100;
I1=Is1*1000;
floattostr(I1,val1);
val1[5]='\0';
lcd_out(1,1,"V =");
lcd_out(1,4,val);
lcd_chr(1,10,'V');
lcd_out(1,12,"I=");
lcd_out(1,15,val1);
lcd_chr(1,16,'A');
w1=I1*V1;
floattostr(w1,val2);
val2[5]='\0';
lcd_out(2,1,"P =");
lcd_out(2,4,val2);
lcd_chr(2,10,'W');
e=e+(w1*1000);
floattostr(e,val3);
val3[5]='\0';
lcd_out(2,12,"E =");
lcd_out(2,15,val3);
lcd_chr(2,16,'W');
delay_ms(1000);
}
}