[patch] Amperage in MinimOSD via Multiwii MSP

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
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

[patch] Amperage in MinimOSD via Multiwii MSP

Post by haydent »

latest update: only changes you need to make now is the last step to minimosd code, as mwc 2.3 has the changes already.


This is why i love open source ! Thanks all.

Via Serial (eg to minmosd) Multiwii only outputs a total of current used,though before it calculates that it actually has the current consumption rate as read by your hardware sensor. (in my case rctimer current voltage sensor).

MinimOSD can show both total current used as "mAh" and current consumption rate "A" (amps) , though as multiwii only outputs mah and not amps to get minimosd to show Amps you would have to connect the sensor to minimosd instead via a hardware mod involving soldering to arduino's legs... (and then enable minimosd ADC)

So here is how to get multiwii to pass amperage reading to minimosd and get minimosd to display it :lol:

im using stock mwc 2.2 release on mega 2560, and KV_Team_OSD_dev_r345 release on hobbyking mimiosd board

So starting in mwc sketch, open "Multiwii" tab in Arduino editor:

Make Line 296 Look like this:

Code: Select all

static uint16_t intPowerMeterSum, intPowerTrigger1, amperage;//haydent added amperage


Around Line 562 make it look like this:

Code: Select all

       //lcdprint_int16(pMeterRaw); LCDcrlf();
      powerValue = ( conf.psensornull > pMeterRaw ? conf.psensornull - pMeterRaw : pMeterRaw - conf.psensornull); // do not use abs(), it would induce implicit cast to uint and overrun

      //haydent capture milli amperage reading for minimosd via serial
       amperage = (uint16_t)(powerValue * conf.pint2ma);
      //haydent capture milli amperage reading for minimosd via serial   
     
      if ( powerValue < 333) {  // only accept reasonable values. 333 is empirical
      #ifdef LCD_TELEMETRY
        if (powerValue > powerMax) powerMax = powerValue;


Then in the Serial Tab, near line 385:

Code: Select all

   case MSP_ANALOG:
     headSerialReply(7);//haydent
     serialize8(vbat);
     serialize16(intPowerMeterSum);
     serialize16(rssi);
     serialize16(amperage);//haydent
     break;


Now finally in the MinimOSD sketch in the Serial Tab:

Near Line 149, make it look like this:

Code: Select all

  if (cmdMSP==MSP_ANALOG)
  {
    MwVBat=read8();
    pMeterSum=read16();
    MwRssi = read16();
    amperage = read16() / 100;//haydent - comes through as milliamps
  } 


also you will need to edit the minim osd config settings , there is something in there about power amperage factor, that it divides your amperage by. so set it to 1

That's it, enjoy !
Last edited by haydent on Thu Nov 21, 2013 4:40 am, edited 13 times in total.

sorg
Posts: 34
Joined: Mon Apr 08, 2013 2:49 pm

Re: [A] Show Amperage in MinimOSD via Multiwii connected sen

Post by sorg »

Nice workaround!

In the future, we should request an extension to the Multiwii serial protocol to get this "current" value straight available. "debug" variables should be used only for... debugging !

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: [A] Show Amperage in MinimOSD via Multiwii connected sen

Post by haydent »

my thoughts exactly, as well they could even collect video voltage as well through a chosen pin, i have a couple spare on my mega

felixrising
Posts: 244
Joined: Sat Mar 23, 2013 12:34 am
Location: Australia

Re: [A] Show Amperage in MinimOSD via Multiwii connected sen

Post by felixrising »

Absolutely, pulling out Amps and Volts from MultiWii over MSP is the way to go, from this power can be calculated. MultiWii is currently calculating pMeter (sum) but not otherwise using the Current reading. There seems to be an orphaned int for pMeterRaw looking for a use too.

Extending MSP and Rushduino OSD to consume this is a logical progression and would save people toasting their MinimOSD whilst trying to solder new pins to the AVR legs.

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: [A] Show Amperage in MinimOSD via Multiwii connected sen

Post by haydent »

"save people toasting" :)

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: [A] Show Amperage in MinimOSD via Multiwii connected sen

