Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- STMicroelectronics Community
- STM32 MCUs
- STM32 MCUs Motor control
- Using MC_GetPhaseCurrentAmplitudeMotor1() function...

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Using MC_GetPhaseCurrentAmplitudeMotor1() function, wrong current

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2021-12-05 03:16 PM

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.

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2021-12-10 10:19 AM

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 5

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2021-12-06 01:56 AM

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2021-12-08 03:42 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2021-12-08 05:25 PM

And one more thing that I do not understand when measuring current is why the measured current is so large, about 15000 units, although the power is just over 100W. My application is designed for 28 Amperes of maximum current and it seemed to me that the number 15000 should correspond exactly to 28A if I indicated it in the engine settings. This number in file drive_parameters.h

`#define IQMAX 15246`

It really depends on the set current of the motor and it will be really true about 15000 for a current of 28 Amperes according to the formula given in the previous message, but I am sure that in reality I do not see this power even close.

Explanation to get a high current at zero speed I am blocking the motor. And I get about 114 watts, which is about 3-4 amperes.

The second moment when the current rises I start to get a Bad CRC Hader error and this knocks down the control through the motor pilot.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2021-12-09 04:56 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2021-12-10 10:19 AM

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

Related Content

- Trying to programmatically get timer details in STM32 MCUs Embedded software
- Issues with One Shunt Current Sensing Using STSPIN32G4 and STDRIVE101 Custom Board in STM32 MCUs Motor control
- Measure Individual Phase Current in STM32 MCUs Motor control
- How to develop code for getting Sine Wave as Analog input and apply it as AO with STM32F407G. in STM32 MCUs products
- Issue with Custom HID Device Using Multiple IN Endpoints on STM32L072CB in STM32 MCUs Embedded software