Home Locks Automatic charger of car batteries on PIC. Charger for car batteries on Atmega8 Scheme and principle of operation

Automatic charger of car batteries on PIC. Charger for car batteries on Atmega8 Scheme and principle of operation

Microprocessor charger for maintenance-free lead-acid batteries.

Rice. 1 Device with cover removed.

Plan.

1) Feedback.
2) Introduction.
3) What is the simplest automation?
4) How can we improve the situation?
5) We come to the question: “What did the user want”?
6) Disadvantages of designs found on the Internet.
7) Creating your own system.
8) Search for a suitable power supply.
9) Preparatory stage (assembly of the analog part).
10) Installation into the housing and reconnection of the transformer.
11) Assembling the digital part.
12) Firmware technique and Fuse bits.
13) What does the user need to see at the top level?
14) Final testing.
15) How can I update the firmware in the future?
16) Autonomous operation algorithm.
17) Firmware and control program.
18) What can you read on this issue?

Feedback.

Since at the end of the article no one sees the link to the forum thread on this topic, I’m putting this link at the very top. That is, if you have questions or suggestions on this topic, then you should go to our forum. Or write to the email address indicated at the VERY bottom of the page.

Introduction.

After the publication of two articles on our website about and UPS for needs, we have many times encountered the problem of charging and testing maintenance-free lead acid batteries (also known as lead acid batteries or, simply put, UPS batteries). By the time of writing this article, the author already had experience in creating and operating for two years an “automatic” charger made from a computer ATX power supply (in turn assembled on a PWM controller). Here is the documentation for and its analogue.

What is the simplest automation?

Well, let's start with the definition. In most circuits of the simplest “automatic” chargers found on the Internet, automation meant limiting the charge current (usually about 1-2A) to a certain threshold voltage (usually about 13.8-14.5V), and then switching to voltage stabilization.

Rice. 2 Block diagram of TL494.

The voltage measurement is carried out through a voltage divider connected to the 1st and 2nd legs, and a current limiter by turning off the output switches of the microcircuit by means of supplying +5V to the 4th leg. In another way, we take an ATX power supply or its analogue, create a current measuring circuit from a 1 Ohm 5W resistance and an optocoupler, connect the optocoupler outputs to current feedback (4th leg), organize a voltage divider (for the 1st and 2nd legs) to limit the voltage to exit, and finally, we organize power supply for the fan - that’s all the work. For clarity, I will give a conversion diagram for .
If the copy from my power supply circuit is different from yours, then with 28 different ATX power supply circuits assembled on and their analogues.
The closest analogue of the circuit for my power supply is here.
If there are power supply diagrams for different cars, but the one you need, as always, is not available, then you will have to copy the diagram yourself. The lack of unification is due to the fact that cheap power supplies are assembled "on the knee", according to the principle as is, including.
But, let's return to our power supplies: unfortunately, such a simple and beautiful solution has a number of technological shortcomings. As it was written on one site with a similar topic: “There is such a science - CHEMISTRY. And everything that happens in batteries obeys the laws of Chemistry. All “smart advice from experienced people” that does not apply to chemistry is harmful by definition” (C) adopt-zu-soroka.
On my own behalf, I would like to add that the battery is at the intersection of PHYSICS and CHEMISTRY, that is, in addition to chemical processes, there is a convention of active mass solution, drying of plates and heating, which are discussed in physics.

What does this mean in relation to our simplest “automatic” charging:
1) A constant “small recharge” that maintains the threshold voltage (in voltage stabilization mode) dries out the batteries (water evaporates from them, which is relatively difficult to add to maintenance-free batteries), which in turn greatly reduces the battery life. Especially if the battery is left to recharge every night.
2) Charging with a large, non-pulsating current at the very beginning of charging (especially with heavily discharged batteries) greatly reduces the remaining battery life (remaining number of charge/discharge cycles), and in some cases the battery does not take a charge without charging.
3) Charging with direct current without pulsation, in tenths of a hertz, increases sulfation and prevents a more complete use of chemicals, because does not allow pauses to equalize the density of the active mass solution.
4) Point 3 also applies to the training discharge, which is simply not implemented in the simplest “automatic” charging, and in most homemade, microprocessor-based charging is not completely controlled.
5) The ECR of a battery is measured at a relatively high frequency, so to measure the ECR it is desirable to have a test discharge circuit with a relatively high current of low duty cycle, i.e. have a testing unit connected without filter capacitors.

To summarize: For one-time use, the simplest “automatic” charges are quite suitable, but with constant (every day) charging of the same battery, the use of the simplest charges greatly reduces the life of the battery being charged. And for the most part, they do not have diagnostic tools at all, since with such an implementation the only diagnostic method is checking with a direct current DISCHARGE lamp 12V 75W. But based on the result of such a test, you can only roughly estimate the percentage of charge, and it is almost impossible to determine the remaining capacity of the battery (the capacity can be indirectly inferred from the ECR value). A closer look at their software revealed an almost complete lack of self-diagnosis in homemade devices.
Departing from the topic, I will say that when setting up my device, I recorded cases of partial corruption of some firmware bytes in the microcontroller, i.e. during programming, it passed verification, but the next day the firmware crashed, and if my system did not have a self-monitoring unit for firmware integrity, the system could behave inappropriately (or possibly ruin the battery).

How can we improve the situation?

Create a circuit for measuring currents (charge current and discharge current) and voltage in normal and measuring modes, which together will make it possible to calculate the amount of energy transferred in both directions and assign the charge to a COMPETENTLY composed algorithm that alternates charge/discharge and cycle duration (that is, algorithm compiled taking into account the physical and chemical structure of this type of battery). True, here it is necessary to clarify that a well-designed algorithm is compiled according to the available data and for a given specific situation, and if the initial data or situation changes, the algorithm must be adjusted.

Let's get to the question:
“What did the user want?”

I don’t know about others, but most of my users need a charger with simple controls that can be used:
1) For charging maintenance-free lead-acid maintenance-free batteries, voltage 12V and capacity from 12V3.3Ah to 12V18Ah. The description is collapsed into "explanations":


2) For daily (more correctly, all night) recharging of not completely discharged lead-acid batteries.
3) For tests to determine the remaining percentage of charge and remaining capacity of lead-acid batteries.
4) For test/training automatic charge-discharge cycles of lead-acid batteries in place (for example, batteries disconnected from UPS in a server cabinet without physically removing them from the cabinet).

In this case, this design must provide:
1) Self-diagnosis function of the main units of the device and sound indication of emergency situations such as: terminal polarity reversal, connecting the battery to the wrong voltage, sudden battery disconnection during charging/discharging, short circuit of the output circuit, etc.
2) Firmware update function without an external programmer (without opening the device case).
3) Memory of the last active mode and, in the event of a power failure and restart, automatically return to the interrupted operation.
4) Sufficient accuracy of the measuring system, the need for which is dictated by the physics and chemistry of the process.

Rice. 3 Dependence of service life on voltage in StendBy mode.

