5984Views9Replies

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

6 Replies

user
neelandan (author)2007-03-30

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.

Select as Best AnswerUndo Best Answer

user
andy (author)neelandan2007-04-02

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

Select as Best AnswerUndo Best Answer

user
westfw (author)andy2007-04-02

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...

Select as Best AnswerUndo Best Answer

user
frank26080115 (author)2007-03-28

There is a very good reason why you can't do it

pic16f628 and pic16f628a don't have a A/D converter feature, try another pic

here's some example code in C, http://www.lika.be/content/view/21/30/ , you can compile it with sourceboost http://www.sourceboost.com it's free

Select as Best AnswerUndo Best Answer

user
andy (author)frank260801152007-03-28

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

Select as Best AnswerUndo Best Answer

user
andy (author)2007-03-28

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

Select as Best AnswerUndo Best Answer