EmbeddedRelated.com
Forums

ADC Issue

Started by Jerry January 29, 2012
--- In l..., "tcirobot" wrote:
> I'd suggest an OpAmp buffer with a series resistor and a cap between the output of the OpAmp and the ADC input of the LPC1769. The cap is between the ADC input and the series R (not between the series R and the OpAmp output).
>
> I recently had this issue on an LPC1765. The circuit I suggested cured the problem. You can experiment with the R and C values but try starting with something like 100 ohms and 470pf.
>

I'm driving the ADC with an opamp in a voltage follower configuration. I've experimented with resistors and capacitors in the configuration you've suggested and others with no positive effect. In fact, the configuration you suggest is useless in my case because I'm measuring the DC voltage of a voltage divider and the cap will block that.

I've come to the conclusion that either my dev boards have too much noise on the analog sections, or that there's too much digital switching going on on the LPC1768 to yield reasonable ADC performance. I've tried two boards from two different manufacturers and they both exhibit similar ADC issues.

I've also tried an external ADC (an MCP3208) with the same configuration and I get very solid ADC performance with no noise apart from the expected Gaussian noise around the expected values.

An Engineer's Guide to the LPC2100 Series

>> or that there's too much digital switching going on on the LPC1768 to yield reasonable ADC performance.
>> I've tried two boards from two different manufacturers and they both exhibit similar ADC issues.

It has to be the software. I have the ADC in my LPC1766 measuring 8 CHs of voltages,
and I get 0.05% accuracy or better every read consistently.
I am measuring +5.0V, +12V, -12V, +48V through simple R dividers and 1 inverter opamp.
My source impedances to the ADC vary from 500 to 5K Ohm.
My Vref is nothing but a simple dual RC lowpass of 10Ohm/0.22uF from the 3.3V.
Full Scale factor for each supply is set to about 3.0V (90%) of the 3.3Vref span.
Nothing fancy at all.

The only variations I see are in the actually DC voltages, which the ADC accurately reflects.

I have even switched the ADC clk freq around, don't see much difference even then.

Now if I don't have the code setup right, I can get totally wild readings back from the ADC.
I would suggest you try different ADC code and see what happens.

Perhaps the Pin I/O settings are not correct. Or there is something else wrong.

I really think the problem must be somewhere in your code.
I've never had problems with ADCs in any NXP MCUs.
It's not the chip.

Chris.



I've seen erratic readings on the LPC1114 and LPC1768 which are quite
repeatable, but they are only caused when one or more of the ADC input
channels is over driven.

In this case it seems that it affects other channels than the ones being
converted.

( by repeatable I mean not the absolute values, but statistically the error
variance seems to be quite consistent ).

I sample the ADC's at 20KHz using a timer interrupt to trigger a burst
conversion, then an ADC interrupt to stop the burst after the last channel
conversion is completed.

My only issue with the ADC's on the LPC devices is that you cannot perform a
single burst conversion ( once started a burst conversion restarts itself on
completion ), but otherwise they are working very well.

So I have to agree with Chris here, look again at the SW.

Regards

Phil.

From: l... [mailto:l...] On Behalf Of
Chris
Sent: 21 March 2012 08:02
To: l...
Subject: Re: [lpc2000] Re: ADC Issue

>> or that there's too much digital switching going on on the LPC1768 to
yield reasonable ADC performance.
>> I've tried two boards from two different manufacturers and they both
exhibit similar ADC issues.

It has to be the software. I have the ADC in my LPC1766 measuring 8 CHs of
voltages,
and I get 0.05% accuracy or better every read consistently.
I am measuring +5.0V, +12V, -12V, +48V through simple R dividers and 1
inverter opamp.
My source impedances to the ADC vary from 500 to 5K Ohm.
My Vref is nothing but a simple dual RC lowpass of 10Ohm/0.22uF from the
3.3V.
Full Scale factor for each supply is set to about 3.0V (90%) of the 3.3Vref
span.
Nothing fancy at all.

The only variations I see are in the actually DC voltages, which the ADC
accurately reflects.

I have even switched the ADC clk freq around, don't see much difference even
then.

Now if I don't have the code setup right, I can get totally wild readings
back from the ADC.
I would suggest you try different ADC code and see what happens.

Perhaps the Pin I/O settings are not correct. Or there is something else
wrong.

I really think the problem must be somewhere in your code.
I've never had problems with ADCs in any NXP MCUs.
It's not the chip.

Chris.





