Author Options:

Analog to Digital 16F628 Answered

I am a learner pic programmer and I am having some major grief trying to get the analog to digital (A2D) feature to work on my 16F628. All I would like to do is to be able to read in a value (either the most or least significant byte) and out put it again, just as a starting point for a project, the rest of which i can figure for myself. I have trauled the web for nigh on.. 3 hours and found few resources, but all were out of date or for a different chip. If anyone could help me either in terms of a bit of ASM code, some general guidence, or a link to a relevant tutorial that would be great. Thanks, Andy


You can do A to D with a digital port pin or two. It involves charging a capacitor with the input voltage, then discharging it and measuring how long it takes. I think there are several application notes at the Microchip web site detailing the process. If you need to do ADC with a single instruction then you will have to use one with a ADC built in. The PIC16F877 is one such.

oo, thank you, that's exactly what I need. Many thanks neelandan, you have brought me back from the brink of dipair. Andy

cause heaven forbid if you'd have to replace your 16f628 with a pin-compatible 16F88 (for example) that DOES have a real A-D converter? You could have free samples in a couple weeks...

Ah, that very well could be why then, i must have miss understood the documentation. Thanks for your help, you probably saved me another 3 hours of frustration. many thanks, andy


11 years ago

When I say "output it" I ment into a register. Sorry, I should pay attention when I proof read, Andy