cancel
Showing results for 
Search instead for 
Did you mean: 

Fluctuations in ADC regular simultaneous mode

rags
Associate II
Posted on June 11, 2014 at 15:08

Hi Everyone,

We are developing a power monitor system. In that we are using ADC Peripheral in Regular Simlutaneous mode. we are taking 256 samples per cycle of 800 Hz. and we are trying to capturing signal from ADC1's channel 0 and ADC2's channel 1 simultanously,  but we are getting too much fluctuation while capturing and we are feeding signals from Function Generator. Waveform is attached with this. Hope you help us as soon as possible.

Thanking you..

#adc-fluctuation-problem #adc-regular-simultaneous-mode #adc-regular-simultaneous-mode #adc-regular-simultaneous-mode #adc-fluctuation-problem #adc-fluctuation-problem
14 REPLIES 14
chen
Associate II
Posted on June 11, 2014 at 15:18

Hi

''Hope you help us as soon as possible.''

Not sure what anyone can do :

You have not said which device you are using.

You have not posted your code.

''we are taking 256 samples per cycle of 800 Hz. and we are trying to capturing signal from ADC1's channel 0 and ADC2's channel 1 simultanously,  but we are getting too much fluctuation while capturing and we are feeding signals from Function Generator''

Have you confirmed that the problem is simultanous mode?

ie Have you captured the values from just one ADC from the Function Generator?

Is single ADC just as 'noisy'

Have you check if the ADC channel is reading noise?

(Some designs have common Vcc and Vref, -Vcc could be very noisy)

rags
Associate II
Posted on June 12, 2014 at 07:25

Hi Sung.chen Chung,

Thanks for reply.

I am using STM32F103RBT6 controller.

We are capturing samples from ADC1 channel 0 and ADC2 channel 1 simultaneously. we are giving sine wave as input from Function generator with 3v amplitude .  

we have checked ADC and there is no noise. We have done the same using Independent mode for 6 channels and its giving exact sine wave with no noise. But problem we are facing is in Simultaneous mode. Code is attached. Reply soon and help me out.

/* Configure ADC1 Channel0 pin as analog input ******************************/

GPIO_InitStructure.GPIO_Pin = (GPIO_Pin_0|GPIO_Pin_1);

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;

GPIO_Init(GPIOA,&GPIO_InitStructure);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);

/* DMA1_Channel1 configuration **************************************/

DMA_DeInit(DMA1_Channel1);

DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)&ADC1->DR;

DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&ADC_ConvertedValues;

DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;

DMA_InitStructure.DMA_BufferSize = 1;

DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;

DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;

DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;

DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;

DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;

DMA_InitStructure.DMA_Priority = DMA_Priority_High;

DMA_Init(DMA1_Channel1, &DMA_InitStructure);

/* DMA1_Channel1 enable */

DMA_Cmd(DMA1_Channel1, ENABLE);

///***************** Timer Configuration***********//

RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE);

TIM2->CNT  = 0x0000;

TIM2->PSC  = 0x0001;

        TIM2->ARR  = 175;

TIM2->DIER = 0X0001;

TIM2->CR1  = 0x0085;

void TIM2_IRQHandler(void)

volatile u16 ADC_1_Value = 0;

volatile u16 ADC_2_Value = 0;

if(TIM_GetFlagStatus(TIM2,TIM_FLAG_Update)==SET)

{

TIM_ClearFlag(TIM2,TIM_FLAG_Update);

*(ADC_Samples_ptr + fi_temp) = ADC_ConvertedValues[0];

fi_temp++;

if(fi_temp > 512)

 {

  fi_temp = 0;

TIM_Cmd(TIM2,DISABLE);

  ADC_Cmd(ADC1, DISABLE);

  ADC_Cmd(ADC2, DISABLE);

    for(fi_temp=0;fi_temp<512;fi_temp++)

{

ADC_2_Value =(ADC_Samples_arr[fi_temp]&0xFFFF0000)>>16;

ADC_1_Value = (ADC_Samples_arr[fi_temp]&0x0000FFFF);

ADC1_Ch0_Samples[fi_temp] = (ADC_1_Value*3.3)/4096;

ADC2_Ch1_Samples[fi_temp] = (ADC_2_Value*3.3)/4096;

}

///************* ADC Configuration************//

RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC2, ENABLE);

   

  /* ADC1 Init ****************************************************************/

  ADC_InitStructure.ADC_Mode = ADC_Mode_RegSimult;

  ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;

  ADC_InitStructure.ADC_ScanConvMode = DISABLE;

  ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;

  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;

  ADC_InitStructure.ADC_NbrOfChannel = 1;

  ADC_Init(ADC1, &ADC_InitStructure);

  ADC_Init(ADC2, &ADC_InitStructure);

  

  /* ADC1 regular channel configuration ******************************/

  ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 1,  ADC_SampleTime_1Cycles5);

  ADC_RegularChannelConfig(ADC2, ADC_Channel_1, 1,  ADC_SampleTime_1Cycles5);

  /* Enable ADC1 DMA */

  ADC_DMACmd(ADC1, ENABLE);

  ADC_DMACmd(ADC2, ENABLE);

  

    /* Enable ADC1 **************************************************************/

  ADC_Cmd(ADC1, ENABLE);

  ADC_Cmd(ADC2, ENABLE);

  

  /* Start ADC1 Software Conversion */

  ADC_SoftwareStartConvCmd(ADC1, ENABLE);

  ADC_SoftwareStartConvCmd(ADC2, ENABLE);

