mah fuel gauge

Just started getting into hardware programming so a little green. Been a long time Web programmer so I have a little understanding of programming.

I got a ardiuno uno to start messing with device programming. I'm looking to create a Mah Fuel gauge.

Here is why I want to do this. I fly remote control helicopters that are fueled by Lithium Ion batterys. Lithium Ion batterys do not like to be discharged over 80% of their capacity.

I usually fly with a timer on my Transmitter. I will fly for 5 min and land.

If I just practice autorotations or stationary hovering piros then usually I only discharge 50% of the lithium ion battery. If I fly hard and really heavy on the controls I could go over 80% on the capacity in 5 min.

So I thought it would be nice to keep track of the milliamps I consume durring the flight.

My larger helicopters can do peaks of 100 amps while my smaller one would do peaks of 50 or 60 amps.

I would probably start the project on the smaller one.

It takes a 1350 mah 25 Volt Lithium Ion (Lipo).

Once 1080 mah is used up from the Lipo I would have to land.

I was thinking I would use a ACS715 with my ardiuno uno for testing at first.

I get the hardware portion of it and have seen several examples on the internet.

But I'm trying to get my head around the calculations in the code.

To get a amp reading from the shunt I think I would do something like this,

sensorValue = analogRead(analogInPin); outputValue = ( ((long)sensorValue * 5000 / 1024) - 500 ) * 1000 / 133;

133 would be the sensors mv per amp of current.

So "outputValue" would be a milliamp reading at that one instance.

So if I do this in a loop and take a reading every (10 ms) and add all my amp readings I should get total milliamps used?

I feel like I am missing something here.

I think I need to take my milliamp readings and compare them to total time to get milliamps used in flight.

Of course the next step would be getting the data from the aircraft to the operator but I will get to that later.

Thanks in advance

Mike

If you are consuming (say) 500mA now and 600mA later (10ms later) you could perhaps assume the average was 550mA for 10ms or 550mA * 0.01 seconds = 5.5mAs (and divide by 60 for minutes and 60 for hours).

You need to be careful because discharging at higher currents is harder on the battery. Or put another way 100mAh at a current of 1 amp is very different from 100mAh at a current of 50amps.

I wonder if it would be just as useful, and a lot easier, to monitor the battery voltage. And be conscious that the shunt will impact the performance of your motors. And it is not easy to measure the tiny voltage drop across a very low ohm shunt.

...R

They make OSDs with mAh usage displays.

The voltage drop is almost lineary correlated with mAh usage between around 95% charge and 80% charge. You could use a voltage divider to measure the voltage and then get mAh from that.

The other question is how are you planning on sending the data back?

Hi thanks for the replies.

Monitoring voltage doesn't work for me. I've tried it. It's because of voltage sag. The only way monitoring voltage would work is if I took a measurement of voltage with the helicopter at rest. IE: land and take a reading of lipo resting voltage. Helicopters are much harder on lipos so you get a big range in voltage.

Voltage monitoring works well in rc airplanes because you are at a more constant load.

So I would have to constantly be calculating my average mah per second to estimate how much more flight time I have?

As far as communication goes I might try blue tooth. I know the range is short but it could transmit to my TX whenever it is in range. https://www.youtube.com/watch?v=21653E-TDos

I would have to be careful using a radio freq because I would not want it to interferer with the actual helicopters radio controls

You can not directly measure mAh. You can measure current, but they use the principle of magnetic fields produced when the system current is put through a coil. Voltage effects the strength of the field so I can only assume it will give shakey ammeter readings…so bad mAh readings.

Edit: As V=IR, R is constant (we can assume in this case), I is dependent on V…if V fluctuates, so does I.

As field strength is proportional to I, by definition also V. So you can not use an ammeter to get a stable reading.

Oh and I have a quadcopter I use, I have one of those bleepy things than give sa low voltage warning. It seems to be faily reliable...I can hold the quad in flight and read it off from a few meters away and seems to be quite stable :S. It is an 80A monster.

Sorry for multiple post:

This seems interesting... http://www.rcgroups.com/forums/showthread.php?t=1919818

