cancel
Showing results for 
Search instead for 
Did you mean: 

ADC gives clumped values that result in a poor waveform.

ZZimm.1
Associate II
hadc4.Instance = ADC4;
  hadc4.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV4;
  hadc4.Init.Resolution = ADC_RESOLUTION_12B;
  hadc4.Init.DataAlign = ADC_DATAALIGN_RIGHT;
  hadc4.Init.GainCompensation = 0;
  hadc4.Init.ScanConvMode = ADC_SCAN_DISABLE;
  hadc4.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
  hadc4.Init.LowPowerAutoWait = DISABLE;
  hadc4.Init.ContinuousConvMode = ENABLE;
  hadc4.Init.NbrOfConversion = 1;
  hadc4.Init.DiscontinuousConvMode = DISABLE;
  hadc4.Init.ExternalTrigConv = ADC_SOFTWARE_START;
  hadc4.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
  hadc4.Init.DMAContinuousRequests = ENABLE;
  hadc4.Init.Overrun = ADC_OVR_DATA_PRESERVED;
  hadc4.Init.OversamplingMode = ENABLE;
  hadc4.Init.Oversampling.Ratio = ADC_OVERSAMPLING_RATIO_2;
  hadc4.Init.Oversampling.RightBitShift = ADC_RIGHTBITSHIFT_NONE;
  hadc4.Init.Oversampling.TriggeredMode = ADC_TRIGGEREDMODE_SINGLE_TRIGGER;
  hadc4.Init.Oversampling.OversamplingStopReset = 
  ADC_REGOVERSAMPLING_CONTINUED_MODE;

Here is how I configured my ADC for continuous conversion using DMA. The issue of "clumpy" data is present in debugger mode in my adc buffer.

The ADC is started with the HAL call:

HAL_ADC_Start_DMA(&hadc4, (uint32_t*)adc_buf, ADC_BUF_LEN);

where adc_buf is a uint16_t buffer of length ADC_BUF_LEN (4096).

Regardless of the method to get the values out, I'm using adc_buf as a ping-pong buffer, the values in the buffer are clumped. Here's an image of my ADC reading a 20Hz signal that has 5Vpp amplitude and is offset by 2.5V. The Vref- is 0V and Vref+ is 5V.

0693W00000QNuygQAD.pngI would love any help that regards a way to make the data points more spread out and continuous looking. Each point in the shown graph is 6-10 individual data points.

Also interestingly the ADC values are not being maxed even though I am at the Vref+ value at the top of the wave.

7 REPLIES 7
MasterT
Lead

You can damage IC applying Vref > Vdd. Read data sheet attentively.

0693W00000QNvDHQA1.png

Ah, I see. What would be a checklist of yours to determine if an IC has been damaged?

Check temperature, if it's not high. Than check input current at Vref (with Vdd=3.3V) - it it's not in excess. May be test overall current consumption by IC in overall. And certainly, run full check-up on adc, INL, DNL, noise etc. If have replacement part - compare with it, better than comparing with ambiguous datasheet spec.

And depends on Vref=5V you mistakenly apply , if it's able to supply < 30-50 mA than less worry, likely REF was powering all chip through ESD schottky diodes, if REF able to provide more than 200 mA - than I 'd throw abused IC to garbage can w/o any tests.

You could use a 40hz timer to trigger the ADC conversions.

The board seems all good with testing. It turns out the hardware I'm using has a voltage divider and voltage clamp that turned the 10V I inputted into 2.8V. Also, Vref is 3.3V and not 5V as I thought. Your responses made me delve deeper into the schematic, so thank you.

I like your line of thinking but my goal is to eventually capture complex signals that vary in frequency. Therefore, this would likely work for my asked problem but will not hold for the larger issue I'm facing. I'm under the impression that I set something up incorrectly because an ADC with the clock speed I'm using (168MHz) should be able to read a simple 20Hz sine wave continuously and smoothly, especially with DMA setup.

Good. Anyway, distortions seen on picture indicate "overdrive" ADC at ground level.

It could happened if sinewave not properly biased to 1.65V, show your driver circuits.