18 posts / 0 new
Last post
Rony
Offline
Last seen:4 years 9 months ago
Master
Joined:2014-05-15 15:02
差分模式的ADC

我正试图了解差异模式如何工作。
我将电压连接到P0_0并接地到P0_1。
I sample channel 0 and 1 in single ended and then in differential mode but the results i get make no sense.
This is the code
//ADC Init
adc_init(gp_adc_se,0);//单结束
ADC_ENABLE_CHANNEL(ADC_CHANNEL_P00);//ADC_CHANNEL_P00
temps [0] = adc_get_sample();//开始采样

adc_disable();
adc_init(gp_adc_se,0);//单结束
adc_enable_channel(adc_channel_p01);//ADC_CHANNEL_P01
temps [1] = adc_get_sample();//开始采样

adc_disable();
adc_init(0,0); //diff mode
adc_enable_channel (0);//ADC_CHANNEL_P00- ADC_CHANNEL_P01
temps [2] = adc_get_sample();//开始采样

Shouldn't temps[2] be equeal to temps[0] - temps[1] ?
谢谢

JE_Dialog
Offline
Last seen:4 days 11 hours ago
Staff
Joined:2013-12-05 14:02
Hello Rony, i will have one

Hello Rony, i will have one of the team contact you. Our datasheet is a bit unclear when it comes to the ADC. Someone will be in touch shortly.

BR JE_Dialog

Rony
Offline
Last seen:4 years 9 months ago
Master
Joined:2014-05-15 15:02
谢谢

谢谢

RvA
Offline
Last seen:7小时31分钟前
Staff
Joined:2014-02-07 14:10
嗨rony,

嗨rony,
You are correct in that subtracting the output values from the single ended inputs should give the same result as the differential input. However you have to make sure to first make the conversion from the ADC value to the actual voltages. See the details shown below

GP_ADC_ATTN3X GP_ADC_SE Input channels Input scale Input limits
0 1 P0_0,P0_1,P0_2,P0_3 0 V至+1.2 V -0.1 V至+1.3 V
0 0 [P0_0, P0_1], [P0_2, P0_3] -1.2 V to +1.2 V -1.3 V to +1.3 V
1 1 P0_0,P0_1,P0_2,P0_3 0 V至+3.6 V -0.1 V至+3.45 V
1 0 [P0_0, P0_1], [P0_2, P0_3] -3.6 V to +3.6 V -3.45 V to +3.45 V

If this does not answer your question, can you show some of the values you read back from the ADC in both single ended and differential mode?
此致,
RvA (Dialog)

Rony
Offline
Last seen:4 years 9 months ago
Master
Joined:2014-05-15 15:02
I think I understand.

I think I understand.
我可以使用adc_init设置gp_adc_se,但如何设置gp_adc_attn3x?

JE_Dialog
Offline
Last seen:4 days 11 hours ago
Staff
Joined:2013-12-05 14:02
嗨rony,please see the

嗨rony,请参阅以下螺纹WHCIH详细信息如何设置3X衰减器。

BR JE_Dialog

http://support.dialog-semicondiondionder.com/using-adc-read-voltage-divider-value.

Rony
Offline
Last seen:4 years 9 months ago
Master
Joined:2014-05-15 15:02
谢谢. I will check that

谢谢.
I will check that

RvA
Offline
Last seen:7小时31分钟前
Staff
Joined:2014-02-07 14:10
嗨rony,

嗨rony,

The table I put in the earlier post is a bit garbled. Here is a better picture:

此致,

RvA (Dialog)

Rony
Offline
Last seen:4 years 9 months ago
Master
Joined:2014-05-15 15:02
Yes, I deciphered it.

Yes, I deciphered it.
将于下周开始使用它。
If I have problems you will be the first to know...
谢谢

Rony
Offline
Last seen:4 years 9 months ago
Master
Joined:2014-05-15 15:02
As promised you will be the

正如承诺的那样,您将成为第一个知道是否存在问题的人。
I connected a setup in which I can measure p0 and p1 single ended and p0 differential.
The values I get from the single ended are logical.
What I get from the differential made no sense to me.
I recorded 2 files in which I manually sweep and recorded what I get p0,p1 and p0-p1
In one of them p0 is always higher than p1 and in the second one it is the opposite.
The measurements are not simultaneous but they are one after the other.
How can I send the data to you?

RvA
Offline
Last seen:7小时31分钟前
Staff
Joined:2014-02-07 14:10
嗨rony,

嗨rony,

Closing this topic for the moment as we discussed by mail that the differential ADC measurements need further documentation and we recommend to use single-ended ADC measurements for the moment.