Details on the issues of “sufficient accuracy of the measuring system” are collapsed into “explanations”.

According to GOST 825-73 “Lead batteries for stationary installations,” the rated voltage of a lead stationary battery of any capacity is considered to be 2V. This is the lowest permissible voltage at the terminals of a fully charged battery during the first hour of discharge in a ten-hour mode at a density of hydrochloric acid solution of 1205 ± 5 kg/m3 and a solution temperature of +25 ° C. The maximum voltage to which batteries are allowed to be discharged at a solution temperature of +25 ° C , is: for discharge modes - no shorter than three hours = 1.8V, and for shorter modes (including 15 minutes) = 1.75V (that is, up to 10.8V on a 12V battery, measured under load or not lower than 12V without load ).
But in the documentation for one of the batteries (see) these parameters are slightly different. Up to 10.8V on a 12V battery at currents from 0.16C or less (from 5 hour discharge to 18 hour discharge) and up to 9.3V on a 12V battery at currents from 1C-3C (from 8 minute discharge to 43 minute discharge). True, with a caveat - at such currents the battery will last 260 charge/discharge cycles or 5 years in StendBy mode.
The same, but on a small scale (but with explanations) is presented in the documentation for the battery.
A graph of the dependence of the battery life on the voltage of constant recharge in the StendBy mode is shown in Fig. 3.
The specified voltage limits to which batteries can be discharged were established empirically. They are selected in such a way that not all of the active mass is converted into lead sulfate during discharge, as this would cause excessive sulfation of the plates.
That is, we can conclude that you cannot discharge below the permissible limit and you cannot recharge above the specified rating - in this case, you work only with the “active mass” and the destruction of the plates in the first case and boiling of the solution in the second are not allowed.


Disadvantages of designs found on the Internet.

We go to the Internet and find several dozen ready-made microprocessor chargers. As they say, the task is at the level of a do-it-yourself school club, so almost every radio amateur begins his creativity with the “invention” of charging from improvised means. But, unfortunately, the quality of the result does not exceed the level of the school club... We look at the description of the devices and their diagrams and on some of them we find not very pleasant things:
1) There is not even a mention of safety precautions when working with batteries and a ~220V network.
2) Lack of precise adjustment of the measuring system (measured voltage and current). As stated above, exceeding or underestimating the parameters can lead to destruction of the plates or boiling off of the solution.
3) Use of expensive current sensors. Let me remind you that a current sensor based on the Hall effect plus a display are more expensive than the entire system taken together. Given that, based on the chemistry and dimensions of the batteries used (let me remind you, my user wanted from 3.3 to 18 Ah), we will not have to measure more than a few amperes. And about the display it is written in paragraph 4.
4) The presence of a bunch of LEDs, buttons and an expensive display on the device body. Have you ever tried to squeeze into the depths of a server cabinet and look at what is written on a display the size of a matchbox at a distance of 1 m? And without setting the mode through the navigation buttons (checking the inscriptions on the display), the found designs do not work. Should I install a larger display and move it along with the buttons on the 1st cable? And once you take it out, these are already two different devices: a separate charging and a separate display.
5) Power supply of the system fan from the charge voltage. That is, either from 16V (see point 5) and at the same time block the step-down part or feed directly from the voltage at the terminals (where we have from 9V to 14V instead of the standard 12V).
6) Creating your own pulse voltage stabilization circuit from the 16V input. That is, the story is on the topic, let's create another additional PWM (one is already in the power supply), but on the low-voltage part, which will increase the dimensions of the circuit, require additional power switches on the radiators and reduce the efficiency of the system as a whole.
7) Discharge algorithm without control of discharge current. And in most cases, without elements for measuring it (I’m not talking about the total current, which is measured almost everywhere, but about the discharge current).
8) The need to rewind the power transformer (3 methods of disassembling and rewinding are detailed below). This will of course give an increase in current, but do we need this increase? With standard windings, the transformer can provide 3-5A, of which in this design we use a maximum of 1-2A (14V*2A=28W) and we don’t need 15A for our technical specification (14.8V*15A=217W).

"Click on this text to expand explanations"

Method 1 = Unsolder the transformer, carefully remove the sticker with the inscription and unwind the yellow tape, heat it in the oven to 150 degrees for 15 minutes and loosen the core manually while wearing gloves.

Rice. 4 After loosening.
PSU SL-Lite

Method 2 = Solder the transformer, carefully remove the sticker with the inscription and unwind the yellow tape, blow the ferrite with a hair dryer from a soldering station or a hair dryer from all sides for a couple of minutes. The halves begin to move relative to each other, just separate them. The reel itself can be easily removed, which is very convenient when winding.

Rice. 5 The process of blowing with a hairdryer.
Photo by DenGess from the SL-Lite BP topic

Method 3 = Solder the transformer, carefully remove the sticker with the inscription and unwind the yellow tape, boil the transformer in water for 10 minutes.

Rice. 6 Do you still cook transformers in kettles?
Photo by DenGess from the SL-Lite BP topic



9) The dimensions of the device often exceed the size of a standard ATX power supply. What is most often left behind is a “discharge energy utilizer”; usually its role is played by a car light bulb from a headlight, which is why the whole structure begins to look a lot like a children’s night light. Moreover, as mentioned above, the light bulb in the “night light” simply turns on, without any control or stabilization of the current it consumes.
10) Lack of self-diagnosis systems and software integrity monitoring systems (I already wrote about this above).

Creating your own system.

Well, since there are no ready-made suitable developments, we will try to describe the procedure for making such a system independently from what was at hand - “I molded you from what I had” (C) is not mine.
Although it was written above that this is a do-it-yourself task at the school club level, its implementation involves high-voltage switching power supplies, therefore, if you have not developed them before, then it is better to start training on something else, less energy-saturated, more low-voltage and, as a result, less dangerous... In addition, batteries, if used incorrectly, are not safe in themselves and battery rooms in all production facilities are classified as class "A" - as extremely fire hazardous.
Well, as always - a disclaimer. I mentioned above about the possibility of fire and electric shock due to violation of operating rules and poor-quality assembly. And I’m talking now about the possibility of chemical damage from the contents of the battery as a result of short-circuiting its terminals and thermal rupture of the housing. That's why You do all experiments with batteries and homemade chargers at your own peril and risk, realizing full responsibility for the possible consequences.
Well, our favorite PUE... Power supply is carried out from an alternating current network 50Hz, 220V in accordance with the “Electrical Installation Rules”. To ensure the safety of people, electrical equipment must be reliably grounded in accordance with the requirements of the PUE and passport requirements for electrical equipment. The room in which the equipment is located must be equipped with a circuit - a protective grounding bus, to which the housings of all devices are connected through a socket network. To connect grounding conductors to the bus, M8 screws must be inserted. The circuit - the protective grounding bus must be connected to a grounding device. The grounding value should be no more than 4 ohms. Grounding indoors must comply with GOST 12.1.030-81. Creation of grounding and compliance with its standards is provided by the user.
If the paragraphs above did not scare you (you agree with them) and you have read on the Internet about safety precautions when working with batteries and the theory of first aid for chemical burns and electric shock, and also stocked up on a fire extinguisher for extinguishing class “E” fires (allows extinguish live equipment) and have completed all measures to improve safety, then we will proceed directly to converting the power supply into microprocessor charging.
And I want to note What is dangerous (if safety precautions are not followed) in this application are batteries and mains voltage ~220V. And the power supply being converted is low-flammable (i.e. it does not support combustion and practically does not burn unless you burn it from outside with a blowtorch...) and does not contain chemically active substances (acids).
Conclusion: These comments apply to almost all chargers that charge batteries and are powered from a ~220V network. Therefore, if the authors of other homemade chargers do not warn you about the “side properties” in their device and the subtleties of its operation, this does not mean at all that these properties and subtleties are not present in them.
Although this article is aimed at relatively experienced users who have owned a soldering iron for several years, below I will describe everything in great detail and step by step - as for beginners. This approach will allow you to fully control the assembly and not forget to check any of the blocks. Those. The process of manufacturing and setting up each block of my will be described below.

