|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
Can't get a steady voltage from adc |
Posted: Wed Jul 09, 2008 6:53 pm |
|
|
Im using a PIC18f25j10.
Im continuously sampling the voltage of a photodiode, and outputting the number in hyperterminal.
If I measure the voltage with a multimeter, I can get a steady, unchanging reading down to the ten thousandths digit. Yet, when I sample with the PIC, my value wavers slightly, about +/- 3, which translates into +/- 0.0097 V. Calculating a running average smooths it out a little bit. If the voltage isn't changing, why is the digital approximation changing? |
|
|
Guest
|
adc unsteady |
Posted: Wed Jul 09, 2008 8:10 pm |
|
|
All DMM have builtin filtering and only update say 3 or 4 times per second.
You don't state how fast or how often you're sampling,but I'll bet it's more than 3 times a second. If you rip apart any DMM or look online for schematics, see how they filter. Proabably a simple R-C network.
Hope this helps.
Jay |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
Re: Can't get a steady voltage from adc |
Posted: Wed Jul 09, 2008 8:57 pm |
|
|
Anonymous wrote: | Im using a PIC18f25j10.
Im continuously sampling the voltage of a photodiode, and outputting the number in hyperterminal.
If I measure the voltage with a multimeter, I can get a steady, unchanging reading down to the ten thousandths digit. Yet, when I sample with the PIC, my value wavers slightly, about +/- 3, which translates into +/- 0.0097 V. Calculating a running average smooths it out a little bit. If the voltage isn't changing, why is the digital approximation changing? |
If you are sampling more than a single channel, are you allowing the A/D to settle (settling time) before you sample the channel?
If you are using VDD as the reference (not a precision external source) is the VDD noise free? i.e. Does is have large power supply filter capacitors and are there sufficient power supply decoupling capacitors used? _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
Guest
|
|
Posted: Fri Jul 11, 2008 1:21 pm |
|
|
Im waiting 10us between setting the channel and taking the reading
My power supply's ripple is around 2.5mV peak
I've put filtering caps on the photodiode as well.
Nothing seems to improve the situation |
|
|
Ttelmah Guest
|
|
Posted: Fri Jul 11, 2008 1:32 pm |
|
|
A number of comments.
How are you measuring the 2.5mV on the supply rail?. If this is with a meter, or even a normal scope, it is unlikely to represent anything near the 'real' ripple on this rail.
How are you buffering the photodiode?.
DVM's, typically have input impedances well over 1MR. The required impedance of the source to feed the PIC ADC (depends on the PIC version involved), but normally wants to be well under 10KR. To read a photodiode with a PIC, requires buffering.
What clock rate are you using for the ADC?.
What else is going on in the processor while you take the reading (any interrupts?).
Best Wishes |
|
|
Guest
|
|
Posted: Fri Jul 11, 2008 1:45 pm |
|
|
Im measuring the ripple with an oscilloscope.
I'm not buffering the photodiode. I assumed that an op amp would just add more noise. All I have is the base grounded, with 2 caps (47uF, 0.1uF) from each diode to ground.
My processor clock rate is 9.216MHz.
Im not running any interrupts.
All the code is doing is measuring 4 input voltages, calculating a running average of each voltage (to smooth things out), running a calculation to give x and y, and outputting the 4 voltages, x, and y to hyperterminal using the hardware uart. |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Fri Jul 11, 2008 3:03 pm |
|
|
With that much capacitance on the analog line you should get a VERY stable reading! I suspect noise on the reference voltage or maybe poor grounding. What is your reference voltage and what A/D readings are you getting? _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
Guest
|
|
Posted: Fri Jul 11, 2008 3:14 pm |
|
|
Photodiodes are tricky things to measure. They are more like a current source than like a voltage source. That is why they are usually buffered with a transimpedance amplifier, which is a fancy name for a current to voltage converter. The classic text on the subject is Photodiode Amplifiers by Jerald Graeme (1996), which you can find used on Amazon.com.
When photodiodes are used in photovoltaic mode (as you are doing), their output voltage is very low. If you used a properly-designed transimpedance amplifier, you could spread out your range and use more resolution on the A/D. In addition, running the photodiode in current mode rather than voltage mode produces an output that is linearly proportional to the incident light. The voltage mode is highly non-linear. If you properly buffer your photodiode, then you won't have to worry so much about pressing the limits of your reference stability.
Robert Scott
Real-Time Specialties |
|
|
libor
Joined: 14 Dec 2004 Posts: 288 Location: Hungary
|
|
Posted: Sat Jul 12, 2008 1:21 am |
|
|
If measuring with the possible highest precision is required you should always use the ADC putting the PIC into sleep mode while the conversion takes place.
You can configure it to set the interrupt ie. wake up the chip when conversion is finished. You should use the built in R/C clock for the adc timing in this mode. There is plenty of this sleep mode AD conversion written in the datasheet.
This mode is used to avoid the electrical "noise" generated by the running digital parts of the chip affecting the measurement with a small level of random error (I am sure this sleep-mode-ADC is not implemented needlessly into all models of PIC) |
|
|
Ttelmah Guest
|
|
Posted: Sat Jul 12, 2008 2:19 am |
|
|
One 'thought', that has not been mentioned, is 'what light is illuminating the diode'?.
Though the very large capacitance should smooth the voltage present, using a photodiode, feeding directly into a PIC, you will see on the voltage changing with mains 'flicker', if there is any room light involved.
I have to agree wholeheartedly, about using a transimpedance amplifier. There is a product on the market, I designed some years ago, using 7 photodiodes, under a series of narrowband filters, and another 'unfiltered' to measure the total light intensity. This measures the transmissive light, and flourescence, from a light pulse on a xenon tube, through certain liquids, and has been superbly repeatable, and accurate. However it uses the external Vref (you _never_ get really good accuracy using the Vdd supply as the Vref), and transimpedance buffers.
Best Wishes |
|
|
Guest
|
|
Posted: Thu Jul 24, 2008 9:04 pm |
|
|
a laser is reflecting/scattering off of an object, back to the sensor. I've got a 650nm laser and a 650nm filter over the sensor, . Im testing this all in a mostly darkened room, so when the laser is off, covering the sensor doesnt change the voltage.
Currently, Im using cheap op amps for initial testing, but I've ordered some high precision/low noise texas instruments opa37 op amps that will eventually buffer the voltages.
Using the start/sleep/read method has given me about another bit of stability in my readings. So now for example, it will vary from 745 to 747, usually staying on two numbers, occasionally hitting the third.
My next step is to get a precision reference IC. Can someone recommend a good one? preferably a 1.024 or 2.048 volt? Also, would using both vref pins with precision references be any better than just one vref and ground? |
|
|
libor
Joined: 14 Dec 2004 Posts: 288 Location: Hungary
|
|
Posted: Fri Jul 25, 2008 2:58 am |
|
|
Anonymous wrote: | Using the start/sleep/read method has given me about another bit of stability in my readings. So now for example, it will vary from 745 to 747, usually staying on two numbers, occasionally hitting the third. |
Good to know it worked. Keep in mind that you might never get stability to the very last bit. The process inherently rounds up or down the invisible fraction that is below the last bit.
Measurement devices you consider "stable" are not showing you the result up to the very last LSB they can convert, and they are also collecting a running average of many consecutive samples, which also results in a stable-looking reading. |
|
|
Guest
|
|
Posted: Fri Jul 25, 2008 10:01 am |
|
|
libor wrote: | The process inherently rounds up or down the invisible fraction that is below the last bit. |
If I use 2.048V as full scale, on 10 bits of resolution, that will be 2mV/division. Hypothetically, if my input is stable to less than 1mV, I shouldnt have rounding errors right? |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Fri Jul 25, 2008 10:13 am |
|
|
If the bit thresholds are 1.000, 1.002, 1.004 etc. and your "real voltage is 1.001999 +/- 0.0005 you will still be getting readings of both 1.000 and 1.002. There is no way to stop at least 1 bit of dither. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
libor
Joined: 14 Dec 2004 Posts: 288 Location: Hungary
|
|
Posted: Fri Jul 25, 2008 10:24 am |
|
|
Anonymous wrote: | if my input is stable to less than 1mV, I shouldnt have rounding errors right? |
Theoretically yes*. but if you look at the datatsheet (A/D CONVERTER CHARACTERISTICS Table)
Integral Linearity Error Max.<±1 LSB
Differential Linearity Error Max.<±1 LSB
Monotonicity: Guaranteed (The A/D conversion result never decreases with an increase in the input voltage and has no missing codes.) That's good.
I don't know the difference between the two kinds of Linearity Errors, but lets's assume you have 0.9 LSB linearity error in a way you have three values on the digital scale corresponding to analog values of only 0.2 LSB apart. (that would mean a changing two last bits! for 0.2 mV input change) ...if I got it right.
..anyway stabilizing your reference voltage would not harm.
*edited: If you're lucky and not getting the 1mV noise on a base signal in the 1mV vicinity of a threshold jump of 2mV each. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|