{"id":410,"date":"2016-04-16T21:56:23","date_gmt":"2016-04-16T21:56:23","guid":{"rendered":"http:\/\/jaisor.net\/?p=410"},"modified":"2016-04-16T21:56:23","modified_gmt":"2016-04-16T21:56:23","slug":"cleanflight-betaflight-virtual-current-sensor-tutorial","status":"publish","type":"post","link":"https:\/\/jaisor.net\/index.php\/2016\/04\/16\/cleanflight-betaflight-virtual-current-sensor-tutorial\/","title":{"rendered":"Cleanflight \/ Betaflight Virtual Current Sensor Tutorial"},"content":{"rendered":"<p>I always considered current sensor, amps and mAh measurements out-of-reach concepts, left for specialized \/ proprietary hardware\u00a0for big-brand builds like the Vortex, DJI etc.\u00a0I knew\u00a0Cleanflight Configurator supports the concept and browsing through the docs few weeks back, I\u00a0stumbled on the <a href=\"https:\/\/github.com\/cleanflight\/cleanflight\/blob\/master\/docs\/Battery.md#virtual-sensor\">Virtual Current Sensor description<\/a>\u00a0It looked simple enough so I tried it, seems to work pretty well, so I decided to share my quick setup.<\/p>\n<p><span style=\"color: #ff0000;\"><strong>DISCLAIMER: Standing\u00a0near 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\u00a0are not at risk of snagging\/cutting something.<\/strong><\/span><\/p>\n<p>As the docs state, the virtual sensor needs to be calibrated\u00a0with an offset and scale parameters using two\u00a0recommended\u00a0methods:<\/p>\n<ol>\n<li>Actual Current Measurement &#8211; with a power analuzer, current meter, etc<\/li>\n<li>Battery Charger Measurement &#8211; with a charger that show accurately how much mAh were charged.<\/li>\n<\/ol>\n<p>I went for #1 as I recently acquired a power analyzer tool for my <a href=\"\/index.php\/2016\/04\/12\/thrust-tests-rotorgeeks-cobras-2300kv-emax-redbottoms-2600kv\/\" target=\"_blank\" rel=\"noopener noreferrer\">thrust test<\/a> setup.<\/p>\n<h2>Setup<\/h2>\n<p><a href=\"http:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.41.35.jpg\" rel=\"attachment wp-att-412\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-412 size-large\" src=\"http:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.41.35-1024x768.jpg\" alt=\"2016-04-16 12.41.35\" width=\"640\" height=\"480\" srcset=\"https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.41.35-1024x768.jpg 1024w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.41.35-300x225.jpg 300w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.41.35-768x576.jpg 768w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.41.35-1536x1152.jpg 1536w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.41.35-2048x1536.jpg 2048w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.41.35-1200x900.jpg 1200w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.41.35-1980x1485.jpg 1980w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<ul>\n<li><a href=\"http:\/\/amzn.com\/B00ORGDQOK\" target=\"_blank\" rel=\"noopener noreferrer\">Power analyzer<\/a> or any other convenient way to measure the LiPo current when disarmed and at full throttle<\/li>\n<li>High-C charged\u00a0LiPo capable of sustaining full throttle of your quad for a few seconds.<\/li>\n<li>Quad running Cleanflight or Betaflight<\/li>\n<li>OSD &#8211; MinimOSD running MW-WII firmware.\u00a0Oscar Liang has an <a href=\"http:\/\/blog.oscarliang.net\/minimosd-micro-setup-naze32-pid-rssi\/\" target=\"_blank\" rel=\"noopener noreferrer\">excellent tutorial<\/a> for how to configure this OSD<\/li>\n<li>Propellers &#8211; choose the most common of your<\/li>\n<\/ul>\n<h2>Secure\u00a0The Craft\u00a0Down<\/h2>\n<p>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.<\/p>\n<p><a href=\"http:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.39.49.jpg\" rel=\"attachment wp-att-414\"><img decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-414 alignnone\" src=\"http:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.39.49-300x225.jpg\" alt=\"2016-04-16 12.39.49\" width=\"300\" height=\"225\" srcset=\"https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.39.49-300x225.jpg 300w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.39.49-1024x768.jpg 1024w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.39.49-768x576.jpg 768w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.39.49-1536x1152.jpg 1536w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.39.49-2048x1536.jpg 2048w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.39.49-1200x900.jpg 1200w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.39.49-1980x1485.jpg 1980w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a> <a href=\"http:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.41.35.jpg\" rel=\"attachment wp-att-412\"><img decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-412 alignnone\" src=\"http:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.41.35-300x225.jpg\" alt=\"2016-04-16 12.41.35\" width=\"300\" height=\"225\" srcset=\"https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.41.35-300x225.jpg 300w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.41.35-1024x768.jpg 1024w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.41.35-768x576.jpg 768w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.41.35-1536x1152.jpg 1536w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.41.35-2048x1536.jpg 2048w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.41.35-1200x900.jpg 1200w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/2016-04-16-12.41.35-1980x1485.jpg 1980w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<h2>Measure The Current<\/h2>\n<p>The Cleanflight docs\u00a0indicate to measure current at disarm Imin and at full throttle Imax.\u00a0If 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\u00a0the 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.<\/p>\n<p><iframe loading=\"lazy\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/_ouiXO6TpHE?feature=oembed\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<h2>Calculate The Parameters<\/h2>\n<p>In addition to the current measurements, you need your\u00a0max_throttle value &#8211; available in the Configuration tab or via CLI:<\/p>\n<pre>#\u00a0get max_throttle\n max_throttle = 1850<\/pre>\n<p>This value\u00a0substracted by 1000 will give you TMax.\u00a0The formula is available from the Cleanflight docs &#8211;\u00a0<a href=\"https:\/\/github.com\/cleanflight\/cleanflight\/blob\/master\/docs\/Battery.md#tuning-using-actual-current-measurements\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/github.com\/cleanflight\/cleanflight\/blob\/master\/docs\/Battery.md#tuning-using-actual-current-measurements<\/a><\/p>\n<p>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:\u00a0<a href=\"https:\/\/www.dropbox.com\/s\/4b6l1yuyb7xk7kr\/VSensor%20Current%20Table.xlsx?dl=0\">https:\/\/www.dropbox.com\/s\/4b6l1yuyb7xk7kr\/VSensor%20Current%20Table.xlsx?dl=0<\/a><\/p>\n<h2>Configure Flight Controller<\/h2>\n<p>Enable the current sensor and enter the\u00a0calculated offset and\u00a0scale parameters<\/p>\n<p><a href=\"http:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/CleanflgihtConfig-1.png\" rel=\"attachment wp-att-427\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-427\" src=\"http:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/CleanflgihtConfig-1.png\" alt=\"CleanflgihtConfig\" width=\"598\" height=\"224\" srcset=\"https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/CleanflgihtConfig-1.png 598w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/CleanflgihtConfig-1-300x112.png 300w\" sizes=\"(max-width: 598px) 100vw, 598px\" \/><\/a><\/p>\n<p>Alternatively via CLI:<\/p>\n<pre>feature CURRENT_METER\nset current_meter_scale = 350\nset current_meter_offset = 40<\/pre>\n<p>Final step is to set the current meter type to virtual. I did not see a GUI version for this and the\u00a0CLI value differs between Cleanflight and Betaflight as follows:<\/p>\n<pre># Cleanflight:\nset current_meter_type =\u00a02\n# Betaflight:\nset current_meter_type = VIRTUAL\n<\/pre>\n<h2>Configure OSD<\/h2>\n<p>Enable amperage display\u00a0in the\u00a0MW-OSD GUI and select FC as the source.\u00a0When all is working, the OSD will reflect the estimated current and mAh drained from the battery.<\/p>\n<p><a href=\"http:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/Screen-Shot-2016-04-16-at-2.12.41-PM.png\" rel=\"attachment wp-att-420\"><img decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-420 alignnone\" src=\"http:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/Screen-Shot-2016-04-16-at-2.12.41-PM-1024x551.png\" alt=\"Screen Shot 2016-04-16 at 2.12.41 PM\" width=\"640\" height=\"344\" srcset=\"https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/Screen-Shot-2016-04-16-at-2.12.41-PM-1024x551.png 1024w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/Screen-Shot-2016-04-16-at-2.12.41-PM-300x161.png 300w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/Screen-Shot-2016-04-16-at-2.12.41-PM-768x413.png 768w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/Screen-Shot-2016-04-16-at-2.12.41-PM-1200x646.png 1200w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/Screen-Shot-2016-04-16-at-2.12.41-PM.png 1323w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><a href=\"http:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/Screen-Shot-2016-04-16-at-1.08.09-PM.png\" rel=\"attachment wp-att-421\"><img decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-421 alignnone\" src=\"http:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/Screen-Shot-2016-04-16-at-1.08.09-PM-300x213.png\" alt=\"Screen Shot 2016-04-16 at 1.08.09 PM\" width=\"300\" height=\"213\" srcset=\"https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/Screen-Shot-2016-04-16-at-1.08.09-PM-300x213.png 300w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/Screen-Shot-2016-04-16-at-1.08.09-PM-768x546.png 768w, https:\/\/jaisor.net\/wp-content\/uploads\/2016\/04\/Screen-Shot-2016-04-16-at-1.08.09-PM.png 832w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><iframe loading=\"lazy\" width=\"640\" height=\"480\" src=\"https:\/\/www.youtube.com\/embed\/tKPj5FUkNJU?feature=oembed\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<h2>Things to keep in mind<\/h2>\n<ul>\n<li>This method will provide only estimated current measurements.<\/li>\n<li>The calculated parameters are unique to your\u00a0individual build<\/li>\n<li>Changing electronics, motors or even propellers will require re-calibration<\/li>\n<\/ul>\n<p>I recommend measuring with some of your more aggressive propellers, in my case 5045BN, perhaps even tri-blades. This\u00a0way at-least you are over-estimating the current, which I believe is better than under. \u00a0Hope you all found this helpful. Please send feedback and questions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I always considered current sensor, amps and mAh measurements out-of-reach concepts, left for specialized \/ proprietary hardware\u00a0for big-brand builds like the Vortex, DJI etc.\u00a0I knew\u00a0Cleanflight Configurator supports the concept and browsing through the docs few weeks back, I\u00a0stumbled on the&hellip; <a href=\"https:\/\/jaisor.net\/index.php\/2016\/04\/16\/cleanflight-betaflight-virtual-current-sensor-tutorial\/\" class=\"more-link\">Continue Reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":412,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[5,7,9,14,23,24,30,36],"_links":{"self":[{"href":"https:\/\/jaisor.net\/index.php\/wp-json\/wp\/v2\/posts\/410"}],"collection":[{"href":"https:\/\/jaisor.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jaisor.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jaisor.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jaisor.net\/index.php\/wp-json\/wp\/v2\/comments?post=410"}],"version-history":[{"count":0,"href":"https:\/\/jaisor.net\/index.php\/wp-json\/wp\/v2\/posts\/410\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jaisor.net\/index.php\/wp-json\/wp\/v2\/media\/412"}],"wp:attachment":[{"href":"https:\/\/jaisor.net\/index.php\/wp-json\/wp\/v2\/media?parent=410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jaisor.net\/index.php\/wp-json\/wp\/v2\/categories?post=410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jaisor.net\/index.php\/wp-json\/wp\/v2\/tags?post=410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}