RCtimer Current and Voltage sensor and MW r1391

Post Reply
teslahed
Posts: 84
Joined: Wed Jun 27, 2012 2:51 pm

RCtimer Current and Voltage sensor and MW r1391

Post by teslahed »

I am trying to setup an RC timer current and voltage sensor to work with my crius all in one pro V1 controlled multiwii hexacopter.
http://www.rctimer.com/index.php?gOo=go ... oodsid=861
http://dlnmh9ip6v2uc.cloudfront.net/dat ... Output.pdf (spec sheet)
50V/90A = 63.69mV / Volt 36.60mV / Amp

I have the current and voltage sensor soldered between the lipo and power distribtion board with the current sensing pin connected with the analogue pin 2 on my crius all in one pro.

I have started by looking at the current sensor - i want to get my flight controller counting the mAh used in flight.

Looking at the code the relevent section appears to be;

Code: Select all

/********************************************************************/
  /****           powermeter (battery capacity monitoring)         ****/
  /********************************************************************/

    /* enable monitoring of the power consumption from battery (think of mAh)
       allows to set alarm value in GUI or via LCD
      Full description and howto here http://www.multiwii.com/wiki/index.php?title=Powermeter
       Two options:
       1 - hard: - (uses hardware sensor, after configuration gives very good results)
       2 - soft: - (good results +-5% for plush and mystery ESCs @ 2S and 3S, not good with SuperSimple ESC)    */
    //#define POWERMETER_SOFT
    //#define POWERMETER_HARD
    /* PLEVELSCALE is the step size you can use to set alarm */
    #define PLEVELSCALE 50 // if you change this value for other granularity, you must search for comments in code to change accordingly
    /* larger PLEVELDIV will get you smaller value for power (mAh equivalent) */
    #define PLEVELDIV 5000 // default for soft - if you lower PLEVELDIV, beware of overrun in uint32 pMeter
    //#define PLEVELDIV 36000 // fixed value for hard - do not tune
    #define PLEVELDIVSOFT PLEVELDIV // for soft always equal to PLEVELDIV
    //#define PLEVELDIVSOFT 5000 // for hard fixed to 5000
    #define PSENSORNULL 510 // set to analogRead() value for zero current; for I=0A my sensor gives 1/2 Vss; that is approx 2.49Volt;
    #define PINT2mA 132 // one integer step on arduino analog translates to mA (example 4.9 / 37 * 1000


This has changed from previous versions.

I am trying to configure mine to provide sensible readings over bluetooth on my smart phone to start with.

I have set powermeter_hard because i am using the hardware sensor

I have left #define PLEVELSCALE 50 alone because i don't understand it and don't fancy trying to search for the other comments in the code

I have left //#define PLEVELDIV 5000 commented out because it's for the software current sensor

I have left #define PLEVELDIV 36000 because it tells me it's fixed for the hardware and not to tune it

I have left //#define PLEVELDIVSOFT PLEVELDIV commented out because i'm using the hardware sensor

I have left #define PLEVELDIVSOFT 5000 because it tells me to set it to 5000 for the hardware sensor

I am not sure about #define PSENSORNULL 0 but i get almost no current comsumed when the hexacopter is sitting unarmed so i might have it right?

I calculated #define PINT2mA 134 with 4.9 / 36.6 (from the sensor specs 36.60mV / Amp) * 1000

Code: Select all

