Powermeter

From MultiWii
Revision as of 11:18, 21 September 2012 by Hamburger (Talk | contribs) (powermeter hardware sensor config.h: sensor types)

Jump to: navigation, search

Powermeter

A powermeter provides two types of information;

* the current measured in mA consumed at each moment from the battery, 
* the accumulated energy drawn over time, measured in mAh

This can tell you a number of things, foremost if the C-rating of the battery is suitable for the current draw of that particular copter and two, how much energy (mAh) has been drawn since powerup - by simple subtraction one may derive how much energy is left (if it was fully charged to begin with).

Powermeter with hardware sensor

For measurement a simple device called current sensor is used. For the powermeter in MWii, a sensor is requred which measures the current from the battery and maps it to an analog voltage in the range of 0 up to 5V which is consecutively read by MWii. First experiments were successfully made with these sensors http://amploc.com/store/index.html but most other current sensors should work as well.

How To

* get the sensor and the datasheet of your sensor.
* get the battery voltage reading to MWii right first. Yes, even though strictly speaking it is not needed when using a current sensor, do it. Get the battery voltage reading to MWii right first
* attach the sensor output to analog pin 2 (promini). Be prepared to install low path filter set to about 25 Hz to sensor input. That is a low pass RC filter. It is needed if the value seen by MWii is too jumpy.
* check your average cycle time or for better accuracy use the new feature to fixate the cycle time to a given value.
* setup the config.h section next

powermeter hardware sensor config.h

As example amploc 25A sensor has 37mV/A (from datasheet), promini arduino analog resolution is 4.9mV per unit; units from [0..1023], cycle time 4000us, sampling rate is cycle_time * PSENSORFREQ , so 4000*6=24000 micro seconds

* #define POWERMETER_HARD
* #define PINT2mA 13 // used for telemtry display: one integer step on arduino analog translates to mA (example 4.9 / 37 * 100
* #define PLEVELDIV 1133 //  compute : 1133 = 37 / 4.9  * 10e6 / 24000  * 3600 / 1000
* #define PSENSORNULL 510 // to start with - what the arduino analog input sees for zero current; depends on sensor. Find the output voltage for zero current in the datasheet, then convert it to arduino value [0Volt ; 5Volt] -> [0 ; 1023]

fine tune

* configure, compile, upload, 
* run with sensor not hooked to battery, so it sees 0A current.
* If possible, run this with mwc not powered via usb but via battery, else the usb power may influence the Vss of the arduino and lead to false readings. 
* use GUI or telemetry to view either power (mAh) or current(A). Current and power should be and stay at 0. If not, you must change PSENSORNULL and repeat the fine tuning. If you are a wizard you can modify MWii code to display that value for you...
* attach sensor to the battery powerline, so it can measure the current drawn from the battery
* done! Enjoy true readings of actual current and energy consumed.

next steps

You may want to setup a warning level for energy (mAh). This can be done via GUI or the lcd.config.menu. If you have a wireless connection you may want to setup telemetry for further information during flight.