Current Sense on DRV8313 + G491RE

Hi, this is a cross/ongoing post within discord. I thought I might post it here for more eyes / expertise.

I am working on trying to get current sense to work properly with a DRV8313 Chip and a G491RE nucleo board. I have a custom driver board modeled off the simplefocMini and b-g431-esc. The driver board has 0.003 Ohm Shunts on the PGND pins of the DRV with similar circuitry to the g431-esc.

So far I have edited and reconfigured some of the b-g431-esc1 to work with the nucleo g491re in platformio (thanks again for the repo Runger). I am able to get readings from Opamp2 and Opamp3 presumably. However I’m not sure how to test the current sense to get stable readings and or check if the gain is set correctly.

Looking for ideas on how I can test this so that I can get Torque control with foc_current. Also any feedback is greatly appreciated. Maybe the b-esc1 circuitry is no needed for low side current sense? My end goal is to create a super cheap board capable of exploiting the full potential of FOC to use on multiple projects.

Thanks :smiley:

This is some of the Output I have when enabling debug. It seems to get through the setup phase, however trips the fault on the chip. I think it’s tripping the builtin current sense on the DRV.

Also I tend to get an error saying that the currents have the same magnitude sometimes.

TIM1-CH1 TIM1-CH2 TIM1-CH3 score: 1
TIM1-CH1 TIM1-CH2 TIM2-CH4 score: 2
TIM1-CH1 TIM2-CH3 TIM1-CH3 score: 2
TIM1-CH1 TIM2-CH3 TIM2-CH4 score: 2
STM32-DRV: best: TIM1-CH1 TIM1-CH2 TIM1-CH3 score: 1
STM32-DRV: Configuring high timer 1
STM32-DRV: Configuring high channel 1
STM32-DRV: Configuring high timer 1
STM32-DRV: Configuring high channel 2
STM32-DRV: Configuring high timer 1
STM32-DRV: Configuring high channel 3
STM32-DRV: Syncronising timers! Timer no. 1
STM32-DRV: Restarting timer 1
STM32-DRV: Stopping timer 1
STM32-DRV: Stopping timer 1
STM32-DRV: Stopping timer 1
STM32-DRV: Syncronising timers! Timer no. 1
STM32-DRV: Restarting timer 1
Current sense init success!
MOT: Monitor enabled!
MOT: Init
MOT: Enable driver.
CS: Switch A-B
CS: Inv A
CS: Switch B-(C)NC
MOT: Align sensor.
MOT: sensor_direction==CCW
MOT: PP check: OK!
MOT: Zero elec. angle: 2.40
MOT: Align current sense.
CS: Switch A-(B)NC
MOT: Success: 2
MOT: Ready.
Motor ready!
Set target position [rad]
Fault: 0 Analog: PhaseA: 0.00 PhaseB: 687.61 PhaseC: -1694.27 Volts: 0.00
Fault: 1 Analog: PhaseA: 0.00 PhaseB: -399.20 PhaseC: -254.99 Volts: 0.00