Rice. 7 Block diagram of the device “on fingers”.

A detailed description of the block diagram is collapsed into “explanations”.

"Click on this text to expand explanations"

And since we decided to explain with our fingers, this device can be clearly compared with the plumbing system shown in Fig. 7 (energy flows in it are animated below in the text). And for complete analogy, the upper left tap depicts control of a PWM controller. The left blue tank is a filter capacitor after the rectifier bridge, two green tanks connected by a small tube are a battery, and the tube, in turn, represents the internal resistance of the battery. The taps under the tank are two relays for disconnecting the battery from the charging/discharging station and disconnecting it from the test systems. The upper right tap is two test DISCHARGE lamps 12V 50W switched on to PWM controlled from the central processor. The lower right tap is a standard stabilized current discharge system consisting of 8 DISCHARGE bulbs at 13.8V 0.16A controlled by a PWM controller.

Standard questions according to the block diagram:
- Why two PWM per discharge?
- Is it possible to have fewer light bulbs? Can I replace them with one light bulb?
- Maybe instead of light bulbs, put one resistor and an LED?
- Okay, this is all clear, but why two switching relays instead of one switching relay?

And the answers to them:
- You need a low duty cycle for a low discharge current and a very high duty cycle for a test current. If you install one controller, then this condition is not met, because we get exactly the opposite, plus the capacitor gets in the way - the blue tank according to the diagram.
- Light bulbs really don’t like the moment of switching on with a cold coil at full voltage, so the voltage and current were lowered by installing several light bulbs.
- Light bulbs, unlike resistances, have the property of stabilizing the current; if this function is assigned to the controller, it will regulate the current by duty cycle, and we need a small and preferably constant duty cycle in a certain voltage range...
- Two switching relays instead of one switching relay are installed FOR RELIABILITY! During testing, there were cases of spontaneous opening of the power switch of the PWM controller due to electromagnetic interference on the wires in the device body.


Finding a suitable power supply.

We find a working computer ATX power supply, preferably with “T” shaped radiators. The easiest way is to search with friends or visit the nearest computer repair company and buy several dead power supplies for $1 per pair.
How to choose the right one based on external features is summarized in “explanations”.

"Click on this text to expand explanations"

How to choose the right one: “T”-shaped radiators are visible through the slots, and you can distinguish the power supply from its more modern version (for example, which is more complex and less suitable for rework) by the size of the microcircuit and the presence of a second microcircuit or transistors in the secondary. That is, if in the secondary you can see two microcircuits or a bunch of transistors, then this is definitely not GS6105, but or its analogue. For example, it is a trimmed version in terms of protection against excess input voltage, but at the same time it is fully compatible in terms of legs. If you have a choice of several damaged power supplies, then you can determine which one is repairable without opening the case by measuring Ohms at the ~220V power cable connector. Either there are ohms at the input, or there is infinity (the input fuse is broken). If the input fuse is broken, then it is better to leave such a unit (repairing the primary is long, difficult and tedious). And, having measured Ohms between ground and +5 bus, we see either the capacitor charge or a resistance of about 1-20 Ohms. If 1-20 Ohms are detected instead of charge, then the +5V bus diode has fused into the nut. If the input fuse does not blow out, then the power supply most likely has protection (but the main conclusion is that you are lucky and this instance has it). And since we don’t need a diode in a 5-volt circuit for our design, in 95% of cases such a power supply can be restored (to check “for starting without load” by replacing it with two ordinary ones), and then remade.
By the way, it has been noted that not all power supplies start without load. Therefore, if the fan in the power supply is broken (and especially if, in addition to the wind blower, the condensers in the secondary have dried out), then an attempt to turn it on by closing PW_On may not lead to the desired result and for this reason the power supply may be recorded as dead.
Attention!!! If the duty switch in the power supply is not working (+5vSb), then the input capacitors after the bridge are charged up to 400V and can remain charged for a long time even after the power supply is disconnected from the network.
I came across a power supply with a circuit vaguely reminiscent of the circuit from this manual.
But if you have a different one, then I am attaching an archive with 28 ATX power supply circuits assembled on and their analogues.
Well, then the power supply needs to be checked under a small load (I use two HDDs - dinosaurs of 25 MB each), and if it doesn’t work, then repair it, look for more information about repairing power supplies on the Internet.


Preparatory stage
(assembly of the analog part).

The preparatory stage includes checking the power supply, setting up the operational amplifier feedback and assembling the discharge circuit.

Rice. 8 Bit part in operation.

Details on this item are summarized in “explanations”.

"Click on this text to expand explanations"

Rice. 9 Grate for cooler.

1) Make sure that the power supply turns on and gives +5 and +12 (with a spread of +/-1V). To turn on the PW_On wire (usually this is a green wire located between two black ones in an ATX plug), you need to close it with a paper clip to one of the black ones (ground). If the power supply does not work or the cooler does not spin well, then we repair the power supply and lubricate the cooler (if even after lubrication it does not spin well, we change the cooler). If the cooler grille is made in the form of slits in the unit body, then to improve airflow and reduce noise, it is advisable to cut it out with pliers and replace it with a standard external grille for the cooler.

Rice. 10 After installing the screen.

Rice. 11 Fan transformer and stabil. +/-5V.