Johnny010: Oh and I have a quadcopter I use, I have one of those bleepy things than give sa low voltage warning. It seems to be faily reliable...I can hold the quad in flight and read it off from a few meters away and seems to be quite stable :S. It is an 80A monster.

hmmm small world. Yah I saw that sbus thing. But then I'd have to go from Spektrum radio to Futaba.

I've done voltage telemetry on helicopters before with Hitec telemetry and the concept just doesn't work with helicopters.

Say I have a low voltage alarm at 3.4 volts per lithium cell. At the end of the flight the resting voltage of a lithium cell should be around 3.75 volts.

I could be 1 minute into the flight and say I do a real hard collective move and I hit a low voltage alarm.

Am I suppose to land now? Probably not since I only have been flying for a minute.

Say I hit a low voltage alarm 3 min into the flight from doing a hard collective move. Now do I land?

Say I don't and I fly till 7 min with no voltage alarms going off. Then I hit low voltage alarm and now I am doing a continous 3.4 volts per cell. I land immediately and resting voltage is 3.6 volts per cell. I put 90% mah capacity back into the pack. Lithium batteries can't take that much, I'm sure you know this. So really I am looking for a solution that watches mah consumption.

Interesting project.
I have thought about something like that on and off for some time, so I thought I would give it ab try.

I don’t fly heli only fixed wing, so I use the battery voltage as a guide, but why not a mah gauge

I did a test with a 500 mAH 2 cell LIPO, and the sketch below.

As a current sensor I used a homemade resistor of about 0.5 ohm, and a light bulb to simulate the motor

With the battery fully charged the current was 1.55A and gave a reading of 39, thats why I used the mystic number 39.74.

I stopped the experiment when the sketch showed 20% used, and then I charged the batery.
I could charge 94 mA so not totally off.
I am sure it can be improved, f.ex.

  • Better calibrating
  • Using Internal Aref
  • A dedicated current sensor

Hey Erni

How often did you take an amp reading?

I was able to track down some code to modify using a SEN-09028 AttoPilot 90amp current sensor. You can get them at Sparkfun.
I have not gotten the sensor yet, so I just stubbed out the analogRead method to give me a random number
between 1 - 1024.
From the sample sketch I would get milliamps from sensor
sensorValue = analogRead(analogInPin);
IFinal = sensorValue/7.4;

A sensor value 1 = .14 ma
1024 = 138.24 ma

I am doing a read from the sensor every 250ms or .25 seconds.
I think I should do a read every 10ms but with the smaller helicopter that would be an average ma reading of
0.036 ma and the smallest reading the sensor does is .14 ma.
So that is why I am doing every 250ms and with the smaller helicopter that is a reading between .14 and 1.62 ma on average.
Maybe I should be using a different sensor? I went with the 90 amp because I thought I could use it on a small and large helicopter. The larger helicopter is capable of spiking 100 amps possible. But in normal flight the larger helicopter would probably
read 2.7 ma to 4.32 ma per 250ms

Also this sensor AttoPilot SEN-09028 is rated for a max amp of 90amps. What if the circuit goes over 90 amps for say a spit second? Does it just not read the current or does it burn up?

Fuel_Gauge_Sense_SEN-09028_90AMP.ino (2.17 KB)

amp draw.xlsx (27 KB)

Hi maarset,

In my simple test sketch I do a reading every millisec. aprox.
The interval is not imporatnt in my sketch because I use the total time per loop to determin the time I have used the measured current.

So if I do 1000 readings in 1.23 seconds I can compute the average milliamp/sec used in that period.
I have converted the mAH to mA/seconds to make the calculations easyer (I think)

I can see your problem with your High Amp sensor, not very high resolution.

My radio is a FrSky Taranis, so I will go after a FrSky current sensor, and by the way, as far as I can see it is plug & play:
The current reading gets send back to my Taranis, and all calculation will be performed in the firmware.

long elapsed_time=0;
float total_mas=0;
float total_used;
unsigned long capacity=1800000; //0.5AH = 500*60*60 =1800000 milliAmpere/sec
int x;
unsigned long mas; //milliAmp/sec
int sensorValue; 
long now_time;

