2025-08-20 7:08 AM
Hello,
I am currently working on a project using MC Workbench 6.3.2 and the B-G431B-ESC1 board using the STM32G431 MCU to control a small motor, and I'm really struggling to wrap ny head around the current conversion formula. In various places in the code, it is explicitly stated that the current conversion formula is Current (digit) = [Current(Amp) * 65536 * Rshunt * Aop] / Vdd micro. However there are parts of this formula that confuse me. For one, the 65536 term seem to come from the adc conversion from voltage to digit. However the adc has only 12 bits, so I'm confused as to why this is not 4096 (2^12) instead. The other value that stumps me the amplification gain, Aop. It is stated to be 9.14 in the code parameters. But when i looked into the amplification parameters, i found the following line of code : LL_OPAMP_SetPGAGain(OPAMP1, LL_OPAMP_PGA_GAIN_16_OR_MINUS_15);
Which seems to indicate the gain is 16? I'm not very familiar with the opamps peripherals so it is possible there is some conversion I'm missing, and I'd like to now how the 9.14 number was reached.
Thank you very much in advance for your time