/********************************************************************/
  /****           powermeter (battery capacity monitoring)         ****/
  /********************************************************************/

    /* enable monitoring of the power consumption from battery (think of mAh)
       allows to set alarm value in GUI or via LCD
      Full description and howto here http://www.multiwii.com/wiki/index.php?title=Powermeter
       Two options:
       1 - hard: - (uses hardware sensor, after configuration gives very good results)
       2 - soft: - (good results +-5% for plush and mystery ESCs @ 2S and 3S, not good with SuperSimple ESC)    */
    //#define POWERMETER_SOFT
    #define POWERMETER_HARD
    /* PLEVELSCALE is the step size you can use to set alarm */
    #define PLEVELSCALE 50 // if you change this value for other granularity, you must search for comments in code to change accordingly
    /* larger PLEVELDIV will get you smaller value for power (mAh equivalent) */
    //#define PLEVELDIV 5000 // default for soft - if you lower PLEVELDIV, beware of overrun in uint32 pMeter
    #define PLEVELDIV 36000 // fixed value for hard - do not tune
    //#define PLEVELDIVSOFT PLEVELDIV // for soft always equal to PLEVELDIV
    #define PLEVELDIVSOFT 5000 // for hard fixed to 5000
    #define PSENSORNULL 0 // set to analogRead() value for zero current; for I=0A my sensor gives 1/2 Vss; that is approx 2.49Volt;
    #define PINT2mA 134// one integer step on arduino analog translates to mA (example 4.9 / 37 * 1000


The PINT2mA value is massively different in this latest dev release than previous versions - several orders of magnitude higher.

So - assuming i've not made any stupid mistakes the only two variables to tune are '#define PINT2mA' and '#define PSENSORNULL'. Is this correct?

I calculated '#define PINT2mA' the formula above and got 134.
I am pretty sure i have '#define PSENSORNULL' correct but not certain.

I then flew my hexacopter for 1 min in the hover position above my bed with a full battery, used the phone to measure the mAh used, then my battery charger to measure the amount of mAh put back into the battery to get it back to full charge. I realise this may not be a perfect means of calibrating, depending on the quality of my balance charger, but i think it's good enough to test with for now.

A 1 min flight shows '492' consumed via the phone and 220mAh of charge put back into the battery pack afterwards. So i'm seeing values that are roughly double what they should be.

Can anyone shed any light on what i'm doing wrong here? Thanks!

teslahed
Posts: 84
Joined: Wed Jun 27, 2012 2:51 pm

Re: RCtimer Current and Voltage sensor and MW r1391

Post by teslahed »

Given that i was getting a value just over twice what i should be getting using #define PINT2mA 134 - i decided to try halving it then using trial and error to find the best value. When flying for a minute, PINT2ma 62 gives a total of 238mAh used, reported over bluetooth on my phone, and 231mAh required to charge the battery back up to full from where it started.

So i think PINT2ma 62 must be about right. But i don't understand the process as described in the wikipedia powermeter entry - i haven't followed that. Have i done this the right way?

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

Re: RCtimer Current and Voltage sensor and MW r1391

Post by Hamburger »

I reworked the dev version from v2.2, yes. The wiki describes v2.2, update pending.
If it works for you then you probably did right

Blasterke
Posts: 3
Joined: Sun Feb 17, 2013 9:31 am

Re: RCtimer Current and Voltage sensor and MW r1391

Post by Blasterke »

I have the bought the same current/voltage sensor from rctimer for my crius aiop. I will install and test it somwhere next week.
Only difference I plan to use the latest revision from the svn folder (at this time r1502). Only 2 parameters need to be configured: PSENSORNULL & PINT2mA. But since the other value's seem fixed I don't think there is a difference.
Since I have no idea at what values to start, I will start with your value of PINT2mA 62 and see what the charger reports, just like you did, and will post my findings here.

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

Re: RCtimer Current and Voltage sensor and MW r1391

Post by Hamburger »

1. get PSENSORNULL right. At zero current adjust PSENSORNULL to get minimal mAh increase
2. only then tune PINT2mA - proportional factor to represent true mAh

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

Re: RCtimer Current and Voltage sensor and MW r1391

Post by haydent »

i have this sensor too, is there a way in multiwii to see your current draw ? (A not mah)

realpastaman
Posts: 93
Joined: Thu Jan 12, 2012 1:10 am

Re: RCtimer Current and Voltage sensor and MW r1391

Post by realpastaman »

