Shop OBEX P1 Docs P2 Docs Learn Events
Battery Minder and code for Propeller — Parallax Forums

Battery Minder and code for Propeller

GamekillerGamekiller Posts: 5
edited 2007-12-06 15:18 in Propeller 1
Well i am back again to see if the public can help me. I first want to thank those that help me with the serial problem i was having. We got that all working.

Now on to a new topic "Battery Minding" and how it may be done.

We are looking at having the propeller monitor how much power it has left on its power supply and on the main drive unit batteries. I am new to a lot of this but i know it can be done.

I wanted to see what people have done out there so i do not have to reinvent the wheel.

Cheers,

Andy turn.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
to mod or not mod. That is the qestion.

www.jambot.com

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-03 07:06
    Download the application note on the use of the counters (AN001) from the Propeller Downloads page. It describes (and gives code for) an analog to digital converter using two resistors and two capacitors (and two I/O pins). Your battery voltage is probably much more than the 3.3V maximum so you can use a simple voltage divider to reduce the battery voltage to something in the 0-3.3V range.
  • Nick MuellerNick Mueller Posts: 815
    edited 2007-12-03 09:13
    > We are looking at having the propeller monitor how much power it has left on its power supply and on the main drive unit batteries. I > am new to a lot of this but i know it can be done.

    Short answer: It can't be done.

    Long answer: You need to measure the current drawn out of the battery and integrate it over time. If the load is varying a lot, you also need correction factors (high load, less consumable capacity).
    Just measuring the voltage is not enough because batteries are designed to have a as much as possible constant output voltage over their live.

    There are special chips available to do the job. Formerly they were from Benchmarkq ("bq") and are now from TI? Sorry, no part numbers in my brain.


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-03 15:19
    Sorry to disagree. It can be done just measuring the voltage. It's just that having the voltage alone is of limited use.
    Each type of battery has a characteristic discharge curve of voltage over time that's affected by the internal resistance
    of the battery and the temperature (and the internal resistance interacts with the discharge rate). In your case, you
    know what kind of battery you're using (probably either lead-acid or NiMH) and what its rated capacity is. You can
    create a table for your battery based on the characteristic curve of voltage vs capacity and estimate where along the
    curve you are. Because the battery load will affect the voltage and you have no current sensor, the estimated charge
    will vary with load, but since the Propeller is controlling much of the load, you will know when there's a light load and
    you can measure the voltage at that point. You can also estimate the drain based on the amount of time the large
    loads are on. Once the Propeller sees the "knee" in the curve that occurs when the battery is nearly exhausted, it
    can correct its estimates for next time (and go into a low power mode asking for a recharge).
  • Nick MuellerNick Mueller Posts: 815
    edited 2007-12-03 15:46
    > Sorry to disagree. It can be done just measuring the voltage.

    It can't be done.
    Allone the influence of the temperature is so big that it is simply useless. Also, the time between end of charge and measuring the voltage has a huge influence.
    For the relation between capacity and voltage (depeding on storage time after a charge): Between 20% and 80% of remaining capacity, you have a voltage drop of as little as 0.05V.

    Ergo: Forget it!

    <http://us.sanyo.com/batteries/pdfs/twicellT_E.pdf&gt;


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • deSilvadeSilva Posts: 2,967
    edited 2007-12-03 16:09
    There are many diagrams available... just study them and try to find an algorithm... Batteries differ enormiously wrt temperature. And they also "age"..... Lead batteries are the most promising kind...
    The diagram I enclose is from some Duracell NiMH cells..
    446 x 317 - 17K
  • RaymanRayman Posts: 14,221
    edited 2007-12-03 16:23
    I does depend on the type of battery. But, there are plenty of devices that just go by the voltage alone... You may think about using the Prop to put a load on the battery while making the measurement, because this is usually more reliable... The trouble is that many battery types will give just about the same voltage right up until they're about to die (lithium batteries are like this). I've found that lead-acid battery voltage is a good indicator of charge, on the other hand. I think that NiMH is about the most complicated type...
  • deSilvadeSilva Posts: 2,967
    edited 2007-12-03 16:30
    No, the most complicated types are the about 20 different kinds of Lithium types smile.gif
  • Sleazy - GSleazy - G Posts: 79
    edited 2007-12-03 17:56
    Theres a really good selection of battery gas gauge / power management by Texas Instruments.· They ususally run off of I2C so you can just go to the object xchange to get an object to read it pretty easy.·Remember·you can have a common bus between the I2C components, so they use up less pins.··I saw one product·there·that would take LI-ion and NiMh and NiCd and alkaline all in the same chip.·Pretty sweet. There are some super crazy battery authentication IC's at the·TI site too.· Good luck finding one in·DIP to prototype with, most are really small outlines.· However, you can get populated evaluation boards that have the chips mounted for you.··Maxim dallas has some nice versions of the battery supervisors , specifically one that allows for simultaneous charging·/·operation.·

    See, Li-ion battery voltage vs. discharge from what I understand is quite more unstable than the conventional types of cells.· Some recommend a buck-boost dc/dc converter to keep the voltage more "linear" or "regulated".··The·in line 3.3v regulator on the protoboard is quite inefficient and should only be viable when·wall power is available.· You might have to worry about the voltage ripple at the output, but most·modes can be snubbed with a rc branch. These sili chips hate noise and get scrambled.·and check out Maxim-ic.com's "power supply cookbook" for a slew of small switched power supplies of all sorts.·

    I actually like TI's tps61081 charge pump·for "regulation".· You can use 1 or 2 li-ion cr-123a cells from parallax's accessory page (very cheap by the way, and rechargable). With the TPS and a few small external components you can get 50v @ 50mA from 2 Li-ions , with efficiencies of about 80% +.· The output of the TPS can also provide 24v, 12v, 6v, and anywhere inbetween with just a few resistors in the circuit to change.· Get a good bulk cap for the output , matched to your instantaneous current demands,· And if your batteries (2 in series) start to lose voltage , the pump will take 3 to 6 volts and can·produce the same output voltage if you can actively change its resistors. Try using a digital pot from the parallax accessory page. ·If you use this method, you can get alot of flexibility out of your battery pack .·

    Theres also a zillion app notes on stuff like this on all kinds of sites.

    i think maybe some experts are floating around in this area.· You can consult maxim-ic's 24hr turnaround design advisors thru email.· They wont respond unless you sound knowledgeable.

    ·
  • ohararpohararp Posts: 24
    edited 2007-12-05 03:38
    Sleazy, how do you go about mounting the 10 SON packages.· Any secrets you want to share?

    Ryan O'Hara
  • Mark BramwellMark Bramwell Posts: 56
    edited 2007-12-05 05:18
    A hint based on an older Basic Stamp project...

    We were trying to determine battery power levels based on rechargeable batteries. How do you measure your own battery voltage? A voltage divider based on 2 resistors always gave the same readings as the voltage decreased. Why? The A/D converter is based on percentage of the supply voltage. If a voltage divider based on 2 x 10k resistors was used, the mid-point always showed 1/2 of the supply voltage, no matter what the supply voltage was at any point.

    The problem was solved by using a zener diode and a resistor as the divider. Since the diode always had a constant drop voltage, the resistor showed what ever was left over and decreased in step with the batteries. At a certain point we are able to put the micro into sleep mode or at least stop using the high powered devices (which were LEDs).
  • simonlsimonl Posts: 866
    edited 2007-12-05 14:09
    Nice one Mark smile.gif Would you mind sharing the circuit diag?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,

    Simon
    www.norfolkhelicopterclub.co.uk
    You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
    BTW: I type as I'm thinking, so please don't take any offense at my writing style smile.gif
  • Nick MuellerNick Mueller Posts: 815
    edited 2007-12-05 14:26
    > The A/D converter is based on percentage of the supply voltage.

    That's why it is common practice to supply the ADC with a regulated voltage, use one with an internal reference or build an external reference.


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • DroneDrone Posts: 433
    edited 2007-12-06 15:18
    Hi Andy, Let's take a step-back...

    I've looked at this issue of battery "health" and "capacity" monitoring in the past. It is a difficult subject. But in doing so, I started to ask some basic questions:

    What is needed? I believe what is most often needed is a way to store data to non-volitile storage before a battery fails. By "fails", I mean voltage is dropping below the point where the system's voltage regulator can't supply the proper voltage and current necessary to keep the system up. In this case you need to sample the system's battery voltage before any regulators and make a decision when to store data to non-volitile memory and either shut the system down in an orderly way or just let it die on its own without adding possible bad data to non-volitile storage in the process.

    If the system is exposed to anything other than room-temperature environments, then you need to reference your A/D or comparator to a temperature compensated voltage reference. There are lots of parts out there for this and some A/D's include them on-chip. Yes there are sophisticated battery managment application-specific parts out there, but I'm talking in a more general sense here...

    For "Human life-critical" systems that have to be "in the field" the battery health is typically determined at the charger. The "Smart" chargers test the batteries for discharge characteristics against battery time in-use and even "recondition" the batteries when needed. Smart chargers have methods that can predict when a battery needs to be changed/serviced, hence warning the user before a system is taken out to the field if battery failure is pending. This kind of strict battery management typically requires predictable battery types and chemistry, not user changeable generic AA-like cells.

    However, there is another approach that is somewhat risky, comparatively simple, but relatively costly: If you're willing to spend more money on batteries, supply enough cells to always supply enough voltage in-case one (or more) batteries fail so the system keeps running. Then do a simple battery voltage test and monitor what happens to the battery voltage over "power on-time" and code an algorithm based on a trigger voltage that decides: ok, we were up for six hours on battery yesterday, but today we're up only three hours - result being: "Alert Will Robinson, Battery Pack May Be Bad!" You need non-volatile storage for this, but not necessarily a real-time clock.

    This approach tells you when your battery pack is failing, not when your battery pack is so low failure is about to happen. This approach doesn't work well with higher current systems that use linear regulators, the higher battery voltage just ends up as heat dissipated in the linear regulators, use switchers instead.

    Another consideration: These days, relatively efficient step up switchers are available that can take every last drop out of a lower voltage battery pack and keep your system up. As always complexity = cost, and you still have to manage things as described herein.

    I suggest you make a decision-tree that outlines exactly what you expect from your "Battery Minder". This will help you & help us help you.

    When you get close to defining what you want to do in power management, I suggest you look at parts from www.linear.com and dowload Linear's completely free LTSpice/SwitcherCADIII general purpose Spice simulation application (of-course Linear's excellent devices come pre-packaged as models in the simulator). There's a good user forum for LTSpice/SwitcherCADIII at tech.groups.yahoo.com/group/LTspice/. I try not to push one vendor's general solutions over another, but Linear Technology has given so much back to the the electronics engineering community with the free LTSpice/SwitcherCADIII, that it deserves mention.

    Best Regards,

    David

    Post Edited (Drone) : 12/6/2007 3:28:49 PM GMT
Sign In or Register to comment.