Attention!!! The computer power supply cannot be turned on without a load, so it must be loaded with something. As an option, connect a half-dead HDD (with rotating mechanics, I use two HDDs - dinosaurs of 25 MB each) or a couple of +12V coolers. A CD-Rom is not suitable as a load, since it does not provide a constant load.
7) We check the stabilization of voltages +5 and -5V and assemble the power supply into the case, while +12/+5/Gnd/-5/-12 from and stabilized +5 and -5V from the installed power transformer should be output from the case. The ~220V 200W light bulb should not smolder or glow.
8) We assemble the circuit from op-amp to . Based on knowledge of electrical engineering (as part of a school physics course), we assemble test dividers from a constant resistance that powers a diode (on conventional diodes the voltage drop is about 0.56 V) to which a variable resistor is connected. By rotating the variable resistor we get a voltage of +0.100V, and on the second similar arm the voltage is -0.100V. I’ll make a separate reservation that the tester must be switched to a scale with millivolts; if your tester has a scale of only 20V or its accuracy class is worse than 0.5, then we are looking for a normal tester.
9) We apply the resulting +0.100V and -0.100V in turn to the input of the current circuit assembled on and select feedback resistors, thereby setting up the measuring part for measuring currents. Our task is to achieve a voltage of 1.250V at the output of the operational amplifier of the current meter. For the charge circuit, +0.100V is used, and for the discharge circuit, -0.100V is used. I’ll make a separate reservation that the tester must be switched to a 2B scale (but not higher than a 3B scale). If your tester does not have such a scale or its accuracy class is worse than 0.5, then we are looking for a normal tester.
10) Using another divider, we get 6,000V, apply it to the input of the voltage measurement circuit assembled at, and adjust the voltage at its output to 1,000V. For those who do not own a tester, I will make a reservation that it is necessary to measure as close as possible, that is, 1,000V is measured on a 2V scale (but not higher than 3V scale), and 6,000V on a larger scale is approximately 10V (but not higher than 20V scale ).
11) Next to the op-amp circuit, a sound alarm has been implemented to indicate erroneous switching on (reversal of polarity) of the battery terminals on the integrated buzzer 1212FXP or its analogue (by the way, if anyone has a datashield for the 1212FXP or its analogue, please send it). When connecting, you must observe the polarity of the buzzer and the blocking diode in case a short circuit is detected in the buzzer; there is a protective current-limiting resistance in the circuit. After assembly, it is advisable to check the buzzer. To test, I used a 9V Krona battery. Before the experiment, it is advisable to disconnect the power supply from the network.
12) We assemble a discharge circuit and configure it for a current consumption of about 0.5A (the load should be selected based on a 10-hour discharge for your battery, while the current will be about 0.1C. For more details, see the documentation for your battery, there on the graph one of the discharge currents gives 10Hr). For those who do not know the terminology, “C” is the battery capacity and for a 7.2 Ah battery 0.1*C=0.72A. My load connection circuit is not entirely standard, but since we are making a current stabilizer (and not a step-down PWM power supply), which should work at almost any value of the input voltage, it was decided to install the switch on the ground side (which is typical for Step-Up , and not Step-Down), with this connection we open it with a voltage that does not depend on the voltage at the input terminals. True, in this case, an alternating voltage is obtained at the load (DISCHARGE bulb), but the bulbs are not polar, and this circuit solves the main function (discharge with a stabilized current).
Attention!!! The Mosfet control circuit must contain a regular high-speed diode. Not a Schottky diode and there is no need to connect both diodes in the BAV70 case, connect only one of them.

Rice. 12 Eight light bulbs.

To make the device compact, instead of one 12V 1A automotive DISCHARGE bulb, I installed 8 13.8V 0.16A DISCHARGE bulbs inside the device (directly on the fan to remove the heat they generate). This solution makes it possible to eliminate the external discharge unit and place all the units in the standard power supply housing. I used a reverse polarity diode removed from the 12V line, usually an analogue of the SR1040 (see instructions for the entire series).
For those who didn’t guess, the bit part is turned on by closing the transistor, that is, by shorting the control pin to ground (grounding through the transistor base resistor).
The ~220V 200W light bulb in the input circuit should glow slightly during experiments with the discharge turned on.
Attention!!! The computer power supply cannot be turned on without blowing off the radiators, so do not turn it on with the cover removed!!!


Installation into the housing and reconnection of the transformer.

Rice. 13 Filter capacitors.

This paragraph discusses connecting a transformer using a new circuit, feedback and noise filtering. It also discusses the need to rewind the transformer and argues that there will be enough current without rewinding. Details on this item are summarized in “explanations”.

"Click on this text to expand explanations"

1) We unsolder all excess in the secondary, then we unsolder the “trunk” and connect it to the central part, adding capacitors. Choose high-quality ceramic capacitors designed for relatively high current. This decision is due to the fact that LowECR 105C capacitors with voltages above 16V are difficult to obtain, so we replace them in pairs - a regular electrolyte and high-quality ceramics. As ceramics, I used polyethylene terephthalate capacitors of the type 1 μF at 250 V.
In this case, we combine the windings from the +5V and +12V lines, obtaining one +16V but with the current from the smallest line. The Chinese usually have linden written on the power supply housing and we must proceed from the actual size of the power transformer. For a 250W transformer (not to be confused with the linden calling it 450W on the label), we can remove current up to 20A from the +5V bus, and up to 6A from the +12V bus. Those. we get current up to 5A.

Rice. 14 Linden 450W (left), 170W (center) and 300W (right).

Yes, of course, you can rewind the transformer (the rewinding method and photographs were described above)... This will of course give an increase in current, well, say up to 15A (for a 250W transformer), but do we need this increase? With standard windings, a transformer can provide 3-5A (for transformers of 100-250W), of which in this design we use a maximum of 1-2A (14V*2A=28W) and we don’t need 15A for our technical specification (14.8V*15A= 217W).
Therefore, I installed ordinary 3-amp diodes. But if you really want to achieve high currents, then choose from 100V Schottky diodes. Well, for example, from the series (see instructions for the entire series) and place them on the radiator.
2) Once again we look at the block diagram (shown in Fig. 2) and suppress the current feedback (on the 16th leg), then remove the switch (on the 4th leg) and replace it with our own on 2 optocouplers, add a 1kOhm 2W adjustment resistance to the output and turn on without feedback. The generation should not fail (the ~220V 200W light bulb should not smolder or glow), and the resistance should be about 36V, while the generator should characteristically “click” (make very quiet sounds like a cricket).
If there is nothing at all at the output, then most likely you have +5V on the 4th leg and it needs to be pulled to ground (check the 10kOhm resistance to ground). If voltage appears at the output only when turned on, and then disappears, it means that the standard current feedback is making itself felt on leg 16.
3) We establish voltage feedback, select a divider so that the output is correctly 2.275V*6=13.65V, and according to the bad advice of “experienced” people who do not “fit” with GOST 825-73 it is equal to 2.450V*6=14.7 B (which, according to the same GOST 825-73, reduces the battery life by 4 times, to 25%, see the graph of the dependence of the battery life on the voltage of constant recharge in the StendBy mode, shown in Fig. 3 above). The ~220V 200W light bulb should not smolder or glow. Then we unsolder the 1kOhm 2W resistance, soldered for adjustment purposes from the output of the converter, which leads to the fact that the frequency of the “cycles” (the sounds produced) will drop three times.
4) Install the discharge circuit and light bulbs on the cooler. We turn on the system. The power transformer should “hiss” characteristically, and the ~220V 200W light bulb should begin to smolder. We don’t experiment without a lid for a long time, because... Without a cover, the primary radiator, deprived of airflow, begins to heat up noticeably. We pay special attention to the quality and correct execution of current circuits (they are marked in bold on l.2 of the diagram). For each of them, I used a double pigtail wire to the ATX plug soldered in the paragraph above.
5) We connect the current part to turn off the output switches and use the discharge circuit to check the correct polarity connection... That is, at the current detector (the one against which the LED weighs) a positive voltage of about + 0.625V should be obtained.
6) If everything went well in step 5, then we connect a 12V 1.5A light bulb to the output and use a variable resistor near the LED to limit the current to 1A (the voltage across the variable resistor is about +1.25V).
7) We make connection wires to the battery. To do this, I took 3 orange and 3 black wires from the pigtail to the ATX plug soldered in the step above. We twist 3 wires into a pigtail and solder standard battery terminals to the twist on one side. On the other hand, two of the three wires of the pigtail are connected to current circuits, and the remaining end is connected to voltage measurement. For aesthetics, we put heat-shrinkable casing on the terminals.
8) Well, now we have an “automatic” charger made from a computer ATX power supply, the automaticity of which means limiting the charge current (we set it to 1A), and when a certain threshold voltage is reached (we set it to 13.8V), the transition to voltage stabilization . And after adding the digital part, we will receive a microprocessor charger for maintenance-free lead-acid batteries.


