16F88 ADC Help

Status
Not open for further replies.

adamthole

New Member
I am trying to make a voltmeter from a 16f88 PIC.

When searching I have only found either assembly code or a PIC using a seperate A to D converter. I am writing the voltmeter program in C, and was wondering if their were any examples in C I could look at?

Any schematics I should look at for the actual voltage input to the PIC?

Thanks
 

Check my tutorial hardware for shematics, I would expect any C compiler that supports the chips to have examples of how to use the A2D?. If not, either use in-line assembler, or write your own C, based on the assembler routines.
 
Here's my example code, written in BoostC... if you're using some other C compiler (which I wouldn't recommend :lol then you'll probably have to modify it a bit, but at least you can get the general idea... but basically, if you just follow the steps to using the ADC found in the datasheet, and have a decent idea of how to use your compiler, then it's very easy, no real tricks involved.

http://www.eegeek.net/electronics/tutorials/PIC/adctest.c

The description from my website:
This program is basically a step up from a "hello world" application. What it does, is read values from the analog-to-digital converter (ADC) on RA0 (port A pin 0) and output them via the serial port. It also echos any characters it receives via serial, back to the computer via serial.
 
Well if you're using CC5x then I definitely recommend BoostC. I started with CC5x, and honestly didn't have any problem with it, except that it is so expensive that I was totally stuck with the limited free version. BoostC has the same kind of free version, however the full version is only about $60 if you ever need it. not to mention, they have an active support forum, and the developers are really on the ball about fixing things and adding new features. For instance, I requested that they add the method of bit accessing used in CC5x (ie- bit 3 of a variable would be variable.3) and they added it as soon as they finished one of their other major additions, just a few weeks after I posted.

Also, CC5x and BoostC are pretty close to compatible. Converting a program from one to the other just takes a couple minutes, and most of it is changing the case of variables (in BoostC, 'porta' refers to an 8-bit variable mapped to the appropriate register in the PIC, and 'PORTA' is a constant with the address of that register)
 
Wow. I am extremely impressed with BoostC. It is awesome. It simulates and even has the cool plugins. Very very cool. Thanks for the link.

BTW, I like declaring constants as individual bits. Is it possible to do a nibble? I am working with an LCD that I am using in 4 bit mode and was wanting to declare the highest nibble of portB to a constant, but I don't know how/if it is possible.
 
I don't think you can do that... but I think that it would probably just be handled as an 8-bit variable behind the scenes when converted to assembly, and would probably produce some inefficient code... so you're probably better off dealing with it as an 8-bit in the first place.
 
While we are on the topic of BoostC, I would pass on what I saw on EBay UK.

There are two recently completed auctions for BoostC 6.0 Compiler & IDE licence about a week apart.

One ended up selling for US$96 and one for US$36. Interesting things happen on EBay.
 
Sounds pretty odd... but what licenses were they? normally lite is $30, full is $60, and pro is somewhere around $150...

Wow, I just found those two auctions, and both were for full licenses... so one guy got a good deal and one guy got totally ripped off... that's excellent :lol:
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…