power meter for 1prebis7 - beta testers wanted

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

Hi,

the software is in beta stage - beware - beta testers wanted.
For the moment you need a LCD display to configure and use.
The buzzer alarm code is untested


Please help to finalize this, I do not yet have a working buzzer, so I cannot at the moment test the actual alarm. That should be relatively easy though.

Motivation:
the alarm based on battery voltage is cool, but on new generation of lipos (for me nanotech and probably others) the voltage drop is small and occurs late. The timer on the TX is kinda static and does not take into account flying style nor breaks.
So I wanted to measure true power consumption and get alarm when battery drained of say 80% capacity (only 20% nominal capacity left).
As a side effect I get separate measurements for each motor, so this may help in adjusting COG or detect bad motors.

idea:
instead of measuring and integrating over time the true current with a special hall sensor I do it in the software only.
Two assumptions:Updated: was assuming linear, then square; now code can deal with general curve.
a) the ESCs+motors provide a characteristic mapping from the input signal to the outputted power within the flying range (works for me, ymmv)
b) the time base (main loop time) is quite stable (seems safe with Alex' code)
For power measurement we sum up the signals sent to each motor over time starting at poweron.
Attach buzzer alarm threshold to the sum value.

Interface:
Updated
Note 1 - communication works with both GUI and LCD display configuration.
Note 2 - the alarm functionality is implemented and works.

Features:Updated
  • independent from actual currents - works independently and equal for wide range of batteries and motor combinations; relies on number of motors and flight time.
  • works for all possible copter configs (TRI, Quadx/plus,Y6, etc.)
  • separate power meter for each motor (up to 6 motors)
  • sum of all power meters
  • accessible via LCD configuration interface and GUI
  • user settable alarm threshold stored in eeprom
  • alarm threshold read and write accessible via LCD configuration interface
  • added feature to LCD config: Exit without Save - same as Enter config - yaw right and pitch up
  • display battery voltage via LCD configuration interface and GUI
how to use:
  • get code or patch your code, apply your usual setup (TRI, yaw-direction, etc.), full binaries at google repository.
  • activate power meter functionality / PMETER is defined by default for now
  • load code into arduino
  • choose battery with largest capacity (in mAh) you want to use
  • go fly (or run on test bench) for apporx. half your usual expected flight time
  • attach LCD or GUI (GUI only works if attaching does not reset the arduino as it does with my mac)
  • use LCD config or GUI and read pMeter values for each motor and the pMeter Sum value
    (for my TRI that gives after ~3 minutes in hover a sum of approx 2500 )
  • if sum is > 30000 contact me, need to change internal divisor (currently set to 10000; sorry for inconvenience)
  • continue flight as you normally would (per timer in TX or voltage alarm or ...)
  • use LCD again, read counters per motor and sum
  • set alarm threshold to this value: last entry in config menu, use sum value, divide by 100
  • save and exit
  • give some thought on the meaning of very different readings for front and tail motors - need to adjust COG?
  • fly with new pack
  • test alarm and inform me whether it works for you

I use it with a set of equal nanotech batteries of two different cpacities (1000mAh and 2200mAh).
My number of motors is constant - 3 for a TRI.
Flight times in hover are ~6 min and ~11 min
hover is at ~50% throttle
For the 1000mAh batteries the pMeter sum is ~4200 (needs 930mAh charge after filght) pAlarm threshold is set to 4200/100=42.
To prove the assumption of linear ESC rating: on another 1000mAh battery for a pMeter sum of 2240 the required charge is 510mAh - were the function absolutely linear, it would have required 520mAh charge - good enough for me.

Hope someone finds this useful,
Hamburger
Attachments
MultiWii1_prebis7_powermeter_TRI60_3S.pde.zip
1prebis7-powermeter firmware
(22.31 KiB) Downloaded 265 times
MultiWii1_prebis7_powermeter.patch.zip
patch to firmware 1prebis7
(4.09 KiB) Downloaded 253 times
Last edited by Hamburger on Wed Mar 30, 2011 11:09 pm, edited 1 time in total.

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

Hi,

first update: completely configurable via GUI, no LCD needed.

Now added features:
- monitor battery voltage via LCD configuration
- send voltage, power and power alarm threshold to GUI
- set power alarm threshold from GUI to arduino

So in the GUI you can watch the power meter as the motors drain your battery.
Only drawback is that it is not in mAh.

Next step for me is to rush to local shop and get buzzers and LED drivers real soon.

On a side note:
for my series of 1000mAh batteries I get quite consistent readings.
8040 <=> 930 mAh
4480 <=> 510 mAh.

Here is the latest code firmware and GUI.
Sorry, the file size limit prevents me from uploading GUI binaries. For each target platform it is at least 2.5MB.
So you will need the Processing environment to compile the GUI yourself (or provide some online upload file space).

Cheers, Hamburger
Attachments
MultiWiiConf1_prebis7_powermeter.pde.zip
GUI source (Processing)
(9.09 KiB) Downloaded 260 times
MultiWii1_prebis7_powermeter_TRI60_3S.zip
MultiWii 1prebis7 powermeter source (arduino)
(22.67 KiB) Downloaded 261 times

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

Sorry,

I forgot to mention:
to read the separate powermeters for your motors is still only possible via LCD - I do not want to flood the data transmission between arduino and GUI with too many data. So if you are interested to see how much more load is on your rear motor(s) compared to front, you need an LCD.

Hamburger

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: power meter for 1prebis7 - beta testers wanted

Post by Alexinparis »

Hi,
Your a) assumption is very interesting. It's a sort of wattmeter approximation.
I didn't thing it would be precise enough to give something accurate enough.

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