Post by haydent »

please note there was a bug that limited it to 4.3 Amps, i dont understand why that multiwii code is there but you can see my fix in the first code box to move my use of the debug before the line : "if ( powerValue < 333) { "

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: [patch] Amperage in MinimOSD via Multiwii connected sens

Post by haydent »

i have updated the opening post to no longer use the debug variable for transferring the amperage reading instead integrating it into the serial protocol

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: [patch] Amperage in MinimOSD via Multiwii connected sens

Post by haydent »

patch for multiwii_shared file added to OP

felixrising
Posts: 244
Joined: Sat Mar 23, 2013 12:34 am
Location: Australia

Re: [patch] Amperage in MinimOSD via Multiwii connected sens

Post by felixrising »

That's the right way to do it. It sure beats these hardware hacks to solder rssi and vbat to the minimosd mega328 legs. It would be good if MSP_ANALOG was permanently extended to cover [vbat0,amps0,psum0,rssi0,vbat1,amps1,psum1]. Other than setting a palarm for the main battery, secondary battery psum and palarm seems like overkill but could be useful for those doing long FPV flights I suppose. Of course, kvteam needs to get involved here too.

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: [patch] Amperage in MinimOSD via Multiwii connected sens

Post by haydent »

thanks for the comment, i may likely add video voltage too but leave it at that. ive even thought it would be good to have a dedicated board that captures all these readings and then passes them to mwc via serial link.

felixrising
Posts: 244
Joined: Sat Mar 23, 2013 12:34 am
Location: Australia

Re: [patch] Amperage in MinimOSD via Multiwii connected sens

Post by felixrising »

If TC ever trolls us with a real DongOSD, maybe that will do it all and we can just go flying instead ;)

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: [patch] Amperage in MinimOSD via Multiwii connected sens

Post by haydent »

sorry your going to have to fill me in on this one, TC?, DongOSD?

also did you get my pm ?

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

Re: [patch] Amperage in MinimOSD via Multiwii connected sens

Post by Hamburger »

for extending an MSP you should post in the 'MSP new serial protocol' thread. Alex does not like rogue extensions of MSPs, I think.
some things to consider:
- did you check with the GUI how it handles the extraneous data?
- you going to extend the GUI to display that data?
- does your extension work or break in case of no amperage sensor?

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: [patch] Amperage in MinimOSD via Multiwii connected sens

Post by haydent »

thanks for the reply ! ill go over those points and make a post in that thread :)

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

Re: [patch] Amperage in MinimOSD via Multiwii connected sens

Post by Hamburger »

cool. Keep the good things coming. If you need support, ping me.
(I have made amperage and max.amperage available for the serial/i2c display telemetry quite some time ago. I find that useful info, not so much during normal flight but when testing motor+prop combinations - easy checking and comparing the hover current)

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: [patch] Amperage in MinimOSD via Multiwii connected sens

Post by haydent »

yes i did see it being used in the lcd tab, thanks.

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

Re: [patch] Amperage in MinimOSD via Multiwii connected sens

Post by Alexinparis »

Hamburger wrote:for extending an MSP you should post in the 'MSP new serial protocol' thread. Alex does not like rogue extensions of MSPs, I think.
some things to consider:
- did you check with the GUI how it handles the extraneous data?
- you going to extend the GUI to display that data?
- does your extension work or break in case of no amperage sensor?


I think it's ok to add a new var shoring the instantaneous amp at the end of MSP_ANALOG.
As it is at the end, it is not mandatory to upgrade the GUI to be still compatible with the current message.

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: [patch] Amperage in MinimOSD via Multiwii connected sens

Post by haydent »

yes that is what i thought after undelstanding how the protocol is read out.

i dont have any plans to integrate it into the gui, as im not looking the learn about that side of things for now

