Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 5 months ago.
FastAnalogIn conversion accuracy.
Hello,
I need a free running ADC in my project and so am using FastAnalogIn. On relatively stable voltages though, I am getting large variances in successive readings.
I am measuring the noise at the ADC pin at <100mV (3.3V full scale), however the ADC readings vary by nearly 1V.
I am working to reduce the noise, however analog noise alone cannot account for this.
Thanks in advance
1 Answer
10 years, 5 months ago.
FastAnalogIn for the KL25 (relevant part, I assume you are using this one), is the same as regular AnalogIn, minus that averaging is disabled. Besides that there is nothing special in the settings. 1V is an enormous amount of noise. Normally I would ask if you maybe have switching digital signals next to your ADC inputs, but that should not be such a result. So are you sure it is within 100mV? Can you try regular AnalogIn? What are you driving the ADC with?
Sorry yes, the KL25Z. I have tried two separate inputs to the ADC pin.
1. The output of an LVDT, which I have scaled/buffered through an opamp (NTE987). Probably not the best opamp for the job but it is what I had handy.
2. I connected my bench adjustable power supply directly across the ADC pin to GND pin.
The noise measurement is with a Tektronix oscilloscope (TDS224) and I've learned to trust those about as far as any piece of test equipment. The noise level is actually mostly <50mV, but will spike every 75Hz or so. The device is being used as a joystick input to the PC and I am assuming that is the USB polling time.
USB and this are the only signals connected to the board. I have put a 10uF cap on the 5V line and it is holding at <25-30mV noise.
Actually taking a length of wire and grounding the ADC pin does give stable readings.
Thanks for the very quick reply!
posted by 31 May 2015Can you try with just a potmeter, or two resistors? Problem with grounding is that if it has a negative offset/noise, it won't show up since it can't be smaller than zero. If you can put it somewhere halfway you don't have that. Although your bench power supply should do the same of course. Just shorter wires with resistors.
Otherwise I'll make a look at it later probably, but don't know how much later that is going to be before I get around to it :). You can also have a look at the source code, or try AnalogIn. Averaging will help, but if there is a problem with the hardware in combination with your circuit I can do little about it :).
posted by 31 May 2015Tomorrow I will have access to the hardware again and will try it with a pot. I'm still learning mbed but will have a go and swapping FastAnalogIn for AnalogIn. You wouldn't happen to know if there was a sample and print to windows program done up already would you? I am currently getting the results through a joystick message and this only "seeing" them visually in the windows joypad calibration tool.
posted by 31 May 2015Easiest is to install a serial terminal program (TeraTerm popular around here, but also Putty of CoolTerm are options), and send the actual values via the programming USB port use printf.
posted by 01 Jun 2015For completeness I wanted to report that I made a "Hello World" program that sample the first 10000 values and hen dumped them out the USB port, as well as a standard "read and dump" one sample at a time program. Whatever the noise issues was it is not the FastAnalogIn library nor the board. FastAnalogIn was noisier that AnalogIn, but at a much lower level that I was seeing in my previous code. I have not tracked down the issue, but it doesn't appear to be related to FastAnanlogIn. Thanks for the help.
posted by 09 Jun 2015