Hi Alex,

Alexinparis wrote:Hi,
Your a) assumption is very interesting. It's a sort of wattmeter approximation.
I didn't thing it would be precise enough to give something accurate enough.


yes, the term Wattmeter has a nice ring.
And surprising it is. I had the chance to have a long talk with an ESC firmware developer and with your fabulous open source code basis this was possible to implement with only little effort (I had to struggle with the GUI-arduino communication the most).

Even if this power measuring is not absolutely accurate (which I would it expect to be), then this technique can be used as an additional safety feature in parallel with battery voltage alarm.
And it is cheap in terms of computing time - I could not see any impact on the cycle time.

Hamburger

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter /wattmeter for 1prebis7 - final - testers wa

Post by Hamburger »

Hi,

this is a powermeter / wattmeter implementation - purely software.

the software has been tested, but use at your own risk.
Beta testers wanted, please provide feedback.
Fully configurable via LCD or GUI.


Motivation:
the alarm based on battery voltage is cool, but on new generation of lipos (for me nanotech and probably others) the voltage drop is small and occurs late. The timer on the TX is kinda static and does not take into account flying style nor breaks.
So I wanted to measure true power consumption and get alarm when battery drained of say 80% capacity (only 20% nominal capacity left).
As a side effect I get separate measurements for each motor, so this may help in adjusting COG or detect bad motors.