Assembling the digital part.

This paragraph describes the connection of the microprocessor, relays, buttons, RS232 parts, and so on. Details on assembling the digital part are included in "explanations".

"Click on this text to expand explanations"

1) Attention!!! The ATMega8 microprocessor (there are also firmware options for ATMega48 and ATMega88) is installed in the socket only in point 6! All tests are carried out with the microprocessor removed.
2) We assemble a circuit for switching on the relay. A 12V relay with a switching current of 10A was chosen as a relay, although if you compare it with a size 3 starter, you can come to the conclusion that the Amperes there are Chinese (just as small). Then we display an LED on the front panel of the case indicating the connection to the battery (indicating that the relay is turned on). I don’t need any other means of indication; anyway, even this LED, when used in a cabinet, will not be visible.
3) We assemble the keyboard circuit, attach it to the front panel, and under it in the case we attach the Reset button so that it can be pressed through the air intake slot with a match.

Rice. 15 Keyboard buttons and below them the Reset button.

4) We assemble the RS232 part and connect it to the bell pin +5Sb through a fuse (this is necessary to power the external control module). Temporarily close the RX and TX pins of the microprocessor socket, open HyperTerminal and check the functionality of the RS232 part.
5) We connect the ends to the DAC, check the limiting diodes, solder them in and check that they cut off the negative voltage during discharge. I used low-voltage Schottky diodes as limiting diodes.
6) If all checks were successful, install the processor and flash it.


Rice. 16 Fitting the board into the case.

Firmware technique and Fuse bits.

What does the user need to see at the top level?

  A user in discharge/charge modes (we’ll talk about service and test modes separately) would like to know about the current state of the process (and the process is characterized by average currents and voltages) with data updated at least once every 5 seconds.
And I would like to know data on energy flows and current process data (total current flowed or drained) to build a graph. The graph is not in relative units, so the data is strictly needed 1 time per minute (preferably with great accuracy).

"Click on this text to expand explanations"

Based on the requirements for minute reports from the device and taking into account that to obtain average data, it is very convenient for the microprocessor to divide by the number 2, to some degree, so we take the number of measurements equal to 2^8 = 256 per minute.
If we assume that the cycles should be about 2 seconds (and each consist of at least 8 sets of measurements), then let’s take the number of cycles equal to 256/8=32
In this case, we obtain the duration of one cycle equal to 60/32 = 1.875 seconds.
Check: 1.875 seconds is within the tolerance of 2 seconds.
In this case, the arrival of sets will be every 60/(32*8)=0.234375 seconds.
Considering that to generate each set it is necessary to take a measurement and calculate the values ​​from it, the need for an interruption occurs every 60/(32*8*2)=0.1171875 seconds... Otherwise, 512 times per minute.
We have 11059200 quartz, so we select the reduction for the first timer to be equal to 64 and it will be incremented 172800 times per second. But we need not 172800 times, but 8.53(3) faster than 172800/8.53(3)=0x4F1A.
A full cycle will take 32*8*2*64*20250/11059200, which is exactly 60 seconds (without remainder)
Check: 60 seconds (without remainder) is equal to the task “cycles exactly 1 minute”.
To change the quartz in automatic mode, we write the formula for calculating the timer period 0xFFFF-(CLOCKr/64)*60/512.
The ADC of the microprocessor has a width of 10 bits, but the documentation says that the absolute error is ±2 least significant digits, so we accept the ADC width = 8 bits. We have 0xFF measurements per minute for each channel, and we take the maximum number of saved minute reports equal to 0xFFFF (for 45 days). Therefore, we allocate 4 bytes per channel for currents, and 5 bytes per channel for powers. It is advisable to number each packet, and we are going to use the device for at least 24 hours - we allocate two bytes (NnNn) for the packet numbers.
We pack all this into a text format and do not send the lowest byte, which is equivalent to dividing by 256 (the system measures 256 times per minute, reports are minute-long, so it was necessary to divide the amount by 256)
Next, we pack it all into a package like this:

>N_NnNnXiXiXiYyYyYyWwWwWwWwTtTtTtTt +#11 +#13

And that’s 37 bytes for minute packets (exactly 60 seconds).
And regarding the current discharge/charge data, which must be provided at least once every 5 seconds, we take the arithmetic average for two cycles (2 cycles * 8 measurements = 16, which is 2 to the power of four = conveniently divided by MK), pack them into the text message, adding a status byte and issuing it to the user every 2*1.875 = 3.75 seconds (which fits within the specified time at least once every 5 seconds).
We will provide the data in text form, therefore, the prefix “>P_” at the beginning.

>P_KkIrIzUu +#11 +#13

And that’s 13 bytes for 4 second packets (more precisely 3.75 seconds).

Final testing.

Autonomous operation algorithm.

  As already written above, the algorithm is compiled according to the available data and for this specific situation... This design was created on an “as is” basis, according to data found on the Internet, from parallel branches and documentation for batteries (i.e. independent research of parameters The author did not test several hundred batteries from different manufacturers). The system was tested on several batteries available to the author and showed positive results, so with a high degree of probability this algorithm is suitable for other similar batteries from other manufacturers.
Therefore, if you notice any inaccuracies in this description or you have ideas on how to improve it, then write to the email address indicated at the very bottom of the page.
One philosopher said: “To believe is to refuse to understand.” Therefore, do not repeat blindly, but check compatibility with your conditions before repeating this design.
Reset - A button that can be pressed with a match through the air duct slot.
To activate self-programming mode.

Remote control.

