cancel
Showing results for 
Search instead for 
Did you mean: 

B-G431B-ESC1 MotorControl "wrong" current measurement (how to obtain the average current through the windings)

JA.1
Associate III

Hi ST Community

I am using a default MotorControl setup with the B-G431B-ESC1 board and a BLDC motor with hall sensors. The project is generated using MC Workbench with default values.

I am having a hard time to decipher the value provided by the function MC_GetPhaseCurrentAmplitudeMotor1. I am familiar with the conversion from the format S16A to Amps, but still get wrong readings.

The amplifying network gain setup is also default with values matching the resistors on the board. The overall network gain is hence 9.14.

When converting the value to Amps, I get values far from what I can read from the power supply. When setting up the motor (using values inherited from motor profiler) the nominal current is set to 3.29A. With this settings I can almost not run the motor with a "high" load (0.5+ Nm). I need to increase this value to 10A+ in order to archive a torque of ie. 2Nm. which on the power supply is requiring far less than 10A. This test is done with no load on startup but adding load while already on the target RPM (so it is not about startup torque).

The Vout (polarization) is 2.057V, while the description says it should be around 1.65V (right between 0 and 3.3V which is the ref. voltage of the ADC).

The min and max Vout is correct wrt. being above 0V and below 3.3V.

Is all of this due to the Vout (polarization) being off? It says it should be at 1.65V, while it is not, due to the resistor network.

If I am using/understanding the MC_GetPhaseCurrentAmplitudeMotor1 function wrong, then how can I from the MotorControl API obtain the current that the motor consumes?

The overall goal is to calculate the motor torque for a screwing application, since for this I have a torque constant ie. 36.9mNm/A. Hence I need the to get the average current through the windings to calculate the torque.

1 ACCEPTED SOLUTION

Accepted Solutions
JA.1
Associate III

I might have solved the "mystery".

And for the matter of fact I get (almost) the same result with all these 3 methods:

float A = (float)MC_GetPhaseCArrentAmplitudeMotor1() * S16A_TO_FLOAT;
float B = fabs(MC_GetIqdMotor1().q) * S16A_TO_FLOAT;
float C = sqrt((float)MC_GetIqdMotor1().q * (float)MC_GetIqdMotor1().q + (float)MC_GetIqdMotor1().d * (float)MC_GetIqdMotor1().d) * S16A_TO_FLOAT;

The "issue" was that the provided torque constant of 36.9mNm/A (or 0.2214Nm/A after gear), is affected by the max. efficiency of the motor AND the loss due to the gear. The max. efficiency is 85% and gear loss is 9%. Hence the 0.2214Nm/A is actually:

0.2214 * 0.85 * 0.91 = 0.1713Nm/A.

Multiplying this with the output of one of the 3 methods mentioned, provides a result that matches the torque measured with the Datum instrument.

View solution in original post

8 REPLIES 8
JA.1
Associate III

@jouko.perkkio​ @DB.7ERGANTIN​ 

Can you help on this? :)

DBE
ST Employee

​Hello JA.1,

MC_GetPhaseCurrentAmplitudeMotor1 gives you the current amplitude (0 to peak)  on the phases which is aligned to what I can read on my current probe attached to one of the phases.  

According to documentation UM2392 chapter 3.1.2 equation 8 that you can find in MC Workbench\documentation\STM32 motor control SDK5.x - Firmware, the torque is given by  Te=(3/2)*Pole_pairs*Flux*Iq when Ld = Lq. In your case, it seems you have already the torque constant which should correspond to (3/2)*Pole_pairs*Flux. Then you should multiply your constant by your Iq to get the torque. You can get Iq thanks to MC_GetIqdMotor1() routine and convert it to Ampere. 

Best regards 

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.
JA.1
Associate III

Thanks for getting back.

I tried to follow your advice this morning. The approach was as following:

// Start motor
MC_ProgramSpeedRampMotor1(speed, rampTime);
 
// Get current
float motorCurrent = fabs(MC_GetIqdMotor1().q) * S16A_TO_FLOAT;

With no load (other than attached to a torque measurement device) this led to a motor current of approximately 1.25A or 0.277Nm (the motor torque constant is 36.9mNm/A with a 6:1 gear ratio resulting in a torque constant of 0.2214Nm/A).

On the power supply the current consumption is way less at around 0.55A. The torque is measured (using Datum Torque Transducer) to 0.205Nm.

​Also when I use the torque command:

