0

I would like to create a 18650 battery automatic management system that can handle and restore used up cells using solar panels for power. To do that I need to create adjustable constant current source that will limit the current/voltage going into the cell/cells to a small enough value.

Since there are more features I would like to implement (like checking cell capacity) I would love to use Arduino with least amount of components as possible to keep the cost down.

My first question is: Will Arduino be fast enough to control a MOSFET that will pump magic pixies into a capacitor to achieve steady value of voltage on said capacitor?

The pseudocode for logic I'm proposing is simpe:

  1. Use ADC to check voltage on the capacitor (or a very small value power resistor when working as current source)
  2. Calculate required voltage adjustment
  3. Use AnalogWrite to set new PWM value into internal PWM controller.

Second question: PWM causes a lot of "switching" in the MOSFET. When MOSFET is not saturated state it's resistance is high and a lot of power is wasted as heat. Would it be possible NOT to use PWM to control it, but instead to turn it OFF or ON each cycle to minimize power loss? Since the batteries have some internal resistance voltage variation of +-20% should be acceptable.

  • 1
    When you have to ask, don't do it. The risk of damaging the battery is too high. There are dedicated chips to charge batteries. I suggest to buy a charger from a well known brand. – Jot Aug 8 '18 at 7:28
  • 1
    The dedicated chips work great with new and shiny 18650. The used up ones have special needs. At this moment I'm restoring them by hand one by one. For example first hour of charging cannot exceed 50mA if voltage of 18650 was initially less than 1,5V. I was able to get 1500mAh (out of nominal 2500mAh) from cell discharged to 0,5V taken out of old laptop. I would prefer to delegate this task to Arduino because it takes a lot of time, and checking the cell temperature every 10 minutes is tedious. – Filip Franik Aug 8 '18 at 7:35
  • There are dedicated charge ICs that will trickle charge if the voltage is too low. Check the datasheet. I’d use a dedicated chip for charging. And use an Arduino to measure capacity. Or buy a charger-doctor from China that measures the mAh for you. – Gerben Aug 8 '18 at 9:25
  • I already have all the stuff you can buy from china, but I had to modify most of it because it tends to overcurrent (it starte with 100mA and not 50mA) and overvoltage (charges up to 4.26V) batteries. I'm trying to design a universal (and cheap) solar powered "used battery management system" that might end up being a KIT at some point. I would like to prototype it with Arduino before I rewrite everything for native execution in ATtiny/ATmega or something similar. I tested that Arduino Bootloader makes ATmegas run much slower in some cases. – Filip Franik Aug 8 '18 at 9:41
  • 1
    1. you can slow down either side's voltage variations with a capacitor. you can pick one large enough to guarantee you plenty of time to read the ADC. 2. you can safely assume MOSFETs switch instantly for your practical application, which at 5v is pretty close to true for logic-level FETs and sub-1amp loads. secondly, the internal resistance is so small anyway (milliohms) that it takes several amps to even slightly warm them. – dandavis Aug 10 '18 at 4:31
1

You are basically describing (if you add an inductor and a diode into the mix) a simple switching regulator. That is, at its simplist, a PWM signal, some smoothing (inductor, diode, capacitor), and feedback.

Use the Arduino's PWM to switch a P-channel MOSFET in the voltage supply. That switched supply is then fed through an inductor, and then smoothed with a capacitor:

schematic

simulate this circuit – Schematic created using CircuitLab

M1 does the switching of the power to charge the rest of the circuit. L1 + C1 smooths the PWM out giving a constant smooth (ish) voltage. D1 completes the circuit between L1 and C1 in one direction only keeping the charge in the right part of the circuit.

R1 keeps the MOSFET turned off when not being driven.

R2 is a very small "shunt" resistor (maybe 0.1Ω for example).

The size of C1 and L1 are determined by the switching frequency of your PWM and the current demands of the circuit. The higher your switching frequency the smaller your inductor can be, The higher your current demands the larger C1 needs to be.

Reading A1 gives the output voltage of the circuit, so you can adjust the PWM (using PID would be good) to get a specific voltage.

Reading A0 and A1 and subtracting one from another gives you the voltage drop across R2. From that, you can calculate the current through R2 using Ohm's Law. You can then use that to adjust the PWM to give you a specific current.

Of course, you can't do both at once. You either have a constant current (during the first charging phase to bring the cell voltage up to 4.2V), and then switch to constant voltage until the current drops to around 0.3C. For dead cells, an initial constant current phase of (IIRC) 0.1C can recover the cell.

Some important notes about lithium cells:

  • They explode (just ask Samsung), so take care. It can be good to do your experimenting with the cell contained within a fireproof container.
  • Lithium Ion and Lithium Polymer cells don't like being over-discharged, but as long as they haven't been reverse charged they can generally be recovered.
  • Cells that are used in a series pack and haven't been charged with a proper balancing charger may well have been reverse charged if the pack has "died".

The reverse charge thing is what actually kills a Lithium cell. Basically, no two cells will have exactly the same capacity. If you have, say, three cells in series and you discharge the whole pack to below the recommended minimum, once cell will have less charge than the others. If that cell hits zero the current from the other cells will start flowing backwards through it, and that backward current causes copper crystals to deposit on the electrolyte layer between the electrodes. Those pierce the electrolyte layer and short the two electrodes together, and at that point the cell is dead. No amount of recovery charging will get it back, it's physically damaged.

So in summary:

  • A single cell that has been over-discharged by itself will generally be recoverable.
  • A series pack of cells that has been over-discharged may well have physically damaged one of the cells in the pack through reverse charge flow.

Will Arduino be fast enough to control a MOSFET that will pump magic pixies into a capacitor to achieve steady value of voltage on said capacitor?

Sure. You should pre-condition your power so it is always within a tolerable limit (i.e., feed your solar panel power through a suitable 5V buck regulator to give a clean 5V supply). There will always be some latency in the circuit due to how long the inductor "resists" changes in the voltage. A typical Arduino takes ~100µs to sample an ADC. In this kind of environment, that time is negligible since it's generally much faster than a single period of PWM. You can't respond faster than one period of PWM anyway.

When MOSFET is not saturated state it's resistance is high and a lot of power is wasted as heat. Would it be possible NOT to use PWM to control it, but instead to turn it OFF or ON each cycle to minimize power loss?

That's what PWM does. It's ON or OFF. On at the start of a cycle, then off part way through. Yes, there is a brief period twice per cycle while it does the switching, but that will be minimal compared to the on and off periods. The losses from that switching will be negligible compared to, say, running a MOSFET as an adjustable resistance controlled from an op-amp with feedback from a current shunt (i.e., a linear regulator).

  • Thanks for the general answer, but you didn't address my questions. The solar panel provides a "random" voltage anywhere from 6V to 48V and my question is if the Arduino at least has the chance respond fast enough to dynamic changes. ADC measurement takes time, logic takes time, changes to PWM take time and in that time voltage on regulator output can escalate making a lovely red lithium colored fire. Physically broken cells can be easily detected. They don't decrease current in last phase of charging (and heat up) or they have high self discharge rate. I use old laptop batteries for cells. – Filip Franik Aug 8 '18 at 9:19
  • 1
    @FilipFranik Since you don't specify any specific Arduino, yes, there are "Arduinos" that are plenty fast enough. Probably even a simple Uno would be fast enough. Especially if you first pass your solar cell power though a normal switching regulator to give a steady 5V - that way there won't be any surprises. Also the indictor works two ways: Not only does it try to keep the voltage up when the fet switches off, it also tries to keep it down when the fet switches on. You don't get instant rises on the output because of spikes on the input. – Majenko Aug 8 '18 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.