I have written pgm in mkroc for energy calculation..using PIC16f877a
can you convert it to mplab??
i dont knw mplab..its lcd&adc initializtion..
[HTMLunsigned float adcval,adcval1,V1,Is,I,I1,Is1,power,energy;
char val[7];
void main()
{
energy = 0;
TRISA=0XFF;
TRISD=0X00;
ADCON1=0X80;
lcd_init(&PORTD);
lcd_cmd(lcd_clear);
lcd_cmd(lcd_cursor_off);
lcd_out(1,1,"V=");
lcd_out(1,9,"I=");
lcd_out(2,1,"E=");
while(1)
{
adcval=Adc_Read(0)*.0048;
adcval1=Adc_Read(1)*.0048;
Is=adcval/100;
I=Is/2.5;
V1=I*5000;
floattostr(V1,val);
val[5]='\0';
lcd_out(1,3,val);
Is1=adcval1/100;
I1=Is1*1000;
floattostr(I1,val);
val[5]='\0';
lcd_out(1,11,val);
power = V1 * I1;
//floattostr(power,p_val);
//p_val[5]='\0';
//lcd_out(2,3,p_val);
energy =(energy + power)*(5/18);
floattostr(energy,val);
//val[5]='\0';
lcd_out(2,3,val);
delay_ms(1000);
}
}][/HTML]