ADC reading stabilty- suggestions?

gerrymcc

New Member
I am using the ADCs in a 28X1 in 10 bit mode. I am not happy with the stabiltiy of the ADC value I am seeing.

I suspect it is a hardware issue, since, when I use a voltage divider from Vss to ADC1 and from ADC1 to Vdd, I get a reading which does not vary in the last place. When I use my application, I see a range of about +/-4 in a count of 300.

The 28X1 has two ground pins. Does anyone know if these are equal, or if one is intended for the analog part of the chip, and one for the digital side? I have looked at the Microchip website, and I can not see any reference to this.

I have a DC gain and offset op-amp circuit driving the ADC. The op-amp is a Burr-Brown OPA2344.

The circuit is wired on a piece of perf board, with a voltage regulator on the board. The 28X1 has 10nF and 2.2uF across the power supply pins at the chip. The op-amp has 10nF across the chip. I have used a star ground and power supply wiring configuration, and I have made the connection between the op-amp and the 28X1 using signal and ground wires twisted together together, and connected to the grounds and the hot pins at each end. This length is about 60mm.

I am reluctant to put caps across the feedback resistors to limit the frequency response, because I want very high DC accuracy, and the leakage of the capacitors will alter the DC gain.

I thought I read somewhere that the ADC input is not a standard analog input, but draws pulses of current. Therefore, I am reluctant to put a series R/shunt C low pass network at the output of the op-amp.

Any thoughts or suggestions would be appreciated.

Thank you.
 

womai

Senior Member
Actually, a R-C low-pass filter between your op-amp's output and the ADCs input could be just what you need. Resistor between op-amp and ADC, and capacitor between ADC and ground.

If designed correctly, it will achieve two things:

1 - smoothen out any high-frequency noise and ripple in your input signal
2 - buffer the current spikes caused by the switched capacitor in the ADC.

For 1, make sure the time constant R x C is small enough to let pass the fastest changes you need to observe, but not much more.

I have attached a short PDF article from the most recent issue of EDN magazine which talks in more detail about the effect of the ADC input's switching, and how to choose the correct values for R and C of the filter. You can get values for the ADC's switched capacitance etc. from the Microchip datasheet of the PIC16F886 (the chip that is used for the 28X1).

The two ground pins on the 28X1 don't have separate functions, but both of them should always be connected to ground.

As for your power decoupling, 10nF is a bit small. I suggest leaving the 10nF caps where they are, but adding 100nF caps in parallel.

Wolfgang
 

Attachments

Last edited:

Dippy

Moderator
That's a useful little article Wolfgang.

In addition, I will state the obvious.

1. Do you KNOW that the test signal is steady and noiseless for your testing?
i.e. Have you 'scoped it? (at the PIC pin).
i.e.(2) have you determined that, if there is any ripple/noise present, that it should result in less than 4 in 300 as an ADC result.

ALSO:
Remember, the PICAXE will be using the voltage supply as the reference by default.
So,
1. How stable is the power supply?
2. Have you inserted the recommended cacpacitance on the regulator. If you have under-capacitored or used crappy caps then this may introduce reg instability.
3. As mentioned by Wolfgang, increase the decoupling value on PICAXE power pins. And, of course that cap is right next to the pins isn't it?
4. The ground to PIC must be good. You say star, we haven't seen your PCB. Just double check that no significant loads are on the PIC Gnd to main Gnd track.

One last thing; have you got any nasty noisy things that may be introducing electrical noise into the signal?

What do Microchip claim for error and inconsistency of the ADC for that PIC?

(For a well wired PIC and using a simple pot/div and using a TTi PSU I typically get +/- 1 or 2). Don't expct 100% stable. Some wobbly factor can be removed with a bit of averaging.
 

eclectic

Moderator
Perhaps I've missed it, but I haven't seen reference to
download circuit or download cable.



From Picaxe manual 2, page 133

“When using the debug command to output 10 bit numbers, the electrical
connection to the computer via the serial download cable may slightly affect the
ADC values. In this case it is recommened that the ‘enhanced’ interface circuit is
used on a serial connection (cable AXE026, not required with USB cable AXE027
as this uses 5V logic anyway). The Schottky diode within this circuit reduces this
affect.”

Also refer to manual 1 p.37.

e
 

slurp

Senior Member
How is the ADC value being used? How you obtain and process the reading can be important.

It's very difficult to work with exact ADC values for a number of reasons, including power supply, component quality, temperature and numerous other reasons.

Our code moves from if x = towards if x > ... or x < ... to deal with a range of ADC values. Now we need to be careful in selecting the ranges and looking for ways to design the separation between multiple target values.