最好的问候,RVA(对话)

Sprhawk.
Offline
Last seen:3 years 1 week ago
Joined:2016-03-03 17:25
我也遇到了

我也遇到了problem with differential mode

Can you give me further documentation of it ?

Rony
Offline
Last seen:4 years 9 months ago
Master
Joined:2014-05-15 15:02
好的

好的
This is what we are doing now.
谢谢

z20121202038
Offline
Last seen:3 years 9 months ago
Joined:2016-03-30 12:51
Hi,

Hi,
About SDK5.0.3:

adc_init(0,GP_ADC_SIGN,0);
adc_usDelay(20);
adc_enable_channel (0);
adc_sample=adc_get_sample();

不应该adc_sample是p0_1- p0_0?
Should the measuring range be [-1.2V, 1.2V] ?

It cannot measuring the correct value base on the above code.

Looking forward to your reply.
谢谢.

MT_dialog
Offline
Last seen:1 month 4 days ago
Staff
Joined:2015-06-08 11:34
Hi z20121202038,

Hi z20121202038,

Depending on the channels that you would like to measure you will have to make the proper adjustments, as the datasheet indicates the GP_ADC_SEL should be 0000 if you would like to measure P00 vs P01, so make sure that the configuration is proper, also configure your pins to ADC functionallity with the GPIO_ConfigurePin. Other than that you can apply the calibration procedure with the below modification since you would like to use differential mode:

代替:

new_adc_off_p = 0x200 - 2 * adc_off_p;
new_adc_off_n = 0x200 - 2 * adc_off_n;

replace the above with this:

new_adc_off_p = 0x200 - adc_off_p;
new_adc_off_n = 0x200 - adc_off_n;

谢谢MT_dialog

z20121202038
Offline
Last seen:3 years 9 months ago
Joined:2016-03-30 12:51
Hi MT_dialog,

Hi MT_dialog,

I am encounter the problem with differential mode
1)
将P00和P01连接到地面。
根据您的建议修改校准程序。
But the output is 0x300 or 0xFF, why not 0?
2)
Is the output is a unsigned integer or signed integer ?
3)
Can you give me further documentation of it ?

谢谢.

z20121202038
Offline
Last seen:3 years 9 months ago
Joined:2016-03-30 12:51
Hi MT_dialog,

Hi MT_dialog,

详细测试如下:

/************************************************************************************/
uint32_t adc_value1 = 0;
uint32_t adc_value2 = 0;
uint32_t adc_value3=0;
uint32_t adc_value4=0;

uint32_t adc_get_vbat_sample(bool sample_vbat1v)
{
uint32_t adc_sample, adc_sample2;
uint32_t att = gp_adc_attn3x;

adc_calibrate();
adc_init(gp_adc_se,gp_adc_sign,att);
adc_usDelay(20);
ADC_ENABLE_CHANNEL(ADC_CHANNEL_P00);
adc_sample = adc_get_sample();
adc_value1 = adc_sample;
adc_usDelay(1);

adc_calibrate();
adc_init(gp_adc_se,gp_adc_sign,att);
adc_usDelay(20);
adc_enable_channel(adc_channel_p01);
adc_sample = adc_get_sample();
adc_value2 = adc_sample;
adc_usDelay(1);

adc_value3 = adc_value2 - adc_value1;

adc_calibrate();
adc_init(0, GP_ADC_SIGN, att);
adc_usDelay(20);
adc_enable_channel(0x0000);
adc_sample = adc_get_sample();
adc_value4 = adc_sample;
adc_usDelay(1);

adc_disable();

return adc_sample;
}

此外,我们将PIN配置为:
GPIO_ConfigurePin( 0,0, INPUT, PID_ADC, false );
GPIO_ConfigurePin( 0,1, INPUT, PID_ADC, false );
/************************************************************************************/

Result:
adc_value1=0;
adc_value2=0x390; // 3.206V
adc_value3=0x390;
adc_value4 = 0x02b;// 0.151V.

Looking forward to your reply.
谢谢.

MT_dialog
Offline
Last seen:1 month 4 days ago
Staff
Joined:2015-06-08 11:34
Hi z20121202038,

Hi z20121202038,

不幸的是没有文件或示例如何使用差异ADC操作,大多数客户不使用差分但单个结束模式,当零电压施加零电压时,ADC的输出应接近1FF或者10位范围,因为您从-1.2V到1.2V测量(或使用衰减器乘以3),ADC的输出是无符号的10位值。还尽量不要在初始化模块并使用差异模式时使用gp_adc_sign。

谢谢MT_dialog