View previous topic :: View next topic |
Author |
Message |
championx
Joined: 28 Feb 2006 Posts: 151
|
16F88 comparator and ADC |
Posted: Mon May 26, 2014 9:49 pm |
|
|
Hi all! i have a simple question about this pic. It is possible to use some analog inputs (ADC channels) and the comparator module?
I need to trigger from a very fast signal (small signal) and I'm planning to do it with the comparator module setting a Vref externally. I already tested it on a 16F648A and it works great. But now i need an analog signal too.
I know this pic has ADCs and comparator modules, but.. can i use them at the same time?
thanks!! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Tue May 27, 2014 12:51 am |
|
|
Yes.
They are completely separate modules, except some of the pins can be used for functions on both.
A little depends on what accuracy you want to use from the ADC?.
The 'VREF+' pin for the comparator, is shared by C2OUT. So this is the first decision. Realistically to use the 12bit accuracy of the ADC, _requires_ using an external Vref. You are unlikely to get anything beyond perhaps 7bits of useable/repeatable accuracy using the supply rail as the reference. Now provided you are happy to use this lower accuracy, 'no problem'.
Now you talk about setting the Vref for the comparator externally. If you look at Figure 13-1 (comparator operating modes), then the bottom left diagram shows the mode that will suit you the best. Here only comparator 2 is enabled, and uses just three pins. RA1, RA2 & RA4. You can put the reference you use for the comparator on the +ve or -ve input, and the signal on the other pin. This then leaves the RA3 pin clear to use for the ADC Vref if required (otherwise you can use the supply rail, with the accuracy limits mentioned), and AN0, AN5 & AN6 available for use as inputs to the ADC.
If required, you can use both comparators, but then you are stuck with using the supply for Vref, and only AN5 & AN6 are available as ADC inputs.
Best Wishes |
|
|
championx
Joined: 28 Feb 2006 Posts: 151
|
|
Posted: Tue May 27, 2014 6:27 am |
|
|
wow! thanks Ttelmah!
I didnt know that the 16F88 had 12 bit adc. I though that was 8 or 10 bits.
I just want it to measure the battery voltage, so i dont need high accuracy.
For high accuracy conversions i use the AD7705.
thanks |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Tue May 27, 2014 10:38 am |
|
|
Apologies. There is another PIC with a short number like this that has a 12bit rather than 10bit ADC. Trying now to remember the number!....
It's an 'oldie'. Something like 16C88. |
|
|
|