Skip to main content
DTort.1
Associate III
December 5, 2021
Solved

Using MC_GetPhaseCurrentAmplitudeMotor1() function, wrong current

  • December 5, 2021
  • 5 replies
  • 1596 views

Hi, I use B-G431B-ESC1 board and Motor SDK 5.Y.3 and am trying to determine the phase current for my application. I am calling the function

I_Phase = MC_GetPhaseCurrentAmplitudeMotor1 ();

but when the motor is running and the current is almost zero, the function returns a large value. About 2600 units. Could it have something to do with the polarization scheme. In the B-G431B-ESC1 board, the polarization voltage is 2.057V, which is more than 1.65V.

I also noticed that 2.057V is 2553 units in a 12-bit ADC, although this may not be necessary and the problem lies elsewhere.

In any case, I don't understand why I get a number around 2600 at almost zero real current.

I have attached a link to a similar question, but there is no answer there.

https://community.st.com/s/question/0D53W0000081i95SAA/calculation-of-the-motor-current-using-the-motor-control-sdk-function-mcgetphasecurrentamplitudemotor1

This topic has been closed for replies.
Best answer by cedric H

Hello @DTort.1​ ,

We found an issue in the implementation of the MC_GetPhaseCurrentAmplitudeMotor1().

We wrongly use the HW cordic module to compute the sqrt of the modulus, but as specified in the data sheet, the result is Ok for input value greater than 0.027 only.

We are preparing a 5.Y.4 version and we will replace the call to the cordic sqrt to a call to the cordic modulus function which is defined between [-1,1].

Thanks for reporting the issue

Cedric

5 replies

cedric H
ST Technical Moderator
December 6, 2021

Hello @DTort.1​ ,

With the release SDK5.Y release, comes the new motor Pilot tool that allows you to log the data coming from the FOC algo without any loss.

If you want to check the current, you can plot the current waveform.

In the motor Pilot you will find a "Graph and Record" frame, if you click on the "Graph" button a high frequency plot window will pop up, and from there you can select to plot Ia and Ib, (you can also record them if you want to do post processing).

As 0 Amp means 2553 units, I am not surprised that "almost zero real current" leads to "around 2600".

Regards

Cedric

DTort.1
DTort.1Author
Associate III
December 8, 2021

It turns out that the "Motor pilot" application returns a completely correct zero current value in s16A units, but the MC_GetPhaseCurrentAmplitudeMotor1(); behaves strangely. I would agree that this is a polarization of 2.057V, but the function should return not a 12-bit ADC value, but a 16-bit value, that is, there is some processing up to the s16A format.

Here's from the description:

/ **

* @brief returns the amplitude of the phase current injected in Motor 1

*

* The returned amplitude (0-to-peak) is expressed in s16A unit. To convert it to amperes, use the following formula:

*

* @f [

* I_ {Amps} = \ frac {I_ {s16A} \ times V_ {dd}} {65536 \ times R_ {shunt} \ times A_ {op}}

* @f]

*

* /

To be honest, I haven’t climbed into the code of this function yet, and I don’t really want to. Perhaps there is another way to get the correct current value inside my application? Any signed number format would have tripled me.

0693W00000Hnv1lQAB.png

cedric H
cedric HBest answer
ST Technical Moderator
December 10, 2021

Hello @DTort.1​ ,

We found an issue in the implementation of the MC_GetPhaseCurrentAmplitudeMotor1().

We wrongly use the HW cordic module to compute the sqrt of the modulus, but as specified in the data sheet, the result is Ok for input value greater than 0.027 only.

We are preparing a 5.Y.4 version and we will replace the call to the cordic sqrt to a call to the cordic modulus function which is defined between [-1,1].

Thanks for reporting the issue

Cedric