As described above, it was decided not to overload the device with display elements due to their high price and low efficiency when using the system in places that are difficult to access for visual inspection.
Therefore, it was decided to equip the device with an RS232 interface, through which this device can be controlled either from a computer or from a control panel. Moreover, in the case of using several chargers in parallel, you can connect one external control panel in turn to each of the chargers.

Charging algorithm.

1) Check the voltage at the terminals. If less than 6.5V, charge is canceled with a sound signal.
2) The charge cycle limits the charge current (usually about 1-2A) to a certain threshold voltage (usually about 13.8-14.5V), and then switches to voltage stabilization.
3) Checking the conditions for the buildup.
4) Checking the drain condition 1:10 flooded.
If during draining the voltage drops below 6.5 Volts = output with a sound signal.
If there was already a build-up, and during the drain 1:10 the voltage dropped below 8.6 Volts = output with a sound signal.
5) Check condition for the end of the charge - If the build-up has already occurred, but the average current per minute is less than 0.09A = output with a sound signal.
6) Checking the conditions for generating a report for two cycles.
7) Checking the conditions for generating a minute report.
8) Check to see if the stop command has arrived via RS232 or if SB4 has been pressed.
9) Go to point 2

Discharge algorithm

1) Check the voltage at the terminals. If less than 12.0V, discharge is canceled with a sound signal.
2) Discharge cycles are carried out with a pulsating current with a maximum of 0.1C (for 7.2Ah at I=0.1C we get I=0.75A).
3) Check the voltage at the terminals. If the average per minute is less than 10.8V, the discharge is canceled with a sound signal.
4) Check the voltage at the terminals. If the average over two cycles is less than 6.5V, the discharge is canceled with a sound signal.
5) Checking the conditions for generating a report for two cycles.
6) Checking the conditions for generating a minute report.
7) Check to see if the stop command has arrived via RS232 or if SB4 has been pressed.
8) Go to point 2

Firmware and control program.

The mathematical part of the project is not simple, so we have so far developed only its basic part. The basic part can control the charging and discharging processes, handles all emergency situations, and has self-diagnosis algorithms. We plan to write algorithms for testing and flexible configuration for your hardware (taking into account part tolerances) later. Therefore, for now the firmware files and the control program are as is (in the test and main set), i.e. the author has completed the system to the point of “But it works for me and I like everything!”, but if you are interested in the further development of the project or have ideas for improvement, then write to the email address at the bottom of the page... we’ll try to come up with something together...
To this system you can add:
1) Adjustment for hardware from a computer via RS232.
2) Loading tuning parameters into the program from hardware.
3) Teletubbies and animations in the control program.
4) Algorithm for testing the remaining capacity and percentage of battery charge.
5) Hardware control panel - a logger device equipped with an LCD display and I2C memory for recording logs.

There is a lot of different types of information on the Internet on the issue of homemade chargers, but, in my opinion, the criterion for its usefulness is its compliance with the physics and chemistry of the processes in the battery. Utility in this context means the absence of negative consequences (harm) for batteries after applying the information in practice. Details and links on this item are collapsed into “explanations”.

"Click on this text to expand explanations"

By profession, I am an engineer who designs automated process control systems (automated process control systems) and is a little far from chemistry (technological chemists usually write technical specifications for the control of chemical processes), so at the end of the article I have collected the most informative, in my opinion, links on this topic . But I do not undertake to judge their compliance (adequate reflection) of the physical and chemical processes in the battery. But I want to warn you that they were written by amateurs and each of them may have its own positive, negative and even, unfortunately, very harmful aspects.

Materials on ATX power supplies:
Powerful power supply by upgrading from smaller power units.
Modification of the power supply..
Charger for lead batteries on MK Atmega8.
Charger for atmega8.

Restrictions.

The device is designed AS IS and the author is not responsible for obvious (or not obvious) damage caused as a result of repetition.

That is, you do all experiments at your own peril and risk.

Read the list of frequently asked questions at

If you have any questions or suggestions, write to me at the address at the bottom of the page

If you found something interesting or useful for yourself on my website and want to see new interesting projects on this site, as well as support and improvements to existing projects, then everyone can support this project, partially cover the cost of hosting, development and rework costs projects.

This device is designed to measure the capacity of Li-ion and Ni-Mh batteries, as well as to charge Li-ion batteries with a choice of initial charge current.

Control

We connect the device to a stabilized power supply of 5V and a current of 1A (for example, from a cell phone). The indicator displays the result of the previous capacitance measurement “xxxxmA/c” for 2 seconds and on the second line the value of the OCR1A register “S.xxx”. We insert the battery. If you need to charge the battery, then briefly press the CHARGE button; if you need to measure the capacity, then briefly press the TEST button. If you need to change the charge current (the value of the OCR1A register), then press the CHARGE button for a long time (2 seconds). Go to the register adjustment window. Let's release the button. By briefly pressing the CHARGE button, we change the values ​​of the register in a circle (50-75-100-125-150-175-200-225), the first line shows the charging current of an empty battery at the selected value (provided that you have a 0 resistor in the circuit ,22 Ohm). Briefly press the TEST button; the values ​​of the OCR1A register are stored in non-volatile memory.
If you have performed various manipulations with the device and you need to reset the clock or measured capacity, then press the TEST button for a long time (the values ​​of the OCR1A register are not reset). As soon as the charge is complete, the display backlight turns off, to turn on the backlight, briefly press the TEST or CHARGE button.

The operating logic of the device is as follows:

When power is applied, the indicator displays the result of the previous measurement of the battery capacity and the value of the OCR1A register, stored in non-volatile memory. After 2 seconds, the device goes into the mode of determining the battery type based on the voltage at the terminals.

If the voltage is more than 2V, then it is a Li-ion battery and the full discharge voltage will be 2.9V, otherwise it is a Ni-MH battery and the full discharge voltage will be 1V. Control buttons are available only after connecting the battery. Next, the device waits for the Test or Charge buttons to be pressed. The display shows "_STOP". When you briefly press the Test button, the load is connected via a MOSFET.

The magnitude of the discharge current is determined by the voltage across the 5.1 Ohm resistor and is summed up with the previous value every minute. The device uses 32768Hz quartz to operate the clock.

The display shows the current value of the battery capacity "xxxxmA/s" and the discharge torus "A.xxx", as well as the time "xx:xx:xx" from the moment the button was pressed. An animated low battery icon is also shown. At the end of the test for the Ni-MH battery, the message “_STOP” appears, the measurement result is displayed on the display “xxxxmA/c” and is remembered.

If the battery is Li-ion, then the measurement result is also displayed on the display “xxxxmA/c” and is remembered, but the charging mode is immediately activated. The display shows the contents of the OCR1A register "S.xxx". An animated battery charge icon is also shown.

The charge current is adjusted using PWM and is limited by a 0.22 Ohm resistor. In hardware, the charge current can be reduced by increasing the resistance from 0.22 Ohm to 0.5-1 Ohm. At the beginning of charging, the current gradually increases to the value of the OCR1A register or until the voltage at the battery terminals reaches 4.22V (if the battery has been charged).

