Skip to main content
CHuan.8
Associate
October 13, 2021
Question

How to manually set current reference in mc api MC_SetCurrentReferenceMotor1?

  • October 13, 2021
  • 7 replies
  • 4811 views

Setting the current reference is describes as:

void MC_​SetCurrentReferenceMotor1(Curr_Components Iqdref);

What should I type to replace Curr_Components and Iqdref?

I want to manually set current reference to increase torque when the​ motor is in low rotation speed. Is it possible?

This topic has been closed for replies.

7 replies

Cristiana SCARAMEL
Technical Moderator
October 14, 2021

Hi @CHuan.8​ and welcome to the ST Community.

Since your question is about STM32 MCSDK, I removed the topic Motor Control Hardware and left only "STM32 Motor Control".

"If you feel a post has answered your question, please click ""Accept as Solution"""
CKlei.1
Associate II
November 29, 2021

Any information available on the question above? I'm very interested in a solution for high torque at low rpm as well.

I'd really love to see an ST Employee to answer questions and not only moving customer questions from one forum to the other or just correcting topics....

cedric H
Technical Moderator
December 1, 2021

Hello @CHuan.8​ ,

"I want to manually set current reference to increase torque when the​ motor is in low rotation speed. Is it possible?"

What do you want to achieve ?

The FOC algorithm embeds a PID speed control that should keep the speed constant whatever the break applied to your motor.

This PID speed will increase or decrease the torque if the speed is to slow or to fast compared to the target.

Now, if the speed is under a certain limit, the observer will not be able to reconstruct the angle and will not be able drive your motor.

So basically, yes you can apply a torque manually, but if your target is to keep a speed constant, I would rather check PID speed parameters.

If you have a speed feedback error, because the speed is to slow, then using a sensor (Encoder or Hall sensor) can be helpful.

Regards

Cedric

PKVSK.2
Visitor II
December 26, 2022

Dear @cedric H​ , you still did not explain how to use the function MC_SetCurrentReferenceMotor1 and how to pass the parameter of type qd_t to it. Please do that right away. Let us answer the question and not divert the topic to something else.

Regards

cedric H
Technical Moderator
January 3, 2023

Dear @Community member​ ,

The MC_SetCurrentReferenceMotor1 is documented in the MCSDK 6.1 release as following:

MC_SetCurrentReferenceMotor1()

Programs the current reference to Motor 1 for later or immediate execution.

The current reference to consider is made of the Id and Iq current components.

Invoking the MC_SetCurrentReferenceMotor1() function programs a current reference with the provided parameters. The programmed reference is executed immediately if Motor 1's state machine is in the #START_RUN or RUN states. Otherwise, the command is buffered and will be executed when the state machine reaches any of the aforementioned state.

The Application can check the status of the command with the MC_GetCommandStateMotor1() to know whether the last command was executed immediately or not.

Only one command can be buffered at any given time. If another buffered command is programmed before the current one has completed, the latter replaces the former.

Parameters

Iqdrefcurrent reference in the Direct-Quadratic reference frame. Expressed in the qd_t format.

if you look at the qd_t format, you will see this:

typedef struct

{

 int16_t q;

 int16_t d;

} qd_t;

In order to call this function in your application, you need to:

include the file mc_api.h

declare a variable of type qd_t :

qd_t myqdValue;

set the value you want:

myqdValue.d=0;

myqdValue.q=15000;

as qd_t represents a current, the format is in S16A. S16A is described in Documentation/html/md_docs_measurement_units.html

and call the c function :

MC_SetCurrentReferenceMotor1(myqdValue);

Does this answer match your expectations?

Regards

Cedric

PKVSK.2
Visitor II
January 4, 2023

Hey @cedric H​ . Hope you are in good health. Thank you for your answer. This is what I did but it looks like there is another underlying problem in the motor control middleware that is not allowing me to do so.

I used MC_SetCurrentReferenceMotor1 with the expectation that it will help me align the motor and I was wrong.

I'm using a 24V 15P-P 730RPMmax Motor with B-G431B-ESC1 with hall sensors. I have configured it accordingly both in the Motor Tab and Speed Sensing tab of the MC WB. The pins assigned in the Digital I/O tab are also correct. I am driving the motor with speed control. This motor has been profiled using ST Motor Profiler.

