CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Battery capacity monitor for ROV
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
rovtech



Joined: 24 Sep 2006
Posts: 262

View user's profile Send private message AIM Address

Battery capacity monitor for ROV
PostPosted: Thu Jul 30, 2015 1:46 pm     Reply with quote

Can anyone point me to a C program to continuously monitor battery amp-hours, both in and out, and remaining.
I have tried searching here and the internet and found one for the Arduino but it is not really what I want and I would have to translate it anyway.
Even a flowchart would be useful.
It seems the best approach is a dedicated chip that continuously integrates the current then averages it and multiplies by time elapsed.
I have voltage and current monitoring already but that does not give me remaining battery capacity. My main PIC communicates bi-directionally with the surface and, using I2C, with three other PICs controlling motors and sensors. They are too busy to calculate battery capacity remaining unless someone can suggest a clever method. There has to be a reset when full charge is reached or errors will integrate to infinity.
rovtech



Joined: 24 Sep 2006
Posts: 262

View user's profile Send private message AIM Address

PostPosted: Thu Jul 30, 2015 6:32 pm     Reply with quote

I think I may have a scheme that will work. Unfortunately I can't post my flowchart image but I can describe it:

1. If the battery voltage is above 14 volts and the current in is less than 0.1 amps the battery is charged so set the AH to 12 (the capacity of this battery). Else continue to 2
2. Clear the variables Total and n
3. Read the Amps, Total=Total+Amps, n=n+1, make up the time to 100 msec.
4. If n<11 goto 3
5. Else 1 sec has elapsed so average the current Total=Total/10 and convert to AH by Total=Total/3600, subtract the AH by AH=AH-Total (Total will normally be negative so its sign should be ignored, if positive it should be added to increase the amp-hours)
6. goto 1

Its a start so I need to add the hardware and get programming.

I need to think about the polarities of the current as it may be positive or negative if the ROV is being charged while in operation. Also the AH could be positive and actually add to the total. Without charging the current will always be negative. It may not be possible to determine if the battery is fully charged with variable loads (often 20 amps) and charge current (up to 8 amps at 14 volts from 200 volts and an inverter). This is a smart battery that does not accept current once it reaches full charge. The shunt is in the negative leg of the battery.


Last edited by rovtech on Thu Jul 30, 2015 6:55 pm; edited 1 time in total
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Thu Jul 30, 2015 6:53 pm     Reply with quote

I have used the DS2438 in a couple of designs.
Might be something to look at.
_________________
Google and Forum Search are some of your best tools!!!!
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Thu Jul 30, 2015 8:26 pm     Reply with quote

Don't forget that you need to establish what the actual capacity of the battery is (not the published specs) if you want to accurately calculate available capacity (also the "capacity" of the battery changes depending on the current draw).

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
rovtech



Joined: 24 Sep 2006
Posts: 262

View user's profile Send private message AIM Address

PostPosted: Fri Jul 31, 2015 7:51 am     Reply with quote

