Current sensing trouble initializing

I have implemented a current sensing circuit on the U and V phases of my circuit controlling a 3phase BLDC motor. Some information on my circuit:

  • TMC6300 motor driver
  • INA240A3PW amplifier
  • 2 phase current sense, third phase is connected to motor normally
  • Motor can only move over a 180 degree radius in my design.

My problem is that when initializing FOC with current sense enabled the initialization often fails. I have added a check that resets the software if the initialization fails as such:

if(motor.initFOC() == 0)
software_Reboot();

in the output I can also see that the value given from initFOC monitoring changes. The options are

  • 0 - fail
  • 1 - success and nothing changed
  • 2 - success but pins reconfigured
  • 3 - success but gains inverted
  • 4 - success but pins reconfigured and gains inverted

but I have seen every result at this point without changing any hardware or software, most common are 3 and 4.

I was wondering if there have been issue recorded like this before and what steps I can take to fix this to be able to use current sensing properly. Also if more information is needed regarding my application, I’d be happy to supply more.

1 Like

Hi @DamianvH ,

Is it possible the motor is hitting its end positions during the calibration? Because that would definitely mess it up…

What value of shunt resistor? A3 is 100V/V which should be quite a lot of gain, but maybe the signal is still a bit poor? The TMC6300 already has very low current capacity (only 1A), maybe your signal is too small or noisy for the ADC.

Are you using the amplifier in inline or low side configuration?

Also if you are using such a small driver, I can imagine you are using a gimbal, do you really need current sensing? (just curious what the motivation is). With slow rotation (limited angle of motion) you will pretty much always have negligible BEMF so the phase voltage should basically always be proportional to phase current, I think.

It can hit the end positions if powered from a non-centered position, but this does not happen normally, no.

The resistors are 10mOhms in-line, my circuit is the same as the one listed in The inline current sensing but I had not seen this post before designing my PCB, could the inverted shunt resister be causing my issue?

If so, how can this problem be fixed? Is this fixable with software or is a hardware change required?

The exact motor I’m using is the GB2208, the reason I’m trying current sense is an attempt to try to optimize the performance of the motor. I’ve recently swapped from an STM32 to a homebrewed set-up using the IMXRT1062 chip from a Teensy 4.1 for the same reason. Performance does seem slightly better with this set-up for controlling the adjustable friction, but maybe with current-sense I can get slightly more out of the motor.

Normally no… it just inverts the output, which is corrected in software.

Hi @DamianvH,
Can you paste your code, so that we have a better idea about the parameters the exact parameters you’ve chosen?

The good thing about current sensing is if you know that the shunts are inverted you can always skip the calibration. The calibration is not needed for FOC. The only reason it is there is to make the library a bit more robust for the users that are a bit less experienced. So if they did not put the right pin order or good shunt polarity, the library finds it itself.
You could do something like this:

current_sense.gain_b *=-1; // if b in inverted
current_sense.skip_align = true;

This way the calibration will be skipped and the library will not try to align the motor and the current sense. Just make sure that the current sense pin 1/a corresponds to the phase 1/a of the motor, pin 2/b to the phase 2/b and so on. Also make sure that you invert the right pin. If you current sense in inverted on the phase 1/a do this:

current_sense.gain_a *=-1; // if a in inverted

and if its the second one:

current_sense.gain_b *=-1; // if b in inverted

Include both if they are both inverted.

Adding these flags in accordance with my PCB design have resolved the issues I’ve had with the initialization of the current_sense, thanks for the input!

1 Like