Need info about ADC in pic16f877a

Thread Starter

mohamedadly71

Joined Nov 18, 2010
2
hello everybody
i am writing a code to read a sine wave of 50hz frequency
which is shifted by 2.5v and an amplitude 2.5v
i have to calculate the R.M.S of the wave using 4 sample method
which i should read a sample from sine wave every 5 milli second
and by using analoge to digital converter to convert it to digital.
i want to define the i/p as porta bit0
but when calculating the value of each sample i found that pic doesn't give the calculated sample on lcd
so please can anyone teel me if the ADC takes time to convert the sample or explain the ADC briefly
the code is:
float t,x5,x6;
char text2[13];
int i;
float y[4]={0,0,0,0};
void main()
{
adcon1=0;
trisa=1;
trisb=0;
lcd_config(&portb,0,2,1,7,6,5,4);
lcd_cmd(lcd_cursor_off);
lcd_cmd(lcd_clear);
for(i=0;i<4;i++)
{
x5=adc_read(0);
x6=(x5*5)/1024;
y=x6;
t=y[2];
floattostr(t,text2);
lcd_out(1,1,text2);
delay_us(4900);
}
}

//so by changing the value of y i can read the sample on the screen
thanks for ur assist
 
Top