# Is there a way to read the total current in LowsideCurrentSense?

**URL:** https://community.simplefoc.com/t/is-there-a-way-to-read-the-total-current-in-lowsidecurrentsense/3832
**Category:** developement
**Tags:** stm32
**Created:** [September 6, 2023, 10:28am UTC](https://community.simplefoc.com/t/is-there-a-way-to-read-the-total-current-in-lowsidecurrentsense/3832 "2023-09-06T10:28:11Z")
**Posts on this page:** 11
**Page:** 2

<div class="post-metadata">

### Author: ![Candas1](https://community.simplefoc.com/user_avatar/community.simplefoc.com/candas1/32/5296_2.png) [@Candas1](https://community.simplefoc.com/u/Candas1)
#### Post date: [September 29, 2023, 10:43am UTC](https://community.simplefoc.com/t/is-there-a-way-to-read-the-total-current-in-lowsidecurrentsense/3832/21 "2023-09-29T10:43:56Z")

</div>

So it has nothing to do with the velocity mode. I guess it’s the same with torque mode without load.

I think with no load it’s more difficult to use the current measurements, there is much more noise. Is it better with only 3(Vq\*Iq)/2Vbus ?

Maybe you have a chance to try using the adc calibration as well.  
Adding the following [here](https://github.com/Candas1/Arduino-FOC/blob/d6da949c5d28f475eba10f6556ee65fe55b5ccff/src/current_sense/hardware_specific/stm32/b_g431/b_g431_mcu.cpp#L112):

> // Run adc self-calibration  
> HAL\_ADCEx\_Calibration\_Start(&hadc1,ADC\_SINGLE\_ENDED);  
> HAL\_ADCEx\_Calibration\_Start(&hadc2,ADC\_SINGLE\_ENDED);

---

<div class="post-metadata">

### Author: ![RaphZufferey](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/r/9dc877/32.png) [@RaphZufferey](https://community.simplefoc.com/u/RaphZufferey)
#### Post date: [September 29, 2023, 10:52am UTC](https://community.simplefoc.com/t/is-there-a-way-to-read-the-total-current-in-lowsidecurrentsense/3832/22 "2023-09-29T10:52:12Z")

</div>

Quite a bit better, yes! And obviously it’s the same in stall conditions, since Vd=0 in stall

 ![image](https://community.simplefoc.com/uploads/default/original/2X/2/2ed57e6f49c2ad6c53a372af275d3c0c3eb6fe4f.png)

---

<div class="post-metadata">

### Author: ![Candas1](https://community.simplefoc.com/user_avatar/community.simplefoc.com/candas1/32/5296_2.png) [@Candas1](https://community.simplefoc.com/u/Candas1)
#### Post date: [September 29, 2023, 11:20am UTC](https://community.simplefoc.com/t/is-there-a-way-to-read-the-total-current-in-lowsidecurrentsense/3832/23 "2023-09-29T11:20:51Z")

</div>

I think I have an idea why Vd\*Id makes it worse.  
In this [post](https://community.simplefoc.com/t/highly-scientific-foc-simulation/3901) I was showing that a delay between current measurement and angle measurement wrongly increases the measured Id.

 ![image](https://community.simplefoc.com/uploads/default/original/2X/f/fcc96401c63da03c8a89bf90f21bc72fdab5d3a0.png)  
As the speed increases, Id is more and more off.

From the other side, Ibus doesn’t seem to be impacted, because it’s only using the angle to define the sign of the current, not to derive Id and Iq.

---

<div class="post-metadata">

### Author: ![Candas1](https://community.simplefoc.com/user_avatar/community.simplefoc.com/candas1/32/5296_2.png) [@Candas1](https://community.simplefoc.com/u/Candas1)
#### Post date: [September 29, 2023, 12:26pm UTC](https://community.simplefoc.com/t/is-there-a-way-to-read-the-total-current-in-lowsidecurrentsense/3832/24 "2023-09-29T12:26:34Z")

</div>

Maybe you can try this also `(3XIbus*SQRT(Vq*Vq+Vd*Vd))/(2*Vbus)`

---

<div class="post-metadata">

### Author: ![Candas1](https://community.simplefoc.com/user_avatar/community.simplefoc.com/candas1/32/5296_2.png) [@Candas1](https://community.simplefoc.com/u/Candas1)
#### Post date: [September 30, 2023, 8:38am UTC](https://community.simplefoc.com/t/is-there-a-way-to-read-the-total-current-in-lowsidecurrentsense/3832/25 "2023-09-30T08:38:51Z")

</div>

@RaphZufferey I created a branch with [adc calibration](https://github.com/Candas1/Arduino-FOC/tree/g431_adc_calibration).

I would be curious to know how it impacts your measurements.

---

<div class="post-metadata">

### Author: ![Anthony\_Douglas](https://community.simplefoc.com/user_avatar/community.simplefoc.com/anthony_douglas/32/2300_2.png) [@Anthony\_Douglas](https://community.simplefoc.com/u/Anthony_Douglas)
#### Post date: [September 30, 2023, 2:06pm UTC](https://community.simplefoc.com/t/is-there-a-way-to-read-the-total-current-in-lowsidecurrentsense/3832/26 "2023-09-30T14:06:06Z")

</div>

It’s glued using shoe goo to the actual motor. It trips when the motor gets too hot, it’s not a breaker that trips when too much current flows, it’s a thermal breaker that trips when the temperature gets above 65 degrees C.

With stepper motors, yes, disconnecting a phase from the driver will actually usually fry the driver, but this does not appear to be a problem with these 3 phase motor drivers, probably because the inductance of the coils is much lower.

---

<div class="post-metadata">

### Author: ![David\_Gonzalez](https://community.simplefoc.com/user_avatar/community.simplefoc.com/david_gonzalez/32/665_2.png) [@David\_Gonzalez](https://community.simplefoc.com/u/David_Gonzalez)
#### Post date: [September 30, 2023, 7:06pm UTC](https://community.simplefoc.com/t/is-there-a-way-to-read-the-total-current-in-lowsidecurrentsense/3832/27 "2023-09-30T19:06:38Z")

</div>

It could definitely be a problem for the driver! this is not the recommended technique for this, it should be software cutting power or kill power to the input of the driver, not the outputs of the half-bridges.

---

<div class="post-metadata">

### Author: ![Anthony\_Douglas](https://community.simplefoc.com/user_avatar/community.simplefoc.com/anthony_douglas/32/2300_2.png) [@Anthony\_Douglas](https://community.simplefoc.com/u/Anthony_Douglas)
#### Post date: [September 30, 2023, 7:21pm UTC](https://community.simplefoc.com/t/is-there-a-way-to-read-the-total-current-in-lowsidecurrentsense/3832/28 "2023-09-30T19:21:09Z")

</div>

It does kill the input to the driver. The power to the driver makes a detour, out to the motor and back again.

---

<div class="post-metadata">

### Author: ![RaphZufferey](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/r/9dc877/32.png) [@RaphZufferey](https://community.simplefoc.com/u/RaphZufferey)
#### Post date: [October 2, 2023, 8:07am UTC](https://community.simplefoc.com/t/is-there-a-way-to-read-the-total-current-in-lowsidecurrentsense/3832/29 "2023-10-02T08:07:46Z")

</div>

Thank you very much, I will try that as soon as possible!

---

<div class="post-metadata">

### Author: ![RaphZufferey](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/r/9dc877/32.png) [@RaphZufferey](https://community.simplefoc.com/u/RaphZufferey)
#### Post date: [November 6, 2023, 7:40pm UTC](https://community.simplefoc.com/t/is-there-a-way-to-read-the-total-current-in-lowsidecurrentsense/3832/30 "2023-11-06T19:40:21Z")

</div>

@Candas1, I have tried your branch, thank you very much. I don’t notice any difference in the current measure, regardless of torque/velocity control. What were you hoping to see? I’ll keep digging to see if I can get **total bus current** , which is important for efficiency measures of the whole system in my case.

---

<div class="post-metadata">

### Author: ![Candas1](https://community.simplefoc.com/user_avatar/community.simplefoc.com/candas1/32/5296_2.png) [@Candas1](https://community.simplefoc.com/u/Candas1)
#### Post date: [November 6, 2023, 7:47pm UTC](https://community.simplefoc.com/t/is-there-a-way-to-read-the-total-current-in-lowsidecurrentsense/3832/31 "2023-11-06T19:47:14Z")

</div>

Adc calibration should slighly improve the adc measurement accuracy.  
At least it had no bad impact.

[Previous page](https://community.simplefoc.com/t/is-there-a-way-to-read-the-total-current-in-lowsidecurrentsense/3832.md?page=1)
