# DRV8305 + TMotor Antigravity 4004 300Kv

First of all, I would like to thank you to all the community that put passion and effort into this project!

I use a TI evaluation board with DVR3505 (BOOSTXL-DRV8305EVM) + T-Motor - Antigravity 4004 300Kv motor.

In particular, I started with the open_loop_position example. In the first instance, I forgot to limit the voltage (motor.voltage_limit), and in a blink of an eye, the motor was about to burn (produced a bit of smoke)! Thus suddenly I powered it down.

So, I tried again with:
`motor.voltage_limit = 1`
and it seems to be working fine. However, this looks like a random value for me.

What is not very clear to me is that the motor’s specification comes with Max Continuous Current, A / 180 S. What is it about?

What’s the correct value to set to `motor.voltage_limit` for my specific motor?

The aforementioned motor is powered with 24V.

That’s a good question. It’s also a problem that bothers me all the time! According to your above parameters, 0.452 * maximum current = limit voltage, 9A can only last 180 seconds, the maximum voltage limit is 9 * 0.452 = 4V, the maximum speed is 4 * 300 = 1200 rpm, the actual desired speed is not only that, the power supply voltage is 24V, at least expected to reach 20V * 300kV = 6000 rpm, the current I = 20V / 0.452 = 44a, the maximum motor current 9A can only last 180s, It seems that this is very contradictory, very looking forward to solving this problem???

When caculating, notice that the motor is spining.
So the formular is like this:
Voltage = R * I + BEMF
24V = 0.452ohm * 9A +19.9V
Sounds much more reasonable.

And I guess 1V is a middle variable indicating the ratio of power to drive the motor and there no exact physical meaning relation to the real voltage.

https://docs.simplefoc.com/voltage_torque_control
I = (U - EMF)/R
Where R is the motor resistance and EMF is the generated back EMF voltage. Thi equation doesn’t take in consideration any dynamics but in general it works good enough.
You are right!
It is also explained in the document, but I just want to speed up the motor. I don’t know how to speed up the High KV motor???

Hello guys.

The physical meaning if it is the limiting of the voltage you are setting to the motor. We are always setting the voltage to the motor, that is the only thing we can set. In your equation you hare:

``````I = (voltage_we_set - back_emf )/R
``````

So you can see that the current will be determined by both what we set and what is the back emf generated in certain moment. But we know that the back emf follows the equation:

``````back_empf = K*velocity
``````

So we know that the worst case current will be for highest possible volaltage, when `back_emf=0`, and that current will be

``````current = voltage_we_set/R
``````

So that is why we limit the `voltage_we_set` using the `motor.voltage_limit`

The new version of the library gives you a way to use current limiting in place of volatge using the equation above. It will calculate it for you if you specify the `motor.phase_resistance`.
You can find more about it in docs.

``````motor.voltage_limit = 1; //V
``````

you can say:

``````motor.phase_resitance = 0.452; // Ohm
motor.current_limit = 2; // Amps
``````

The library will then use the equations above (without using the back emf ) to calculate the voltage limits for you.

If you wish to run your motor more efficiently and use it in open loop with higher velocities, you will need to increase the `voltage_limit` with the velocity.

You can implement something like this in your loop:

``````// set 2Amp current
// phase reistance 0.452 Ohm
// K is the back-emf constant of your motor - if you dont know it you  can guess it (start with small values and build up )
motor.voltage_limit = 2*0.452 + K*target_velocity; // 2Amps current
motor.move(target_velocity);
``````

Let me rephrase what you said to check out that I understood correctly

The following equation tells us how much current will be drained by the motor:

``````I = (voltage_we_set - back_emf )/R
``````

However, in a certain condition, the `back_emf` might be very low. This turns out a high current drained by the motor. For example, when the motor is not spinning, the `back_efm~0`.
In this latter case, the aforementioned equation becomes:

``````I = (voltage_we_set)/R
``````

To avoid that high current will be fed into the motor, we introduce:

``````motor.voltage_limit
``````

Is what I said correct?

One more question. you said that I can set the following parameters in order to limit the voltage:

``````motor.phase_resitance = 0.452; // Ohm
motor.current_limit = 2; // Amps
``````

In the datasheet, there is written Max Continuous Current, A / 180 S. @feng said “180 seconds” but I am not quite sure about this answer. In the International System of Unit second is expressed as lower-case “s”, not upper-case “S”
How did @Antun_Skuric calculate `motor.current_limit = 2`?

Thanks again for your further help

Im still a bit confused.

This is true only when setting the `driver.voltage_power_supply` equal to real input voltage, right?
My understanding is what we care is torque, velocity and position and what is really needed for FOC is current of 3 phases but not voltage. And` motor.voltage_limit` is used to prevent the motor from over current. So setting `motor.voltage_limit = driver.voltage_power_supply` provides maximal power.
Besides, I thought using inline current sensors to protect hardware is a better way.

Can @hbozyq expand on the following statement?

This is true only when setting the `driver.voltage_power_supply` equal to real input voltage

In my case I have:

``````driver.voltage_power_supply  = 24
``````

and, from what I understood from @Antun_Skuric, I need to limit the voltage and therefore, indirectly, the current.

SimpleFOC requires `driver.voltage_power_supply` to be set correctly i.e. to your real input voltage - if you set it wrong then your drivers won’t be getting the correct voltage. I think that is all the @hbozyq meant.

