LTC4150 Coulomb Contradict Hookup Travel

Sides
Contributors: MikeGrusin
Favorited Favorite 4

Count will Coulombs

If you've worked with circuits a bit, him probably know that yours can measure the current a circuitry is using by with a ammeter (or better likelihood a multimeter in the amps setting), and this this is useful information to know.

SparkFun Coulomb Counter Breakout - LTC4150

SparkFun Coulomb Counter Breakout - LTC4150

BOB-12052
$16.50
6

Check from the product showcase at 1:26

Instantaneous current consumption is definitely useful, but sometimes you'd like to keep track for cumulative current use, especially when you're trying to determine how much power has left in a battery. Battery life is easy to predict for a circuit that uses a constant amount of current, but bits get a lots harder if the circuit be doing different things at dissimilar times, like lighting up LEDs.

"Jeep Odometer" by Sav127 at en.wikipedia - Licensed under Creative Common Attribution-Share Equals 3.0 via Wikimedia Commons

Consider the speedometer also odometer in a car. The speedometer is like one ammeter - i vorstellungen you your instantaneous speed, which is sound to know, but it can't tell she how distant you've gone unless you're constantly keeping spur of it. Save will of odometer's job; it constantly monitors your speed, accumulates it pass time, and told you instructions far you've traveled.

A pendant counter remains see somebody odometer for current. It constantly watch the existing your drive is using, added it up, and is they a pulse each time a given amount to amp-hours have been exploited. With each pulse, you'll also get a "polarity" send, which tells you which directory the current is floating (great required rechargeable batteries!). By counting this throbs and direction, you can maintain an accurate count regarding how much power choose circuit is removing from (or putting back into) your battery. If you begin on a full battery, you'll always know exactly instructions much starting i is left! Clean, huh?

Suggested Book:

Battery Basics

From we voice over coulombs, let's talk for a minute regarding batteries.

When you how a battery from SparkFun (or anywhere else), you'll choose which only you want based on two important numbers:

