cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F3 PGA stability with low voltage signals

JThev
Associate II

Hi,

I am trying to use all the 4 PGAs in the STM32F303 to amplify and measure some low voltage signals (100-200mV with a gain of 8 or 16) coming from a temperature sensor. Doing so on one channel works fine, and I am able to get accurate readings once the system has been calibrated.

However, as soon as I start using a second channel with a second sensor, the value measured on the first channel drops by about 1% with no reason. And it gets even worse if I add a third channel.

I reproduced this on the STM32F3 Discovery board with a very simple voltage divider, so I don't think my external hardware is a problem here.

Has anybody ever experienced this problem? Is there an easy way to fix it?

Thank you in advance for any help.

Julien

Below is how the OPAMP and ADC are initiallised via the HAL library:

/* OPAMP1 init function */
static void MX_OPAMP1_Init(void)
{
 
  hopamp1.Instance = OPAMP1;
  hopamp1.Init.Mode = OPAMP_PGA_MODE;
  hopamp1.Init.NonInvertingInput = OPAMP_NONINVERTINGINPUT_IO0;
  hopamp1.Init.TimerControlledMuxmode = OPAMP_TIMERCONTROLLEDMUXMODE_DISABLE;
  hopamp1.Init.PgaConnect = OPAMP_PGA_CONNECT_INVERTINGINPUT_NO;
  hopamp1.Init.PgaGain = OPAMP_PGA_GAIN_8;
  hopamp1.Init.UserTrimming = OPAMP_TRIMMING_FACTORY;
  if (HAL_OPAMP_Init(&hopamp1) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }
 
}
/* ADC1 init function */
static void MX_ADC1_Init(void)
{
 
  ADC_MultiModeTypeDef multimode;
  ADC_ChannelConfTypeDef sConfig;
 
    /**Common config 
    */
  hadc1.Instance = ADC1;
  hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
  hadc1.Init.Resolution = ADC_RESOLUTION_12B;
  hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
  hadc1.Init.ContinuousConvMode = ENABLE;
  hadc1.Init.DiscontinuousConvMode = DISABLE;
  hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
  hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
  hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
  hadc1.Init.NbrOfConversion = 1;
  hadc1.Init.DMAContinuousRequests = DISABLE;
  hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
  hadc1.Init.LowPowerAutoWait = DISABLE;
  hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;
  if (HAL_ADC_Init(&hadc1) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }
 
    /**Configure the ADC multi-mode 
    */
  multimode.Mode = ADC_MODE_INDEPENDENT;
  if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }
 
    /**Configure Regular Channel 
    */
  sConfig.Channel = ADC_CHANNEL_3;
  sConfig.Rank = ADC_REGULAR_RANK_1;
  sConfig.SingleDiff = ADC_SINGLE_ENDED;
  sConfig.SamplingTime = ADC_SAMPLETIME_601CYCLES_5;
  sConfig.OffsetNumber = ADC_OFFSET_NONE;
  sConfig.Offset = 0;
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }
 
}
/** 
  * Enable DMA controller clock
  */
static void MX_DMA_Init(void) 
{
  /* DMA controller clock enable */
  __HAL_RCC_DMA1_CLK_ENABLE();
  __HAL_RCC_DMA2_CLK_ENABLE();
 
  /* DMA interrupt init */
  /* DMA1_Channel1_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
  /* DMA2_Channel5_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(DMA2_Channel5_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(DMA2_Channel5_IRQn);
 
}

1 ACCEPTED SOLUTION

Accepted Solutions
JThev
Associate II

I asked the question directly to ST and they came back to me with an explanation and a good workaround.

This behaviour is hardware related. The reason is because when the PGA voltage divider is activated, it is creating some current flow in VSSA, which generates an offset in the output of all Op Amps. The offset increases which each PGA being activated.

The workaround is to configure all the Op Amps in Standalone mode and to use external resistor bribges to set the gain. The drawback is that it is using 2 extra microcontroller pins per Op Amop and adds components to the BOM. However, all the tests I have been doing so far showed the solution is working and the accuracy of the measurements is much better.

I hope this will help in the future.

Julien

View solution in original post

1 REPLY 1
JThev
Associate II

I asked the question directly to ST and they came back to me with an explanation and a good workaround.

This behaviour is hardware related. The reason is because when the PGA voltage divider is activated, it is creating some current flow in VSSA, which generates an offset in the output of all Op Amps. The offset increases which each PGA being activated.

The workaround is to configure all the Op Amps in Standalone mode and to use external resistor bribges to set the gain. The drawback is that it is using 2 extra microcontroller pins per Op Amop and adds components to the BOM. However, all the tests I have been doing so far showed the solution is working and the accuracy of the measurements is much better.

I hope this will help in the future.

Julien