cancel
Showing results for 
Search instead for 
Did you mean: 

Spike in AD conversions for STM32F407

rschembari
Associate II
Posted on September 20, 2016 at 10:35

Hi, we have a problem in temperature AD acquisitions. The sensors are two Microchip MCP9700T-E/LT and are connected to ADC CH13 (pin &sharp18) end CH3 (pin &sharp26) through only a 22ohm resistance.

The ADC is triggered by a 10Khz pwm timer and is set as:

   

// APB2-> 84MHz

    // L'a/d pu� andare al max a 36MHz (vedi datasheet STM32F40x)

    // quindi il prescaler minimo � /4 (=21MHz)

    ADC_CommonInitTypeDef aci;

    aci.ADC_Mode = ADC_TripleMode_InjecSimult; //Injected simultaneous mode only

    aci.ADC_Prescaler = ADC_Prescaler_Div4;

    aci.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled; //DMA disabilitato

    aci.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;

    ADC_CommonInit(&aci);

    // Config. modalit� conversione

    ADC_InitTypeDef ai;

    ai.ADC_Resolution = ADC_Resolution_12b;

    ai.ADC_ScanConvMode = ENABLE;

    ai.ADC_ContinuousConvMode = DISABLE;

    ai.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;

    ai.ADC_ExternalTrigConv = ADC_ExternalTrigInjecConvEdge_None;

    ai.ADC_DataAlign = ADC_DataAlign_Left;

    ai.ADC_NbrOfConversion = ADC_NO_OF_INJ_CH;

    ADC_Init(ADC1, &ai);

    ADC_Init(ADC2, &ai);

    ADC_Init(ADC3, &ai);

    // abilito gli ADC

    ADC_Cmd(ADC1, ENABLE);

    ADC_Cmd(ADC2, ENABLE);

    ADC_Cmd(ADC3, ENABLE);

    // configurazione canali ADC

    ADC_InjectedSequencerLengthConfig(ADC1, ADC_NO_OF_INJ_CH);

    ADC_InjectedSequencerLengthConfig(ADC2, ADC_NO_OF_INJ_CH);

    ADC_InjectedSequencerLengthConfig(ADC3, ADC_NO_OF_INJ_CH);

The problem are the spikes that appear when starts the conversion (see attached for waveform of the two channel at mcu pin 18 and 26). This spike is exactly in the conversion instant, and then the measures are totally wrong. If we change the ADC trigger frequency, the spike moves in according to the change, but don't change if we change the other ADC sets.

The only change that we have, in amplitude and in duration of the spike, is when we change the channels conversion sequence.

Can you help me?

Thank you

0690X00000603CEQAY.jpg0690X00000602jcQAA.jpg0690X000006035ZQAQ.jpg0690X000006032eQAA.jpg

#adc
8 REPLIES 8
John F.
Senior
Posted on September 20, 2016 at 14:39

Is the

MCP9700T

power supply properly decoupled? The

MCP9700T

output may be perturbed when the ADC input samples it because of capacitative loading. If you want high speed sampling then maybe you need to buffer the

MCP9700T

  with a voltage follower op-amp with sufficient bandwidth and drive capability. If you could accept lower speed sampling try dividing down the clock by 8 to clock the ADC at 10.5MHz. Also maybe try increasing the ''

ADC_TwoSamplingDelay_'' to more than 5 cycles.

rschembari
Associate II
Posted on September 20, 2016 at 17:09

Hi John, the MCP9700T is properly decoupled, and I don't think is an HW problem because with some specific channels conversion sequence in one pin, the spike dissapears and in the other increase. I'm sure that with an follower opamp the problem will be solved, because I haven't spikes in other channels. I would know if there is some known issue for this ADC and if there some workaround SW. I already tested the lower speed sampling and ''ADC_TwoSamplingDelay'' more than 5.

Thanks

John F.
Senior
Posted on September 21, 2016 at 09:08

No doubt you have already read Application note AN2834, ''... ADC accuracy in STM32Fx Series ...'' in particular section 3.4.1 ADC input stage problem. Although the

MCP9700T is not a high impedance source, its dynamic performance when first loaded by the ADC input may be poor.

rschembari
Associate II
Posted on September 26, 2016 at 12:14

Great, I haven't read this Application note, and the problem decribed in section 3.4.1 seems my problem, but the calculation seems incorrect.

The MCP9700T has 20 ohm of Output Impedance, I added 22 ohm, Csh = 16 pF and fADC = 21Mhz and then with the formula in section 3.4.3: Tsample (cycles) > fADC * Rin * Csh * ln(2^(N+1)) I have 0.133 less than a cycle. Maybe I must add also RADC of 1K, and in this case I have 3.16 cycles, but so none can set 3 cyles or less.

Where is the mistake?

Thanks

rschembari
Associate II
Posted on September 26, 2016 at 12:26

I have wrote wrong values, from datasheet CADC = 4 p and RADCmax = 6 kOhms, so none can set less than 5 cycles (4.54 is the result).

John F.
Senior
Posted on September 27, 2016 at 08:43

The issue is not just the ''DC'' output impedance of the MCP9700T but how it responds to transient loads. When the ADC input connects to sample, its internal sampling capacitance may be charged to some value from a previous different channel. The MCP9700T output has to charge / discharge the ADC sampling capacitance and then settle to its correct value. In a device like the MCP9700T which is designed to have a low quiescent current, the output stage may take longer to settle after being disturbed by an external load. That's why I suggested buffering the output with a separate op-amp ... to isolate the MCP9700T output from the ADC. You'd need a fast sampling oscilloscope to see what's actually happening buth the description above is my best guess.

rschembari
Associate II
Posted on September 28, 2016 at 11:28

Yes, I must put an opamp in this signal path, the problem is that I haven't room in the board. I had chosen the temperature active sensor, instead of NTC, for this reason. I will try with 15 sample cycles.

Thank you

John F.
Senior
Posted on September 29, 2016 at 08:34

If you have I2C on your PCB, you could consider the MCP9800 which is the same temperature sensor but with built in ADC and an I2C interface.