from my test the gui doesnt seem to be affected by it being there, nor should anything be affected if no amperage sensor as my code is between the if "powerhard" block

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by haydent »

so have i done all i need to, will it get added, can i move onto my next one ? thanks.

kataventos
Posts: 702
Joined: Sun Aug 28, 2011 8:14 pm
Contact:

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by kataventos »

Nice, it should be extended to the GUI as well, that is the only way to get the job done exactly as it should.

Cheers,
-KV

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by haydent »

that way people will notice it there :)

kataventos
Posts: 702
Joined: Sun Aug 28, 2011 8:14 pm
Contact:

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by kataventos »

Hi,

Multiwii GUI is at this time used for more then just debug and check/program the FC, some are using it during real time flight.
If we have that data available on the serial protocol, the first integration should be on Multiwii GUI (my thoughts) even if the main goal is the OSD.

Many other projects already being developed will most certainly use this data as well, for example Alex UART radio project in future (regarding the telemetry part) or for example the FRSky telemetry project ;)

-KV

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by haydent »

ok ill try and do it :)

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by haydent »

ok so i checked out the mwc conf folder on the svn and there's just 2 files, any tips on how i integrate this addition into the gui ?

i was expecting a bit more to build a gui...

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

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by Hamburger »

the extended MSP is in r1542 for you to try with the GUI. untested - I have no modified GUI and no modified OSD.

test
Posts: 25
Joined: Sat Jul 27, 2013 12:16 am

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by test »

haydent here, (away for weekend, and cant remember password), thanks for adding the patch ! how do i modify the gui to show the new MSP value ?

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

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by Hamburger »

I have not done GUI coding for long time. I guess your best bet is to look at how the rssi value gets handled in gui and duplicate that for the amperage value.

kataventos
Posts: 702
Joined: Sun Aug 28, 2011 8:14 pm
Contact:

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by kataventos »

Hamburger wrote:...best bet is to look at how the rssi value gets handled in gui and duplicate that for the amperage value.

:mrgreen: Understood :lol: I will ASAP ...

test
Posts: 25
Joined: Sat Jul 27, 2013 12:16 am

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by test »

sorry but i dont understand where is the gui source files ?

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

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by Hamburger »

Trunk/multiwiiconf_shared

test
Posts: 25
Joined: Sat Jul 27, 2013 12:16 am

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by test »

ok thanks ill look into it deeper, just was expecting a few more files to make an exe and all that that the gui is, but im guessing in this case the one file is all that needs to be modded and it is loaded in

test
Posts: 25
Joined: Sat Jul 27, 2013 12:16 am

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by test »

nope still stuck, i dont get how you get from the one pde file into a jave exe app...

i downloaded the standard 2.2 zip, unpacked it deleted the pde (that is one the svn) and ran the gui, it still opened and looked the same...

felixrising
Posts: 244
Joined: Sat Mar 23, 2013 12:34 am
Location: Australia

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by felixrising »


kataventos
Posts: 702
Joined: Sun Aug 28, 2011 8:14 pm
Contact:

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by kataventos »

Hi,

to code the GUI you need Processing and controlP5 installed and of course the GUIconf.pde that you deleted ;)

-KV

test
Posts: 25
Joined: Sat Jul 27, 2013 12:16 am

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by test »

yes, i did google it just b4 felix posted that... and posted that id found the thread here about it. my post did not make it i see now... thanks guys for the pointes

test
Posts: 25
Joined: Sat Jul 27, 2013 12:16 am

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by test »

testing 123

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by haydent »

hope its not too late to squeeze this into 2.3, but here is a patch to add amperage display to the GUI

[update]changed patch syntax to context
Attachments
r1604.gui.amperage.display.zip
(1.01 KiB) Downloaded 207 times

felixrising
Posts: 244
Joined: Sat Mar 23, 2013 12:34 am
Location: Australia

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by felixrising »

