Bilal
Joined: 24 Apr 2010 Posts: 75 Location: Islamabad
|
A/D problem |
Posted: Thu Oct 21, 2010 11:12 pm |
|
|
Hi. I am using PIC16F877A. I want to use 2 A/d channels at the same time. One for temp sensor and other for voltage measurements (simple a variable resistor).
The problem is one both are not independent (I guess).
Voltmeter value is changing with temp sensor value.
This is my code
Code: |
void main()
{
float value;
float volts;
int decic,TC,TF,decif;
float tempc,read,tempf;
setup_port_A( ALL_ANALOG );
setup_adc( ADC_CLOCK_INTERNAL );
lcd_init();
do{
set_adc_channel(1);
read = Read_ADC();
tempc=read*1.5;
tempf=(1.8*tempc)+32;
lcd_gotoxy(1,2);
printf(lcd_putc,"Temp %f C",tempc);
set_adc_channel(0);
value = Read_ADC();
volts= value/51;
lcd_gotoxy(1,1);
printf(lcd_putc,"Volts %f",volts);
} while (TRUE);
}
|
Please kindly help me with this problem.
thanks _________________ ... |
|