# High current when motor isn't spinning

**URL:** <https://community.simplefoc.com/t/high-current-when-motor-isnt-spinning/414>\
**Category:** Uncategorized\
**Created:** [January 3, 2021, 1:34pm UTC](https://community.simplefoc.com/t/high-current-when-motor-isnt-spinning/414 "2021-01-03T13:34:52Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![erwin74](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/e/5f9b8f/32.png) [@erwin74](https://community.simplefoc.com/u/erwin74)\
**Post date:** [January 3, 2021, 1:34pm UTC](https://community.simplefoc.com/t/high-current-when-motor-isnt-spinning/414/1 "2021-01-03T13:34:52Z")

</div>

I observed relative high current and therefore relative high temperature on my driver board when the motor was not spinning (Target : 0.00). The reason for that was - so far i investigated - that there was still some pwm signal on the driver. I fixed that temporarily by adding following code to the setPhaseVoltage method:

 ![Capture1](https://community.simplefoc.com/uploads/default/original/1X/0a63ab9c33c087f2b7ad056eddb7890c273ebb96.png)

After that the signal in idle state disappeared and current/heat went down. This is for sure not the solution but maybe a starting point for further investigations. @Antun_Skuric maybe you can have a look at it?

---

<div class="post-metadata">

**Author:** ![Owen\_Williams](https://community.simplefoc.com/user_avatar/community.simplefoc.com/owen_williams/32/105_2.png) [@Owen\_Williams](https://community.simplefoc.com/u/Owen_Williams)\
**Post date:** [January 3, 2021, 4:09pm UTC](https://community.simplefoc.com/t/high-current-when-motor-isnt-spinning/414/2 "2021-01-03T16:09:23Z")

</div>

Are you in openloop mode? High current is totally normal and expected in openloop. The current is holding the rotor in place.

If you want zero current at zero velocity, I’d suggest changing motor.voltage\_limit inside loop(). You can read motor.shaft\_velocity and programmatically decide how much voltage\_limit (and this current) to use.

In closed loop I’m drawing 40mAh when target velocity is zero. If you are getting higher current in closed loop mode then that is a worry.

---

<div class="post-metadata">

**Author:** ![Antun\_Skuric](https://community.simplefoc.com/user_avatar/community.simplefoc.com/antun_skuric/32/21_2.png) [@Antun\_Skuric](https://community.simplefoc.com/u/Antun_Skuric)\
**Post date:** [January 3, 2021, 4:21pm UTC](https://community.simplefoc.com/t/high-current-when-motor-isnt-spinning/414/3 "2021-01-03T16:21:11Z")

</div>

Yeh, this is not a solution but it is a good starting point.

Basically at this point we are centering our output voltage around half of the power supply (duty cycle 0.5) And that is why you see some pwm even when the voltage\_q is in 0.

In theory duty cycle 0.5 on all three phases will result in pwm like this one:

 ![Untitled Diagram (75)](https://community.simplefoc.com/uploads/default/original/1X/2e5a2b200b7704f5d71a5da8d1842cbdac2cb97d.png)

Where all three phases are in the same time on and in the same time off. Which means that the line voltage of the motor will always be 0 in between Ua-Ub, Ub-Uc and Ua-Uc.

But as you said, it is possible that due to the misalignment of the phases or some other issue that I am not familiar with there are some voltages across the phases that induce certain currents. We will try to look into this soon.

---

<div class="post-metadata">

**Author:** ![erwin74](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/e/5f9b8f/32.png) [@erwin74](https://community.simplefoc.com/u/erwin74)\
**Post date:** [January 3, 2021, 9:19pm UTC](https://community.simplefoc.com/t/high-current-when-motor-isnt-spinning/414/4 "2021-01-03T21:19:16Z")

</div>

Thanks for the fast and detailed response!

I use 6pwm in closed loop with voltage control mode (G431-ESC with hall sensors). In rare cases t’s between 30-40mA. In most cases it’s 60-80mA. I also have observed up to 150mA in few cases.

So far i havn’t found out what is the reason for this big range of ‘stand-by’ current. After further observations i’m even not sure if my first assumption with the source code changes are correct. I have to investigate it further.

@Antun_Skuric, thanks for the detailed explanation. In my naive thinking i didn’t expect such a behavior, when the setpoint is zero (voltage\_q = 0) in voltage-control mode. Anyhow, it is a nice feature, like a motor break.

The question now is, how can i ‘disable’ the driver/motor, so that it will not consume energy? I tried already to use the method disable() without success (G431\_ESC board doesn’t have a enable pin for the mosfet driver). I further tried to pause the HardwareTimer, but this created even more troubles (undefined state of output state of U V W pins). Any suggestions for me?  
@Owen_Williams unfortunately I couldn’t follow your suggestion with motor.voltage\_limit and motor.shaft\_velocity. Is there an example i can look into?

---

<div class="post-metadata">

**Author:** ![Antun\_Skuric](https://community.simplefoc.com/user_avatar/community.simplefoc.com/antun_skuric/32/21_2.png) [@Antun\_Skuric](https://community.simplefoc.com/u/Antun_Skuric)\
**Post date:** [January 3, 2021, 9:47pm UTC](https://community.simplefoc.com/t/high-current-when-motor-isnt-spinning/414/5 "2021-01-03T21:47:10Z")

</div>

Hey @erwin74,

We do not support this feature at the moment. But this is something that is important to implement and we should definitely include it in next release.  
I mean to be able to switch the phases off completely.

Could you please (if you have time) create a github issue so that we do not forget and it will make us resolve it quicker. 😃

Which stm chip are you using and which pins are you using?  
Is it just one timer or you are running low-high pairs on different timers.

---

<div class="post-metadata">

**Author:** ![erwin74](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/e/5f9b8f/32.png) [@erwin74](https://community.simplefoc.com/u/erwin74)\
**Post date:** [January 4, 2021, 8:56am UTC](https://community.simplefoc.com/t/high-current-when-motor-isnt-spinning/414/6 "2021-01-04T08:56:38Z")

</div>

github issue added.

I use the stm32G431CB processor with following pins:  
#define PHASE\_UH PA8  
#define PHASE\_VH PA9  
#define PHASE\_WH PA10  
#define PHASE\_VL PA12  
#define PHASE\_UL PC13  
#define PHASE\_WL PB15  
{PA\_8, TIM1, STM\_PIN\_DATA\_EXT(STM\_MODE\_AF\_PP, GPIO\_PULLUP, GPIO\_AF6\_TIM1, 1, 0)}, // TIM1\_CH1  
{PA\_9, TIM1, STM\_PIN\_DATA\_EXT(STM\_MODE\_AF\_PP, GPIO\_PULLUP, GPIO\_AF6\_TIM1, 2, 0)}, // TIM1\_CH2  
{PA\_10, TIM1, STM\_PIN\_DATA\_EXT(STM\_MODE\_AF\_PP, GPIO\_PULLUP, GPIO\_AF6\_TIM1, 3, 0)}, // TIM1\_CH3  
{PA\_12, TIM1, STM\_PIN\_DATA\_EXT(STM\_MODE\_AF\_PP, GPIO\_PULLUP, GPIO\_AF6\_TIM1, 2, 1)}, // TIM1\_CH2N  
{PB\_15, TIM1, STM\_PIN\_DATA\_EXT(STM\_MODE\_AF\_PP, GPIO\_PULLUP, GPIO\_AF4\_TIM1, 3, 1)}, // TIM1\_CH3N  
{PC\_13, TIM1, STM\_PIN\_DATA\_EXT(STM\_MODE\_AF\_PP, GPIO\_PULLUP, GPIO\_AF4\_TIM1, 1, 1)}, // TIM1\_CH1N

→ just one timer, which should be perfectly synchronized?!

---

<div class="post-metadata">

**Author:** ![Antun\_Skuric](https://community.simplefoc.com/user_avatar/community.simplefoc.com/antun_skuric/32/21_2.png) [@Antun\_Skuric](https://community.simplefoc.com/u/Antun_Skuric)\
**Post date:** [January 4, 2021, 9:14am UTC](https://community.simplefoc.com/t/high-current-when-motor-isnt-spinning/414/7 "2021-01-04T09:14:14Z")

</div>

> [@erwin74](#):
>
> github issue added.

Thanks.

> [@erwin74](#):
>
> just one timer, which should be perfectly synchronized?!

Yes, I would say they are synchronized as well. We will have to look into this more carefully.  
Maybe @Owen_Williams could look into it with a scope?  
I will check for nucleo and bluepill.

If you wish to do a quickfix to disable the phases you can look into the funciton `LL_TIM_CC_DisableChannel` and `LL_TIM_CC_EnableChannel`. We call the `LL_TIM_CC_EnableChannel` in driver init:

```auto
LL_TIM_CC_EnableChannel(HT->getHandle()->Instance, LL_TIM_CHANNEL_CH1 | LL_TIM_CHANNEL_CH1N | LL_TIM_CHANNEL_CH2 | LL_TIM_CHANNEL_CH2N | LL_TIM_CHANNEL_CH3 | LL_TIM_CHANNEL_CH3N);

```

This function starts the 6PWM mode.

---

<div class="post-metadata">

**Author:** ![Antun\_Skuric](https://community.simplefoc.com/user_avatar/community.simplefoc.com/antun_skuric/32/21_2.png) [@Antun\_Skuric](https://community.simplefoc.com/u/Antun_Skuric)\
**Post date:** [January 4, 2021, 10:17am UTC](https://community.simplefoc.com/t/high-current-when-motor-isnt-spinning/414/8 "2021-01-04T10:17:43Z")

</div>

I am also wondering if this problem as something to do with the question @Juxo has asked few days ago.  
[https://community.simplefoc.com/t/ringing-at-gpio-and-mosfet/384](https://community.simplefoc.com/t/ringing-at-gpio-and-mosfet/384)

---

<div class="post-metadata">

**Author:** ![Juxo](https://community.simplefoc.com/user_avatar/community.simplefoc.com/juxo/32/61_2.png) [@Juxo](https://community.simplefoc.com/u/Juxo)\
**Post date:** [January 4, 2021, 2:56pm UTC](https://community.simplefoc.com/t/high-current-when-motor-isnt-spinning/414/9 "2021-01-04T14:56:58Z")

</div>

I don’t know if it has anything to do with it either. But my DRV8302 board was destroyed with only 2A current consumption. One of the shunt resistors went up in smoke.  
I’m currently testing my motor with an Infineon development board. There is also a small oscillation of the output voltage here, but that is in the range of + - 1V maximum. And is therefore not critical.

---

<div class="post-metadata">

**Author:** ![Antun\_Skuric](https://community.simplefoc.com/user_avatar/community.simplefoc.com/antun_skuric/32/21_2.png) [@Antun\_Skuric](https://community.simplefoc.com/u/Antun_Skuric)\
**Post date:** [January 4, 2021, 4:02pm UTC](https://community.simplefoc.com/t/high-current-when-motor-isnt-spinning/414/10 "2021-01-04T16:02:17Z")

</div>

3 posts were split to a new topic: [Infineon bldc shields impression](https://community.simplefoc.com/t/infineon-bldc-shields-impression/417)

---

<div class="post-metadata">

**Author:** ![Owen\_Williams](https://community.simplefoc.com/user_avatar/community.simplefoc.com/owen_williams/32/105_2.png) [@Owen\_Williams](https://community.simplefoc.com/u/Owen_Williams)\
**Post date:** [January 4, 2021, 5:24pm UTC](https://community.simplefoc.com/t/high-current-when-motor-isnt-spinning/414/11 "2021-01-04T17:24:38Z")

</div>

@erwin74  
Extremely hacky and untested. I don’t think it is any better than your approach apart from not changing library code.

```auto
 void loop() {

    static float last_voltage_limit = 0;
    if (abs (motor.shaft_velocity_sp) < 0.01) {
        last_voltage_limit = motor.voltage_limit;
        motor.voltage_limit = 0;
    } else if (last_voltage_limit > 0) {
        motor.voltage_limit = last_voltage_limit;
        last_voltage_limit = 0;
    }
}

```

I’ve not noticed variations in current except when I plug/unplug USB whilst also powering board from bench power supply. I should probably stop doing that 😉 !

Do you have any load on your motor? I’d expect variations in current if your motor is opposing a gravity load at zero velocity.

---

<div class="post-metadata">

**Author:** ![erwin74](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/e/5f9b8f/32.png) [@erwin74](https://community.simplefoc.com/u/erwin74)\
**Post date:** [January 6, 2021, 10:30am UTC](https://community.simplefoc.com/t/high-current-when-motor-isnt-spinning/414/12 "2021-01-06T10:30:53Z")

</div>

Last days couldn’t find time for it. Today i implemented your (Antun) approach, and i works as expected - thanks!

I also looked into the signal with scope:  
all signals are fine,

- no ringing observed (just little engaging, but this is normal) like Juxo did on his configuration
- all 3 phases are perfectly synchronized
- dead time is fine 400 ns (fpwm = 25kHz; dead time = 2%)  
Still have 60 mA when supply voltage is around 14 V, even when no load (no motor) is connected. I have no explanation for it. The high side mosfet drivers should only need few mA (25 kHz, Mosfet Ciss = 4,8nF). Anyhow, now i can turn of the driver and that’s just fine for me.

---

<div class="post-metadata">

**Author:** ![erwin74](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/e/5f9b8f/32.png) [@erwin74](https://community.simplefoc.com/u/erwin74)\
**Post date:** [January 6, 2021, 10:56am UTC](https://community.simplefoc.com/t/high-current-when-motor-isnt-spinning/414/13 "2021-01-06T10:56:17Z")

</div>

@Owen_Williams  
I have also found out from where this big variations on input current comes from 🤔

It’s too bad to tell, but also interesting in some way: My driver board is connected to an usb-hub (for programming and debugging) with a separate power supply. On that hub, some more development boards are connected to. The assumption was that all this devices are supplied by the usb-hub. But this isn’t the case 😆. When i turn on the power supply for the ESC board (14V), then this ESC board snaps the power supply for all boards on the usb-hub. Probably because the 5V regulator on the ESC boards has a slightly higher output voltage, than the 5V regulator from the USB hub… and the winner takes it all.

→ Lesson learned: You should know your participants well.