The amount of charge current depends on the value of the OCR1A register - the larger the value, the larger the charge current. When the voltage at the battery terminals exceeds 4.22V, the value of the OCR1A register decreases. The recharging process continues until the OCR1A register value is 33, which corresponds to a current of about 40 mA. This ends the charge. The display backlight turns off.

Settings

1. Connect the power.
2. Connect the battery.
3. Connect the voltmeter to the battery.
4. Using the temporary + and - buttons (PB4 and PB5), we ensure that the voltmeter readings on the display and the reference voltmeter match.
5. Long press the TEST button (2 seconds), memorization occurs.
6. Remove the battery.
7. Connect the voltmeter to the 5.1 Ohm resistor (according to the diagram near the 09N03LA transistor).
8. Connect the adjustable power supply to the battery terminals, set the power supply to 4V.
9. Briefly press the TEST button.
10. We measure the voltage across the 5.1 Ohm resistor - U.
11. Calculate the discharge current I=U/5.1
12. Using the temporary buttons + and - (PB4 and PB5) we set the calculated discharge current I on the indicator “A.xxx”.
13. Long press the TEST button (2 seconds), memorization occurs.

The device is powered from a stabilized source with a voltage of 5 Volts and a current of 1A. Quartz at 32768Hz is designed for accurate time keeping. The ATmega8 controller is clocked from an internal oscillator with a frequency of 8 MHz, and it is also necessary to set EEPROM erase protection with the appropriate configuration bits. When writing the control program, educational articles from this site were used.

The current values ​​of the voltage and current coefficients (Ukof. Ikof) can be seen if you connect a 16x4 display (16x4 is preferable for debugging) on ​​the third line. Or in Ponyprog if you open the EEPROM firmware file (read from the EEPROM controller).
1 byte - OCR1A, 2 bytes - I_kof, 3 bytes - U_kof, 4 and 5 bytes are the result of the previous capacity measurement.

Video of the device working:


Batteries are very common today, but commercially available chargers for them are usually not universal and are too expensive. The proposed device is intended for charging rechargeable batteries and individual batteries (hereinafter the term “battery” is used) with a rated voltage of 1.2...12.6 V and a current of 50 to 950 mA. The input voltage of the device is 7...15 V. Current consumption without load is 20 mA. The accuracy of maintaining the charging current is ±10 mA. The device has an LCD and a convenient interface for setting the charging mode and monitoring its progress.

A combined charging method has been implemented, consisting of two stages. At the first stage, the battery is charged with a constant current. As it charges, the voltage across it increases. As soon as it reaches the set value, the second stage will begin - charging with a constant voltage. At this stage, the charging current is gradually reduced, and the battery maintains the specified voltage. If the voltage for any reason drops below the set value, charging with a constant current will automatically begin again.

The charger circuit is shown in Fig. 1.

Rice. 1. Charger circuit

Its basis is the DD1 microcontroller. It is clocked by an internal RC oscillator at 8 MHz. Two channels of the microcontroller ADC are used. Channel ADC0 measures the voltage at the output of the charger, and channel ADC1 measures the charging current.

Both channels operate in eight-bit mode, the accuracy of which is sufficient for the device being described. The maximum measured voltage is 19.9 V, the maximum current is 995 mA. If these values ​​are exceeded, the inscription “Hi” appears on the HG1 LCD screen.

The ADC operates with a reference voltage of 2.56 V from the microcontroller's internal source. To be able to measure a higher voltage, the resistive voltage divider R9R10 reduces it before applying it to the ADC0 input of the microcontroller.

The charging current sensor is resistor R11. The voltage that drops across it when this current flows is supplied to the input of op-amp DA2.1, which amplifies it approximately 30 times. The gain depends on the ratio of the resistances of resistors R8 and R6. From the output of the op-amp, a voltage proportional to the charging current is supplied through a repeater to the op-amp DA2.2 to the ADC1 input of the microcontroller.

An electronic switch is assembled on transistors VT1-VT4, operating under the control of a microcontroller that generates pulses at the OS2 output, following at a frequency of 32 kHz. The duty cycle of these pulses depends on the required output voltage and charging current. Diode VD1, inductor L1 and capacitors C7, C8 convert pulse voltage into direct voltage, proportional to its duty cycle.

LEDs HL1 and HL2 are charger status indicators. The HL1 LED on means that the output voltage has been limited. The HL2 LED is on when the charging current is increasing, and off when the current does not change or decreases. When charging a healthy discharged battery, the HL2 LED will first turn on. Then the LEDs will flash alternately. The completion of charging can be judged by the glow of only the HL1 LED.

By selecting resistor R7, the optimal contrast of the image on the LCD display is established.

The R11 current sensor can be made from a piece of high-resistance wire from a heater coil or from a powerful wirewound resistor. The author used a piece of wire with a diameter of 0.5 mm and a length of about 20 mm from the rheostat.

The ATmega8L-8PU microcontroller can be replaced by any of the ATmega8 series with a clock frequency of 8 MHz and higher. The BUZ172 field-effect transistor should be installed on a heat sink with a cooling surface area of ​​at least 4 cm2. This transistor can be replaced with another p-channel transistor with a permissible drain current of more than 1 A and low open-channel resistance.

Instead of transistors KT3102B and KT3107D, another complementary pair of transistors with a current transfer coefficient of at least 200 is suitable. If transistors VT1-VT3 operate correctly, the signal at the transistor gate should be similar to that shown in Fig. 2.

Rice. 2. Gate signal graph

Inductor L1 is removed from the computer power supply (it is wound with a wire with a diameter of 0.6 mm).

The microcontroller configuration must be programmed according to Fig. 3. The codes from the V_A_256_16.hex file should be entered into the microcontroller program memory. The following codes must be written to the EEPROM of the microcontroller: at address 00H - 2CH, at address 01H - 03H, at address 02H - 0BEH, at address 03H -64H.

Rice. 3. Programming the microcontroller

You can start setting up the charger without an LCD and a microcontroller. Disconnect transistor VT4, and connect the connection points of its drain and source with a jumper. Apply a supply voltage of 16 V to the device. Select resistor R10 such that the voltage on it is within 1.9...2 V. You can make this resistor out of two connected in series. If a 16 V voltage source is not found, apply 12 V or 8 V. In these cases, the voltage across resistor R10 should be about 1.5 V or 1 V, respectively.

Instead of a battery, connect an ammeter and a powerful resistor or car lamp in series to the device. By changing the supply voltage (but not lower than 7 V) or selecting the load, set the current through it to 1 A. Select resistor R6 so that the output of op-amp DA2.2 has a voltage of 1.9...2 V. Like resistor R10, It is convenient to make resistor R6 out of two.

