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.
6 years, 5 months ago.
why are the my lpc1768 not reading the same voltage on analog in as i do with my meter?
I am feeding a a voltage on an analog input with a 220k pot and printing the voltage to a display. I am measuring right on the input with my multimeter. this is some examples:
multimer: 0.000V mbed: 0.000V
multimer: 1.014V mbed: 0.917V
multimer: 2.007V mbed: 1.818V
multimer: 3.300V mbed: 2.987V
Almost 100mV difference at worst!
this is the code im running:
while(true) { vbat = ain.read(); lcd.locate(0,1); lcd.printf("vbat: %3.3f%V\n", vbat*3,3); wait(0.2); }
Any one have any clue as to what is going on here?
Could look at input impedance. Something in the 100k range is very high. Usually the micro will have a max recommended input impedance, maybe 2k. The AD pin pulls a little current when it samples which can cause the voltage to sag if input impedance is too high. This could be too fast to register on the meter. You can put an opamp between the resistor and the AD input. Or you can try adding more caps to the AD input pin to source the current and preserve voltage when the AD samples. Or lower your resistor values.
posted by Graham S. 24 Mar 2018The solution: changed 3,3 to 3.3. Compiler ignored the decimal and scaled to wrong value :)
posted by Morten Herreborg 04 Apr 2018