The resistor selections and the calculations using in the ADC key decoding is elegant (ref: http://www.picaxeforum.co.uk/showthread.php?t=7791 ) but the principal of separation of ADC values is important to it's sucess.

I regularly use ADC with reflective IR for dohyo (competition ring) edge detection in Mini Sumo robots, the inital task of detection appears simple - white reflection of IR is very different to the black but there are a number of factors that can effect the theshold for action and problem are often observed with builder first robots. Ambiant lighting, variation in surface reflection (one dohyo to another) but the biggest oversight in (software) design is usually the start position markers - these are brown lines, they don't appear in the setup most builders use for testing!

Considering the ADC, black may return 255-245 and white say 40-50. As we approaching the black / white transition of the edge we might see values close to 180 and a theshold may not seem inappropriate at 200 for edge detetion (responding in a safer position, further from the edge) until you cross the brown line in the centre of the ring and cross the theshold and trigger unplanned avoidance moves!

regards,
colin
 

womai

Senior Member
Hi Eclectic,

yes I forgot to mention the enhanced download circuit. That should definitely be there as well. Gerrymcc, would it be possible to post a few pictures of your setup to show the wiring etc., as well as the circuit schematic?

From my experience, with a well-designed circuit the values coming from readadc10 are stable to within 1 LSB (meaning with a clean input source your digitized value should only vary by 0 or 1, which is the theoretical limit anyway, so e.g. always 300, or always either 300 or 301). A variation of 4 LSBs points to noise coming in somewhere. The fact that reading a voltage divider produces a stable result points to noise most likely either in the input signal itself, or at the op-amp.

Apart from analog filtering (which uses the least computing power), it's also possible to filter digitally by reading more often and then averaging the result.

w1 = 0

for b0 = 0 to 10
readadc10 0, w1
next b0

w1 = w1 / 10


Wolfgang
 

Dippy

Moderator
Thats what I said in #3.

Anyway, gerry needs to do some testing (i.e. work) before this can be sorted.
 

jglenn

Senior Member
**circuit is wired on a piece of perf board**

Sometimes that may cause problems with a 10bit precision analog circuit, I do a lot of wirewrap proto's, sometimes to RF, which is really hairy. You need as short as possible connections. Try a perfboard with a ground plane, it will work wonders. A pcb with ground and power planes will clean a lot of stuff up.

I've used a technique that makes engineers scream, on pic chips with a/d coupled to slightly noisy pressure sensors that must discriminate tiny pressure differences. Simply a big cap across the opamp output (to ground) feeding the a/d, I just eliminate the R in the RC filter. Have used 1uF to 10uF with great results. It never hurts the opamp, and has tons of stabilization. But don't tell your engineer about it. Probably illegal.
 

womai

Senior Member
Not illegal, just very ill defined. I'm not saying it can't work (it can), but it's not a reliable way to design. You basically rely on the output impedance of the opamp acting as your resistor. That may have a lot of variation from one part to the next (especially if the two parts happen to be from different production lots, different fabs, different manufacturers, etc.). Also, even worse, if the capacitance becomes too large, many opamps will start to oscillate. In the worst case you have a marginally stable prototype and then the next circuit will oscillate even though nominally it is identical. There is also a chance that you kill you opamp because for a while (until it is charged up) a capacitor looks like a short to ground, which can overload your output stage; that damage can be cumulative, meaning the circuit won't go up in smore right away, but its lifetime will be greatly reduced.

Wolfgang
 
Last edited:

InvaderZim

Senior Member
I am reluctant to put caps across the feedback resistors to limit the frequency response, because I want very high DC accuracy, and the leakage of the capacitors will alter the DC gain.
The signal is coming from an op-amp, right? Leakage on most caps is small enough that I have trouble seeing the DC accuracy straying enough for a 10-bit ADC to notice, since the amp is low impedance. Just don't pick a monstrously large R in the RC filter.

If you have the means, a scope would be wonderously helpful; analog work is not easy if you can't see the details.
 

gerrymcc

New Member
Thank you

Everyone- thank you for taking the time to read and reply. Very much appreciated.

After posting my question, I was discussing it with a colleague, which prompted me to do two things- recheck the noise specs for the op-amp driving the ADC (I am still convinced that is not a problem) and to have a second look at the Microchip datasheet, this time around the ADC section. I am not sure if I did find the right one (I had real difficulty locating this information on the PICAXE site, and 16F886 does not ring true at the moment), but the chip I did see suggested that 2.5K was the upper limit for the source impedance driving the ADC input and still stay within the Microchip specs. This was much higher than I had expected- I was thinking that perhaps 100 or 200ohms might be the limit- making a sensible low pass filter much more unwieldy. I did put in a quick 1K and (very large number of) nF low pass filter, and this made a big improvement. The circuit does not have to respond quickly, so heavy filtering here is OK. I will play around a bit with this network next week.

Wolfgang- thank you for your included reference. In the interests of brevity in my original question, I did not include all that I did to investigate this problem myself. I did use a CRO on the op-amp output, and saw 150-200mV P-P noise. This was much higher than I expected, but, as the CRO probe ground connection was in a loop and well removed from the op-amp circuit, I put this down to noise and pick-up on the CRO probe. Wolfgang- I am now convinced that your article explains (almost) everything, especially since the low pass filter made such a dramatic improvement. I was pretty convinced that the combination of 2.2uF and 10nF directly across the 28X1 pins would not allow too much digital noise to find its way around the rest of the circuit. 10nF immediately across the op-amp power supply pins I was confident would keep them stable. As somebody said, the fact that I could get a steady reading using two resistors did point to external noise, but I could not think what could be causing it. As this is the first time I have used a SAR ADC, I was not aware just how noisy they could be. Lesson learned and noted!

To provide a bit of background: The power supply regulator is a discrete design, using a temperature compensated 2.5volt voltage reference as the reference. This same reference is used in several other places in the project. The +5volts is clean, as seen on the CRO. After thermally settling down, it wanders around by <1mV at 5.000v. I did this to ensure that the ADC value was accurately determined. 1 bit with the 10bit ADC is only 4.9mV.

The voltage source I was testing this with, is a Keithley Sourcemeter (which is settable to better than 0.1mV, and very clean), and the voltage measurements are made with an Agilent 34401A 6.5digit multimeter.

I recognise only too well that building this project on perf board is not the ideal way to go- but it is the only way I have. Over the years, I have had lots of "issues" with ground loops, and using a star wiring system back to common power and ground points for the op-amp and PICAXE wring was my attempt this time to minimise these. There is still possibly a little way to go on this.

Digital averaging was another thought I did have before I put in the filter, and that is still something I could implement.

Thank you again for all your ideas and suggestions. gerrymcc
 

gerrymcc

New Member
Thank you

Everyone- thank you for taking the time to read and reply. Very much appreciated.

After posting my question, I was discussing it with a colleague, which prompted me to do two things- recheck the noise specs for the op-amp driving the ADC (I am still convinced that is not a problem) and to have a second look at the Microchip datasheet, this time around the ADC section. I am not sure if I did find the right one (I had real difficulty locating this information on the PICAXE site, and 16F886 does not ring true at the moment), but the chip I did see suggested that 2.5K was the upper limit for the source impedance driving the ADC input and still stay within the Microchip specs. This was much higher than I had expected- I was thinking that perhaps 100 or 200ohms might be the limit- making a sensible low pass filter much more unwieldy. I did put in a quick 1K and (very large number of) nF low pass filter, and this made a big improvement. The circuit does not have to respond quickly, so heavy filtering here is OK. I will play around a bit with this network next week.

Wolfgang- thank you for your included reference. In the interests of brevity in my original question, I did not include all that I did to investigate this problem myself. I did use a CRO on the op-amp output, and saw 150-200mV P-P noise. This was much higher than I expected, but, as the CRO probe ground connection was in a loop and well removed from the op-amp circuit, I put this down to noise and pick-up on the CRO probe. Wolfgang- I am now convinced that your article explains (almost) everything, especially since the low pass filter made such a dramatic improvement. I was pretty convinced that the combination of 2.2uF and 10nF directly across the 28X1 pins would not allow too much digital noise to find its way around the rest of the circuit. 10nF immediately across the op-amp power supply pins I was confident would keep them stable. As somebody said, the fact that I could get a steady reading using two resistors did point to external noise, but I could not think what could be causing it. As this is the first time I have used a SAR ADC, I was not aware just how noisy they could be. Lesson learned and noted!

To provide a bit of background: The power supply regulator is a discrete design, using a temperature compensated 2.5volt voltage reference as the reference. This same reference is used in several other places in the project. The +5volts is clean, as seen on the CRO. After thermally settling down, it wanders around by <1mV at 5.000v. I did this to ensure that the ADC value was accurately determined. 1 bit with the 10bit ADC is only 4.9mV.

The voltage source I was testing this with, is a Keithley Sourcemeter (which is settable to better than 0.1mV, and very clean), and the voltage measurements are made with an Agilent 34401A 6.5digit multimeter.

I recognise only too well that building this project on perf board is not the ideal way to go- but it is the only way I have. Over the years, I have had lots of "issues" with ground loops, and using a star wiring system back to common power and ground points for the op-amp and PICAXE wring was my attempt this time to minimise these. There is still possibly a little way to go on this.

Digital averaging was another thought I did have before I put in the filter, and that is still something I could implement.

Thank you again for all your ideas and suggestions. gerrymcc
 
Top