Nice work Haydent. It makes much more sense to include amperes, this way you can see what your current draw is - I'm surprised it wasn't included already considering that the pmetersum is derived from this information in the first place. Hopefully someone (*hamburger* cough cough) will pick this up soon. :)

krtek2k
Posts: 25
Joined: Mon Jul 15, 2013 10:57 am
Location: Decin , Czech Republic

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by krtek2k »

I am hoping too , amperage is nice.

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

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by Alexinparis »

haydent wrote:hope its not too late to squeeze this into 2.3, but here is a patch to add amperage display to the GUI

[update]changed patch syntax to context

It will be included, but after 2.3

Adrianm1972
Posts: 7
Joined: Mon Sep 23, 2013 10:24 pm

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by Adrianm1972 »

I have just about everything working perfectly on my Mega Pro 3Ez running MW2.3, However, I am still not able to get powermeter to work and display amps in my MinimOSD. I have read everything everywhere several times and no matter what I try I always get a displayed 4.0A. I even bought an Amploc 25A sensor to get everything exactly as in the wiki

Do I need to make the changes in post #1 to get this working or is something else the matter?

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by haydent »

i replied to your other post in the other thread in more detail, but basically you need to make the changes to minimosd only now as my changes for mwc are implemented in 2.3

kataventos
Posts: 702
Joined: Sun Aug 28, 2011 8:14 pm
Contact:

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by kataventos »

Hi Haydent,
this is going to be added to the main code for the next release. Just one point, the calculations can not or should not be in serial scketch.

Cheers,
-KV

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by haydent »

ok thanks, do i need to correct that or will you be/have ?

djborden
Posts: 3
Joined: Tue Feb 25, 2014 7:40 pm

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by djborden »

Do the changes required in minimOSD still apply, or have they been implemented? Does it also apply the the Rush-OSD version as well? I'm running Eosbandi's MW version 2.3 B5 with the Baro fix.

I haven't been able to get the voltage to scale past 2.5 volts or so and I have tried everything I've come across after many hours of reading. Not sure if what is showing is just noise or a reading of some sort. I'm using the RCtimer 50v90amp current and voltage sensor.

Any help would be greatly appreciated...

David

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by haydent »

if you are using mw 2.3 then and a recent kv osd, then you will have the amperage via msp option

as for volts, you may want to check you have the right analog pin chosen, see if the reading you are getting changes at all with different supplied voltage (ie battery at different charge levels) if so the signal is getting through it just may be the settings in config.h that need adjustment. you can check your volts in mw gui too

o_lampe
Posts: 117
Joined: Sat Nov 02, 2013 5:09 pm

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by o_lampe »

Hi all,
this thread is a bit older, but fits perfect to my problem.
I'm using MW2.3 and MWOSD.
I'm reading battery voltage and amperes through the MSP-Serial port, because I don't want to fry my minimOSD board.

I got it working somehow, but find it very annoying, I have to set the zero adjust and gain values through hardcoded parameters.
I'd really like to set those values with the MWiiConf tool.
Has this been patched by now, but not released officially?

THX
Olaf

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by haydent »

as i said, amperage readings by multiwii are now available in the msp since 2.3

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

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by shikra »

Sure would be nice to have those settings on the GUI bit like the camstab and servo ones have migrated

o_lampe
Posts: 117
Joined: Sat Nov 02, 2013 5:09 pm

Re: [patch] Amperage in MinimOSD via Multiwii MSP

Post by o_lampe »

shikra wrote:Sure would be nice to have those settings on the GUI bit like the camstab and servo ones have migrated

Would it be possible to use the MWOSD-GUI to calibrate ( more like an aftermath-routine ) the MSP-data?
Also nice would be an "auto-zero" button in the GUI ( both GUIs) instead of a slider.
When the user pushes the button, the actuall reading is the zero current value.
I found out, that everytime I change the gain, I have to recalibrate the zero value again... :evil:

Post Reply