Turn off the power, connect the LCD and install the microcontroller. Connect a resistor or a 12 V incandescent lamp with a current of about 0.5 A to the output of the device. When you turn on the device, the LCD will display the voltage at its output U and the charging current I, as well as the limiting voltage Uz and the maximum charging current Iz. Compare the current and voltage values ​​on the LCD with the readings of a standard ammeter and voltmeter. They will probably vary.

Turn off the power, install jumper S1 and turn on the power again. To calibrate the ammeter, press and hold the SB4 button, and use the SB1 and SB2 buttons to set on the LCD the value closest to that shown by the reference ammeter. To calibrate the voltmeter, press and hold the SB3 button, and use the SB1 and SB2 buttons to set the value on the LCD equal to that shown by the reference voltmeter. Without turning off the power, remove jumper S1. Calibration coefficients will be written to the microcontroller EEPROM for voltage at address 02H, and for current at address 03H.

Turn off the power to the charger, replace the VT4 transistor, and connect a 12 V car lamp to the output of the device. Turn on the device and set Uz = 12 V. When Iz changes, the brightness of the lamp should change smoothly. The device is ready for use.

The required charging current and maximum voltage on the battery are set using buttons SB1 "▲", SB2 "▼", SB3 "U", SB4 "I". The charging current change interval is 50...950 mA in 50 mA steps. The voltage change interval is 0.1...16 V in steps of 0.1 V.

To change Uz or Iz, press and hold the SB3 or SB4 button, respectively, and use the SB1 and SB2 buttons to set the required value. 5 s after releasing all buttons, the set value will be written to the EEPROM of the microcontroller (Uz - at address 00H, Iz - at address 01H). It should be borne in mind that holding the SB1 or SB2 button pressed for more than 4 s increases the speed of parameter change by approximately ten times.

The microcontroller program can be downloaded.


Publication date: 25.09.2016

Readers' opinions
  • Oleg / 05/19/2018 - 21:49
    Please send me the eeprom firmware file by email [email protected] I've been pushing for over a month and the flower doesn't come out!!!
  • Sasha / 01/19/2018 - 19:10
    Folks, has anyone assembled this device!
  • Yuri / 01/19/2018 - 18:35
    Question to the author. The output of microprocessor 1 is hanging in the air. This is not a typo.

This device is designed to measure the capacity of Li-ion and Ni-Mh batteries, as well as to charge Li-ion batteries with a choice of initial charge current.

Control

We connect the device to a stabilized power supply of 5V and a current of 1A (for example, from a cell phone). The indicator displays the result of the previous capacitance measurement “xxxxmA/c” for 2 seconds and on the second line the value of the OCR1A register “S.xxx”. We insert the battery. If you need to charge the battery, then briefly press the CHARGE button; if you need to measure the capacity, then briefly press the TEST button. If you need to change the charge current (the value of the OCR1A register), then press the CHARGE button for a long time (2 seconds). Go to the register adjustment window. Let's release the button. By briefly pressing the CHARGE button, we change the values ​​of the register in a circle (50-75-100-125-150-175-200-225), the first line shows the charging current of an empty battery at the selected value (provided that you have a 0 resistor in the circuit ,22 Ohm). Briefly press the TEST button; the values ​​of the OCR1A register are stored in non-volatile memory.
If you have performed various manipulations with the device and you need to reset the clock or measured capacity, then press the TEST button for a long time (the values ​​of the OCR1A register are not reset). As soon as the charge is complete, the display backlight turns off, to turn on the backlight, briefly press the TEST or CHARGE button.

The operating logic of the device is as follows:

When power is applied, the indicator displays the result of the previous measurement of the battery capacity and the value of the OCR1A register, stored in non-volatile memory. After 2 seconds, the device goes into the mode of determining the battery type based on the voltage at the terminals.

If the voltage is more than 2V, then it is a Li-ion battery and the full discharge voltage will be 2.9V, otherwise it is a Ni-MH battery and the full discharge voltage will be 1V. Control buttons are available only after connecting the battery. Next, the device waits for the Test or Charge buttons to be pressed. The display shows "_STOP". When you briefly press the Test button, the load is connected via a MOSFET.

The magnitude of the discharge current is determined by the voltage across the 5.1 Ohm resistor and is summed up with the previous value every minute. The device uses 32768Hz quartz to operate the clock.

The display shows the current value of the battery capacity "xxxxmA/s" and the discharge torus "A.xxx", as well as the time "xx:xx:xx" from the moment the button was pressed. An animated low battery icon is also shown. At the end of the test for the Ni-MH battery, the message “_STOP” appears, the measurement result is displayed on the display “xxxxmA/c” and is remembered.

If the battery is Li-ion, then the measurement result is also displayed on the display “xxxxmA/c” and is remembered, but the charging mode is immediately activated. The display shows the contents of the OCR1A register "S.xxx". An animated battery charge icon is also shown.

The charge current is adjusted using PWM and is limited by a 0.22 Ohm resistor. In hardware, the charge current can be reduced by increasing the resistance from 0.22 Ohm to 0.5-1 Ohm. At the beginning of charging, the current gradually increases to the value of the OCR1A register or until the voltage at the battery terminals reaches 4.22V (if the battery has been charged).

The amount of charge current depends on the value of the OCR1A register - the larger the value, the larger the charge current. When the voltage at the battery terminals exceeds 4.22V, the value of the OCR1A register decreases. The recharging process continues until the OCR1A register value is 33, which corresponds to a current of about 40 mA. This ends the charge. The display backlight turns off.

Settings

1. Connect the power.
2. Connect the battery.
3. Connect the voltmeter to the battery.
4. Using the temporary + and - buttons (PB4 and PB5), we ensure that the voltmeter readings on the display and the reference voltmeter match.
5. Long press the TEST button (2 seconds), memorization occurs.
6. Remove the battery.
7. Connect the voltmeter to the 5.1 Ohm resistor (according to the diagram near the 09N03LA transistor).
8. Connect the adjustable power supply to the battery terminals, set the power supply to 4V.
9. Briefly press the TEST button.
10. We measure the voltage across the 5.1 Ohm resistor - U.
11. Calculate the discharge current I=U/5.1
12. Using the temporary buttons + and - (PB4 and PB5) we set the calculated discharge current I on the indicator “A.xxx”.
13. Long press the TEST button (2 seconds), memorization occurs.

The device is powered from a stabilized source with a voltage of 5 Volts and a current of 1A. Quartz at 32768Hz is designed for accurate time keeping. The ATmega8 controller is clocked from an internal oscillator with a frequency of 8 MHz, and it is also necessary to set EEPROM erase protection with the appropriate configuration bits. When writing the control program, educational articles from this site were used.

The current values ​​of the voltage and current coefficients (Ukof. Ikof) can be seen if you connect a 16x4 display (16x4 is preferable for debugging) on ​​the third line. Or in Ponyprog if you open the EEPROM firmware file (read from the EEPROM controller).
1 byte - OCR1A, 2 bytes - I_kof, 3 bytes - U_kof, 4 and 5 bytes are the result of the previous capacity measurement.

Video of the device working:

New on the site

>

Most popular