I don’t think Antun calculated `motor.current_limit = 2`. He was just suggesting a starting value you might use. Well below your 9A limit which causes damage after 180seconds. When too much power is put through a motor it not only damages the stator windings but the heat can demagnetize the rotor magnets. From the datasheet, it should be perfectly safe to put 9A through your motor momentarily (e.g. to move a robot leg) but continuously running at 9A will degrade or break your motor.

Thanks for the answer but I still have dubs on my original question:

What’s the correct value to set to `motor.voltage_limit` for my specific motor?

In my specific case, if I don’t put any limitation, the motor suddenly becomes hot.
Rather than put a random number, like `motor.voltage_limit = 1`, is there a way to calculate it properly?

If 9A is the parameter that I have to consider, should I set the parameters in this way?

``````motor.phase_resitance = 0.452; // Ohm
motor.current_limit = 9; // Amps
``````

Moreover, I am not quite sure that @hbozyq meant what you just said. Because he also said:

So setting `motor.voltage_limit = driver.voltage_power_supply` provides maximal power.

…which really confuses me. Hopefully, he will answer

Perhaps, I understood what @Antun_Skuric meant.

The motor comes with also some testing data:

For example, according to the above picture, if I want to achieve up to 0.204 Nm of torque, I should limit the current as follows:

``````motor.phase_resitance = 0.452; // Ohm
motor.current_limit = 5.6; // Amps
``````

or

``````motor.voltage_limit = 0.452 * 5.6
``````

In this case, the motor will be warm but not that hot (56 C)

Is this sound reasonable?

Still my understanding:
The real duty cycle `dc_x = Tx*voltage_limit/voltage_power_supply`
When `voltage_limit =1; voltage_power_supply=12;`,its meaning limit the power to 8.33%.
Setting `voltage_limit =2; voltage_power_supply=24;` is the same.

Whats more, Im learning FOC algorithm now and have no idea where these caculation derive from.
Any reference?

Hey guys,

Let me try to explain the limiting bit more in detail.

Our BLDC motor is a electric motor which has only one type of input the voltage `V`. In the particular base of the BLDC, we have three phase voltages `Va`,`Vb` and `Vc` which create the voltage vector `V`. This vector is calculated as as vector sum of the three phase voltages and its calculation is based on park and clarke transformations in most cases. In general voltage vector `V` will rotate in its coordinate system with the same velocity as the physical rotation velocity of the motor and will be aligned with the physical rotor angle the whole time in order to produce the torque. But once when you have calculated your `V` you can imagine it as a DC motor voltage. And the behavior of the BLDC voltage in the voltage torque mode will be exactly the behavior of the voltage controlled DC motor.

The maximal dc voltage we can set to the motor phases is the power supply voltage `driver.voltage_power_supply` and additionally we can limit this value in the driver `driver.voltage_limit` . The `driver` class will make sure then that it never surpasses the `driver.voltage_limit` value on its outputs , for any phase `Va`,`Vb` or `Vc`. Driver does not know anything about our voltage vector `V`, it only knows the voltages it has to set on its phase outputs. Here is how it looks, this is an image from the docs.

In the BLDC motor class, during the FOC calculation, we can limit the voltage vector magnitude `V` using the variable `motor.voltage_limit`. This limit is a bit different to the one in the driver because this one limits the dc voltage we set to the motor and the driver one limits the phase voltages, as shown on the figure.

In general since the phase voltages `Va`,`Vb` and `Vc` and sinusoidal the maximum voltage vector magnitude `V` can be `driver.voltage_limit/2`. You can see a bit more docs on this subject in the botom of this docs page.

So the rule of thumb is to use `driver.voltage_limit` if you are really unsure of your motor parameters and use this variable as a safety feature in order to guarantee that not just your voltage vector magnitude `V` but also phase voltages `Va`,`Vb` and `Vc` will not surpass certain value.
But in most cases you will not need to set this variable and the limit will be:

``````driver.voltage_limit=driver.voltage_power_supply
``````

In those cases you will be setting the voltage vector magnitude `V` limit using `motor.voltage_limit`.

Now we have already discussed that what you really want to limit is the current, not the voltage. But if you are not measuring the current there is no way you can limit it in real time. The only way you can limit is is to limit the voltage vector magnitude `V` to the value that you are sure that it will no generate currents higher than the value you wish it to be. The current of the electric motor can be written as:

``````I = (V - Vbemf)/R = (V  - k*vel)/R
``````

where `V` is our vector magnitude, `R` is phase resistance and `Vbemf` is the back emf induced voltage due to the motor rotation. And the back emf can be calculated using the motor emf constant `k` and the current motor velocity `vel`

You can see in the formula that the back emf is proportional to the velocity and you can also see that current will decrease with velocity. This means that your current for a given voltage vector `V` will be maximal if your motor is not moving `vel=0`. And maximal current will be:

``````I = V/R
``````

So a rough rule can for current limiting, to a certain value `I_max`, is to limit the voltage vector `V` to the value:

``````motor.voltage_limit = I_max*R;  // Volts
``````

Finally the library provides you way to use this feature automatically if you specify the phase resistance `R` to the motor class. It will give you the way to use the current vector limit instead of voltage:

``````motor.phase_resistance = R;  // Ohms
motor.current_vector = I_max; // Amps
``````

You can find a lot more about it in the docs.

These equations are the Space vector calculations. You can find a bit more about the in the docs.