ADC configuration for DC measurements

7 posts / 0 new
Last post
icujba
Offline
Last seen:4年5个月前
Joined:2015-05-13 08:04
ADC configuration for DC measurements

Would like to know the recommend ADC configuration for correct and stable DC measurements with SDK 3.0.8.0

Based on the information available in "UM-B-004 DA14580_581 Peripheral Drivers_v1.4.pdf" and "DA14580_DS_v3.1.pdf" my configuration currently looks like this:

adc_calibrate()
adc_init(GP_ADC_SE | GP_ADC_CHOP, ADC_POLARITY_UNSIGNED, 0 /* no GP_ADC_ATTN3X*/ )
adc_enable_channel(ADC_CHANNEL_P00)
adc_get_sample()
adc_disable()

Looking at adc_get_vbat_sample() it seams that :
1. GP_ADC_CHOP usage is not preferred, although highly recommended in "DA14580_DS_v3.1.pdf", and instead two samples with opposite GP_ADC_SIGN are used
2. a 20 microseconds delay is used right after adc_init() which maps with the timing characteristics described in "Table 293" from "DA14580_DS_v3.1.pdf" (Note: same 20 microseconds delay is being used after adc_int() in adc_calibrate()).

1. ADC_INIT()之后需要20微秒延迟?
2.考虑到ADC_INT()设置GP_ADC_DELAY2_REG是否通过GP_ADC_DELAY_REG和GP_ADC_DELAY2_REG控制必要的延迟。
3. Is there more information available about the inner workings of the ADC related registers ?

Device:
RvA
Offline
Last seen:3 weeks 1 day ago
Staff
Joined:2014-02-07 14:10
Hi Icujba, In case you do not

Hi Icujba, In case you do not use attenuation no delay is required. With attenuation (required in case you intend to measure voltages > 1.2V) you should add some delay to allow the internal caps to be charged. This should be more in the range of 4us. There is more information regarding the inner workings of the ADC this is however not available pubicly. Do you have some specific questions?

最好的问候,RVA

icujba
Offline
Last seen:4年5个月前
Joined:2015-05-13 08:04
嗨RVA,

嗨RVA,
谢谢你的回复。我将使用建议ed delay for the "with attenuation" scenario.
Best regards, Ionut

Jarkko S
Offline
Last seen:5 years 10 months ago
Joined:2015-06-25 13:04
Hi,

Hi,

I have really simple code and I do not get consistent results from the ADC (at least lowest 4 bits shall discarded, so the effective resolution is 6 bits, you had make that also in battery.c) and looks like that ADC has also quite huge offset-error and the calibration does not help. The offset error is the main problem especially at lower voltages...

My test setup is really simple: external_power--->100k ohm resistor ---> Input pin (configured as PID_ADC). Code uses your examples as is so the adc functions has not been modified (except at last stage is added CHOP bit)

uint16 u16ADC = 0U;
UINT16 i = 1000u;
uint16 u16Min = 0xFFFFU;
uint16 u16Max = 0U;
dbg_print(“\ n \ radc att 1x,calib在meas之前,1000x单次meas \ n \ r”);
adc_enable_channel(ADC_CHANNEL_VDD_REF);
adc_calibrate();
adc_init(GP_ADC_SE, 0, 0); // single ended mode, 1V18
adc_enable_channel(ADC_MEAS_TEMP);
while(i--)
{
u16ADC = adc_get_sample();
if( u16ADC < u16Min ){u16Min = u16ADC;}
if( u16ADC > u16Max ){u16Max = u16ADC;}
}
adc_disable();
DBG_PRINT( "ADC min: 0x%x, max: 0x%x, diff %u\r\n", u16Min, u16Max, u16Max-u16Min );

With 50mV the recorded maximum value is correct, rest are too low:
ADC att 1x, calib before meas, 1000x single meas
ADC min: 0xf, max: 0x3b, diff 44

我还尝试平均10个样本,但结果仍然〜50mV误差〜17%,140mV有〜5,5%误差和550mV 1,7%的误差,最小误差(〜1,25%)达到〜700mV水平达到在这个错误后看起来保持稳定......

提高电压没有帮助,min / max样本之间的差异保持相同(并且再次最高的样本是正确的)
ADC att 1x, calib before meas, 1000x single meas
ADC min: 0x150, max: 0x17a, diff 42

ADC calibration registers values varies between that range after calibration...
offp:0x204-0x208
OFFN: 0x1f8-0x1FA

数据表中未描述ADC功能,所以我想获得所有材料。还有一些寄存器位(GP_ADC_CHOP,GP_ADC_IDYN ......)可以做某事,但根据您的参考设计(电池非常稳定的DC-SOURCE?)不使用...

Enabling the GP_ADC_CHOP in adc_init() then the results are better in terms of min/max difference but now max is not so close the actual value...
ADC att 1x, calib before meas, 1000x single meas
ADC min: 0x158, max: 0x176, diff 30

I'll guess that GP_ADC_CHOP shall be definitely used. Can GP_ADC_I20U & GP_ADC_IDYN be enabled simultaneously what is the difference between constant vs dynamic ?

Jarkko S
Offline
Last seen:5 years 10 months ago
Joined:2015-06-25 13:04
抱歉说这件事

抱歉说这件事maximum value is correct, I looked the diff at 50mV the 44dec as ad conversion result is 50mV assuming 1,18V ref. So there are no ways to determine the "correct" value in sw...

Jarkko S
Offline
Last seen:5 years 10 months ago
Joined:2015-06-25 13:04
I'll guess that I figured out

我猜我想出了一些问题的部分(Min&Max之间的差异很大),外部电源存在噪音。我向测量结束添加了Capasitor,解决了那个。仍然看起来如何抵消错误,这是一个功能吗?错误看起来是〜5%-2%在下端最高...

mV print is converted using following formula AVG*1180/1023 and ADC values are now decimals
72mV (measured) gives (CHOP_ON): ADC min: 65, max: 67, diff 2, AVG: 66 mV: 76
366mV (measured) gives (CHOP_ON): ADC min: 314, max: 316, diff 2, AVG: 314 mV: 362
692mV (measured) gives (CHOP_ON): ADC min: 588, max: 590, diff 2, AVG: 588 mV: 678
835mV (measured) gives (CHOP_ON):ADC min: 706, max: 709, diff 3, AVG: 707 mV: 815
1066mV (measured) gives (CHOP_ON):ADC min: 903, max: 906, diff 3, AVG: 905 mV: 1043

kurbylee
Offline
Last seen:3年6个月前
Joined:2014-11-05 09:10
I need to sample at max speed

I need to sample at max speed(about 50KHz),for example I get 1000 sample continuesly,I cann't use capasitor ,So,the offset of smaple to me is huge.
anyone can tell me how to solve it??