Il 21/03/2012 09:44, Phil Young ha scritto:
>
>
> I've seen erratic readings on the LPC1114 and LPC1768 which are quite
> repeatable, but they are only caused when one or more of the ADC input
> channels is over driven.
>
> In this case it seems that it affects other channels than the ones being
> converted.
>
> ( by repeatable I mean not the absolute values, but statistically the
> error
> variance seems to be quite consistent ).
>
> I sample the ADC's at 20KHz using a timer interrupt to trigger a burst
> conversion, then an ADC interrupt to stop the burst after the last channel
> conversion is completed.
>
> My only issue with the ADC's on the LPC devices is that you cannot
> perform a
> single burst conversion ( once started a burst conversion restarts
> itself on
> completion ), but otherwise they are working very well.
>
> So I have to agree with Chris here, look again at the SW.
>
> Regards
>
> Phil.
>
There are too much messages about adc reading problems.

I will try to put this week a sample project to test the LPC adc that
may work for all the LPC families.
If it is ok for all I will do it with LpcXpresso that is also free and
you can download from http://lpcxpresso.code-red-tech.com/LPCXpresso/
It is limited to 128KB flash applications after a free registration
without registration is 8KB limited.

I will put it on www.lpcware.com that it is the newest NXP website to
find updated informations, tools and applications for LPC ARM
microcontrollers. It is managed by NXP but without the restriction of
the main corporate site.
> From: l...
> [mailto:l... ] On
> Behalf Of
> Chris
> Sent: 21 March 2012 08:02
> To: l...
> Subject: Re: [lpc2000] Re: ADC Issue
>
> >> or that there's too much digital switching going on on the LPC1768 to
> yield reasonable ADC performance.
> >> I've tried two boards from two different manufacturers and they both
> exhibit similar ADC issues.
>
> It has to be the software. I have the ADC in my LPC1766 measuring 8 CHs of
> voltages,
> and I get 0.05% accuracy or better every read consistently.
> I am measuring +5.0V, +12V, -12V, +48V through simple R dividers and 1
> inverter opamp.
> My source impedances to the ADC vary from 500 to 5K Ohm.
> My Vref is nothing but a simple dual RC lowpass of 10Ohm/0.22uF from the
> 3.3V.
> Full Scale factor for each supply is set to about 3.0V (90%) of the
> 3.3Vref
> span.
> Nothing fancy at all.
>
> The only variations I see are in the actually DC voltages, which the ADC
> accurately reflects.
>
> I have even switched the ADC clk freq around, don't see much
> difference even
> then.
>
> Now if I don't have the code setup right, I can get totally wild readings
> back from the ADC.
> I would suggest you try different ADC code and see what happens.
>
> Perhaps the Pin I/O settings are not correct. Or there is something else
> wrong.
>
> I really think the problem must be somewhere in your code.
> I've never had problems with ADCs in any NXP MCUs.
> It's not the chip.
>
> Chris.
>
>
>
>



--- In l..., "Chris" wrote:
> Now if I don't have the code setup right, I can get totally wild readings back from the ADC.
> I would suggest you try different ADC code and see what happens.

My setup: LPCXpressio board with LPC1769, and a NGX LPC1768 board. Input to ADC channel 0 is the output of an opamp configured as a voltage follower. Input to the opamp is a voltage divider with two 10K resistors, so the voltage will be 3.3v / 2. ADC channels 1-7 are grounded.

I tried some ADC code I downloaded from NXP in case I might have had a bug in my code. I get exactly the same results: random conversion values all over the 0-4095 count range (with most of them concentrated around the expected 2048 counts).

My test code allocates 4096 32-bit words of memory, zeros it out, and goes into a loop reading the ADC and incrementing the memory location corresponding to the count returned by the ADC. I've collected several million conversions, and while most of the conversions result in a count close to 2047, there are significant numbers of counts ranging from 0 all the way up to 4095 with particular emphasis on bad counts within twenty counts of 4095. Sample rate is not too high, perhaps a few hundred a second.

> Perhaps the Pin I/O settings are not correct. Or there is something else wrong.

The ADC pin I'm sampling is set in ADC mode, the pull-up/pull-down is disabled. I've tried various ADC clock rates, all the way down to less than 1 MHz.

I've tried different ADC channels and tried setting the unused channels to outputs and setting them to 0. None of this changes the results.

> I really think the problem must be somewhere in your code.
> I've never had problems with ADCs in any NXP MCUs.

That's possible, but I've used ADC code from NXP in place of my driver and I see the same bad conversions at the same rate.