idea:
instead of measuring and integrating over time the true current with a special hall sensor I do it in the software only.
Two assumptions:
a) the ESCs+motors provide an almost linear mapping from the input signal to the outputted power within the flying range (works for me, ymmv)
b) the time base (main loop time) is quite stable (seems safe with Alex' code)
For power measurement we sum up the signals sent to each motor over time starting at poweron.
Attach buzzer alarm threshold to the sum value.

Interface:
Note 1 - I could not yet get the interaction with the GUI to work, for now all interaction is done via LCD display configuration.
Note 2 - the alarm functionality is implemented but needs testing, I have no buzzer attached; need to visit local shop.

Features:
  • independent from actual currents - works independently and equal for wide range of batteries and motor combinations; relies on number of motors and flight time.
  • works for all possible copter configs (TRI, Quadx/plus,Y6, etc.)
  • separate power meter for each motor (up to 6 motors)
  • sum of all power meters
  • accessible via LCD configuration interface
  • user settable alarm threshold stored in eeprom
  • alarm threshold read and write accessible via LCD configuration interface
  • added bonus feature to LCD config: Exit without Save - same as Enter config - yaw right and pitch up
  • added bonus feature to LCD config: wrap around menu items list, so it is easy to reach the last of the items now.
  • monitor battery voltage via LCD configuration
  • view voltage, power and power alarm threshold live in GUI
  • set power alarm threshold in GUI, write to arduino
how to use:
  • get code or patch your code, apply your usual setup (TRI, yaw-direction, etc.)
  • activate power meter functionality / PMETER is defined by default for now
  • load code into arduino
  • choose battery with largest capacity (in mAh) you want to use
  • go fly (or run on test bench) for apporx. half your usual expected flight time
  • attach LCD or GUI (if it does not reset the MultiWii as it does on Mac due to USB implementation)
  • use LCD (or GUI) config and read pMeter values for each motor and the pMeter Sum value
    (for my TRI that gives after ~3 minutes in hover a sum of approx 2500 )
  • if sum is > 30000 contact me, need to change internal divisor (currently set to 10000; sorry for inconvenience)
  • continue flight as you normally would (per timer in TX or voltage alarm or ...)
  • use LCD or GUI again, read counters per motor and sum
  • set alarm threshold to this value: last entry in config menu, use sum value, divide by 100
  • save and exit
  • give some thought on the meaning of very different readings for front and tail motors - need to adjust COG?
  • fly with new pack
  • test alarm and inform me whether it works for you

I use it with a set of equal nanotech batteries of two different cpacities (1000mAh and 2200mAh).
My number of motors is constant - 3 for a TRI.
Flight times in hover are ~6 min and ~11 min
hover is at ~50% throttle
For the 1000mAh batteries the pMeter sum is ~8100 (needs 930mAh charge after filght) pAlarm threshold is set to 8100/100=81.

Hope someone finds this useful,
Hamburger
Attachments
Conf_1prebis7_powermeter.diff.zip
Patch for the GUI Conf_1prebis7
(1.6 KiB) Downloaded 220 times
1_prebis7_powermeter.diff.zip
Patch for MultiWii 1prebis7
(5.25 KiB) Downloaded 219 times

User avatar
BlueAngel
Posts: 30
Joined: Sun Feb 27, 2011 11:35 am

Re: power meter for 1prebis7 - beta testers wanted

Post by BlueAngel »

really interesting idea.
Maybe i have some time and will test that.

Felch
Posts: 9
Joined: Mon Mar 21, 2011 9:23 pm

Re: power meter for 1prebis7 - beta testers wanted

Post by Felch »

Very interesting code. I'd like to test it but...forgive me a newbie question: how does one apply Your patches? Especially to the GUI code (I have written code in assembly and for PIC processors thus far, that's why i have no experience in arduino environment).
I managed to apply changes simply by comparing codes of flight controller but the GUI seems to be different. Search in forum also didn't give me a clue.

Veljo

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

Veljo,

forgive my ignorance. I am used to *nix development environments. There you find a tool called patch which does exactly that, a) create patch by comparing to versions and b) applying a patch to one file and thus create a modified version.

Felch wrote:Very interesting code. I'd like to test it but...forgive me a newbie question: how does one apply Your patches? Especially to the GUI code (I have written code in assembly and for PIC processors thus far, that's why i have no experience in arduino environment).
I managed to apply changes simply by comparing codes of flight controller but the GUI seems to be different. Search in forum also didn't give me a clue.
Veljo


For your convenience I attach the two complete source code files.
To compile the GUI you will need the Processing program - similar to the Arduion program.
Plus you need to get the ControlPS library and install that together with the Processing program.

Hope that helps,
Hamburger
Attachments
MultiWii1_prebis7_powermeter_TRI60_3S.pde.zip
MultiWii 1prebis7 source with powermeter code included
(22.49 KiB) Downloaded 229 times
MultiWiiConf1_prebis7_powermeter.pde.zip
GUI source - Processing code
(9.09 KiB) Downloaded 222 times

Felch
Posts: 9
Joined: Mon Mar 21, 2011 9:23 pm

Re: power meter for 1prebis7 - beta testers wanted

Post by Felch »

Thanks! Homework should be done before asking questions... :)
The program for compiling GUI *.pde releases is Processing found here: http://processing.org/
Mentioned ControlP5 library could be downloaded from here: http://www.sojamo.de/libraries/controlP5/index.html
I am still wondering how to apply a patch under windows. Is it a Linux feature only ?

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

Felch wrote:Thanks! Homework should be done before asking questions... :)
The program for compiling GUI *.pde releases is Processing found here: http://processing.org/
Mentioned ControlP5 library could be downloaded from here: http://www.sojamo.de/libraries/controlP5/index.html

