Automation for CTC or extend battery life

As a result of the publication of stories about my autonomous solar energy system, described here , here and here , similar questions were often asked: what is the payback period and how long will the system last? It should be noted that one of the most expensive and moody parts of the system are batteries. It is energy storage that wears out the fastest, the battery capacity drops and the number of remaining charge-discharge cycles is steadily decreasing. Motorists are well acquainted with the reduced battery capacity when a sudden sharp frost does not leave a chance for an old battery to start a car.
I wondered how to determine the residual capacity of the battery so that it was as simple and fast as possible.

To begin with, a little theory to understand how to measure the residual capacity of the battery and what it takes.

The control and training cycle of the charge-discharge is carried out to prevent sulfation and determine the battery capacity. Control and training cycles are carried out at least once a year and are performed as follows: charge the battery with normal current to a full charge; withstand AB 3 hours after the cessation of charge; adjust the density of the electrolyte; include charging for 20-30 minutes to mix the electrolyte; carry out a control discharge with a constant normal current of a 10-hour mode and control the time of a full discharge to a voltage of 1.7 V per can (10.2 V per battery); battery capacity is defined as the product of the discharge current and the discharge time. After a check discharge, the battery is immediately charged and fully charged. If it turns out that the battery capacity is less than 50% of the nominal, it is considered to be faulty.
A manual control discharge requires the constant presence of maintenance personnel to fix and adjust the discharge current. (c) taken from here

That is, to determine the residual capacity, we need to discharge the battery with a load with a known and constant power to 10.2 (in other sources it is recommended to discharge a 12V battery no lower than 10.8V) Volts. You can just buy such a device and not puzzle over the invention of a bicycle, but the daily struggle with laziness requires new achievements and inventions.

So, guided by the principle "The simpler the more reliable", it was decided to assemble our own automated device for measuring the residual capacity of the battery, and at the same time, conducting the CTC. Since the chargerI already had, then there was no need to reinvent the wheel. All that was needed was to turn on this charge on time. But you need to discharge something that has a constant load, regardless of the ambient temperature and battery voltage. The easiest way is to discharge car incandescent bulbs. The power rating is written directly on them, so the current consumption can be calculated by simple arithmetic: W / 12 = load current. That is, a 60 W lamp will consume 5 Amps. The battery is discharged with a current of 10% capacity or 0.1C and charged with the same current.
As a result of a five-minute reflection, a technical task was compiled for the future device:
1. Fixing the time of the beginning of the discharge process
2. Monitoring the battery voltage
3. Upon reaching the critical voltage, the device should disconnect the load and turn on the charger
4. Fixing the time of the end of the discharge process

From all this it follows that we need:
1. Arduino Nano - 175 rubles
2. RTC1307 - 56 rubles
3. Relay - 131 rubles
4. LCD 2x16 i2c - 222 rubles
5. 3 resistors of 10 kOhm, a certain number of wires - 50 rubles
Total: 634 rubles

In order for Arduina to understand the voltage at each moment of time on the battery, it was necessary to connect the battery to the arduino. This cannot be done directly, since the analog inputs of the controller can accept no more than 5V, so it was decided to assemble a voltage divider from 3 resistors of 10 kOhm. The battery minus and the minus of the controller were connected directly. The controller was powered from a separate power source. The connection diagram and code are presented below:

Sketch KTC
``````// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include
#include
#include
#include "RTClib.h"
#include
int rtc[7];
byte rr[7];
LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display
#define RELE_NAGRUZKA 2 //объявляем работу реле нагрузки на пине 2
#define RELE_ZARYADKA 3 //объявляем работу реле зарядки на пине 3
int analogPin = 0;
int flag=0;
float val=0;
float valkoef=0;
void setup ()
{
DDRC|=_BV(2) |_BV(3);  // POWER:Vcc Gnd
PORTC |=_BV(3);  // VCC PINC3
RTC.get(rtc,true);
lcd.init();                      // initialize the lcd
lcd.backlight();
lcd.home();
pinMode(RELE_NAGRUZKA, OUTPUT); //инициируем реле только на выход
pinMode(RELE_ZARYADKA, OUTPUT); //инициируем реле только на выход
lcd.clear();
digitalWrite(RELE_NAGRUZKA, HIGH);
RTC.SetOutput(DS1307_SQW32KHZ);
EEPROM.write (0, rtc[2]); // при старте записываем значение времени, часы
EEPROM.write (1, rtc[1]); // при старте записываем значение времени, минуты
}
void loop ()
{
val = analogRead(analogPin); // считываем значение напряжения с аналогового порта
valkoef=val/74,49; // приводим снятое с аналогового пина значение к обычным вольтам
RTC.get(rtc,true);
lcd.setCursor (0,0);
lcd.print (rtc[2]);
lcd.print (":");
lcd.print (rtc[1]);
lcd.print (":");
lcd.print (rtc[0]);
lcd.print (" str");
lcd.print (":");
lcd.setCursor (0,1);
lcd.print (valkoef);
lcd.print (" ");
lcd.print (flag);
if (valkoef < 10.72)
{
flag=1;
EEPROM.write(2, rtc[2]); // записыываем время окончания разрядки, часы
EEPROM.write (3, rtc[1]); // записыываем время окончания разрядки, минуы
}
if (flag==1)
{
digitalWrite(RELE_NAGRUZKA, HIGH); // выключаем нагрузку
lcd.print (" stp");
lcd.print (EEPROM.read(2)); // выводим время окончания разрядки
lcd.print (":");
}
if ((valkoef > 10.72) && (flag==0))
{
digitalWrite(RELE_NAGRUZKA, LOW);
}
else
{
digitalWrite(RELE_NAGRUZKA, LOW);
}
delay(500);
}
``````

How does the device work? Elementary!

The load is connected to the first relay, to the second memory. Moreover, it is better to break the high-voltage power supply circuit of the charger so as not to leave the device turned on without a battery. When the controller is turned on, the first line displays the current time and the start time of the load. The second line displays the current voltage on the battery and the end time of the discharge when the battery reaches a critical voltage. Immediately upon reaching the values, the load relay switches off and the charge relay switches on. If you add a couple of buttons, you can easily adjust the voltage threshold adjustment or the real-time clock setting. At this stage, there was no such task, so the code is as simple and functional as possible. Subtracting the discharge start time from the end time, you can get the capacity if you multiply the time by the current consumed by the load.

Conclusion
So, to organize a control and training cycle for any battery, having a charger, 600-700 rubles for spare parts and a couple of hours of time, is very simple. Do not forget that a charged battery lasts longer, and periodic CTCs give you the confidence that you will know for sure that the car will start in the morning, in spite of any frosts.