Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Error in reading Analogue voltages in PIC16F877a's ADC

Status
Not open for further replies.

bilal shareef

Member level 1
Member level 1
Joined
Dec 11, 2010
Messages
36
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Visit site
Activity points
1,549
Hello everybody,
I am trying to measure the analogue voltages from 0 to 5 VDC from PIC16f877a's ADC but i am getting some error in the voltage.

For example: When the in put voltage is to the ADC is 2.33V the controller reads 2.43V. Whats the issue please help.
 

#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.
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top