• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC 16F877A ADC matters

mokh

New Member
hi,

im having dificulties on ADC in PIC16F877A. i did the programming and it works fine with hardware. the problem here is when the input(RA0) is not present, the output of the adc is random and not zero. it supposed to be zero right?

note: the adc output goes well when there are analog input level between the Vref+ and Vref-.
 

ericgibbs

Well-Known Member
Most Helpful Member
mokh said:
hi,

im having dificulties on ADC in PIC16F877A. i did the programming and it works fine with hardware. the problem here is when the input(RA0) is not present, the output of the adc is random and not zero. it supposed to be zero right?

note: the adc output goes well when there are analog input level between the Vref+ and Vref-.
hi,
If the ADC input is 'floating' I would expect it to pick up em noise,
if you have the ADC part of your program running and sampling the ADC input, you will get random results.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
Exactly, you can't leave the input pin just floating as it's high impedance and picks up noise. Adding a resistor from the pin to ground should stop it, I get no such pickup on my analogue tutorial board.
 

Stellarcore

New Member
Hrm.. that gives me an idea, I wonder if you could use a floating ADC as a way to get (pseudo?) random numbers.

It would be interesting to collect bunch of samples with it and see the distribution with a histogram or something.
 

mokh

New Member
the problem is, i need it to be floating.

what exactly i do is using the potentiometer to giving variable analog input to the adc. however, i removed the potentiometer stopper for some reason, so the potentiometer can turn 360degree. the problem appear when the potentiometer contact move to the point where i connect to the PIC. it mean, it connect to itself. not to vcc or ground.

i dont think modifie the potentiometer is an option.

btw, thanks for make me clear about the random output :rolleyes:
 

Diver300

Well-Known Member
You need a resistor or two to stop the input floating when the potentiometer is in the dead area. If the resistance is much higher than the potentiometer, there will be little effect when the potentiometer is working normally.

A capacitor to ground could also help reduce the noise, if the potentiometer is far from the PIC, or there is a mains voltages nearby.

If you have a 10k:eek:hm: potentiometer, a 330k:eek:hm: resistor to ground from the wiper will have no noticable effect unless the potentiometer is in the dead area.

A 1:mu: F capacitor in parallel with the resistor will help keep noise down.

The PIC will read 0 when the potentiomer is in the dead area. You can make this read full scale by connecting the resistor between the wiper and Vcc. You can also make it read mid-scale by fitting resistors in both positions.
 

mokh

New Member
thank you all! i solved the problem. i put a series resistors 40k. 1st when i tried with 200k, 300k, the pin cant goes low maybe the resistant too high. then i tried with 40k and it work. im using 10k potetiometer, so 40k is enough as it is higher than 10k i think.

once again, thank you!:D
 

EE World Online Articles

Loading

 
Top