cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4, OPAMP calibration

vincenthamp9
Associate III
Posted on November 07, 2015 at 16:53

Hello

Has anyone gotten the OPAMP calibration with STM32L4 (or similar) controllers working so far? I've initialized OPAMP1 as PGA with just a positive input and simply called the HAL function for calibration. Sadly the results aren't very satisfying. The calibration routine always ends up to drive the output to a negative offset. Pretty much all analog input voltages end up being ''sucked'' to ground and only high input voltages to begin with are passed through... (so e.g. everything till 100mV reads as ''zero'' at the OPAMP output, although the gain is set to 16) So far I had to tweak the trimming registers myself in order to achieve useful results. Did anyone have similar experiences?

/* OPAMP1 GPIO Configuration
* PA0 ------> OPAMP1_VINP
* PA3 ------> OPAMP1_VOUT
*/
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* Peripheral OPAMP_MOTOR init */
hopamp_imotor.Instance = OPAMP_IMOTOR;
hopamp_imotor.Init.PowerSupplyRange = OPAMP_POWERSUPPLY_HIGH;
hopamp_imotor.Init.Mode = OPAMP_PGA_MODE;
hopamp_imotor.Init.NonInvertingInput = OPAMP_NONINVERTINGINPUT_IO0;
hopamp_imotor.Init.InvertingInput = OPAMP_INVERTINGINPUT_CONNECT_NO;
hopamp_imotor.Init.PgaGain = OPAMP_PGA_GAIN_16;
hopamp_imotor.Init.PowerMode = OPAMP_POWERMODE_NORMAL;
hopamp_imotor.Init.UserTrimming = OPAMP_TRIMMING_USER;
if(HAL_OPAMP_Init(&hopamp_imotor) != HAL_OK)
return HAL_ERROR;
/* Run calibration routine */
HAL_OPAMP_SelfCalibrate(&hopamp_imotor);

4 REPLIES 4
K.Oku
ST Employee
Posted on November 16, 2015 at 14:16 Hello, Vinci. It looks like calibration routine has some incompatibility to the PGA mode. As a workaround,you canrun the calibration with standalone mode or follower mode. Then back to PGA mode after the calibration. By doing following modification, your code worked fine.

/* Run calibration routine */

OpampHandle.Init.Mode = OPAMP_STANDALONE_MODE ;
 if(HAL_OPAMP_Init(&OpampHandle) != HAL_OK)
 return HAL_ERROR;

HAL_OPAMP_SelfCalibrate(&hopamp_imotor);
 OpampHandle.Init.Mode = OPAMP_PGA_MODE;
 if(HAL_OPAMP_Init(&OpampHandle) != HAL_OK)
 return HAL_ERROR;
 Regards.

K.Oku
ST Employee
Posted on November 17, 2015 at 09:20

Hello, Vinci.

I did some TYPO in code, I corrected.

Regards.

K.Oku
ST Employee
Posted on November 17, 2015 at 09:32

Hello, Vinci.

Sorry, I had difficulty of this web interface.

I did TYPO in handler name, please use the original one.

&

hopamp_imotor

Regards.

vincenthamp9
Associate III
Posted on November 17, 2015 at 11:00

Haha I guess I'd have figured that one out one my own. 🙂

But thank you very much for the suggestion with changing the opamp mode. I still have to finetune a little myself, but the initial guess from the calibration routine is way better.