Curious about Current sensing

Hey! I find the Odive to be a very impressive piece of hardware and its coding is vastly complex!
I’m very curios as to how the current sensing works on a lower level. I am aware that the Odrive uses two low side current sense shunt resistors that are fed to an amplifier on the DRV chip. why just two and not three? also on the low level coding, how did you manage measuring and calculating current flowing through it? I do know a little about current measuring with shunts but I just so many questions and wish to understand the board and the only real part I cant understand is the current sensing.

so, ill keep this starting post brief with a couple questions to help me understand.

how are you able to measure current on just the low side?

are you syncing the sampling of the adc with the PWM output so that you only measure when the low side mosfets are on?

are you using a proportional control loop for the current control?

Are you are measuring bi directional?

even just a brief overview on how the current control works would be amazing!
I’ve never really been able to wrap my head fully around current control works fully and have always failed to implement it in practice.

This is a limitation of the DRV8301, we plan to use a different DRV chip on ODrive v4 that supports 3 shunts.

Yep exactly.

The phase currents are sampled, then transformed into the “rotor reference frame”, then it’s a PI control loop to generate the voltages in the rotor frame, then transformed back, and then we PWM the phases. Key terms to look up to learn more is FOC (field oriented control), “Park and Clarke” transforms, and SVM (Space Vector Modulation).

Yes the amplifier can amplify a bidirectional range, it’s mapped onto an output centered on VREF/2. Have a look at the DRV8301 datasheet.