MC_ProgramTorqueRampMotor1((int16_t)(1.5 / S16A_TO_FLOAT), rampTime);

I would expect an average motor current of 1.5A. However this is shown as much less on the power supply.

I somehow suspect that values in the resistor network is the explanation to this?

I need an integrated functions for this. An algorithm that samples the current so I can read out both a short-term value and an averaged value to be able to get a more stable readout of the load, as the current normally fluctuate a lot due to the overall control loop.

JA.1
Associate III

I might have solved the "mystery".

And for the matter of fact I get (almost) the same result with all these 3 methods:

float A = (float)MC_GetPhaseCArrentAmplitudeMotor1() * S16A_TO_FLOAT;
float B = fabs(MC_GetIqdMotor1().q) * S16A_TO_FLOAT;
float C = sqrt((float)MC_GetIqdMotor1().q * (float)MC_GetIqdMotor1().q + (float)MC_GetIqdMotor1().d * (float)MC_GetIqdMotor1().d) * S16A_TO_FLOAT;

The "issue" was that the provided torque constant of 36.9mNm/A (or 0.2214Nm/A after gear), is affected by the max. efficiency of the motor AND the loss due to the gear. The max. efficiency is 85% and gear loss is 9%. Hence the 0.2214Nm/A is actually:

0.2214 * 0.85 * 0.91 = 0.1713Nm/A.

Multiplying this with the output of one of the 3 methods mentioned, provides a result that matches the torque measured with the Datum instrument.

jouko.perkkio
Associate III

I have not done the torque unit conversion at all. But that seems to be covered already..

When you program the torque ramp, you request the phase current. Not average (nor RMS whatsoever) current. So with your A, B and C, you get the phase current which is fed to the motor. According to my understanding, the phase current is the amount of current which is fed during the FET stage ON time. And a FET is OFF for a long period of time, depending on the rotational speed, which allows for phase voltage to rise.

I don't know your battery, let's assume it is 24V. And current limit is set to 10A. This has theoretical power capability to of 240W. For example at startup or during load, it may be that you "stall" to maximum PHASE current limit, and the phase voltage gets to rise only to around 5V or something. This converts to RMS power of 5V * 10A = 50W. Its PWM controlled current, and the 10A is pulled from the DC link capacitors mostly. So your current meter will show current draw of I = P/U = 50W / 24V = 2.1A. This RMS current feeds the DC link capacitors.

Would that sound logical to your case?

What comes to the DC offset value "Vout (polarization)" which you mentioned, it does not contribute to the current reading. It is of good practice to have the "no current" voltage level at VCC/2 = 1.65V because it will support maximum ranges of current measurement to "both directions". At motor startup, there is always a "calibration phase", which measures the "zero current" DC level. This level is used to zero the offset from current measurement. It's kind a must-have, because otherwise you would always end up in nasty offset current reading because of non-perfect component values, temperature and aging variations. So an offset value of 2.057V will yield you same current readings as 1.65V at zero current. The previous one just will "clamp to 3.3V" earlier due to less headroom.

jouko.perkkio
Associate III

Oh, by the way. I suggest that you measure the phase voltages too. Or I mean, use the API functions to request the phase voltage. You probably get amazed that the readings are pretty low compared to battery voltage... It will give you some viewpoint between RMS current draw from the battery and what flows in to the motor.

Then, the current setting in the MC Workbench is a hard limit for the PHASE current. So if your motor does not allow the phase voltage to rise close to battery voltage at normal usage, you probably want to increase the current limit.

But remember, the programmed current limit is the actual amount of current flowing to the MOTOR. Not the RMS current from the battery. So if you increase the phase current (to get bigger torque), make sure that the motor and wiring can withstand the current.

During my exploration, too thin motor wires melted down with 100A phase current. And this in turn burned one of by power stage boards. Now the wires are 10AWG which can take the hit :)

Thanks a lot for the explanation.

It makes perfectly sense, and your example resembles findings I've made.

I must find the balance between having a higher limit for phase current and not melting down the motor wires. :D

You're welcome!

And to be precise, the insulation of the motor wires was the thing that melted away.. Copper did not melt, but due to the resistance of too thin a wire, the copper just got hot enough to melt the insulation. And this resulted in a short-circuit between phase wires. Which in turn burned by power stage because I had bypassed some over-current interlocks :relieved_face:

My new motor cables have now fairly heavy-duty insulation which does not seem to melt even with a solder gun..

Have fun! I definitely have had lots of fun with this :beaming_face_with_smiling_eyes: