Hope you guys are doing great.

Ever since I published my first blog post discussing the design and implementation of temperature gradient cut-off ATtiny24 smart charger for NiMh batteries I wasn’t fully satisfied with the power or the actual charging circuit, initially I decided to build the charger controller and the power circuit separately since I knew that I’d be making changes in the design as I go along.

For those of you who are lost at this point, here’s a link to my first post discussing the design of the my smart NiMh charger.

https://lonetechnologist.wordpress.com/2016/04/25/designing-a-delta-tempdelta-time-temperature-gradient-charge-termination-smart-charger-for-nimh-battery-pack/

Although I am fairly comfortable at this point with the control circuit but the power circuit has one obvious problem, it’s too bulky for my liking! the LM350 dissipates a lot of heat, I had to mount a fan on top of it to cool it off and since only recently I was beginning to think that I should get a case made for the project it just didn’t seem that the final version would look elegant owing exclusively to the big foot print.

I haven’t had any experience with using a switching regulator but anyone with basic electronics training would know that high current designs based around switching regulators are comparatively smaller in size to a regular linear regulator design and this comes due to the fact that switching regulators are efficient and hence waste less heat as compared to linear regulators and therefore require a much smaller heat sink and possibly no fan to remove the wasted heat. Secondly since we will be making a switching constant current charger/power circuit therefore it’s worth mentioning that in order to bias an LM350 as a constant current regulator for high currents approaching to 2 Amps you need big power resistors which in my case took most of the area on the perf-board but for a switching regulator we’ll be using a feedback technique that allows for usage of normal sized resistors saving up a lot of space in the process.

And yes for those of you who might argue probably the biggest reason an SMPS is lighter and smaller than a simple linear voltage supply is because high frequency ferrite core transformers are smaller and add a lot to the size reduction of the design, however in my case I have mentioned the aspects that have allowed me to make my circuit smaller.

Choosing a Switching Regulator

The obvious selection criteria for an LM350 replacement is to look for a regulator that can handle 3 Amps, is adjustable and can easy handle input voltages of around 35 volts (the more the better). After doing a little online search I found the LM2576-ADJ as a reasonable choice. The LM2576-ADJ is a buck regulator meaning you can have an output voltage of your choice which is lower than the input voltage.

LM2576-adj
The LM2576-Adjustable

Looking at the LM2576 you see it has two more pins than your usual linear regulators, the pin 5 is a normal TTL logic level ON and OFF signal that can enable or disable the chip at will while the fourth feedback pin might be new to you who haven’t worked with a switching regulator before, like me.

Essentially since a switching regulator regulates the internal oscillator’s duty cycle (PWM) in order to regulate its voltage output to a desired level therefore it needs to know what voltage is at the output pin, this is where the feedback pin comes into use.

For an explanation of how the DC-DC buck convertor works, check out Afrotechmods comprehensive video on the subject.

 

The Circuit Design

