0

Cleanflight / Betaflight Virtual Current Sensor Tutorial

I always considered current sensor, amps and mAh measurements out-of-reach concepts, left for specialized / proprietary hardware for big-brand builds like the Vortex, DJI etc. I knew Cleanflight Configurator supports the concept and browsing through the docs few weeks back, I stumbled on the Virtual Current Sensor description It looked simple enough so I tried it, seems to work pretty well, so I decided to share my quick setup.

DISCLAIMER: Standing near an armed multi-rotor running at full throttle is dangerous! Do at your own risk. Check and re-check your straps or other stabilization system and ensure the craft cannot lift, tilt, fall off or cut through the restraints. Make sure the propellers and other moving parts are not at risk of snagging/cutting something.

As the docs state, the virtual sensor needs to be calibrated with an offset and scale parameters using two recommended methods:

  1. Actual Current Measurement – with a power analuzer, current meter, etc
  2. Battery Charger Measurement – with a charger that show accurately how much mAh were charged.

I went for #1 as I recently acquired a power analyzer tool for my thrust test setup.

Setup

2016-04-16 12.41.35

  • Power analyzer or any other convenient way to measure the LiPo current when disarmed and at full throttle
  • High-C charged LiPo capable of sustaining full throttle of your quad for a few seconds.
  • Quad running Cleanflight or Betaflight
  • OSD – MinimOSD running MW-WII firmware. Oscar Liang has an excellent tutorial for how to configure this OSD
  • Propellers – choose the most common of your

Secure The Craft Down

This is the most important step. Ensure your quad will not endanger anybody or cause damage when running at full throttle. I strapped mine down to a heavy saw-horse as shown below and ensured the blades spin free and the LiPo/power analyzer are safely out of the day.

2016-04-16 12.39.49 2016-04-16 12.41.35

Measure The Current

The Cleanflight docs indicate to measure current at disarm Imin and at full throttle Imax. If your VTX requires additional button to power-on, press it. I personally chose to ignore the initial current spike at full throttle, and waited a second or so to settle before taking the value. I am not sure if motor-stop is factored anywhere, as it doubles the Imin value, I guess this is question for the firmware developers.

Calculate The Parameters

In addition to the current measurements, you need your max_throttle value – available in the Configuration tab or via CLI:

# get max_throttle
 max_throttle = 1850

This value substracted by 1000 will give you TMax. The formula is available from the Cleanflight docs – https://github.com/cleanflight/cleanflight/blob/master/docs/Battery.md#tuning-using-actual-current-measurements

Since the formula is a bit long and I have several quads, I created this spreadsheet that gives the final numbers easily. Feel free to download and share: https://www.dropbox.com/s/4b6l1yuyb7xk7kr/VSensor%20Current%20Table.xlsx?dl=0

Configure Flight Controller

Enable the current sensor and enter the calculated offset and scale parameters

CleanflgihtConfig

Alternatively via CLI:

feature CURRENT_METER
set current_meter_scale = 350
set current_meter_offset = 40

Final step is to set the current meter type to virtual. I did not see a GUI version for this and the CLI value differs between Cleanflight and Betaflight as follows:

# Cleanflight:
set current_meter_type = 2
# Betaflight:
set current_meter_type = VIRTUAL

Configure OSD

Enable amperage display in the MW-OSD GUI and select FC as the source. When all is working, the OSD will reflect the estimated current and mAh drained from the battery.

Screen Shot 2016-04-16 at 2.12.41 PMScreen Shot 2016-04-16 at 1.08.09 PM

Things to keep in mind

  • This method will provide only estimated current measurements.
  • The calculated parameters are unique to your individual build
  • Changing electronics, motors or even propellers will require re-calibration

I recommend measuring with some of your more aggressive propellers, in my case 5045BN, perhaps even tri-blades. This way at-least you are over-estimating the current, which I believe is better than under.  Hope you all found this helpful. Please send feedback and questions.

jaisor

Leave a Reply

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