cancel
Showing results for 
Search instead for 
Did you mean: 

ADC Value Distortion

pythomancer
Associate II

Hello,

I have been experiencing a problem with the usage of the internal ADC on my STM32L476RG Nucleo64 development board. Unfortunately I have not been able to find similar problems online or in the forums.

I would like to use the highest possible sampling rate (5.33 MSps according to https://wiki.st.com/stm32mcu/wiki/Getting_started_with_ADC). However, this wiki article uses the clock divisor of 64x and sample time of 92.5 cycles.

For testing purposes, I am generating a 1Hz 3.3Vpp sine wave with an Agilent 33250A waveform generator and measuring the signal on the wire to the ADC pin with an oscilloscope. As sample rate increases, the signal is distorted immensely.

pythomancer_0-1707984906191.png

The signal at 64x clock divisor.

pythomancer_1-1707984934444.png

The signal at 8x clock divisor.

pythomancer_2-1707984962233.png

The signal at 1x clock divisor.

It seems odd to me that the ADC is strong enough to overpower a waveform generator.

I am using DMA sampling across five channels (though this signal is only on the first one) and writing into a 500x5 buffer.

 

void OptionReadAllRaw() {
	eprints("Option 0: Read Raw Data From All Sensors\r\n");
	OpMode = ReadAllRaw;
	HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED);
	HAL_ADC_Start_DMA(&hadc1, (uint32_t*) SensorData,
	SENS_BUF_LEN * SENS_BUF_WID);
}
void TickReadAllRaw() {
	if (SensorDataLastProcessed != SensorDataFresh) {
		uint16_t offset = SENS_BUF_LEN / 2 * SensorDataFresh;
		SensorDataLastProcessed = SensorDataFresh;
		char interm[100];
		ClearString(sbuf);
		for (int i = 0; i < SENS_BUF_LEN / 2; i++) {
			sprintf(interm, "%i %i %i %i %i\r\n",
					SensorData[i * SENS_BUF_WID + offset + 0],
					SensorData[i * SENS_BUF_WID + offset + 1],
					SensorData[i * SENS_BUF_WID + offset + 2],
					SensorData[i * SENS_BUF_WID + offset + 3],
					SensorData[i * SENS_BUF_WID + offset + 4]);
			strcat(sbuf, interm);
			eprints(sbuf);
		}
	}
	HAL_Delay(200);
}

 

I am aware that this will not be sending all of the data; my main issue for now is that the data is bad.

The ConvCplt and ConvHalfCplt callbacks only flip a flag.

pythomancer_3-1707985262505.png

pythomancer_7-1707985370755.png

 

pythomancer_4-1707985323993.png

pythomancer_5-1707985334048.png

pythomancer_6-1707985346887.png

Could anyone explain what is happening, and how I can ensure that the ADC readings of values are accurate at the highest possible sample rates?

Please let me know if I can provide any more information on the setup.

Thanks in advance.

 

 

5 REPLIES 5
AScha.3
Chief

Hi,

Whats the output impedance from the generator ?

Because i see no distortion, the signal is just getting small...looks like high impedance there.

-> ADC here is " Capacitive Charge Redistribution ADC " , 

read about : 

https://www.renesas.com/us/en/document/apn/r14an0001-operation-sar-adc-based-charge-redistribution-rev100

The higher the sampling rate, the lower its input impedance ! So you have to drive it with low impedance buffer amp, if you want hi speed sampling.

See ds -> adc...

AScha3_0-1707987578806.png

AScha3_1-1707987636304.png

 

If you feel a post has answered your question, please click "Accept as Solution".

I will look at the impedances, thank you.

Here are some more images:

pythomancer_0-1707987813725.png

pythomancer_1-1707987834080.png

I suspect that the smearing in the big wave and the jumps in the close up are caused by individual samples - this is at 256x clock divisor, so the slowest that DMA continuous read will go.

 

The waveform generator has a (fixed) output impedance of 50 Ohm - is that alright?

 

 

ONadr.1
Senior III

This looks like a problem with the high output impedance of the generator. There may be a problem in the generator or its settings, in the wiring, in the PCB. I would try to load the generator circuit through a resistor, using the unchanged wiring. I would also try measuring with an oscilloscope at different points in the signal path (generator output, PCB connection, MCU pin)

50 ohm is perfect ! (standard for sig.gen. also...)

But when you see the adc switching its 5pF sampling cap to the pin and this giving a visible jump: you have maybe 50K ohm ... 1Mohm impedance at the input pin !

NEVER 51 ohms !

Look again, what you connected and take a DMM to check the resistance of the cabels you use.

 

btw some sig. generators have output switch : hi-impedance / 51 ohm --- look at your setting there.

If you feel a post has answered your question, please click "Accept as Solution".

Thank you both for your answers... I see now it was a brain moment - the waveform generator itself has 50Ohm impedance, but I was using a 1MOhm Probe... 😬

The signal generator was a test, I will update further if I encounter similar problems on sensors...

Thanks again