Fortunately Texas Instrument has a very well written literature (# snva557) on how a constant current charger power circuit can be designed using an LM2576 regulator and this is what I have based my design on.

snva557 charger
The original circuit as presented in Texas Instruments literature # snva557

The above is used for a 12 volt NiMh battery to be charged at a constant current of 2.2 Amps, I have modified the above circuit slightly in order to get selectable current levels of 700 mA and 1.8 Amp staying true to the specifications of the original LM350 based charging circuit.

The Op-Amp is a wonderful component as you’ll find out that just by selecting different feedback resistor values I have managed to get the required current output.

new
The Modified Circuit Design for 700 & 1800mA Current Outputs

Please ignore the crudity of the diagram, here just by adding two 12 volt relays (yes I can’t help using them!) I have managed to switch between 700 mA and 1.8 Amp, well in actual it’s around 1.73 Amps since my calculations were a bit off but it’s still good enough for me, the controller can select between the two current levels depending on what’s required for the charging process, also not shown in the above diagram I have added a red LED fed from 12 volts through a 1K ohm resistor as well and in case you are wondering I have only used the 0.1 ohms resistor instead of the 0.05 ohm because it was easily available.

The Code Upgrade

Well I was hoping the new power circuit will be fully compatible with the code that’s already on the ATtiny24 but unfortunately that is not the case, I had to do some minor adjustments in the code which will work with this power circuit.

void setup()
{
pinMode (3, OUTPUT); //Indication LED
pinMode (2, OUTPUT); //Relay control
pinMode (10, OUTPUT);//Thermistor control
pinMode (7, OUTPUT);//E/S LED
pinMode (9, OUTPUT); //High current mode ON
pinMode (4, OUTPUT); //Moderate current mode ON
analogReference(EXTERNAL);
delay(5000);
digitalWrite(3,HIGH);
digitalWrite(2,HIGH);//start charging
delay(2000);
if(analogRead(A6) >= 608) //if connected battery voltage equals or is greater than 16.7 volts, terminate charging with error to protect overcharge.
{
digitalWrite(2,LOW);
for(;;)
{
digitalWrite(3,HIGH);
delay(500);
digitalWrite(3,LOW);
delay(500);
}}
}
//int cycle = 0;
byte Count = 0;
void loop()
{
unsigned long Temp_C=0, Temp_N=0, x=0, y=0, TempN=0, TempC=0, b=0;
byte a=0, i = 0;
//int volts1, volts2;
//volts1 = analogRead(A6);
delay(1000);
if(analogRead(A6) >= 546)//When battery voltage is greater than or equal to 14.4 volts
{
digitalWrite(4, HIGH); //Turn OFF 700 mA mode
digitalWrite(9,HIGH);//Select 0.8C charging mode
}//digitalWrite(2,HIGH);//Start Charging
digitalWrite(10,HIGH);
//delay(5000);
delay(2000);
for(a=0;a<=5;a++){
Temp_C = analogRead(A1); //at 2.3V starts with 587
delay(1000);
if(Temp_C>=503)//Temp_C can be equal to 503000
{
x = 13975;
y = 9930680;
}
if(Temp_C<=502&&Temp_C>=386)
{
x = 11852;
y = 9186300;
}

  if(Temp_C<=385)//Temp_C can be equal to 385000
{
x = 9527;
y = 8144330;
}
Temp_C = Temp_C*10000; // 385*1000 = 385000
TempC = y-Temp_C; //(814433 – 385000)*10
TempC = TempC/x; //
b = b+TempC;
}
digitalWrite(10,LOW);
//b = b/6;
TempC = b/6;
a = 0;
b = 0;
if(analogRead(A6) >= 696) //when connected battery voltage at 18 volts (3.38 volts on the A6 pin) — edited on 17/4/2016 to 826 from 845, needs 3.30 volts on A6 now
{
digitalWrite(2,LOW);

for(;;)
{
digitalWrite(3,LOW);
}
//Count++;
}
while(i<=59)
{
delay(1000);
i++;
}
x=0;
y=0;
digitalWrite(10,HIGH);
delay(2000);
for(a=0;a<=5;a++){
Temp_N = analogRead(A1); //at 2.0V gets 503
delay(1000);
if(Temp_N>=503)
{
x = 13975;
y = 9930680;
}
if(Temp_N<=502&&Temp_N>=386)
{
x = 11852;
y = 9186300;
}
if(Temp_N<=385)
{x = 9527;
y = 8144330;}
if (Temp_N <= 365)//E/S when temperature is 45 degree or higher
{
digitalWrite(3,HIGH);
digitalWrite(7,HIGH);
digitalWrite(2, LOW);
for(;;){}}
Temp_N = Temp_N*10000;
TempN = y-Temp_N;
TempN = TempN/x;
b = b+TempN;
}
//digitalWrite(10,LOW);
TempN = b/6;
if(TempN > TempC)//Emergency cutoff charging
{
if(TempN-TempC >= 8)
{
digitalWrite(3, LOW); //Indicator LED
digitalWrite (7, HIGH); //E/S LED
digitalWrite(9, LOW);
//delay(2000);
digitalWrite(4,LOW);
delay(60000);
digitalWrite(2,LOW);//Relay control pin
for(;;){}
}}
Count++;
if(Count == 180) //Turn off charging after 3 hours regardless of termination conditions
{
digitalWrite(2,LOW);//Turn off charging
for(;;)
{
delay(500);
//digitalWrite(3,LOW);
digitalWrite(7,HIGH);
delay(500);
//digitalWrite(3,HIGH);
digitalWrite(7,LOW);
//delay(500);
}}
}

The Final Circuit on Perf-Board with Side by Side Size Comparisons

IMG_20160617_163814
The new switching charging circuit
IMG_20160617_163902
The LM2576 heat sinked with thermal grease
IMG_20160617_165122
The new charging circuit side by side with the old one based on the LM350, a definite size and performance advantage. Did I mention it looks a lot less uglier?

Finally here’s a short video of the complete charger circuit in action hooked up to the old controller board.

 

Final Words

All credit to the guys over at Texas Instruments for publishing such a smart and easily hackable design, well what basically started as a side project has turned out to be quite an interesting run so far, I am wondering if I can upgrade my controller circuit now, I already have an ATtiny24 but the ATmega328 isn’t that hard to accommodate on a similar sized board, I can try reducing some of the extra components, may be put in an LCD and a keypad to set battery voltage and charging current levels before charging starts and make it truly universal. Thanks for all your support and interest.

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s