Trying to figure out A/D jargon in the LPC User's Manual

I’m trying to determine the true equation to arrive at the voltage on the A/D input of a LPC2138. I designed my voltage divider circuit to give a full scale of 3V input to the A/D, based on this line from the User’s Manual:

“Measurement range 0 to 3 V”

Now I’m trying to calculate that voltage and I read this section:

“Zero in the field indicates that the voltage on the Ain pin was less than, equal to, or close to that on VSSA, while 0x3FF indicates that the voltage on Ain was close to, equal to, or greater than that on V3A.”

i.e. the output of the pin is V/V3A. I have 3.3V going in to VREF and VDDA3.

What does ‘V3A’ refer to? In my configuration, is a the maximum reading going to be 3/3.3, or 3.3/3.3?

V3A is the voltage applied to the reference pin of the ADC (VREF).

In your case, you say you have 3.3V

So, with a 10 bit converter there are 2^10 or 1024 values.

Each value represents 3.3/1024 volts or about 3.22 millivolts

The ADC values are zero relative so you will read between 0 and 0x3FF hex.

The ADC has to compare your input signal value against its reference and determine whether or not you are “close”…

The error is equal to about 1/2 of a bit or 1.6 mV.

You should take the ADC value, divide by 1023 and multiply by 3.3.

Or is it divide by 1024 but add 1 to the ADC value? Hmmm…?? :slight_smile: You have to decide how to handle the 1/2 bit error.

So you are saying that this quote:

“Measurement range 0 to 3 V”

is wrong?

Or was it wrong to give 3.3 as a reference? It seemed too handy just to filter the supply voltage and use it.

I’m going to apply 3V and 3.3V respectively and observe my output through serial. I just wanted to know the right way to do it.

Yes, it is wrong. Take a look at the datasheet. VRef is typically specified at 3.3V so you’re ok. Range is 0-Vref which is 0-3.3V in your application.

When you apply 3.0 to the input and have 3.3V as Vref you should get something around 0x3A2 (930) as a result.

AVRef for the ARM is a separate supply and can be connected to 3.3V. However, probably that 3.3V supply is in error by a percent or two, which means your readings will be in error likewise.

You can use a precision 3V reference that is powered from 3.3V. Now your readings will be accurate, similar to the reference accuracy.

You probably don’t want to rely on a single reading, but rather average them. If you shift every reading taken 6 bits left and add that to the running total, then average that, you can essentially get rid of the half-bit errors.