3 years, 9 months ago.

FRDM-KL25Z AnalogIn accuracy


I want to use a couple of spare pins on a FRDM-KL25z to measure battery voltage (from a nominal 3.7v LiPo) and external charging voltage (nominally 5v). I tried connecting these up to the PTB0 and PTB1 pins with a voltage divider and measuring the signal with AnalogIn. The results though are rather inaccurate, and suggest that I'm doing something wrong (but what? its a very simple circuit), or there is a very large non-linearity in the ADC.

If I connect the analog pin to 0v or 3.3v I get 0 and close to 65535, as expected. If I connect to 3.3v with a voltage divider I get close to 32768, as expected, but I don't get anything close to accurate if I try to measure 3.7v or 5v through the divider. What should be 3.7 comes out as equivalent to 4.2 (way too high, I checked with a meter), and the 5v indicates as around 5.5 (again too high, it is actually about 4.8 according to my multimeter). I've spent a long time googling and I can't find this as a known problem with the FRCM-KL25z. The impedance of the ADC circuitry is quite low, so I experimented with lots of different resistances in the divider, down as low as 100 ohm. In fact the ADC readings were quite stable independent of the voltage divider resistance (up to 10K or more). For my application it isn't a huge problem if it doesn't indicate quite right, if I can determine how to correct it. But does anyone use the analog pins on the FRDM, and has any suggestions?

Be the first to answer this question.