Thanks dyeatman. I have been looking at the specs on the DS2438 and am wondering if the chip exists in my battery because it has a connector on it. Smart batteries don't say much about the battery and I had trouble even finding what charging voltage to apply. I have emailed them. (smartbattery.com SB12 for data sheet)
I have to be careful not to approach "empty" because the battery will shut itself down and I will have to pull the ROV up by the cable. According to the specs the discharge voltage is very flat and the capacity decreases very little (to 96% after 500 cycles and to 80% after 2000 cycles. How I would calculate "full" I don't know. What is a "cycle"? Is it 50% discharge or 100%? I don't know.
My plan is to assume the 12 AH (spec at 102% of this up to 100 cycles) and alarm at 80% so I have time to drive it up to the surface. Right now I'm guessing but the last use of 40 minutes only charged 2 amps for1.5 hours so it looks like 3 AH total. I was surprised and expected closer to 12 AH especially since I was seeing 18 amps discharge at full throttle. It sure beats the AGM battery I used before.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Fri Jul 31, 2015 8:46 am     Reply with quote

You said for use in an underwater ROV.

You do know that TEMPERATURE has a big effect on capacity
of L-ion batteries right ????

so from an on deck temperature of say 25 C you drop it in the water where as you submerge it gets colder. if you are only down for a few minutes - irrelevant -
BUT if it is a long mission you are losing capacity TWO ways.
One knowable based on discharge current.
The other hopelessly opaque .

curves like the one below don't encourage me that what you wish to know can be calculated with enough precision to matter.
note that 25 Cis the sweet spot and that both hotter, but
ESPECIALLY COLDER are not your friend

http://blog2.optibike.com/wp-content/uploads/2009/12/lithium-battery-temperature-vs-capacity.jpg

getting continuous V-I data from the batery pack may be the most you can hope for.

curves like this show the problem and the mission profile can only complicate it further........
http://www.google.com/imgres?imgurl=https://www.windows2universe.org/earth/Water/images/temperature_depth.jpg&imgrefurl=http://www.windows2universe.org/earth/Water/temp.html&h=731&w=600&tbnid=U1wXf9MgnroIuM:&docid=KNFpmYH5XgWftM&ei=DYm7Ve3SLom7-AGxoomACg&tbm=isch&ved=0CB0QMygAMABqFQoTCK2NmYDNhccCFYkdPgodMVECoA
rovtech



Joined: 24 Sep 2006
Posts: 262

View user's profile Send private message AIM Address

PostPosted: Fri Jul 31, 2015 9:57 am     Reply with quote

Thanks asmboy,
yes that is a slight problem for me. The worst case is -2 deg C because sea water becomes ice at that point and 80% capacity would be the least of my problems.
Practically the capacity is 92% at +10C and I'm not likely to use it in such cold water, more like +15C where the capacity is 95%.
Also I am sending charging current down. My 12/24 volt inverter for the motors, and the 200/14 volt charging inverter, do create heat which I blow with a fan to keep the front window clear. The few watts would not have much effect on internal temperature in the long run with the metal case sucking heat out.
I am monitoring internal temperature so I can adjust the AH remaining. Peukerts law can be ignored for these batteries and if I can believe the 99%efficiency I don't have to allow much for current IN, as I would with a lead-acid battery.
There is information on the smartbattery.com site if you click on the FAQ and other tabs at the top of the page. Data sheet does not seem to work. They replied to my email and said 14.5 volts for full charging so I can probably get more in. I was using 14.0 volts.
The first part of my flowchart is flawed; if I am operating at 5 amps discharge and charging at 5 amps the net current is zero and the software will think the battery is fully charged and reset the capacity to 12 AH. I think this initialization needs to be manually set after charging and before launching. I'm not sure what other battery monitors use.
The DS2438 seems horribly complicated but would keep a continuous record of charge state, maybe. I don't like the single wire comm as I use I2C for everything except to the surface (RS422/485 if I remember correctly). I already have an instrumentation amp on my shunt and a protocol for measuring current (0v=-25amps, 2.5v=0amps, +5v=+25amps). Moving one wire to a dedicated PIC is simpler than re-inventing the system.
Ttelmah



Joined: 11 Mar 2010
Posts: 19540

View user's profile Send private message

PostPosted: Sat Aug 01, 2015 12:28 pm     Reply with quote

First thing to understand, is that temperature is much more important than it appears. While it has a significant effect on capacity, it has a much larger effect on the relationship between battery voltage and state of charge. A battery that is half charged, at 0C, produces less voltage than the same battery 3/4 charged at 20C. You can produce a 'charge model' for any battery, with a multi dimensional relationship, of voltage, current, cell temperature, and age, versus state of charge. However it is complex.

Hence Coulomb counting (current*time), is used. However, the Coulomb counter approach tends to have progressive errors as the battery ages, and if charging is not always to the same point.

Have a look at the LTC2941, which is a typical IC to do this.
<http://www.digikey.com/product-detail/en/LTC2941CDCB-1%23TRMPBF/LTC2941CDCB-1%23TRMPBFTR-ND/2355189>

This is for much smaller batteries, but the same principles can be used.

This can be improved, by using rest periods to reset the points on the curve.

The descriptions at:
<http://www.mpoweruk.com/soc.htm>
and
<http://liionbms.com/php/wp_soc_estimate.php>

are a great start.

Now for what I assume are quite high current, using a Hall effect sensor for measuring current is much better. With this, and systems to measure temperature & voltage, together with EEPROM to remember past performance a really accurate measure can be built.

Manufacturers like Texas, do a huge range of products for this, ranging from single cell solutions for phones, to parts designed for things like electric cars:

<http://www.ti.com/lsds/ti/power-management/battery-fuel-gauge-products.page>

Select your battery technology, and number of cells, to narrow the range. Depending on your load, something like the BG24Z100 might well be applicable. However this is dependent on the battery having built in cell-balancing technology. The manufacturer of your battery is the first place to start. They should be able to recommend management systems.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sun Aug 02, 2015 6:31 am     Reply with quote

what also puzzles me is this:

If you have baseline power supplied by the tether cable
AND
the battery is there for PEAK current demands only
...
i assume the ROV buoyancy has a good range of engineered control -
then there exists the possibility of using a good old fashioned sealed lead acid cell pack with well known, pretty easy to characterize parametrics for charge/discharge. lt's really really CHEAP to swap out when it's tired.

In a first iteration, bedside boosted LVAD that i designed the electronics for, Pb-acid was my goto UPS backup// continuous power source and quite easy to safely evaluate for charge retention.
To say nothing of mid cycle charge-up/rundown stability.

That ancient technology worked very very well in the 21st century.

Re-engineering to get size and weight down with Li-ion was the bane of my existence...

What I and Mr. T have been trying to say, oh so gently, is that everything you already know or believe about rechargeable batteries is scant preparation for using LI-ion packs. ESPECIALLY in the specific way you want to do it.

The interaction of shallow charge /discharge and potential for low temperature excursions - during both charge and discharge-- is going to make a laughing stock of your best estimates of charge quantification.

Ask yourself why two posters who have had had direct experience with Li-ion
systems would go out of their way to caution you so strongly to be
CAUTIOUS and skeptical about with adopting LI-ion technology when low temperature was at issue.

Are you fixated on doing it the hardest way possible?
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Aug 02, 2015 8:39 am     Reply with quote

I have to agree that sealed lead acid would be my choice! Back in '84 when I developed our remote energy control systems it was vital to have a reliable backup supply for at least 8 hours. After a wee bit of research I decided on the SLA that Gates offered. Heck if it was good enough for the USN subs, it has to be OK for me. Gates presented lots of data about charging them, load curves,etc. All the nitty-gritty data that is VITAL to get the most out of a battery.I built into the power supply units an automatic load test with 2 setpoints( low and really low). 'Really low' gave me an hour to get to the building and effect repairs.
SLA is a well known device whereas Li-ion seem to be 'young'. Given the nature of your project, I'd go with SLA.

You might also look into using 'supercaps' if possible to smooth out the high current demands. Draining a lot of energy out of any battery is hard on them,reducing their lifespan.


Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19540

View user's profile Send private message

PostPosted: Sun Aug 02, 2015 12:01 pm     Reply with quote

I have to add one other 'caveat', about the Lithium battery technologies.

Look what happened to Boeing in 2013...

They tried to switch from Lead acid to Li-Ion for the flight battery packs on the 787. Spent a lot of time and research to get this 'right', yet as soon as it was used for real problems appeared. Small errors in design, coupled with poor inspection.

They _needed_ to have battery temperature monitoring on every cell. They 'ruled out' the possibility of thermal runaway, when it is a problem that needs to be considered with these batteries.

Amusingly (for some), as a separate thing, airlines still recommend water fire extinguishers for use on Lithium batteries. As a person who has seen what happens when you drop a 100Ah cracked Lithium cell into water, it makes me cringe gently....
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Aug 02, 2015 12:06 pm     Reply with quote

re: airlines still recommend water fire extinguishers for use on Lithium batteries. Idiots !

Doesn't surprise me though.. They never adopted my PIC based 'plane down pinger'. Prototype lasted over 2 1/2 years,unique ID,etc.
As the saying goes, you can't fix stupid ?

Jay
rovtech



Joined: 24 Sep 2006
Posts: 262

View user's profile Send private message AIM Address

PostPosted: Sun Aug 02, 2015 1:38 pm     Reply with quote

I lived on a sailboat for a year with a new set of Gel batteries and was not impressed. With hindsight I would have used golf cart batteries like other boaters were doing. That was 15 years ago so I do have experience. I resist new fads but battery technology has made a leap forward. If you have not tried the new LiFePO4 Smart batteries maybe you should.
The only advantage to using lead acid is that you get plenty of warning when the battery is low, which it usually is. A 12AH lead acid battery only gives 6AH of useful power. When the voltage sags in my application the 24v inverter draws more current to keep the motor voltage at 24v, eventually there is a runaway situation and the battery is dragged down below operating levels and I lose control until I shut down and reset. The lead acid battery only gives 300 cycles of deep discharge to 50%. They also give far less if high currents (12 amps) are drawn.
The 12AH LiFePO4 gives 12AH at 12 amps dropping to 11.5AH after 500 full cycles of 100% discharge and are still useable with 80% capacity after 2000 cycles. OK I don’t believe everything I read so it may not be quite that good but I am comparing specs of the two batteries.
I bought the wrong LiFePO4 battery that was intended for starting motorcycles and not deep discharge. It self destructs if it is discharged below 8v and that is exactly what happened. There was no such warning on the battery or specs and I only found out be speaking to an engineer trying to find out what happened. The one I have now is protected and shuts down before that point and is designed for deep discharge.
I swapped out a new AGM (Advanced Glass Matt lead acid) for the new battery, added 6 lbs of ballast, and got a huge improvement in performance.
I need something better than a stopwatch to make sure I can bring the ROV to the surface. It has to be a modification I can do in a day or so, life is too short to re-design everything. Battery voltage cannot be used because the drop is too sudden.
The ADCs on the PICs I use only handle 0 to +5v, not negative inputs. My shunt amplifier offsets the output so 0v is -20 amps, +2.5v is 0 amps, and +5v is +20 amps. My plan is to loop n times and add the current, then divide by n to get the average current. This can be in 8 bit binary especially if n is a multiple of 2. Now to get the real amps I subtract 128 from the result if it is above 128, or subtract the result from 128 if it is below 128. This gives the number of bits above or below 128 (current in or current out). The range -20 to +20 amps is 40 amps so I multiply this number of bits by 40/255 (amps per bit) to get actual amps. This is divided by the time for the measurements to get ampere-hours which is added or subtracted from the total remaining AH. A crude adjustment for temperature can be factored in and perhaps a factor for # of cycles like two DIP switches connected to the PIC. I don’t have a keyboard or non-volatile memory at present.
I appreciate the suggestions of the dedicated chips and would consider them if I was making a commercial product where weeks of work and re-design was warranted but I have a working system and want to keep things simple. I asked why a shunt manufacturer was still selling them to the USA and China and was told because they were more reliable and rugged than Hall effect sensors. They sell millions of dollars of shunts so there must be a reason.
I had hoped someone had written some software to do this, even with a special chip but I am nearly there and will post the code when working. I may even put the battery in the 'fridge and charge and discharge it to see what happens (4 deg C).
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sun Aug 02, 2015 3:25 pm     Reply with quote

re"'fridge and charge and discharge "

i do like your determination.....
if i was testing this, i would:
* charge to believed "full" state at 25 C
* put system with battery into fridge connecting a motor equivalent tuneable load element such as the ELTEST EL2A-LC or DATEL DTL2A-LC ( same part really)

http://pdf1.alldatasheet.com/datasheet-pdf/view/194101/ETC2/DTL2A-LC.html

* run fake profiles with the vari-load on a heat sink outside the fridge while doing the sort of charge dance you expect to do in the icy deep.

the vari-load is easy to program with another PIC and SPI control
for peak current drains of up to 20 A

and see what happens over some long cycling of the battery

i have a large quantity of these programmable current loads -- and have found them a priceless aid in testing load - line performance for quite some time.
rovtech



Joined: 24 Sep 2006
Posts: 262

View user's profile Send private message AIM Address

PostPosted: Sun Aug 02, 2015 6:59 pm     Reply with quote

I have a programmable load but a power resistor is much easier. the discharge curve is quite flat and an average of start and stop current is close enough. It's not like the lead acid battery discharge that goes down to 10 volts for discharge. I don't want it below 11.5v so a lead acid battery is pretty near useless to me and has demonstrated that in real life experience. The LiFePO4 battery is great but you all make a good point about temperature of which I am aware. One of the first things I found on the internet was a sad story of a guy who parked his electric bike in the open in winter and soon after starting for home the battery shut down. My idea of exploring is in the Bahamas in water I can swim in.
Yes, start with a warm charge, place in 'fridge overnight, then discharge and count th AH which is really what this project is all about.
Next charge and count AH to cutoff, then discharge and count AH. I may even do it with the AH meter. I have the PIC working with a graphics display to monitor what happens and am workng on the AH program.
I will let you know how it works.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group