> It's not the chip.

I hope not. Perhaps it's the boards I'm using.

I also tried an MCP3208 8-channel SPI external ADC with one of its inputs connected to the output of the opamp driving the 1768's ADC and I see no spurious conversions -- all conversions are tightly clustered around 2048. This is with the MCP3208 mounted on a solderless breadboard with no bypass caps or any filtering.

--- In l..., "Jerry" wrote:
> I'm driving the ADC with an opamp in a voltage follower configuration. I've experimented with resistors and capacitors in the configuration you've suggested and others with no positive effect. In fact, the configuration you suggest is useless in my case because I'm measuring the DC voltage of a voltage divider and the cap will block that.
>

I didn't suggest that you AC-couple the ADC input. Adding a cap as I suggested will not block DC. I don't think you understand what I'm suggesting.

Your description of your circuit is confusing. Do you drive the ADC input directly from the output of an opamp, or not. In your last sentence quoted above it sounds like you have a resistor divider network at the input of the ADC.

In either case... I'd suggest that you read some application notes about common problems with sample-and-hold circuits in ADCs and commonly recommended solutions (if you haven't already done so). In my case, the recommended solution (which I suggested to you) solved my issues (which are the same symptoms you are reporting).

--- In l..., "tcirobot" wrote:
> --- In l..., "Jerry" wrote:
> > I'm driving the ADC with an opamp in a voltage follower configuration. I've experimented with resistors and capacitors in the configuration you've suggested and others with no positive effect. In fact, the configuration you suggest is useless in my case because I'm measuring the DC voltage of a voltage divider and the cap will block that.
> > I didn't suggest that you AC-couple the ADC input. Adding a cap as I suggested will not block DC. I don't think you understand what I'm suggesting.

You said this "I'd suggest an OpAmp buffer with a series resistor and a cap between the output of the OpAmp and the ADC input of the LPC1769. The cap is between the ADC input and the series R (not between the series R and the OpAmp output)."

I took this description to mean this: opamp output->resistor->cap->ADC input, all in series. If you meant something else, it was unclear.

> Your description of your circuit is confusing. Do you drive the ADC input directly from the output of an opamp, or not. In your last sentence quoted above it sounds like you have a resistor divider network at the input of the ADC.

My resistor divider is feeding the non-inverting input of the opamp, which is in a voltage follower configuration. The output of the opamp is directly driving the input of the ADC.

> In either case... I'd suggest that you read some application notes about common problems with sample-and-hold circuits in ADCs and commonly recommended solutions (if you haven't already done so). In my case, the recommended solution (which I suggested to you) solved my issues (which are the same symptoms you are reporting).

I'm well-familiar with the issues surrounding sample-and-hold circuits in ADCs and have been implementing them for almost thirty years. The ADC on the LPC1768 is one of the few that has given me so much trouble.

I'm using essentially the same circuit to drive the ADCs on other projects that use, among other things, a TI Luminary LM3S1968, a PIC32, an AVR32, and one or two using an MCP3208 and *none* of these have issues with shotgun scattering of conversion results throughout the entire conversion range.

On Monday 30 January 2012 05:48:35 Jerry wrote:
> I'm seeing an intermittent problem when reading the ADC on an LPC1768. I'm
> reading ADC channel 1 in software-start mode and 99% of the time I'm seeing
> results within range.

Just a wild thought. Are you using a smps to power the 1768 board. Try using a
regular transformer supplied linear regulated supply.
If, as you say you have a voltage follower feeding the ADC pin, the very low
impedance on the follower output should pretty much take care of everything
upto the internal S/H.
After all the hoops jumped thru, might as well jump thru changing to a linear
psu to verify.

--
Rgds
JTD
--- In l..., jtd@... wrote:
> Just a wild thought. Are you using a smps to power the 1768 board. Try using a
> regular transformer supplied linear regulated supply.

JTD,

Thanks for the suggestion. In my last attempt, I powered the board with a 12v battery. You can't get power any cleaner than that. Still see the same symptoms in the ADC conversion results.

On Thursday 22 March 2012 20:41:39 Jerry wrote:
> --- In l..., jtd@... wrote:
> > Just a wild thought. Are you using a smps to power the 1768 board. Try
> > using a regular transformer supplied linear regulated supply.
>
> JTD,
>
> Thanks for the suggestion. In my last attempt, I powered the board with a
> 12v battery. You can't get power any cleaner than that. Still see the same
> symptoms in the ADC conversion results.

:( True.

--
Rgds
JTD