question: How do portable batteries know when to give or receive charge?
comment: The electrons will go where the voltage "forces" them to go, much like water falls or flows where gravity pulls it. So if the battery is the only generator of voltage, then the chemicals inside will react and produce electrons that will go through your device. However, if you connect a "more powerful" source of electricity, like for example a USB 5.0 V to a (normally) 4 V battery, the electrons go INTO the battery (because there's a 1 volt difference) and force the chemicals inside the battery to "un-react", thereby "charging" the battery. Basically to charge a battery you just connect a slightly higher voltage to it.
passages: For Ni-Cd and NiMH batteries, the voltage across the battery increases slowly during the charging process, until the battery is fully charged. After that, the voltage "decreases", which indicates to an intelligent charger that the battery is fully charged. Such chargers are often labeled as a ΔV, "delta-V," or sometimes "delta peak", charger, indicating that they monitor the voltage change.
   Section::::Type.:Universal battery charger–analyzer.
  
  The most sophisticated types are used in critical applications (e.g. military or aviation batteries). These heavy-duty automatic “intelligent charging” systems can be programmed with complex charging cycles specified by the battery maker. The best are universal (i.e. can charge all battery types), and include automatic capacity testing and analyzing functions too.
  
  Section::::Type.:USB-based charger.
   Internally, a smart battery can measure voltage and current, and deduce charge level and SoH (State of Health) parameters, indicating the state of the cells. Externally, a smart battery can communicate with a smart battery charger and a "smart energy user" via the bus interface. A smart battery can demand that the charging stop, request charging, or demand that the smart energy user stop using power from this battery. There are standard specifications for smart batteries: Smart Battery System, MIPI BIF and many ad-hoc specifications.
  
  Section::::See also.
  
  BULLET::::- Battery charger
  
  BULLET::::- CMOS battery
  
  BULLET::::- Rechargeable battery
  
  Section::::External links.
   BULLET::::- "dumb" batteries, which lack any internal electronic circuitry.
  
  The output current of a smart charger depends upon the battery's state. An intelligent charger may monitor the battery's voltage, temperature or time under charge to determine the optimum charge current and to terminate charging.
   A BMS may monitor the state of the battery as represented by various items, such as:
  
  BULLET::::- Voltage: total voltage, voltages of individual cells, minimum and maximum cell voltage or voltage of periodic taps
  
  BULLET::::- Temperature: average temperature, coolant intake temperature, coolant output temperature, or temperatures of individual cells
  
  BULLET::::- State of charge (SOC) or depth of discharge (DOD), to indicate the charge level of the battery
  
  BULLET::::- State of health (SOH), a variously-defined measurement of the remaining capacity of the battery as % of the original capacity
   Section::::Type.:Fast charger.
  
  Fast chargers make use of control circuitry to rapidly charge the batteries without damaging any of the cells in the battery. The control circuitry can be built into the battery (generally for each cell) or in the external charging unit, or split between both. Most such chargers have a cooling fan to help keep the temperature of the cells at safe levels. Most fast chargers are also capable of acting as standard overnight chargers if used with standard NiMH cells that do not have the special control circuitry.
  
  Section::::Type.:Three stage charger.
   Once the simulated battery voltage is set, the user connects the charger to be tested to the input of the simulator. The charger will detect that a battery has been connected and the charging process will begin. The simulator keeps the voltage constant at the set value, while the analogue ammeter indicates the charging current. If the battery simulator has current limit feature and if the current exceed the maximum set value, the simulator automatically increases the voltage to limit the current
   Smart battery charger
  
  A smart battery charger is mainly a switch mode power supply (also known as high frequency charger) that has the ability to communicate with a smart battery pack's battery management system (BMS) in order to control and monitor the charging process. This communication may be by a standard bus such as CAN bus in automobiles or System Management Bus (SMBus) in computers. The charge process is controlled by the BMS and not by the charger, thus increasing security in the system. Not all chargers have this type of communication which is commonly used for lithium batteries. 
   BULLET::::- The wearable Portable People Meter carried by each panelist;
  
  BULLET::::- A base station for each PPM, where each panelist in the household places it overnight to recharge the battery; and
  
  BULLET::::- A portable recharger for vacations and other trips away from the home base.
   The output of a timer charger is terminated after a pre-determined time. Timer chargers were the most common type for high-capacity Ni-Cd cells in the late 1990s for example (low-capacity consumer Ni-Cd cells were typically charged with a simple charger).
   The open-circuit voltages of batteries and solar cells are often quoted under particular conditions (state-of-charge, illumination, temperature, etc.).
  
  The potential difference mentioned for batteries and cells is usually the open-circuit voltage. The open-circuit voltage is also known as the electromotive force (emf), which is the maximum potential difference when there is no current and the circuit is not closed.
  
  To calculate the open-circuit voltage, one can use a method similar to that below:
  
  Consider the circuit:
  
  If we want to find the open-circuit voltage across 5Ω resistor. First disconnect it from the circuit:
   The most common sizes of sealed lead acid (SLA) batteries use Faston tabs, but some larger batteries use L terminals, while some very specialized designs use other, sometimes proprietary terminals, such as older Panasonic camcorder batteries (of the type used for VHS shoulder-mounted camcorders).
  
  Section::::UPS battery terminals.
   BULLET::::- LED Indications: The Led glows as per indicating the amount of charging ability left with the powerbank. Some powerbanks have a line of LEDs, with the number of LEDs lit indicating state of charge. Other powerbanks may simply have one LED which changes color or flashes when the charge of the internal battery is low.
  
  Some power banks have a built-in wireless charging pad. Power banks are available in different capacity ratings.
  
  Section::::Type.:USB-based charger.:Compatibility.
  
  Although a standard exists for USB chargers, there are two areas of common incompatibility.
   The central controller of a BMS communicates internally with its hardware operating at a cell level, or externally with high level hardware such as laptops or an HMI.
  
  High level external communication are simple and use several methods:
  
  BULLET::::- Different types of serial communications.
  
  BULLET::::- CAN bus communications, commonly used in automotive environments.
  
  BULLET::::- DC-BUS - Serial communication over power-line
  
  BULLET::::- Different types of Wireless communications.
  
  Low voltage centralized BMSs mostly do not have any internal communications. They measure cell voltage by resistance divide.
   For LiPo battery packs with cells connected in series, a specialised charger may monitor the charge on a per-cell basis so that all cells are brought to the same state of charge (SOC).
  
  Section::::Applying pressure on LiPo cells.
  
  Unlike lithium-ion cylindrical and prismatic cells, which have a rigid metal case, LiPo cells have a flexible, foil-type (polymer laminate) case, so they are relatively unconstrained. 
   Computers may give a signal to users that an internal standby battery needs replacement. Portable computers using rechargeable batteries generally give the user some indication of the remaining operating time left on the battery. A Smart Battery System uses a controller integrated with an interchangeable battery pack to provide a more accurate indication of the state of battery charge. 
  
  Section::::Batteries not part of a system.
   BULLET::::- Current sensors which monitor the power consumed, and maintain the connection only if the demand is within a predetermined range. Sensor wires react more quickly, have fewer parts to fail and are possibly less expensive to design and implement. Current sensors however can use standard connectors and can readily provide an option for suppliers to monitor or charge for the electricity actually consumed.
  
  BULLET::::- Additional physical "sensor wires" which provide a feedback signal such as specified by the undermentioned SAE J1772 and IEC 62196 schemes that require special (multi-pin) power plug fittings.
   Highlights in the battery simulator are the IGBT or MOSFET high frequency regulator (which allows the equipment to work with constant current and voltage), the programmable digital panel.
  
  On the front panel of the equipment there may be the following elements:
  
  BULLET::::- Digital voltmeter
  
  BULLET::::- Analogue ammeter
  
  BULLET::::- Test voltage selector
  
  BULLET::::- Potentiometer fine tension adjustment.
  
  BULLET::::- Potentiometer current selection (0-200 A)
  
  BULLET::::- self-test
  
  BULLET::::- automatic stop in case of failure.
   The battery pack also contains a variety of temperature, voltage, and current sensors. Collection of data from the pack sensors and activation of the pack relays are accomplished by the pack ’s Battery Monitoring Unit (BMU) or Battery Management System (BMS). The BMS is also responsible for communications with the world outside the battery pack.
  
  Section::::Specifics.:Charging.
   Batteries designed for use inside a portable uninterruptable power supply (UPS) typically use Faston tabs, often with an adapter cable between those and the UPS's internal battery connectors. Larger external battery packs use a variety of connectors, including the Anderson Powerpole MultiPole series (as used by Tripp Lite), which are color-coded and keyed for specific voltages. Very large batteries as installed in battery rooms such as are found in datacenters use bolted connections from cell terminals to bus bars or flexible cables.
  
  Section::::Dry battery terminals.
   The battery pack also contains relays, or contactors, which control the distribution of the battery pack’s electrical power to the output terminals. In most cases there will be a minimum of two main relays which connect the battery cell stack to the main positive and negative output terminals of the pack, those supplying high current to the electrical drive motor. Some pack designs will include alternate current paths for pre-charging the drive system through a pre-charge resistor or for powering an auxiliary buss which will also have their own associated control relays. For obvious safety reasons these relays are all normally open.
   Charge controllers are sold to consumers as separate devices, often in conjunction with solar or wind power generators, for uses such as RV, boat, and off-the-grid home battery storage systems.
  
  In solar applications, charge controllers may also be called solar regulators. Some charge controllers / solar regulators have additional features, such as a low voltage disconnect (LVD), a separate circuit which powers down the load when the batteries become overly discharged (some battery chemistries are such that over-discharge can ruin the battery).
   The charger is a small box, usually powered by a battery. It contains an electronic circuit that steps the battery voltage up to the high voltage needed for charging. The box has a fixture that requires one to press the end of the dosimeter on the charging electrode. Some chargers include a light to illuminate the measurement electrode, so that measurement, logging and recharging can occur with one routine motion.
   A "smart charger" should not be confused with a "smart battery". A smart battery is generally defined as one containing some sort of electronic device or "chip" that can communicate with a smart charger about battery characteristics and condition. A smart battery generally requires a smart charger it can communicate with (see Smart Battery Data). A smart charger is defined as a charger that can respond to the condition of a battery, and modify its charging actions accordingly.
  
  Some smart chargers are designed to charge:
  
  BULLET::::- "smart" batteries with internal protection or supervision or management circuitry.
   Additionally, a BMS may calculate values based on the above items, such as:
  
  BULLET::::- Maximum charge current as a charge current limit (CCL)
  
  BULLET::::- Maximum discharge current as a discharge current limit (DCL)
  
  BULLET::::- Energy [kWh] delivered since last charge or charge cycle
  
  BULLET::::- Internal impedance of a cell (to determine open circuit voltage)
  
  BULLET::::- Charge [Ah] delivered or stored (sometimes this feature is called Coulomb counter)
  
  BULLET::::- Total energy delivered since first use
  
  BULLET::::- Total operating time since first use
  
  BULLET::::- Total number of cycles
  
  Section::::Functions.:Communication.
  