#include <16f877a.h>
#DEVICE ADC=10
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#include <flex_lcd.c>
#include <math.h>
void main()
{
//Initialize and Configure ADC
setup_adc_ports( ALL_ANALOG );
setup_adc(ADC_CLOCK_INTERNAL );
set_adc_channel( 0 );
lcd_init();
printf(lcd_putc,"\fHELLO WORLD");
delay_ms(100);
while(true)
{
set_adc_channel( 0 );
delay_ms(10);
for (a=0;a<5000;a++)
{
//Read ADC Value
value1 = read_adc();
if (value1>value2)
{value2=value1;}
}
set_adc_channel( 2 );
delay_ms(10);
for (a=0;a<5000;a++)
{
//Read ADC Value
value3 = read_adc();
if (value3>value4)
{value4=value3;}
}
voltsa=(value2*0.0048875855327);
voltsb=(value4*0.0048875855327);
lcd_gotoxy(1,1);
printf(lcd_putc,"%f",voltsa);
lcd_gotoxy(1,2);
printf(lcd_putc,"%f",voltsb);
value1=0;
value2=0;
value3=0;
value4=0;
}
}
- - - Updated - - -
Actually i am using 2 channels for measuring 2 different voltages and i am getting error in both the readings when i compare them with the multi-meter.