广告C in differential mode

18 posts / 0 new
Last post
Rony
Offline
Last seen:4 years 9 months ago
Master
Joined:2014-05-15 15:02
广告C in differential mode

I am trying to understand how the differential mode works.
I am connecting voltage to P0_0 and ground to 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
//广告C Init
adc_init(GP_ADC_SE,0); //single ended
adc_enable_channel(ADC_CHANNEL_P00); //ADC_CHANNEL_P00
temps[0]=adc_get_sample(); //start the sampling

adc_disable();
adc_init(GP_ADC_SE,0); //single ended
adc_enable_channel(ADC_CHANNEL_P01); //ADC_CHANNEL_P01
temps[1]=adc_get_sample(); //start the sampling

adc_disable();
adc_init(0,0); //diff mode
adc_enable_channel (0);//广告C_CHANNEL_P00- ADC_CHANNEL_P01
临时工[2]= adc_get_sample ();/ /开始采样

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

JE_Dialog
Offline
Last seen:2 days 23 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
Thanks

Thanks

RvA
Offline
Last seen:4 days 19 hours ago
Staff
Joined:2014-02-07 14:10
Hi Rony,

Hi 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 to +1.2 V -0.1 V to +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 to +3.6 V -0.1 V to +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?
Best regards,
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.
I can set GP_ADC_SE by using adc_init, but how do set GP_ADC_ATTN3X?

JE_Dialog
Offline
Last seen:2 days 23 hours ago
Staff
Joined:2013-12-05 14:02
Hi Rony, please see the

Hi Rony, please see the following thread whcih details how to set the 3x attenuator .

BR JE_Dialog

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

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

Thanks.
I will check that

RvA
Offline
Last seen:4 days 19 hours ago
Staff
Joined:2014-02-07 14:10
Hi Rony,

Hi Rony,

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

Best regards,

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.
Will start using it next week.
If I have problems you will be the first to know...
Thanks

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

As promised you will be the first to know if there are problems.
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:4 days 19 hours ago
Staff
Joined:2014-02-07 14:10
Hi Rony,

Hi 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.

Best regards, RvA(Dialog)

sprhawk
Offline
Last seen:3 years 6 days ago
Joined:2016-03-03 17:25
I am also encounter the

I am also encounter the 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
OK

OK
This is what we are doing now.
Thanks

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();

Shouldn't adc_sample be 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.
Thanks.

MT_dialog
Offline
Last seen:1 month 2 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:

instead of:

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;

Thanks 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)
Connect P00 and P01 to ground.
Modify the calibration procedure as your advise.
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 ?

Thanks.

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

Hi MT_dialog,

A detail test as follows:

/************************************************************************************/
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;
}

also, we configure the Pin as :
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.
Thanks.

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

Hi z20121202038,

Unfortunatelly there is no documentation or an example how the to operate with the differential ADC, most of the customers are not using the differential but the single ended mode, when zero voltage is applied the output of the ADC should be close to 1FF which is half or the 10 bit range since you are measuring from -1.2V to 1.2V (or multiplied by 3 with the attenuator), the output of the ADC is an unsigned 10bit value. Also try not to use the GP_ADC_SIGN when initializing the module and using the differential mode.

Thanks MT_dialog