void setup() {
  Serial.begin(9600);
  now_time=millis();
}

void loop() {
  mas=0;

  for(x=0;x<1000;x++){
    sensorValue = analogRead(A0);
    mas+=sensorValue;
    delay(1);
  }//for

  elapsed_time=millis()-now_time;
  total_mas=total_mas+((elapsed_time*39.74*mas/1000)/x);
  float total_pct=(100*total_mas)/capacity;

  Serial.print("mAs used ");
  Serial.println(total_mas);
  Serial.print("Capacity used ");
  Serial.println(total_pct,2);
  Serial.println("================");
  now_time=millis();
}

I gotcha Erni. Thanks. I posted in the Sensor section too. See if someone knew of a sensor with better resolution.

Do you like the Open Source Taranis? Are the Gimbals good quality? I've been researching the Taranis but I always wondered about the Gimbal quality. I have a JR9303 TX and the gimbals on that are way better than my old Spektrum DX6i. I tried a Futaba 8FG. Felt too light in my hands but the gimbals were amazing.

So I'm looking to get a futaba 14SG or Mikado Vbar Control TX to do a Mah fuel gauge if I can't get this to work. Or maybe a Taranis :P

I have been very pleased with my Taranis so far. I just bought it a couple of month ago.

I have a Futaba FF9, and a Spektrum DX7.

The Gimbals I think is as good as my old Futaba (I am not too critical so not the right person to ask :D), but the switches are more like Spektrum, they got that cheap feel and sound. I bought it because I wanted the telemetry. So far I have a vario sensor, and the voltage sensor is included in the receiver. I use it to monotor the battery voltage (remember I am a fix wing pilot). It can be used to monitor receiver voltage instead, but that is not very interesting as I always use BEC.

Good luck with your sensor project.

So I made some more progress with my project.

Got a serial LCD wired up. Still trying to figure that one out.

I hooked up a AttoPilot 180AMP to a couple of my helicopters.

I'm getting a voltage reading which is very accurate. But I am not getting a MA amp reading.

When I output the raw data from analogRead from the A0 port I always get 0. Tried a couple more analog ports on my Arduino Uno. Same results. I even moved a magnet near the AttoPilot with no changes. Always 0.

I wonder if I messed it up when I soldered it? Should a magnet simulate current?

So I'm thinking the reason my Attopilot 180Amp sensor is not outputting any amp readings because my amp draw is too low. Not enough resolution. So I should use maybe a Attopilot 80Amp. But I can't do that because I will have peaks over 100 amps. Don't want to burn it up.

So maybe I need to use a Allegro ACS758 Hall Effect sensor. But I'm not sure if it will have the resolution to read tiny amp draws.

This is starting to get to me.

SUCCESS!!!

So I came up with this idea of using my Lipo Charger which has the ability to discharge a fully charged Lipo into a Deep Cell Marine battery. I hooked up the AttoPilot sensor between the lipo and the charger. So the charger was acting as the load against the system.

Now I was getting an analog reading from the sensor for amps.

So previous tests of just running the helicopter under very little load was not enough to get a reading from the sensor.

With the charger discharging the lipo into the deep cell marine batter I can see in the Charger display how much MAH is leaving the lipo. And it is way off. My Program is showing more MAH coming out of the lipo than what the charger is showing.

This is what I am doing in the script. In my loop statement I'm reading the current from the sensor every 250ms or 1/4 a second.

delay(250); sensorValue = analogRead(analogInPinI ); IFinal = sensorValue/3.7; //180 Amp board RollingTotalMAH = RollingTotalMAH + IFinal; msCount = msCount + .25; // Seconds lapsed if ( (((int)msCount % 10) == 0) && (CalculatedMah == 1)) //print out total mah used every 10 seconds { Serial.print("MAH "); Serial.println(RollingTotalMAH); }

I think I am missing something. I think TIME needs to be involved in the equation since we are dealing with MAH or amp hours.

Mike