sounds right.
I am still wondering how to apply a patch under windows. Is it a Linux feature only ?

you need a programm called "patch" to apply the patch file. Should be available for almost any os. All *nix I know have that included in their development environment. (But I uploaded the complete source in a previous post, so no need to patch Alex' original files)

Hamburger

arnaldo
Posts: 49
Joined: Sun Mar 06, 2011 4:53 pm

Re: power meter for 1prebis7 - beta testers wanted

Post by arnaldo »

can you upload the complete executable package? you can use 4shared

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: power meter for 1prebis7 - beta testers wanted

Post by Alexinparis »

@Hamburger,
do you want an access to the code repository ?
So that you could upload and share your modification in the branch section.

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

with Alex' consent, the code will be available in the code repository as binay package (which always includes source).
May take a day for me to prepare my latest code - twiggling with the underlying theory and algorithm some more.

Hamburger

User avatar
fr3d
Posts: 97
Joined: Sun Feb 06, 2011 11:21 am
Location: Cappelle la grande near the ch'ti village
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by fr3d »

hye, can you post executable windows gui file ?
really enjoy to test your mod.(trying to do similar but not working with 1.7prebis and lcd, 16bits values must be changed into 8 bits....lost lot of time to do conversion and the answer were one line above .... :evil:

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

GUI binaries for all supported platforms and code can be found here
http://code.google.com/p/multiwii/sourc ... Hamburger/

in arduino code, change battery pin ! My pin 3 in broken, so in code it is set to 2, but default is 3. If battery monitor worked for you then switch the define from my 2 to default 3.

Waiting for your feedback,

Hamburger

User avatar
zara
Posts: 7
Joined: Wed Mar 30, 2011 1:17 pm
Location: Mainz, Germany
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by zara »

Great idea, this sounds very promising! I will test it this weekend and give you my feedback.

Zara

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

Hamburger wrote:GUI binaries for all supported platforms and code can be found here
http://code.google.com/p/multiwii/sourc ... Hamburger/

in arduino code, change battery pin ! My pin 3 in broken, so in code it is set to 2, but default is 3. If battery monitor worked for you then switch the define from my 2 to default 3.
Hamburger


It seems I left some people confused, so
please be advised:
  • you have to use both my GUI and my arduino code, because I extended the protocol between the two. That is how the GUI gets to know and display current voltage etc. from the copter)
  • I made the GUI into a fullscreen application, because on my mac this is the only way the GUI with the OpenGL for the animated copter works. If you do not like that, no problem, you got the source and can compile your own.

Hope that clears things for you.
Hamburger

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

If any of you is interested in some background on this topic, you may find this discussion helpful:
http://www.rcgroups.com/forums/showthread.php?t=1412483

If you feed adventerous, hook up an amperemeter to one of your motors (!with prop!) and measure the current for 0%, 12,5%, 25% etc. up to 100% throttle. Or even better, measure the current for throttle values in the MultiWii GUI - those range from 1000 to 2000. Do that in steps of 100 or 125. Either way mail me those number togehter with info on motor, ESc, prop, battery, so I can fit them in and see whether this has a chance to work independent of individual motors.

Hamburger

User avatar
zara
Posts: 7
Joined: Wed Mar 30, 2011 1:17 pm
Location: Mainz, Germany
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by zara »

Quick update from me - I had some time tonight so loaded your code from the google repository and did a few short test flights with my quad on a 1000mAh 3S battery. These flights were followed by checking used "Power" from the GUI and fully recharging the battery. The results I had from this test are as follows: 80, 157, and 227mAh discharge respectively, corresponding to Power readings of 498, 1134, and 1696. Linearity looks very good, though not tested for higher discharges yet.

As my board (Paris 2.0) does not directly support the optional buzzer, and I did not want to start soldering tonight, I made a slight modification to the code to use the camera trigger output (A2) on the Arduino to activate a cheap "discovery buzzer" which attaches to a regular Rx port once the alarm threshold is reached.

I have now set my threshold to 6000 (approx 800mAh) and will do another test flight tomorrow. If this works, it should be way better than any cheap lipo alarm - especially with the nanotech or similar lipos which drop their voltage when it's almost too late. I'l also test with a larger 2200mAh to see what kind of differences (if any) I may note.

I have to say, your code looks very promising!

Zara

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

Zara,
thanks for the positive feedback. Please be aware that you may have to callibrate the counter and your alarm threshold when you switch to different type of battery,(but not if using equal batteries). This would in theory the result of diffeent voltage decay over discharge, because the currents supplied to motors are also tied to the actual voltage.
So if you switch from your 1000mAh brand x batteries to your 2200mAh brand y batteries then callibrate again.

This should not be neccessary for batteries of same brand and capacity. That is how it works for me.
Hamburger.

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

Updated approximation curve data

Sorry to bother you all, but from experiments I found that the square curve I used is way too low for throttle above 50%.
So here comes a new better one. The foundation data can be seen over at RCG in that theoretical thread - which is becoming more and more experimental with increasingly good results.

So here is what to change - just replace one set of curve data with the other:

/* real square function */
/*const uint32_t amperes[16] = {3, 15, 34, 62, 97, 140, 191, 250, 315, 389, 472, 562, 659, 765, 879, 1000 };*/
/* experimentall curve (above square curve for values > 50%) */
const uint32_t amperes[16] = {3, 16, 34, 53, 92, 145, 224, 309, 382, 461, 566, 671, 789, 882, 941, 1000 };

The downside is you would have to do your callibration for the alarm value all over, sorry.
Hamburger

User avatar
zara
Posts: 7
Joined: Wed Mar 30, 2011 1:17 pm
Location: Mainz, Germany
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by zara »

Hamburger wrote:Zara, Please be aware that you may have to callibrate the counter and your alarm threshold when you switch to different type of battery


That's what I figured. I had one discharge run on my larger batteries and the resulting value was off to the rest of the series. Not by much, but it was still noticeable. Not a big caveat for me, I try to have a specific set of batteries per craft. And even for a mixed battery scenario, there are fairly straight forward solutions...

I'll install your new data set before I run my testing this evening. However, as I am limited to my living room until the weekend, I won't be going very far beyond hover... Perhaps I'll find the time to migrate your code over to 1preter7 just for the sake of experience :D

I figure it should also be easy to add a simple coefficient to your code (result of battery specific calibration) so that the power consumed and the alarm threshold are both represented as mAh. But I'm getting ahead of myself...

Zara

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

zara wrote:I figure it should also be easy to add a simple coefficient to your code (result of battery specific calibration) so that the power consumed and the alarm threshold are both represented as mAh. But I'm getting ahead of myself...
Zara


Zara,

I gave that some thought and I think while it is nice to read it complicates things. This coefficient would be specific for every battery type-ESC-motor-prop combination. To get sensible results, every user would have to run experiments with each of his combinations.

The way it is represented now works out of the box (once we have it polished), user just uploads, does one testrun, reads counter, measures recharge mAh, does linear math and sets alarm threshold. The counter is not as self-explanatory as reading in mAh would be but it has the advantage of being simple and universal.

Anyway, if you are up to it, feel free to give it a go.

Me, I am more concerned with the practical generality of the approach. If we find that it requires a specific curve for every battery-ESC-motor-prop there is, then I would persue to factor in the voltage as a next step.Theory says, that energy rises to the cube of ESC input signal. For now we take voltage as constant. But we could factor in the voltage - we have the reading already. This sounds reasonable, as the voltage effectively drops when current is high. So it might give better results. But it increases calculation time and adds complexity (voltage*signal^2 or voltage^2*signal or a combination, which?). So I want to avoid it if possible.

As a last resort I will get a hall sensor and use TRUE power consumption at the battery connectors.
Hamburger

User avatar
zara
Posts: 7
Joined: Wed Mar 30, 2011 1:17 pm
Location: Mainz, Germany
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by zara »

Well, as I said, I was getting ahead of myself :lol: You have a point.

I did another test series tonight with the new curve you provided earlier. Floating around in my living room, I tried to bounce the quad up and down so that throttle use was a bit more realistic to real flight rather than just hovering in one place until the alarm sounds. The result is not linear, but still seems cohesive:

Code: Select all

  "P"  y [mAh]     p/y
 2085      226     9,23
 4046      410     9,87
 6047      567    10,66
 9068      710    12,77

I've also attached a plot of the values below. I would still like to independently test if the results are repeatable (i.e. if battery drain for P=2000 remains relatively constant), but with a single 1000mAh which only charges at 1C I didn't have the time tonight. I should receive two 1300mAh nanotech batteries tomorrow, I'll run a more detailed test series when I have them...

Zara
Attachments
Capture.PNG

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

zara wrote:I did another test series tonight with the new curve you provided earlier. Floating around in my living room, I tried to bounce the quad up and down so that throttle use was a bit more realistic to real flight rather than just hovering in one place until the alarm sounds. The result is not linear, but still seems cohesive:

Code: Select all

  "P"  y [mAh]     p/y
 2085      226     9,23
 4046      410     9,87
 6047      567    10,66
 9068      710    12,77

I've also attached a plot of the values below. I would still like to independently test if the results are repeatable (i.e. if battery drain for P=2000 remains relatively constant), but with a single 1000mAh which only charges at 1C I didn't have the time tonight. I should receive two 1300mAh nanotech batteries tomorrow, I'll run a more detailed test series when I have them...
Zara


Grreat. That is the procedure I follow myself mostly.
To be honest, the p/y values you get do not look too stable. (in a perfect setup should be one constant, characteristic for your setup).
So there goes the idea of a universal signal-to-current curve, too bad.
Well, maybe it is still useful if you fly closer to your average flying style and duration?
May I ask which motors and props, how many, your copter has?
(My main test copter is a TRI with Turnigy 2205-50 motors, 9x5 SF props, hk ss ESC 10A, standard is 1000mAh nanotech batteries)

Hamburger

User avatar
zara
Posts: 7
Joined: Wed Mar 30, 2011 1:17 pm
Location: Mainz, Germany
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by zara »

Don't give up that easily. I still find it quite useful. The VBAT implementation is... improvable. Apart from the problems with current "nanotech" lipos and their late voltage fall-off, I measure quite a lot of variation in voltage during regular operation. I'm routing the buzzer output to D13 (driving my LED strips via transistor) and it's all over the place. The battery monitoring implementation as of now would need to average to become halfway usable. I'm giving this implementation some thought...

This aside, your code still gives me a much more reliable guesstimate of battery state. It needs individual calibration, but so does voltage monitoring (resistor variance, battery behaviour, etc).

Here the specs on my copter:
Quad X
Motors: Turnigy 2204-14T
ESCs: Hobbyking SS Series 8-10A
Lipo: SLS 1300mAh 3S 25-50C
Props: GWS Style 6x3
Total weight ready to fly: 490grams (incl battery)
Thrust to weight ratio: approx 2.6:1
Hover throttle: 1600 [990:2010]

PS: Above specs are with the new batteries. Yesterday's test series was with a Turnigy 1000mAh 20C

User avatar
zara
Posts: 7
Joined: Wed Mar 30, 2011 1:17 pm
Location: Mainz, Germany
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by zara »

No time this evening, but perhaps still something to think about:

Code: Select all

   Battery     "P"   y[mAh]     P/y
  TGY 1000    2085      226    9,23
  SLS 1300    2676      282    9,49
  TGY 1000    4046      410    9,87
  TGY 1000    6047      567   10,66
  TGY 1000    9068      710   12,77
  TGY 1000   11184      858   13,03
  SLS 1300   16547     1275   12,98

Not sure I want to get closer to 1C discharge :D

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

don-t know if anyone is still interested.
I have some catchup to do with 1.7 now.
From there I will try a different approach and factor in the voltage - we have that value already.
On a different track, I will evaluate the usefulness of direct measurement of the current with a hall sensor close to the battery.

Feel free to pm me if you are interested.
Hamburger

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

ported to v1.7.
Included together with telemetry patch here viewtopic.php?f=8&t=253
Hamburger

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

Gentlemen,

it works well enough.
With some theoretical input form here http://www.rcgroups.com/forums/showthread.php?t=1412483
I can predict/compute the drained capacity with an error of approx 30mAh for a 1000mAh battery. Verified on two different copters, one on 2S, other on 3S. See for yourself.

3S chart
3S chart


This nicely complements the voltage alarm.
Code is the goolge repository as always. powermeter must be activated via #define as always.

Thank you for your support. Ready for integration in main branch.
Hamburger

User avatar
zara
Posts: 7
Joined: Wed Mar 30, 2011 1:17 pm
Location: Mainz, Germany
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by zara »

Hamburger wrote:Ready for integration in main branch.
Hamburger


Wow, that is awesome news! Can't wait to try it out!
Zara

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

just curious what users will prefer.

Method 1 - current implementation:
Now, it works by displaying an abstract number and allows user to set another abstract number as alarm threshold.
This alarm value has to be found for each copter+batterycapacity with one or more test runs:
- get voltage reading right first
- charge battery,
- fly until capacity is down to approx 20% (or whereever user wants alarm to kick in
- attach GUI or LCD and read abstract first number (labeled powermeter sum)
- recharge battery and note consumed capacity. ok, then proceed, else start again (or use linear calculation to extrapolate found value)
- set alarm threshold in GUI or LCD config to this found value
(maybe reapeat two to three times to get a better averaged value)
pro: uses abstract numbers, so you only have to remember abstract alarm number for each battery capacity you fly.
con: abstract number is just that - abstract

or we could enhance/complicate it to
Method 2 - individually scale values to represent mAh
Numbers displayed for powermeter (consumed energy) and alarm threshold both in mAh.
- get voltage reading right first
- charge battery
- fly until capacity is down to approx 20% (or whereever user wants alarm to kick in
- attach GUI or LCD and read consumed capacity displayed (not the correct value yet)
- recharge battery and note true consumed capacity
- divide displayed value by true value, we call the result factor.
- change parameter in code from

Code: Select all

#define PLEVELDIV 10000
to

Code: Select all

#define PLEVELDIV (factor*10000)
<- you must calculate this and replace value
- upload modified code to arduino
- set alarm threshold in GUI or LCD config to the mAh value where alarm should kick in
(maybe reapeat two to three times to get a better averaged value)
pro: displays actual mAh
con: needs to change code (or add yet another GUI configurable parameter) to suit different battery capacity - else values are pure wrong


Fly and enjoy alarm, Repeat for other battery capacities and other copters.
Always remember: this is pure software with lots of assumptions which may fail due to various reasons. But it does add another layer of protection for your lipos and - it is free.

What do you think?
Hamburger

User avatar
BlueAngel
Posts: 30
Joined: Sun Feb 27, 2011 11:35 am

Re: power meter for 1prebis7 - beta testers wanted

Post by BlueAngel »

I would say, just use the mAh.
If you attach LCD after a short flight, you will see mAh and not a abstract number, where you have to do the math again in your head. ;)

Felch
Posts: 9
Joined: Mon Mar 21, 2011 9:23 pm

Re: power meter for 1prebis7 - beta testers wanted

Post by Felch »

I'd prefer SI units like mA/h also. If we measure something, we get a value with unit. But of course units are hard to determine since all depends of load used (motors). Loop time is not precisely constant as well.
I think that one version of Powermeter might use Hamburger's approach (which is very clever indeed !) and another might use a calibrated current sensor connected to a free pin of Atmega (ADC7 is free for example). In this way we do not need to calibrate powermeter.
Code might "poll both methods": if current sensor is not connected (input stays at zero), it will use estimated values like Hamburger proposes. If current sensor input is detected, it switches to this source or makes both calculations.

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

ok,

new version is in google repository, version 1-7-plus.here
http://code.google.com/p/multiwii/sourc ... ger%2Fv1.7

added features:
+ LCD abort
+ LCD_TELEMETRY (and redefine for GUI)
+ POWERMETER
+ FreeIMU adaption with configurable address

powermeter can now be scaled to display mAh.
LCD Telemetry has new additional mode that is triggered via TX (disarmed & throttle=low & roll=left & pitch=up) and does not require LCD with buttons! It uses sequential hopping through 4 LCD telemetry pages. Should work with all 16x2 lcds.

you also need the modified MultiWiiConf-1-7-powermeter.

Hamburger

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by jevermeister »

Hi,
sorry to bring this old thread upo again.

@Hamburger: Do you have a link where to buy a current sensor for the powermeter hard option?

I grow sick of dead Lipos and Lipos that cannot hold the voltage stable so I want to monitor the real mAh usage.

Nils

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: power meter for 1prebis7 - beta testers wanted

Post by shikra »

www.flytron.com

I use theirs with osd, not multiwii though

KaiK
Posts: 58
Joined: Thu Jul 28, 2011 8:32 pm
Contact:

AW: power meter for 1prebis7 - beta testers wanted

Post by KaiK »

I have bought a ACS758LCB-100U-PFF-T at Ebay for 10 usd, it is working great on the CL-OSD...

next weeks I will give it a try on Multiwii...

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

I use amploc sensors. any sensor that does linear I->U representation might work.

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by jevermeister »

Hi,
I got myself a ACS758LCB-100U-PFF-T Sensor and soldered a Lipo passthrough.

Hamburger,
what is the next step, What do I have to connect to the flyduino?

Sensor Dataport to Pin2 but what about the other two pins of the sensor?
On will be ground and the other one is VCC?

Who do I calibrate it in the software!?

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by jevermeister »

Hi,
I misunderstood the manual and reverse connected the sensor,
I put vcc to viout and vice versa,
I only have mv output right now, but they seem to be proportional to the throttle.

I use a multimeter to measure it.

is the sensor fried?


Nils

KaiK
Posts: 58
Joined: Thu Jul 28, 2011 8:32 pm
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by KaiK »

Just solder the + Pin of Lipo to IP+, IP- then goes to your motors...
VCC is +5V (from ESC or Arduino), GND is GND, VIOUT is the signal, which is 0.6V when power is zero and 4,6V when power is 100A.

Just measure Voltage with multimeter between GND and VIOUT and you will see, if this works.

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by jevermeister »

Okay,
thats the behavior I have here.
I thought 0A was 0,5*VCC.

Thank you for helping me out.

Now back to testing and calibrating

Nils

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

hope you did not fry your sensor.
Short answwer,
all sensors I know require +5V, common ground with mwc and provide analog output 0-5V proportional to current. output voltage must be proportional to current for powermeter to work as is.
1. You have to find the sensor's output voltage for 0 current next.
from therre, follow instructions in config.h

I will do the wiki page for this next thing.

KaiK
Posts: 58
Joined: Thu Jul 28, 2011 8:32 pm
Contact:

AW: power meter for 1prebis7 - beta testers wanted

Post by KaiK »

VCC/2 on bidirectional sensors...
But you have a unidirectional with twice the resolution...


User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by jevermeister »

Thanks for the Wiki page.

My sensor is working now.
I applied a digital moving aberage filter of 128 samples.Maybe we could integrate it into the trunk and activate it via define.Like that one does not need a filter hardware.

I am struggling with the correct values for pleveldiv and pint2ma right now. The shown values are differing from my powermeter I am using for testing. Somehow my sensor behaves very different to its datasheet.
For example the I=0voltage is a 0,6V and not Vss/2...
I keep on trying.

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by Hamburger »

jevermeister wrote:I applied a digital moving aberage filter of 128 samples.Maybe we could integrate it into the trunk and activate it via define.Like that one does not need a filter hardware.

then you should set PSENSORFREQ to 1 or you will miss all the interesting spikes. Still, 128 samples sounds like a lot to me. But then, I am not an engineer, so what do I know. If it works, then that is that.
I am struggling with the correct values for pleveldiv and pint2ma right now. The shown values are differing from my powermeter I am using for testing. Somehow my sensor behaves very different to its datasheet.
For example the I=0voltage is a 0,6V and not Vss/2...
I keep on trying.

are you using the correct datasheet for your sensor?
I know there are sensors with curves going from 0V@0A to 5V@maxA style, but if your datasheet says Vss/2 then it is strange you see 0,6V only. You have common gorund between sensor and mwc?

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: power meter for 1prebis7 - beta testers wanted

Post by jevermeister »

Hi,

I did some trial and error finding 128 samples because I had serious jitter.
I am not sure if this is too high, I will do some further testing on that, but giving the overall speed of the CPU it is still a lot less smoother than using a 25Hz lowpass filter.

I use the datasheet that came with my sensor, there are some different versions of it but all share Vcc/2 as 0A value. Kaik already mentioned that he has the same behavior.
I am very new on this subject so I may have missed something important.

I applied common ground to FC and sensor and use 5V from FC.

Nils

Post Reply