Yet, I'm not able to run the motor. I've observed that MX_MotorControl_Init only initializes the motor and programs speed ramp with the target value assigned in the MC WB. Hence, I called the MC_StartMotor1(); function in order to start the programed ramp. This is not working for me. I'm having a speed feedback error and i do not know what might be causing this. What is the process of starting the motor with hall sensors otherwise?

PS: Although the motor needs big time tuning of the PI values, I'm able to move the motor to desired target speed (RPM) in the sensorless speed control mode. I wish to run the motor with sensored speed control mode since I also need to achieve position control. Need your assistance in controlling it with sensors.

Regards

PKVSK.2
Visitor II
January 4, 2023

I found the following information in the MC Docs.0693W00000Y7MZcQAN.pngMy question is, if I use Hall Sensors as speed sensing, which of the above (torque ramp, speed ramp or current ref) do I set in order to start motor successfully?

cedric H
Technical Moderator
January 4, 2023

Hello @Community member​ ,

Your issue seems coming from the Hall sensors configuration. Hall sensors send to the control algorithm a mechanical angle information. The control algo uses an electrical angle. You must configure the shift between the electrical angle and the mechanical one. One other point, the way you connected the 3 phases, and the 3 Hall sensors are important.

From the SDK 6.1 we introduced a really nice feature in order to help you to achieve the hall sensor configuration.

If you open the Pilot and select the profiler, you will be able now to also profile your hall sensors. The tool will guide you through all the different steps to determine your all sensors configuration.

Please give it a try and provide feedback about your profiling results.

Cedric

PKVSK.2
Visitor II
January 4, 2023

Hey @cedric H​ ,

I have profiled previously mentioned motor using both MC prof 6.0 and 6.1.

6.1 seems to have voltage issues since there is no max voltage parameter that we can input. I either get undervoltage or overvoltage faults. Let me share the pictures:

MC profiler 6.0:

0693W00000Y7ORaQAN.png 

MC profiler 6.1:

0693W00000Y7OSEQA3.png6.1 has voltage calculation issues. The profiling fails every time. Please note that I'm not even giving extra RPM (730RPM) in 6.1, while I have actually provided 1500RPM in 6.0 and it still profiled fine for 730RPM.

Also, I'm not able to profile Hall Sensors.

I have disassembled my motor so I can see the order of Hall Sensors placed in the Motor. I might be going wrong in the "Placement Electrical Angle". I've provided it has 60 degree right now.

ST Employee
January 4, 2023

Hello @Community member​,

I have several ideas to try to make the profiler work:

1: do a test by trying to leave the Max speed field blank and let the profiler find the max speed.

2: do a test leaving also the max current field empty

3: do a test by setting a lower max current (5 or 3)

Finally use the detect pole pairs feature to check that the pole pairs entered are correct.

If no solution works, can I have some more information about your power supply so that I can try to reproduce the problem?

Thanks

PKVSK.2
Visitor II
January 5, 2023

Hello @Zied b.​ ,

I have tested both 6.0 and 6.1 MC profiler and I can clearly see issues with 6.1.

About my review on the new profiler software:

I followed your instructions from previous message, and the motor stops moving after 25% profiling and makes a noise with increasing frequency (similar to the sound achieved when revving electric bike) until a over/under voltage error pops up. All this while the motor does not spin. Hence, I believe the new profiler needs more development.

I was able to profile both my motors (36V and 24V) using 6.0 and the same 24V controller (B-G431B-ESC1) and I achieved 600 RPM and 730 RPM respectively for both motors. (600 RPM only for 36V motor because I'm profiling it with 24V controller and supply).

I want to develop my application using the profiles I have with me at the moment. Can you please help me find the phase shift between my hall sensors (placement electrical angle)?

Please find the image of the hall sensor placement in my motor below:

0693W00000Y7SNIQA3.jpg

ST Employee
January 5, 2023

Hello @Community member​ ,

I did some tests to reproduce the problem you have with a motor that looks like yours.

I have encountered the same problems as you regarding the over and under voltage.

I solved the problem and made the motor run by first setting a low max current, then I increased it little by little until I made the motor run.

I did the same for the max speed I put a high max speed then I lowered little by little until I stabilized the motor.

The easiest way to find the "electrical angle placement" is to get the 6.1 profiler to work, as it has a feature to detect this.