I'm using the APM 2.5 Power Module to measure current and voltage on Multi Wii

http://code.google.com/p/ardupilot-mega/wiki/Voltage

This device also powers my Crius AIOP V2

I have Vbat working well

The APM 2.5 Power Module has no offet and so i set t PSENSORNULL accordingly - This works well and mAH does not increase until it sees current being drawn -

This page http://www.multiwii.com/wiki/index.php?title=Powermeter Talks about cycle time 4000us.

Is this just used for calculating the time factor for mAH?

Is there no other clock calculation on Multi Wii to do this from power up without knowing the cycle time?

Im still confused as to how to get the Gui to switch between showing current drawn in Amps or mAH? Is this possible?

Thanks for any help on this

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

Re: RCtimer Current and Voltage sensor and MW r1391

Post by haydent »

Im still confused as to how to get the Gui to switch between showing current drawn in Amps or mAH? Is this possible?


this is what i was wondering about too, but will look into the code to work it out...

i believe the cycle time is needed to calculate mah as that is a time relevant measurement...

i locked mine to 4000 so it matched with the wiki numbers and i now get good accuracy

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

Re: RCtimer Current and Voltage sensor and MW r1391

Post by Hamburger »

I reworked implementation, so v2.2 and dev code work differently. Wiki describes v2.2

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

Re: RCtimer Current and Voltage sensor and MW r1391

Post by haydent »

yes it seems to have been updated since then

teslahed
Posts: 84
Joined: Wed Jun 27, 2012 2:51 pm

Re: RCtimer Current and Voltage sensor and MW r1391

Post by teslahed »

Hamburger wrote:1. get PSENSORNULL right. At zero current adjust PSENSORNULL to get minimal mAh increase


Thanks for this.

I've been trying to get my powermeter working again. I have powered the crius all in one pro v1.0 with a lipo via a ubec so that i can connect via bluetooth with zero current flowing through the current and voltage sensor.

With PSENSORNULL at any value other than zero i get a slow climb on the mAh counter. 1 produces about 1mAh per 10 seconds and 10 about 1 per second. I didn't bother going higher than 10.

So i've left this value at 0 and am concentrating on tuning PINT2mA

2. only then tune PINT2mA - proportional factor to represent true mAh


Since it's proportional is there a way of doing this that's better than trial and error? I.e. just do one flight with a reasonable PINT2mA and measure the mAh consumed vs mAh put back in on the charger, then calculate from this?

i.e. 250mAh consumed according to bluetooth, 294mAh put back in on charger, #define PINT2mA 54

so 1/250 x 294 = 1.176

So #define PINT2mA 54 x 1.176 = #define PINT2mA 63 ?

I will be doing lots of short flights over the next few days to test this.

Also i don't have a low pass filter between the rctimer current and voltage sensor and my crius AIOP - how important is this?

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

Re: RCtimer Current and Voltage sensor and MW r1391

Post by Hamburger »

It is simple linear scaling yes.

teslahed
Posts: 84
Joined: Wed Jun 27, 2012 2:51 pm

Re: RCtimer Current and Voltage sensor and MW r1391

Post by teslahed »

I am tempted to add a 25hz low pass filter in between the current sensor and the multiwii board as the wikipedia article suggests this is a good idea.

If i do this will i have to retune my settings? With a resistor as part of the RC circuit in between the current sensor and the board wont i be dropping some voltage across the resistor? Given the analog input on the flight controller is reading voltage to calculate mAh consumd i would have thought this would affect things.

Everything i've just read about low pass filters suggests picking the resistor value is very important - any suggestions as to what would work well from someone who's already done this?

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

Re: RCtimer Current and Voltage sensor and MW r1391

Post by haydent »

back on this sensor again, i found my readings where off once i compared to a watt meter, it was my pint2ma value, i recalculate it here: viewtopic.php?f=8&t=3230&p=42811#p42811

Post Reply