Optimal Current Sensing Setup for STM32G4

Hi all,

I have been working on a little board of mine that uses the STM32G4 and I intend on starting out with the SimpleFOC lib. However, after going through the documentation I am still lost on what is the best setup for current sensing that produces the best result for SimpleFOC implementation. The easiest implementation seems to be low-side sensing as that is the most common but it is less accurate than inline.

I saw that the STM32G4 has built-in opamps that can be used; however, if I am using an existing driver with opamps already (eg. DRV8323RS), is it still necessary to use them?

Thank you,
Victor

I’m not terribly well versed in the hardware and software so take my response with a grain of salt. Hopefully someone who knows this stuff pretty well can wiegh in if I got something wrong.

The way I understand it, inline is a bit harder to design a board with as the shunts produce both positive and negative voltage. The benefit come software wise since you don’t need to worry too much about syncronizing your ADC calls with the MOSFETs.
The driver you are looking at has bi-directional op amps so I think that means it can handle inline current sensing.

Meanwhile low side sensing can only detect current when you have the target low side MOSFET active. This makes software a bit harder to make as you need to time your ADC calls with the MOSFET being on. They will also suffer a bit at higher rpm as the time you have to measure becomes smaller and smaller. It’s benefit is that hardware becomes easier as your shunts only produce a positive voltage and simpler circuitry can be employed for current sensing.

Now, the hard code has already been done for low side and the driver you are looking at seems to solve most of the problems with inline current sensing. I think inline would still be a bit better than low-side but I’m not terribly familiar with the code for SimpleFOC.

Probably not. If the DRV8323 has enough gain to boost the shunt voltage to safely measuable levels (3.3v I think. Check your chips datasheet) then you shouldn’t need them.

1 Like

I have made a mistake. (probably one of several lol)

The DRV8323 doesn’t have enough “common mode range” for inline current sensing. Whatever that means.

Thanks for this - I guess I don’t really have a choice but to use low side at this point. Also given that the software is done for low-side it shouldn’t be a concern. Thanks!