Virtual current sensor setup in betaflight for brushed Quadcopters

Disclosure: This post may contain affiliate links, meaning I get a commission if you decide to make a purchase through my links, at no cost to you.

By | September 11, 2016

Why?

All my quadcopters so far have onboard telemetry for voltage and current. Even my smallest build, a brushless 120-sized quad (my loved LKTR 120), has a current sensor. It’s so convenient to be able to see how much you drained the battery. When i started to build my TinyWhoop i was missing this feature. I did not find a current sensor light enough (the AUW with battery is <25g). I came across a post about the virtual current sensor feature of betaflight. In principle you measure the maximum current in a static test setup and the flight controller will estimate (or better guess) the current based on the stick inputs. That’s far from accurate but it should give you a rough number. WARNING: when you do this to bigger quadcopters make sure to fixate them well, we will give full throttle to the motors! I only recommend this to do on small, brushed copters.

Measurements

Before starting with the configuration we will have to do some measurements. A lab power supply and a multimeter are convenient. If you do not have a lab supply you can work around this issue by soldering an adapter that allows you to measure the current drawn from the lipo battery.

First of all we will make sure that the voltage readings of the flight controller are accurate. Start the betaflight configurator and connect the lab supply or the battery. Measure the voltage with a multimeter and compare it to the voltage given by the betaflight gui. Mine was slightly off, i changed the voltage scale parameter on the configuration tab from 110 to 115. That solved the issue, my battery voltage now reads perfectly.

Next, we will have to measure the idle current $I_{min}$. My small quadcopter draws $I_{min}=0.36A$ when idle. Write down this number, we will need it later. We will now measure the maximum current draw. Fixate the copter to a stable structure and keep the propellers mounted. Open the motor tab and enable the motor output. Set the master slider to the maximum, your quad will now give full throttle. Write down the current $I_{max}$ and shut down the motors. My small 6mm based brushed copter draws a maximum $I_{max}=3.14A$.

Calculations

In order to calculate the proper settings for your setup we will need another value, it is the so called max_throttle variable. Open up the CLI and enter get max_throttle. For a typical brushed setup you should get a value of 2000. Now calculate $T_{max} = max\_throttle – 1000$.

Now use the following formula to calculate the current_meter_scale variable:

current_meter_scale $ = {{(I_{max} – I_{min}) *100000}\over{T_{max}+ {{T_{max}*T_{max}}\over{50}}}}$

The current_meter_offset calulates as:

current_meter_offset $ = I_{min} * 100 $

Entering the measured values of my brushed TinyWhoop F3 setup this gives

current_meter_scale $ = {{(3.14A - 0.36A) *100000}\over{1000+ {{1000*1000}\over{50}}}} = 13.23...$

and

current_meter_offset $ = 0.36 * 100 = 36$

With the calculations finished get back to the betaflight configurator. Enter the current meter scale and offset into the appropriate input boxes on the configuration tab and save. Optionally you can also enter the following commands into the CLI:

set current_meter_offset=36
set current_meter_scale=13
save #save and reboot

Now take a test flight, fly for approximately the half of flight time you expect from your batteries. Write down the mAh the flight controller reports back to you. Now recharge your batteries and write down the mAh that were charged into the battery as well. You will notice that both values differ. On my TinyWhoop they differed a lot… Now we will try to compensate for that. This can be done by calculating:

current_meter_scale $ = current\_meter\_scale_{old} * {{consumption_{measured}}\over{consumption_{charger}} $

On my TinyWhoop the flight controller reported 90mAh while the charger did put 130mAh back into the battery. The formula above gave me a new current_meter_scale value of 18. I had to iterate the process two times and my tuning ended with a current_meter_scale of 24. For normal flights this gives me a nice approximation of the current my flight used.

Leave a Reply

Your email address will not be published. Required fields are marked *