cancel
Showing results for 
Search instead for 
Did you mean: 

ADC measurement issue

SohamC
Associate III

Hello all,

Currently I have been working on a project which involves reading values using ADC. This is the following connection:

 

SohamC_0-1770726822035.png

AD8495 is used as an ambient temperature sensor. The connections given in the image are taken from the datasheet for adr8495. I have connected the output to channel A0 of my ADC on board with STM32F407ZGT6. The configuration of ADC is as follows.

 
static void MX_ADC1_Init(void)
{
 ADC_ChannelConfTypeDef sConfig = {0};

 hadc1.Instance = ADC1;
 hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
 hadc1.Init.Resolution = ADC_RESOLUTION_12B;
 hadc1.Init.ScanConvMode = ENABLE;
 hadc1.Init.ContinuousConvMode = DISABLE;
 hadc1.Init.DiscontinuousConvMode = ENABLE;
 hadc1.Init.NbrOfDiscConversion = 3;
 hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
 hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
 hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
 hadc1.Init.NbrOfConversion = 3;
 hadc1.Init.DMAContinuousRequests = DISABLE;
 hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
 if (HAL_ADC_Init(&hadc1) != HAL_OK)
 {
  Error_Handler();
 }

 sConfig.Channel = ADC_CHANNEL_VREFINT;
 sConfig.Rank = 1;
 sConfig.SamplingTime = ADC_SAMPLETIME_480CYCLES;
 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
 {
  Error_Handler();
 }

 sConfig.Channel = ADC_CHANNEL_0;
 sConfig.Rank = 2;
 sConfig.SamplingTime = ADC_SAMPLETIME_84CYCLES;
 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
 {
  Error_Handler();
 }

 sConfig.Channel = ADC_CHANNEL_1;
 sConfig.Rank = 3;
 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
 {
  Error_Handler();
 }
}

The issue I am facing is as follows: Whenever I power the board using STLINK using 5v provision on it, and the adr8495 is powered as well, the ADC works properly showing the reading with respect to the ambient Temperature of the room.

But whenever I power the circuit using a Linear Power supply 5V, the ADC measurements change and are drastically reduced. I have checked all the common issues like grounding , any short connections,

but I have not been able to find an issue. One thing that might help is whenever I power the board using STLINK-V2 the 3.3Pin on the board is stable around 3.25V , and whenever Linear power supply is used the Pin is stable around 3.35V

I also came up with the idea of using VREFINT as for measuring the Vref that the board is actually getting powered by, and use that value for the engineering conversions i.e Converting raw ADC values to millivolts.

Can anyone provide any suggestion? Do ask if you have any query related to connections or the firmware.


Edited to apply proper source code formatting - please see How to insert source code for future reference.

25 REPLIES 25

> Interfacing adc with external circuitry is not easy task.

I can only second that.
Which is why I use to keep my external input stages simple, and test them separately.

> I'd  recommend buffer adc inputs by low voltage R2R outputs op-amp, powered by analog domain 3.3V, and buffer may have resistors at its own inputs.

Occasionally I supply the opamps with 5V since the types at hand don't nearly reach rail levels. In this case I add a 3.1V zener diode to protect the ADC input.

> CMOS/ JFET high input impedance op-amp keep good precision even with high value of resistors, ...

Although in my limited experience, they are more prone to oscillations.


But to circle back to the OP's issue :
I would (again) recommend to validate the ADC itself with a precise low-impedance voltage source, which could be a battery in the simples case (checked with a good multimeter).
If the ADC measurements for this setup are good, the problem must be the thermocouple + amplifier stage.
The basic method of elimination.


@Ozone wrote:

> Interfacing adc with external circuitry is not easy task.

I can only second that.
Which is why I use to keep my external input stages simple, and test them separately.

> I'd  recommend buffer adc inputs by low voltage R2R outputs op-amp, powered by analog domain 3.3V, and buffer may have resistors at its own inputs.

Occasionally I supply the opamps with 5V since the types at hand don't nearly reach rail levels. In this case I add a 3.1V zener diode to protect the ADC input.

Both advices are naive and counterproductive.

Using zenners as a clamp does not really  protect anything, since internal dynamic impedance of zenners at 3.3V well above 50 Ohms, do your math to get overvoltage level with 100 mA injected current. Secondly, zenners start to conduct below specified voltage and consequently introduced huge amount of non-linearity into measured data/ results.

Testing a driver separately from the load (adc in this case)  is also ill-advised. SAR ADC is quite specific load, that practically not possible to simulate or replace by linear RC alternative. For high precision, opa driver selection is could be done only based on hardware tests, since data sheets for opa provide load specification / charts for Resistive loads only

 

> Both advices are naive and counterproductive.

This was and is not an advice.

> Using zenners as a clamp ...

It's written "Zener".

Have an alzheimer? 

Read your personal inbox ones more:

 

MasterT to Ozone
‎22-09-25 10:27 AM
 
*** off

Never comment my post, *** ***

 

I'm not here to pander to fragile egos.

I did test it , using a linear power supply. I set it to ground and then to 3.3V ; both of which gave the readings 0 and 4095 respectively. So the issue I guess must be with either the Vref going high(thus ADC counts decreases) or because of missing components.
But this was done on a breadboard , thus noise of millivolts is expected and will alter the readings. I have decided to go with fixed 3300 value while converting raw ADC counts and handle the rest in firmware and calibration. 
The reading do dip a little but the linearity is preserved.