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.

Need help with adc pic 16f877a

Status
Not open for further replies.

tamer1221

Newbie level 5
Joined
Jan 2, 2009
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,334
adc pic16f877a

im using mikroc to program
unsigned temp ;

void main() {
temp=0;
TRISB = 0x00;
ADCON1 = 0x8E;
TRISA = 0xFF;


while(1) {
PORTB = 0x00;
temp = ADC_read(0);
delay_ms(50);

if(temp>40)
{
PORTB=0x00;
DELAY_MS(50);
PORTB=0xff;
DELAY_MS(50) ;
}
}
}
the problem is the led keep blinking even when 0 volt is applied to an0
 

adc pic

The pic has a 10-bit A/D converter. If you are using the 5 Volt rail as a reference, 40 is not a very large voltage.

5 / 1024 = 0.0048 volts per bit
40 * 0.0048 = 0.192 volts.

You could easily have 200mV of noise on your input?
 
adc in pic16f877a using mikroc

that is the problem my input is 0.20 v
 

pic16f877a using 10bit adc program

Remember you cannot directly measure down to 0v. You really need to condition the signal first, say with a low noise op amp. Better to scale input so you measure say from 1-4 volts. You can the calibrate in software to give 0 to vmax output
 

adc in pic

as far as I remember.. there was an ADC_setup() function you should call before reading!
 

dont use adc function directly .. write program specifically how u need the output
 

use veritable resister with ground for RA0 pin and try
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top