I looked at the ADC data book, Alain. Thanks. And thanks (again!) to Darrel.
I've done ADC before, with the 12F683 at 4 MHz and 8 bits.
Should I do anything different for the 16F88 at 8 MHz and 10 bits?
I looked at the ADC data book, Alain. Thanks. And thanks (again!) to Darrel.
I've done ADC before, with the 12F683 at 4 MHz and 8 bits.
Should I do anything different for the 16F88 at 8 MHz and 10 bits?
Russ
N0EVC, xWB6ONT, xWN6ONT
"Easy to use" is easy to say.
There are a few things to do differently.
First thing is obvious, DEFINE ADC_BITS 10
And, Right Justify the result ADCON1.7 = 1
Then go here, and start using 12-bits or more.
http://www.darreltaylor.com/DT_Analog/
<br>
DT
I already oversample on the 12 bit-ers. I use averaging as part of the math. Rather than use something like (sample * 9) >> 4, it is better just to perform 9 conversions, add them together and shift. I typically only need 3 digits of precision.
The thing most people ignore is the quality of their reference and dividers. They try to get 10-12 bits (or more) of resolution when using Vcc as the reference voltage. That just doesn't work. We use an LM4120-4096 (4.096V) reference with 0.2% accuracy. All voltage dividers use 0.1% resistors.
I have code that has to run on 8720s. 8722s and 8723s (the user doesn't know what chip they have in their unit and I have to do field upgrades). I read the processor type and speed (PLL enabled or not - I have chips running at both 20 and 40Mhz) from the CONFIG registers and do a right shift (>>2) on the result if the chip is an 8723. I have to change all the timing, buad rates, A/D clocks as well. It all works well, though.
Charles Linquist
If the thing you are reading also operates with a Fixed Reference, then sure ... you should use a reference on the A/D.
But most things are "Ratiometric" and a fixed reference will transfer any ripple on the power supply straight into your A/D readings. And regulators like 7805's that can't keep a constant voltage will make the readings wander all over the place.
References have their place, but I believe you should not use them unless the right conditions are met.
0.1% resistors ... gotta agree with that though.
<br>
DT
The power supply voltages I have to read are never ratiometric.
Charles Linquist
Exactly. Perfect example.
They are their own power supplies.
If VDD to the PIC changes, the other voltages don't necessarily change.
So there is no Ratiometric relationship, and a Fixed reference is required (like you have).
But when reading POTs, many pressure transducers, or any sensor that is resistive in nature, it will likely be ratiometric and a Fixed reference will distort the readings.
I guess I just thought that this was a bit limiting.
It's quite possible to get 12-bits or more without a Fixed reference.They try to get 10-12 bits (or more) of resolution when using Vcc as the reference voltage. That just doesn't work.
If you are reading a Ratiometric device.
Fortunately, whether or not a reference is used can be changed in the ADCON1 register, so even within the same project you might have some Fixed or unreferenced sources, and other ratiometric devices that change with VDD.
If you know the difference, Use the reference for the fixed sources, and no reference (VDD) for the ratiometric ones.
DT
I don't think I did a very good job of explaining myself.
I almost always have to read a 4 output EXTERNAL power supply (cPCI, VPX, uTCA or VME). I have to make certain that the voltages are within tolerance. I have to be a voltmeter, and have to be very accurate - regardless of what the PIC supply is.
Charles Linquist
Bookmarks