Skip to main content
Associate
August 20, 2026
Question

ADC Offset

  • August 20, 2026
  • 1 reply
  • 45 views

Hello,

i ‘m using the library with FOC mode using a custom board with a STM32G474RE microcontroller, Hall sensor and 3 shunts for the phase current measurements. The maximum phase current will be about 28A. The shunts resistors are 1mohm. The voltage value is amplified by a INA with gain 20 and the voltage offset for zero current is 1.65V. Since the microcontroller VREF+ is very unstable and ADCs sometimes go crazy i decided to switch to the internal reference voltage set to 2.5V with successful results. The problem is that the motor control library uses a indecent constant, defined in the file mc_config.c without a define, set to 32767 as the offset for currente measurements. But 1.65/2.5*65536 is not equal to 32767. The workbench does not allow to set any offset. By changing manually that value it works! But changing values manually in a huge, chaotic and disorganized code is risky and error-prone. Is there any way to change these values safely?

 

Leonardo

1 reply

GMA
ST Technical Moderator
August 20, 2026

Hello ​@Leo4,

32767 is a default value.
PhasexOffset are computed at OFFSET_CALIB state.

If you agree with the answer, please accept it by clicking on 'Best answer'.Best regards.GMA