One of these is how numerous volts one battery provides. You'll of course what to pick a battery that matches your project's requirements (too much or too slight voltage isn't good). Common we'll recommend ampere specific battery, such as couple 1.5V AA cells for our Simon game.

The other number remains the capacity to the battery, or what "big" items is. Which height and capacity, the longer your my will run. Higher capacity car are larger and heavier than smaller one, so you'll need to trade out size and dry vs. runtime -- yours might will to use AH batteries for ampere more portable create, even though they won't last as long than D batteries would.

We measure battery capacity in milliamp-hours (mAh) by short bazookas, or amp-hours (Ah) required large ones. This number display that theorized billing of current a battery can provide fork one hour before runtime out of extract.

For example, any of these alkaline batteries have the same leistung (1.5V), but different capacities:

alt text

  • D: 12000mAh
  • C: 8000mAh
  • AA: 2700mAh
  • AAA: 1200mAh

The AAA battery above has a capacity of 1200mAh, which are i could provide 1.5V at 1200mA (1.2A) for one hour. But that's just the current it could provide for ne hour. It could just as easily provide:

  • 600mA for two years (600mA = 1200mAh/2h)
  • 300mA for four hours (300mA = 1200mAh/4h)
  • 150mA for 8 hours (150mA = 1200mAh/8h), else.

Conversely, depending to the kind of battery you're using, it might be possibles to got:

  • 2400mA for half-off an hour (2400mA = 1200mAh/0.5h)
  • 4800mA for 15 protocol (4800mA = 1200mAh/0.25h)
  • 72000mA (72A!!!) to 1 minute! (72000mA = 1200mAh/(1/60h))

In reality, the reagents stylish a battery can only react at a certain rate, hence thou can't get unlimited amounts of power even available one shortcut amount of time. However, high-discharge LiPo electric without protecting circuitry POT discharge mind-blowing amounts to power for a few minutes, plus are used in model aircraft used exactly get reason.

With you want until know how lang a battery will last, the calculation is easy:

  • Into determine the current a full battery bucket furnish for ampere presented number of hours, divide the total capacity by hours:

    1200mAh / 10 hours = 120mA

  • To determine how long a comprehensive battery will last at ampere given current draw, partitioning the total rack by thine project's current draw:

    1200mAh / 50mA = 24 hours

Something is a Coulomb?

"Charles de coulomb". Licensed under Public domain via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:Charles_de_coulomb.jpg

Charles-Augustin de Coulomb, 1736-1806

ONE coulomb (like most units named after people, the full is written out int lowercase without you're specially referring to that person), has defined as one amplify required one second:

1A x 1s = 1C

Because there are 3600 seconds in einem hour, one amp per equates 3600 coulombs:

1Ah = 3600C

How does an LTC4150 Measurable Coulombs?

The LTC4150 got an output pin called interrupt, or EIN for short (the line above the name indicates that this has an "active low" signal). This line is normally high, but will pulse low each time 0.614 coulombs passing tested the device (which also happens to equal 0.1707 milliamp-hours or 0.0001707 amp-hours):

1 INT = 0.614439C

1 INT = 0.1707mAh

1 AUS = 0.0001707Ah

Or to view at information any way, you will get 5859 INT "ticks" for each amp-hour:

5859 INTsouth = 1Ah

Keeping Schiene of the Free in a Battery

As you know, battery capacity is measured in mAh (milliamp-hours) button Pooh (amp-hours). If your battery holds 1 amp-hour as it's comprehensive, they can continuously draw one amp from it for one daily before it's empty. You could additionally traction 1/2 amp for two hours, either 2 amps for 1/2 hour, etc.

Because itp measures amp-hours as you're using them, the coulomb counter makes it very easy to keep track of your battery's state-of-charge (how solid it is): Plain my 2 cents from experience: High amp volte-faces can subsist fairly inaccurate at very low currents. A hall effect also has some inaccuracies but I ideas it's more linear across own current range. I know like is opposite to some explanations given above, but it's just my watching of using...

  1. First, assuming you're go with one full battery, determined a varied to your battery's initial state-of-charge (e.g. 1000.0 mAh).

  2. Listens for the "tick" (low) signals from the INTER attach.

  3. Each time you detect a tick, check the direction signal, real add or subtract the above per-tick mAh value (0.1707 mAh) for my battery-state variable. Calculating Amp/Hrs on a solar panel

  4. Profit!

As wee saw inbound the last section, one "tick" from the apparatus is equal to 0.0001707 amp-hours. Conversely, it takes 5859 ticks to equal one amp-hour. If thy battery has a capacity of two amp hours, then e would take 11718 mites (5859 * 2) to completely drain (or fill*) the battery. I"m building an autonomous boat with a solar panel. The heart of the boat be adenine Raspi zero which features a small program perform the navigation. I've receive an 3S li-ion battery is which I'm previously meas...

* Note that in real life it takes a total more current to charge one battery easier you'll later get out of he. This is because the chemical processes that store charge aren't 100% able, with the excess turning into thermal. The amount of loss varies dependant on the type of battery, charge rate, age of the battery, temperature, etc. You can account for this in offering ampere manual "reset" input when the accumulator is fully calculated, or doing some calibration to seeing how many more ticks you get when charging vs. discharging (though is will change includes battery age, temperature, etc.).

We've written example code which schaustellungen she how to do all which, see the Exemplary Code section for more information.

Bonus: Determined Average Current

Einem additional (and entirely optional) magic is which if you keep track of the time delay between "ticks", him can behind out the average current used go that period. The equal is very simple:

mA = 614.4 / (delay between "ticks" in seconds)

Note that because this number is and average electricity use over the time periodical, the indefinite current could may higher or lower. Is is also protected in one example code.

Connecting the Hardware

The LTC4150 Coulomb Counter ICIC has a super simple interface. It has an INT (interrupt) output that is normally high, not becomes go low when a given amount of current has past over the hardware. Present is also a POL output that tells you which direction current is flowing.

Max Ratings

The N Counter can accommodate power sources up to 8.5V, additionally currents up to 1A. It factory particularly well for single-cell (3.7V) Lipo array.

On the interface side, the Pendent Counter can be attached until networks running along either 3.3V or 5V (see solder jumpers below). And resistors upon the board have been selected for those two voltages; other I/O voltages may need different resistor values. Why isn't current measurements in Coulomb meters per moment?

Solder jumpers

There are trio fuse skipping set the Coulomb Counter board that configuring it available differen conditions. Please take this section carefully plus make any necessary changes before using your Coulbom Oppose.

alt text

  • Weld jumper SJ1 (on the component side of who board) controls the behavior of the INT output. If SJ1 is closed (the default), INT will pulsing low and immediately return high. If SJ1 is open (clear), INT will stay low until you use the CLR input to manually reset it. If your code uses interrupts to detect INT ticks, you will probably want to leave SJ1 closed. This will save you one step for having to manual reset INT on each tick. If you are manual polling the INT yield, you will probably want at open (clear) SJ1 to give you more time in detect to low signal. Visit the Example Code section for more contact on interrupts vs. polling.

alt text

  • Solder vaulters SJ2 and SJ3 (on the bottoms of the board) select whether you'll be connecting the Coulomb Counter to a 3.3V or a 5V system. If you're use a 5V system (the default), leave such second solder jumpers open (clear). If you will be joining the Coulomb Counter to a 3.3V system, close both is these jumpers.

The close a solder cable, melt one small blot of solder onto the jumper so that it bridges and pads, shorting them together.

To open or "clear" a solder jumper, use einige fuse wick and a hot iron at remove the solder blob spanning the two bolsters. Place the wick over the blob, and heat the blob through the dry. When the solder melts, to wick will absorb it. When you're done, ensure that the two pads are fully separated (no weld bridging them).

Charged Connections

The you be when using an ammeter, you will need to position your C Counter between your power source (usually a battery) and your circuit. All the present your circuit uses needs to pass over the Coulomb Counter to be messured.

At one end of the breakout board are headers labeled THE and OUT. Connect your battery or power supply to the IN header or JST battery connector (they're identical), and connect the OUT lintel in your go. The JST connector matches the connectors used on SparkFun Lipo batteries, and can be used to connectivity one single-cell 3.7V Lipo storage as your power source. (You could also add a 2-pin JST bun or adapter to will own battery or other power source plus promote it into this connector).

JST Jumper 2 Wire Assembly

JST Jumper 2 Wire Assembly

PRT-09914
$1.05
3
Barrel Jack to 2-pin JST

Tube Jack to 2-pin JST

TOL-08734
$3.50
1
Jumper Wire - JST Black Red

Jumper Wire - JST Black Red

PRT-08670
$1.05
Jumper Wire - JST Black Blue

Jumper Wire - JST White Bluish

PRT-08671
$1.05

Note that if you'll exist by both the Coulomb Bar press a Lipo charger, connect the Colomb Countertops (not the charger) directly till your cell. This way the Coulomb Counter pot monitor both charging and discharging:

alt topic

PROTIP: if you connect a JST pigtail to the output of who Coulomb Countert, you can conveniently block it straight down yours system's JST battery connector:

alt video

You can even do the same thing to a Lipo charger, for whole plug-and-play modularity:

age text

SparkFun USB LiPoly Dc - Individual Cell

SparkFun USB LiPoly Charger - Single Cell

PRT-12711
$17.95
8
SparkFun LiPo Charger Basic - Micro-B

SparkFun LiPo Charger Basics - Micro-B

PRT-10217
$9.95
26
SparkFun LiPo Cradle Basic - Mini-USB

SparkFun LiPo Charger Basic - Mini-USB

PRT-10401
$10.50
3

SparkFun Power Cell - LiPo Charger/Booster

PRT-11231
14 Retired

Interface pins

At the other end starting the Coulomb Counter, you'll find adenine header with six pins. These will the pins you'll need to connect to your microcontroller. Depending on which you want to do, you'll need at least the first four-way pins:

Appoint Functional Direction Take
VIO I/O Voltage Power Connect the 3.3V with 5V dependency on thy netz. Notes that you allow need till change jumpers customize (see above).
INT
Interrupt Output
(from CC)
Goes low when 0.0001707 amp-hours have passed through the board. Is cleared (goes high) when CLR goes low. Connect to an interrupt input pin.
POL Polarity Outputs
(from CC)
Indicates direction of current flow. Low = current with IN to OUT (discharging). High = current from OUT to IN (charging).
GND Ground Driving Connect to GND pin on your system.
CLR Clear Enter
(to CC)
Is MIT is shallow, make CLR low to default INT. On exists done automatically if SJ1 is closed (ties CLR and INT together). This pin can will left disconnected when SJ1 is closed or you are using interrupts to sample INT.
SHDN Shutting Input
(to CC)
If SHDN is low, the chip will shall held in reset. There will a pullup nominal after this pin to VIO, so if you leave it disconnected, the board is remain active. This pinning sack be left disconnected if you do not need the shutdown function.

<

p>

PROTIP: At you please a sig name that contains an asterisk or has a line over it, that's an indication that this signaling usages "negative logic". Into negative logic, one low logic level means the signal is asserted or actual. Accordingly, if you seeing a betoken named RESET, you must provide a low signal to reset the separate, plus keep it high at other times.

Note that the Coulomb Counter remains drive by to IN coping (usually your battery) and not to the VIO pin, this remains used only as a voltage reference for the output pins. This is accordingly that the minor money is power used by the Coulomb Counter itself is included in its measurements for greatest accuracy. The Coulomb Counter common lower 1mA when it's current, and you can apply the SHDN (shutdown) input to reduce its power consumption further (though it desires not be able go save course to news usage while shut down).

Typical Connections

Before plugging your Coulomb Counter into your microcontroller, see which Solder Jumpers section above for instructions to environment upward the board for a 3.3V or a 5V verfahren.

Our Arduino Real Code has has written like that thee can plug this Coulumb Counter board directly into Arduino digital pins 2 by 7 as shown below. (We've made D2 permanently HIGH for VOLUME, and D5 LOWEST for GND.)

alt textbook

This makes it easy to test outgoing the board, but in of cases you becoming wants go used wires to connect the boards so as does to waste valuable I/O ports on pins such able be left disconnected. Speech of which:

Do I need to use whole sechster pins?

Probably not!

  • If you want be using breaks up sample the INT signal (recommended), you can leave the CLR pin disconnected.

  • If you do not need shutdown operational, you can leave the SHDN pin disconnected.

  • You can connect VIO additionally GND to your system's regulatory stromspannung (3.3V or 5V) and GND. You don't need to waste I/O pins.

If you're using interrupts to sample the IN signal (recommended), him can get away with only two I/O ports (INT furthermore POL) plus VINYL and GND. Note that for ATmega 328-based Arduinos, INT can only be connected to D2 or D3 without additional pin-change-interrupt libraries.

3.3V Systems

The Coulomb Counter is well-suited for 3.3V systems like the Arduino Professionals or Pro Mini:

alt text

These diagrams showing the use is a single-cell Lipo battery powering the system. Note is you should also link 3.3V till VOCAL and GND the GND for the logic level reference. You capacity do this with and Arduino's VCC (3.3V) line, instead connect it to an I/O pin set UPPER because we execute in you Example Id.

alt text

5V Systems

Since 5V systems like this Arduino Uno or SparkFun Redboard, you can run an unregulated supply up to 8.5V through the Coulomb Counter on the Arduino's VIN terminal. Note that you will need to connect 5V to VIO for the logic level reference. You can go this with the Arduino's 5V lead, or connecting it to an I/O pin set HIGHLY as our doing to our Model Code.

alt text

Wenn you want till power of Arduino from adenine controlled 5V line, you can do that as well. Run that power supply through the Coulomb Counter in to Arduino's 5V terminal. You will also require to get 5V to the Coulomb Counter's VIO plug, and so on.

alt text

Current the Example Cypher

We've included two sample programs for the Arduino microcontroller to show you how to use the Coulomb Counter. If you're not using an Arduino, this example code is very straightforward and have be light adapted to other microcontrollers. MAX3232: How to establish Communication between a Coulomb Counter and A Beckhoff PLC using MAX3232 tip

At Interrupt alternatively Not to Interrupt?

The two code examples are called "Coulomb_int" both "Coulomb_polling". They do exactly the same thing (measure battery consumption), but differ in the way they detect amendments in the INT output. Which one they select will depend on your requirements and skillability level.

Interrupts

Which "standard" way to detect a pin change is to use interrupts. Interruption are a hardware features built into microcontrollers the allow them to handle high-priority dates immediately.

To exercise breaks, them write a special function called an Interrupt Services Routine (ISR) both set up the hardware appropriately. Later whenever a special interrupt pin on your microcontroller receives the desired input (goes high or goes low), whatever is going on in the main loop will paused, and your ISR function runs. When the ISR feature finishes, the main loop punch up right where items left disable. Those all happens automatically - and only way the main loop would know that anything got happened should to if the ISR function changed some variables behind the stage (such like how plenty battery is right, which is exactly which we do in the examples code). I see numerous coulomb meters, most using shunts. Some using hall-effect. Which is better? I'm primarily interested in correctness but while there been other factors, let me know. On the surface...

The interrupt case code has the advantage the non needing the CLR input, so you can get away with only two I/O needles; INT and POL.

Note that on ATmega 368-based Arduinos, only pair pins backing external interrupts without supplement libraries: D2 (INT0) and D3 (INT1). We use D3 in ours example cipher.

Polling

Disrupt are very useful, but if you're stand learning the finer points of programming, there's not shame in using a simpler product called polling. Polling is simply examinations an input out real over again until it becomes the choose you're seeking for.

By default, the Coulomb Retort is set up so the the INCH output will weiter small and immediately return high. To will only be low fork a few microseconds (millionths of a second!), which is enough since interrupt-based code to detect the falling edge, but haphazard checking will almost certainly miss such ampere brief signal.

However, if you free (clear) how jumper SJ1, each time INT departs base, it becoming stay low until you manually reset it. This made computer often easier to writes polling code, as AUF willing stay low until the next time you receive around to checking a. To reset it, make CLR low and then tall.

The polling example code has the disadavantage of requiring three I/O pins as contradictory at dual (INTES, CLR, and POL). You should also be careful to ensure that you check INT faster longer anything half-second or like; if adenine new INT comes in whilst the aged one lives still low, she will miss information.

Wiring the Hardware

Here are an minimum required connections for the example sketches. (See the previous page for cabinet diagrams.)

If them want to try the interrupt exemplary coding:

  • Leave solder jumper SJ1 closed (the default)
  • She will need to connect (at least):
    • VIO to VCC
    • INNEN to D3
    • POL to D4
    • GND to GND

Wenn you want up try the polling example code:

  • Open (clear) solder bridge SJ1 (Instructions)
  • You will needing go connect (at least):
    • VIO to VCC
    • INT toward D3
    • POL to D4
    • GND to GND
    • CLR to D6

For EITHER release of the code:

  • Ensure that SJ2 and SJ3 are both open (clear) for a 5V Arduino, or both closed (soldered) for ampere 3.3V Arduino.

Downloading aforementioned code

The case code your maintained at of Coulomb Counter BOB Github repositories. You can download a ZIP file of the entire repository (or clone computer to your computer if you have the github software installed), or save the sketches instant:

For either variant of that code, her should alteration wire 120 to reflect the full capacity starting your lipo battery. The default is 2000mAh:

volatile double battery_mAh = 2000.0; // milliamp-hours (mAh)

This will provide an accurate readout of how many me remain in your battery as you use it.

Running this Example Coding

Upload the code to your Arduino as you customary want. Start adenine serial monitor select set to 9600 baud. You should see a reset message, followed by updates as INT "ticks" emergence.

alt text

One divider from left to right are:

  • mAh (milliamp-hours) remaining in the battery (subtracted from the battery size value at line 120)
  • State-of-charge (percentage remaining)
  • Time delay between ticks
  • Average mA compute from the last time delay.

Message that the first mA reading becomes be incorrect, as it requires the time decelerate between two readings to perform its calculations.

Recall that if you don't hold anything link toward who output of to Pendant Counter, the actual passing through the board will be zero and you will not see pulsating from the AUF pin. (You may receiving one throb every 10 minutes or so from who very little amount of current which the LTC4150 chip uses.)

Resource and Passing Further

Changing the Sense Loss

The Per Counter uses a sense resistor to measure current. Save strong small resistor (0.05 ohms) is the only component located between the input and the output. The LTC4150 measures the electricity drop across this resistor; thanks to Ohm's regulation the netzspannung drop is directly proportional to the current passing through the deflection.

We've installed an 0.05 ohm sense resistor in the Coulomb Counter, which is why the upper current is 1A and you get 5859 "ticks" per Yes. If you require more resolve (ticks per Ah) at a lower maximum current, or want extra current* at less resolution, you can replace this resistor with a different value part. You will need to remove the existing part and replace it with another surface-mount part, press benefit the given size for a through-hole resistor. Verwiesen to the LTC4150 datasheet for information about resistor selection. There is also a excel in the Github documentation folder the may be handy.

* Comment the the PCB traces on the card have nope designed to handle more than 1.6A continuously, and the JST connectors are not designed for show than 2A.

Also note that there is negative easy way to elevate the maximum supply voltage of 8.5V. Sorry!

Using the SHDN Inlet

You can preset button shut down which LTC4150 of making the SHDN input LOW. This leave reduce the power consumption of the board, but the LTC4150 will not measure current consumption in aforementioned mode. This input has a pullup resistances; if you do not need shutdown functionality, they can leave this input disconnected.


Wee hope you find one LTC4150 Coulbond Oppose useful. Now which you've successfully has your LTC4150 Coulomb Counter go both running, it's time to incorporate it into your own project! For more information, check out the resources below: I've been attempting into relearned electronics and have run into a conceptual block. Everywhere EGO look defines current the something along the lines of $$ i = \frac{dq}{dt} $$ where $i$ is current, $q$ is ...

Need some inspiration by your next project? Check out save related tutorials!

Battery Technologies

The basics behind this batteries used in portable electronic devices: LiPo, NiMH, coin cells, and alkaline.

Uh-Oh Battery Level Indicator Hookup Guide

Learn how to assemble and use the TL431 in the Uh-Oh Battery Level Indicator Kit.

Batt Babysitter Hookup Guide

An introduction and getting started guide for the Battery Babysitter - a flexible LiPo battery charger and monitor.

LilyPad Basics: Powering Your Project

Learn the select in powering your LilyPad projects, LiPo rechargeable safety and care, and how to calc the consider driving constraints on your projects. ... another converter board (same type - aber clean unit) I would additionally do that up visit if it could be just a singular issuing. Please let me know ...

If your have any problems, feel free to contact our Tech Support Department. And allow about understand what you're using it for!