ADC resolution setting

29 Oct 2010

Hi,

I'm new to mbed platform, so maybe my question is not good.

I took a look at the MCU datasheet and I saw that I can put the ADC in 10 bits mode. I was wondering how I can do that with the mbed library.

Thanks in advance :)

29 Oct 2010

The output is normalised to 1, so simply multiply the float value returned from the analogue read by 1024.

29 Oct 2010
Yeah, I don't see any mention of 10-bit mode either. Why would you need it anyway? BTW, instead of using floating-point multiplication, you can take the 16-bit value returned by read_u16 and shift it four bits to the right.
29 Oct 2010

 

user Igor Skochinsky wrote:
Yeah, I don't see any mention of 10-bit mode either. Why would you need it anyway? BTW, instead of using floating-point multiplication, you can take the 16-bit value returned by read_u16 and shift it four bits to the right.

 

That's actually a much better idea! The M3 doesn't have an FPU does it?

29 Oct 2010

I want the 10bit resolution because with 12 bit the max sampling freq is 200KHz, in 10bit mode the max sampling rate is 500KHz.

I don't really need 12 bit, but I need more speed :)

29 Oct 2010

user Igor Skochinsky wrote:
Yeah, I don't see any mention of 10-bit mode either. Why would you need it anyway? BTW, instead of using floating-point multiplication, you can take the 16-bit value returned by read_u16 and shift it four bits to the right.
You can take a look at section 12 of the LPC1768 datasheet :)

29 Oct 2010
Okay, I downloaded the latest datasheet and indeed it has a table for 10-bit ADC mode. However, there is no sign of this in the user manual (Rev. 2 — 12 August 2010), so I think even if it's real, it will likely be present only in the newest silicon revisions.
29 Oct 2010 . Edited: 29 Oct 2010

Uhhmm right it must be the reason :)

Thanks for the information, I'll try to use the ADC in interrupted mode at 200KHz and see if it's enough. If not i'll take an external ADC.

30 Oct 2010 . Edited: 30 Oct 2010

hello,

I am facing with stability in the ADC value .

I put a variable resistor betwen the Vout 3.25V and ground. The 3rd pin is connected to the P15  (analog input).

after moving the cursor I have 1.6V for example on the P15.

I send the result to the serial via USB PC  and in Tere Term

P15 value 19204 P15 value 18116 P15 value 19476 P15 value 20132 P15 value 18420 P15 value 18420 P15 value 20196 P15 value 19396 P15 value 18116

Here is the code used

#include "mbed.h"

AnalogIn Temperature(p15);

Serial pc(USBTX, USBRX);// tx, rx

int main() {

unsigned int LUI_Temperature=0;

while(1) {   LUI_Temperature = (Temperature.read_u16());

pc.printf("P15 value %d",LUI_Temperature);

}

}

 

I do not understand why I have some much variation in the value get from ADC.

How are coded the 12 bits return by ADC in the variable  ( bit 15 to bit 4o or bit 11 to bit 0 )?

If some has some idea?

Additional information, when you put 0V impossible to get something close to !

When you put 3.3V impossible to get something close to 65535 !

A+

Sares

30 Oct 2010

How many ohm is your variable resistor ?

You must respect the max impedance.

30 Oct 2010

It is a 10K variable resistor.

06 May 2013

Hello, am new to mbed environment and lately am working on a project to read and store a strain gauge value. everything seems working except ADC always put zero to the output all the time. below is part of the code for ADC conversion

ADC adc (150000,1); .... while (1) { adc.setup(p20,1); adc.select(p20); adc.start(); while(!adc.done(p20)); wait(1); fprintf (fpp,"%05f\n\r", adc.read(p20)); }