11 years, 4 months ago.

Incorrect ADC conversion

Hi,

I wanted to check the ADC conversion of LPC1768, I have encountered the following problems, request help on them!

Background: 1. I am giving an interrupt @1Khz to the board. 2. Converting at every rise edge! Conversion time = 20 micro seconds. 3. I am trying to convert a 100 Hz sine wave. 4. I am performing conversion around 2000 times and then writing it into a file. 5. There is a 10nF capacitor across the analog input and ground.

Problem: 1. The kit said that the converted value is a float normalised between 0 to 1. : I am getting float values in between 0 to 5000.0 2. The values when plotted have overshoots and abrupt phase change at random places.

In the attached image, issues are circled in red.

How do I address these two issues?

Regards, Manants

Am unable to attach the image!

posted by Manas Savkoor 15 Jan 2013

2 Answers

11 years, 4 months ago.

@Erik Olieman: Thank you! Was able to resolve the errors! Saw your comments now! Here is the answers according to my debug: 1. adc.read returns an int value, hence was getting int! 2. Overshoots and abrupt phase change is due to noise!

My recommendation in general to people who use interrupts and ADC based on my experience is as follows: 1. Adding a very small capacitor (15-50 pF) across the analog pin and Ground solves it. 2. Ditto interrupt (edge triggered). 3. take float as data type of read and not int.

Regards, Manas

Accepted Answer
11 years, 4 months ago.

If you are getting floats between 0 and 5000 you have an error in your code, since the float is normalized between 0 and 1. So you have to post your code for that.

Regarding point 2, there is no capacitor allowed between analog input and ground: max 15pF capacitance at the input and 7.5kOhm output resistance according to the datasheet. Now you probably can get away with a bit more than that, but 10nF is alot more.

I have made the code public, below is the link: https://mbed.org/users/manants/code/adc_timer_try7/ Please let me know the error. Not posting it here as it will be long!

Regards, Manants

posted by Manas Savkoor 15 Jan 2013

You are using a custom ADC library. Which can be useful, but for your speed not really required probably. Anyway that library does not normalize the output, it just returns the raw value.

posted by Erik - 15 Jan 2013