FRDM Board Analog Calibration

17 May 2013

Hi,

I'm new to ARM, but have spent lots of time with PIC and Arduino/ATmega. Working with the FRDM board, and it's pretty sweet. Been having issues with the analog reading part. First attempt was filled with noise. Seems the Analog block needs to be calibrated on startup/reset. Calibration process provides gain settings, but offset is handled in software. my signal should idle and fluctuate around V/2, but my 10bit ADC is returning idle values around 800! I'm trying to load a value into the PG register, but it doesn't seem to stick. Still abit new to C/C++. Can someone see what I'm doing wrong?

I put the analog portion of mbed official freescale core into a .h file. Here's the code https://mbed.org/users/biomurph/code/AnalogIn_frdm/

17 May 2013

While it probably will get a bit more accurate with filling those registers, it really shouldn't make much of a difference on what you read, and definately not what you describe.

When you say it returns idle values around 800, which code did you use? The read function returns a float between 0 and 1, and the read_u16 should return a left alligned result: so if you then get 800 it really isn't anywhere near halfway. So if I were you I would first check that your code is correct, and that that pin actually has the voltage you expect it to have.

17 May 2013

I'm using Pulse Sensor www.pulsesensor.com when there is no change in the sensor, the voltage output is at V/2, which should be 512 using a 10 bit ADC. the ADC result is right justified in my settings. i get an ADC range between 0 and 1023.

17 May 2013

AnalogIn is left justified though. Well unless the settings you changed, changed that too.

Your printf format specifier is invalid. What happens if you just use AnalogIn, no aditional calibration, and then preferably use %f in your printf statement and use the read command. That should just give back the AnalogIn value as a fraction of the supply voltage. Or if you want to use read_u16, use just %d as format specifier.

The tl;dr is that it should work fine without the calibration. And since it is just a heartbeat sensor it won't matter if you got an offset of a few LSB.