thanks.....

chen
Associate II
Posted on June 12, 2014 at 10:34

Hi

''We are capturing samples from ADC1 channel 0 and ADC2 channel 1 simultaneously. we are giving sine wave as input from Function generator with 3v amplitude .  

we have checked ADC and there is no noise. We have done the same using Independent mode for 6 channels and its giving exact sine wave with no noise. But problem we are facing is in Simultaneous mode.''

Have you connected both ADC1 and 2 to the same signal generator?

Next thing to try,  ADC1 to signal generator and ADC2 to fixed voltage (or 2nd signal generator).

Then swap them over.

I am thinking that the ADCs are successive approximation type. They rely on charging up capacitors and then dumping the charge from one cap to another. I think maybe the signal generator trying to charge 2 sets of ADC sample/hold caps is a problem or that the sample and hold one one ADC is interfering with the other.

frankmeyer9
Associate II
Posted on June 12, 2014 at 12:57

I am thinking that the ADCs are successive approximation type. They rely on charging up capacitors and then dumping the charge from one cap to another. I think maybe the signal generator trying to charge 2 sets of ADC sample/hold caps is a problem or that the sample and hold one one ADC is interfering with the other.

Of course, the signal generator need an appropriate (low) output impedance to drive both ADCs. Separate ADC units (ADC1 and ADC2) are assumed to have separate S&H logic and capacitors.

Might it have to do with the following note from the reference manual (sect. 11.9.2, page 229) ?

Note: Do not convert the same channel on the two ADCs (no overlapping sampling times for the  two ADCs when converting the same channel).

 

I have some trouble to fully digest it's cryptic meaning. I would assume any channel of ADC1 to be totally independant of all channels of ADC2 (aside of GPIO Pin conflicts).

raptorhal2
Lead
Posted on June 12, 2014 at 20:25

fm:

I am sure they are referring to cases where the same pin is connected to the same channel number of 2 or 3 ADCs. For example concurrent conversion of ADC1 channel 1 with ADC2 channel 1 or ADC3 channel 1 is not OK because all are on PA1. Concurrent conversion of ADC1 channel 4 (PA4) with ADC3 channel 4 (PF6) is OK.

Cheers, Hal

rags
Associate II
Posted on June 13, 2014 at 07:03

Hi Everyone,

Thanks for replies.

I tried with different voltages as input but still conflict remains same. i used two signal generators. still i am getting same result. donno what to do. I have given timer delay 5micro seconds to capture each samples. Is there any problem in that?

i am using different channels for different ADC's. ADC1 channel 0- PIN 14[PA0]. and ADC2 Channel 1- PIN 15[PA1]. I have attached some samples of waveform.

Thanks in advance....

________________

Attachments :

Sampled_Waveform.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I00r&d=%2Fa%2F0X0000000bSB%2FAhFqsWJ_LGRv6bV2FWHL3i4DR4008RMAmD0eVXNnYFs&asPdf=false
frankmeyer9
Associate II
Posted on June 13, 2014 at 08:50

I am sure you are right, and this was one of my interpretation of this note.

However, those nebulous statements might be appropriate for religious scriptures, but not for technical reference manuals.

frankmeyer9
Associate II
Posted on June 13, 2014 at 08:59

Have you tried to connect both 'simultaneous' inputs to a fixed voltage (a 1.5V dry cell, for instance, and GND), and checked the waveform for noise ?

Have you tried to operate both ADCs separately (not in simultaneous mode) and compare the noise in both channels with former results ?

I suspect a problem with VDDA stability, either from suboptimal external circuitry, or from internal interferences (possibly with other, digital units).

raptorhal2
Lead
Posted on June 13, 2014 at 16:50

The 1.5 cycles sampling time is very short. Just in case the signal generator's output impedance is not very low, try 15 cycles. Your total conversion will be 30 cycles which should still fit inside your sampling window.

Cheers, Hal