4 posts / 0 new
Last post
Bharath
Offline
Last seen:1 year 5 months ago
加入:2016-04-14 07:03
Wrong ADC values.

Hi,
in our design we are using a 1M/1M voltage divider to read the battery voltage.
Every time we read we are getting a voltage of 2.8V whereas the battery voltage is 4.17V.
We are using the below configuration to read the ADC value.

adc_calibrate();
adc_usDelay(20);

adc_init(GP_ADC_SE, GP_ADC_SIGN, GP_ADC_ATTN3X);
adc_usDelay(20);

adc_enable_channel(ADC_CHANNEL_P01);

adc_sample = adc_get_sample();
adc_usDelay(1);

adc_init(GP_ADC_SE, 0, GP_ADC_ATTN3X );
adc_enable_channel(ADC_CHANNEL_P01);

adc_sample2 = adc_get_sample ();

adc_sample = (adc_sample2 + adc_sample)/2;
adc_disable();

Are we missing something? How should we configure the GPIO?

Device:
MT_dialog
Offline
Last seen:2 months 1 week ago
工作人员
加入:2015-06-08 11:34
Hi Bharath,

Hi Bharath,

You will have to configure your pins in the periph_init() with a PID_ADC functionallity, check if that is causing the problem that you are experiencing. Also by setting the attenuator, the actual input of the ADC is fed through the internal voltage divider and that will make you ADC input impedance much lower than your voltage divider (300K with the attenuator and infinite without) and that can alter the voltage division of the external divider that you have. Try not to use the attenuator (that will make the input impendance of your ADC infinite) and try to use a larger division factor on the external voltage divider.

Thanks MT_dialog

Bharath
Offline
Last seen:1 year 5 months ago
加入:2016-04-14 07:03
Hi MT_dialog,

Hi MT_dialog,
Thanks for your suggestion. We have initialized the pin in periph_init() as PID_ADC.
What values for resistors we can use so that the effect of attenuator can be ignored?

Thank you
Bharath

MT_dialog
Offline
Last seen:2 months 1 week ago
工作人员
加入:2015-06-08 11:34
Hi Bharath,

Hi Bharath,

As mentioned previously, you can try to remove the internal attenuator (so that you have infinite impedance on the ADC, in the adc_init() dont use the GP_ADC_ATTN3X as a last parameter but set it as 0) and place an external divider that will divide the voltage of the battery to the maximum measuring value of the ADC.

Thanks MT_dialog