• Howdy! we're looking for donations to finish custom knowledgebase software for this forum. Please see our Funding drive thread

trying to make a LiPo charger/balancer

dirty_d

10 kW
Joined
Jun 16, 2007
Messages
985
Location
Massachusetts
I just got a cheap electric RC airplane a couple weeks ago and just bought a lipo pack and a cheap lipo charger, maybe too cheap. id like to make my own charger in case the other one doesn't cut it, ill learn more about electronics in the process too. i think ive gotten the current limiting down, same basic idea as the current limiting throttle fechter posted. im not sure about the specifics of how the charge cycle should go, how this circuit here does it is just try to maintain 2A(1C for 2000mAh pack) as long as possible without going over 12.6V(peak voltage for 3s pack). im not sure if the voltage should be cut off as soon as 12.6V is reached or its ok to let it stay? im not really sure how the balancing should be done, i was thinking if i had some kind of voltage reference IC at 4.2V for each cell with the ground attached to that particular cells negative terminal and the supply attached to the +12.6V rail and have an op-amp turn on a FET with resistor thats in parallel with that cell if the cell voltage goes above 4.2V. or maybe an IC that does all that for me and just turns on an output when the cell gets above 4.2V to switch on the FET. i haven't been able to find any precise voltage references or voltage detectors that work like that though. any help would be greatly appreciated!

heres what i have so far, i should have put the fet on the low side with the current sense resistor to the left of it.
charger2.jpg
 
I'm thinking the same thing. With these Thundersky cells they would be so big (40 Ah each) that you really are not going to be able to charge them as fast as you would like using anything on the market. Patrick has suggested that you combine them into packs of four and then use an SLA charger on them. But this still means that you are not isolating each cell and unless you also add a BMS that can balance at those loads you will not get the most out of the cells.

Seems to me you need:

:arrow: A voltage source with high current abilities.

:arrow: A bunch of comparators to sense the voltage.

:arrow: A way to turn off each cell when the charging is done.

With Thundersky cells you can charge them at a truly amazing 120 amps per cell. (that's the claimed upper limit) Without some very powerful hardware as your base you will not be able to do this.


So those are the design issues I'd want to address... being able to go to the cell level with big power and instant cutoff once done are the big priorities.

For the sake of simplicity I'm okay with having individual wires connecting to individual cells. With only 12 cells I don't mind having to plug and unplug that many if it means that I can charge it really fast as a result.
 
They make a number of chips that have a voltage reference and comparator combined just for monitoring battery voltages. If you look on page 4 of http://endless-sphere.com/forums/viewtopic.php?f=14&t=2498 , you'll see Victor's voltage clamper circuit. Something like that would make a good balancer.

The chips Gary and Bob use for the LVC circuit could probably be used also.
 
ok cool that circuit looks like it will do what i want, theres a couple things im confused about though, first off i looked at the datasheet for the LM431 still don't really get how it works, its an adjustable breakdown voltage zener diode? and if so im not sure how its adjusted to a fixed value since the supply voltage is varying as the cell charges so the voltage at the voltage divider is too, also does current slowly start to flow as the breakdown voltage is approached or is it sudden and exactly at the breakdown voltage? Let me see if ive got this right, when the cell voltage goes above the breakdown voltage of the LM431 then the voltage at the base of the MPSA63 will be at cell voltage minus breakdown voltage volts below the emitter and a current will flow from emitter to base and turn the rest of the circuit on, i haven't really learned all that much about how exactly BJTs work, does there need to be a minimum potential difference between base-emitter for current to flow or will any difference let current flow, or is there just a minimum for collect-emitter?

file.php
 
im thinking the best way to do this wouldn't be to discharge each cell if they reach over a certain voltage but rather discharge the highest voltage cell in the pack, and keep doing that continuously until the pack is fully charged, and the rate that the lowest cell has to be discharged doesnt need to be a lot because it starts right fron the start when charging begins instead of very near the end when all of the cells are approaching the peak voltage. im not exactly sure how to do this though, i guess you would need 3 or more op amps for a 3 cell pack, or you could use micro controller with 3 or more A/D converters with at least 8 bit resolution, id rather just use the op-amps though. this is gonna take some thinking.
 
:arrow: What's the best high current energy source to start with?

Many of these battery chargers are 12 volts for SLA's but they now often have elaborate programs for desulfation built into them.

Imagine the Thundersky's with 120 amps per cell capacity in charging. I don't think I need the full 120 amps, but even getting 50 amps might be hard to do.


12 cells, 120 amps, 3.2 volts = 4,608 watts of power?

12 cells, 50 amps, 3.2 volts = 1,920 watts of power?
 
im not really worried about the power source for this right now as it only has to put out 12.6V at a max of 2A. the only way i can think of to do the kind of balancing i want is to put an opto-isolator on each cell and have the output of it go through a resistor to ground then have the voltage drop across the resistor go to an A/D converter for each cell. then the PIC can look at each of the 3 A/D channels and whichever one is highest set the corresponding output pin to high that is connected to a transistor in parallel with the corresponding cell, thats a little more complex than i would like it to be though, there has to be a way do do it without getting into the digital stuff. like an IC with a certain number of inputs and the same number of outputs and whichever input is the highest the corresponding output will be high and all others will be low, does something like that exist? or is there a simple way to do that with discrete components that i just don't see?
 
dirty_d said:
im not really worried about the power source for this right now as it only has to put out 12.6V at a max of 2A.
:arrow: What type of cells do you have in mind?

That's only 25.2 watts...
 
i might be able to do something like this with an 8 bit Microchip PIC, they are only about $2 each and the one i was looking at had a 7 channel 10 bit A/D converter you can set high and low reference voltage for A/D conversion so for 0-5V thats 1024 different binary values for that range or 4.8mV precision. im not even sure if this will work or if there is a better way to do it but here is what i drew up real quick.

AD0-AD2 go to each cells positive terminal and the voltage is converted to binary relative to where it is between Vcc and Vss

GP0-GP2 switch on and off the transistors connected to each cells negative terminal, only the transistor connected to the cell that you are checking will be on at any one time, this sets Vcc to the cells negative terminal and Vcc to 5V above that. i guess a big capacitor will keep the PIC from resetting(will this work?)

GP3-GP5 switch on a transistor in parallel with whatever cell is the highest voltage. the discharge current should be pretty small compared to the charge current i would think since the balancing starts right from the beginning of charging.

balancer.png
 
dirty_d said:
2000mAh lipo cells for an rc airplane.

Oh... that's 20 times lower capacity per cell that the Thundersky cells. I was figuring you were going to build a bike.
 
I'm not sure how steady the voltage clamping is with Victor's circuit. I suspect the current will slowly rise as you try to exceed the set point.

When a string of batteries is charging, the the shunt regulator on highest voltage cell will kick in first. The rest of the cells will continue to get the full charging current until they reach the voltage set point too.

The PIC approach is very attractive for a number of reasons. I still need to think about how you would sample and drain individual cells in a string to balance them. I'm pretty sure it would work if the measurement and draining were done sequentially, as long as the cycle time was relatively short. Sample/drain one cell at a time.
 
Has anyone tried using multiple computer power supplies?

D15-1013-main.jpg


250 Watts - $14.99

If I bought one for each Thundersky cell (12 * $15 = $180) and then added the needed comparison circuitry to get it to stop when it should I would be getting 3000 watts worth of charging power. (the 12v might be divided three ways and maybe I'd go with a higher watt level, but you get the idea)

Each cell can handle:

40 amps * 3C = 120 amps @ 3.2 = 384 watts

...so this is actually a conservative energy level to use for Thundersky cells. I like the idea of "divide and conquer" so having many chargers means less centralized stress to worry about. (and the standard chargers that run at a couple of amps is just not enough when you can in theory charge at 120 amps)

There's sure to be some near throwaway power supplies out there of smaller power levels compared to the newer computers.
 
fechter, the way i was going to do it was have an infinite loop, iterate over each cell storing each cells voltage, check which cell has the highest voltage, turn on an output pin that turns on a transistor to drain that cell, then sleep for some time, then go back and do it again.

i realize that circuit above wont work. i cant figure out how to check each cells voltage individually since to check a voltage with the A/D converter the voltage has to between the Vss and Vdd pins on the PIC, you want the negative terminal of the cell you are checking at the same potential as Vss on the PIC. the only way i can think of doing it is to have some kind of opto-isolator on each cell that takes its voltage and outputs the same voltage except relative to the real ground in the circuit instead of the cells negative terminal. im pretty sure i could do this with an opto-isolator with a photo-transistor so that a higher voltage cell will cause more current through the led and more current through the transistor and convert that to a voltage with a resistor. im not sure how precise that would be though id like it to be very close to the actual voltage. do they make specific kinds of opto-isolator for convertign a voltage relative one ground to the same voltage relative to another ground that are very precise?
 
i think i have a solution, and its simpler, cheaper, and probably more accurate than all the other things ive thought of. the chip i think i will use is an Amtel AVR they have a bunch of different versions but the one im going to use is this http://www.atmel.com/dyn/products/product_card.asp?PN=ATmega48. it has a 6 channel A/D converter, 6 PWM channels, i2c serial interface, and a whole bunch of other crap that i don't know what means. and they are only $2.50 in single quantity, i dunno how thats possible, a basic stamp seems like its slower than this and doesn't do as much but they are over $30, i don't get it.

but here is the deal, ill run the uC off of a 5V regulator running off of the cells. for cell1 its positive terminal will go straight to AD channel 1, for cell2 there will be a voltage divider to divide the voltage by two and feed that to AD channel2, for cell 3 same deal except divide it by 3. that way all the inputs are between ground and Vcc. then in software i will read in each voltage, keep AD1 the same, multiply AD2 by 2, and multiply AD3 by 3. after that i can subtract AD1 from AD2 to get the real voltage of cell2 and subtract AD2 from AD3 to get the real voltage of cell3. then just compare them all and drain the highest voltage one, or leave them all alone if they are within a tolerance of each other.

i wrote up this python script just to show how ti will work, of course its going to be a lot harder to do this on a 8-bit micro-controller and trying to multiply 10-bit numbers from the A/D. ill have to do the math and comparison myself somehow.

Code:
#!/usr/bin/python

# these will be unknown to our uC
cell1 = 3.751
cell2 = 3.974
cell3 = 4.127
ad1 = 0
ad2 = 0
ad3 = 0

from time import sleep
from os import system


def do_ADC():
	# uC operates at 5V, scale these visible cell voltages to be inputted to AD channels via resistive dividers
	# next 3 lines exit physically not in code
	Vcell1 = cell1
	Vcell2 = (cell1 + cell2) / 2.0
	Vcell3 = (cell1 + cell2 + cell3) / 3.0
	
	#get data from the A/D converter
	global ad1, ad2, ad3
	ad1 = Vcell1
	ad2 = Vcell2
	ad3 = Vcell3
	
def drain_cell(cell):
	global cell1, cell2, cell3
	if cell == 1:
		cell1 = cell1 - .023
	elif cell == 2:
		cell2 = cell2 - .023
	elif cell == 3:
		cell3 = cell3 - .023
		
def stop_drain():
	#i would set all the transistor drive pins to low here
	nothing = 0

# psuedo uC code
while 1:
	do_ADC()
	#multiply each voltage by how much it was resistivley divided by
	v1 = ad1
	v2 = ad2 * 2
	v3 = ad3 * 3

	#calculate each cells actual voltage
	Vc1 = v1
	Vc2 = v2 - v1
	Vc3 = v3 - v2 
	
	#print the voltages so we can see if this is working
	system("clear")
	print "Cell voltages: ",Vc1, Vc2, Vc3
	
	
	if max(Vc1, Vc2, Vc3) - min(Vc1, Vc2, Vc3) > .02:
		if max(Vc1, Vc2, Vc3) == Vc1:
			drain_cell(1)
		elif max(Vc1, Vc2, Vc3) == Vc2:
			drain_cell(2)
		elif max(Vc1, Vc2, Vc3) == Vc3:
			drain_cell(3)
	else:
		print "Cells balanced."
		stop_drain()
	
	sleep(1)
 
There you go, that's what I was thinking of. I think this is how the BMS works on most hybrid cars. You could put the same voltage divider on all the cells. Measure each tap then make the processor subtract the readings to get the cell voltages. With the right code, you could randomly connect the taps and the processor could figure out the correct order. :wink:

With 6 channels, you could do 6 cells.

You could send individual voltage values to a remote display like a Packtrakr if you wanted to.
Even a simple LED display of some sort that indicates charging status would be nice.

During charge, you could possibly use the PWM outputs to drive FETs that switch a big resistor across the cell. The resistor might get hot, but not the FETs. To drive the FETs, you'd need to offset the gate drive voltage. A standard gate driver chip like the IR2101 would work, but there might be a simpler(cheaper) way to do it.

Just thinking ahead, if you used some 8 channel MUX chips, you could expand the system to as many cells as you want.
 
my only concern is that when you divide the voltage from the higher cells then multiply it in software you are multiplying the error from the ADC by however much you multiply it. im not sure what you mean by use PWM on the fets, i was just going to turn an output pin on going to the fet driver until that cell is no longer the highest cell, then turn that one off and turn on whichever one goes to the fet on the highest cell.
 
dirty_d said:
im not sure what you mean by use PWM on the fets, i was just going to turn an output pin on going to the fet driver until that cell is no longer the highest cell, then turn that one off and turn on whichever one goes to the fet on the highest cell.

I guess if the cycle is fast enough, it will be like the same thing.

What I was thinking is when the voltage gets up to the max, you start increasing the duty cycle on the PWM to keep the voltage at the set point, but I think your approach is simpler and will have the same result.
 
I'm not sure if this is going to work, theres going to be a 2% error if you use 1% resistors for the voltage dividers and then the 10 bit ADC is only accurate to +- 2 least significant bits. so for the signal to the ADC between 0-5V you have an accuracy of +-(5.0 / 2^8 = .02V). so at any time the cells can be .04V apart(thats not counting the voltage divider error). im not sure what to do about this, fetcher got any ideas?

EDIT: actually its not as bad as it seems, with a max difference between any two cells of .04V then you can just set the charge voltage to 4.18V per cell
and 12.54V for the pack, the worse case is 4.16 + 4.18 + 4.2 = 12.54V
 
That's not so bad.

You can calibrate it to eliminate some of the error. Put something in the code as a scale factor, run it and measure the actual voltage, then calculate what scale factor will correct the voltage.
 
actually its ever better than not bad! i was wrong about the error, +-2 LSB on a 10-bit ADC means for a 0-5V signal (5 / 2^10) * 2 = 9.7mV. thats not bad at all, and it gets even better, you can oversample the signal to increase the bit resolution. if you want to increase the resolution to 11-bits all you have to do is this, take four 10-bit samples(785, 784, 786, 787), add them together(3142), and binary right-shift them to bring it down to 11-bits(3142 >> 1 = 1571). that will be your new 11-bit binary representation of the sampled voltage, and with the +-2 LSB that will only be off by (5.0 / 2^11) * 2 = 5.8mV. and you don't have to stop there you can increase the bit resolution to whatever you want, if you wanted to go to 12-bit resolution you take 16 10-bit samples, add them, then right shift by 2, then you're only off by 2.2mV. and i believe the +-2 LSB is before you null out any gain and offset error.
 
i just got my lipo pack and cheapo charger along with the AVRs, im glad i decided to make my own charger because the cheap one i bought sucks, i monitored it during charging and it went up to 4.25V per cell and didn't seem to be slowing down, i disconnected the pack at that point since i didn't want to let it go any farther to see when it would cut off. the open circuit voltage on the charger is 4.45V per cell so the might have been how high it would have brought the cells had i not been watching it!

as far as the analog circuitry goes instead of the voltage dividers on each battery i think it would be better to use an op-amp in a difference amplifier configuration like this http://en.wikipedia.org/wiki/Image:Opamp-differential.svg. that way the error wont get multiplied in software and the first cells negative terminal doesn't need to be at ground potential.

I was having trouble getting the code onto the AVR but i finally got the programming board to work, its very simple to make yourself and costs less than $5, the AVRs were $4 each with 16KB of flash ROM for program code and 1KB of RAM, its called an ATmega168. i just made a simple program to generate a PWM signal(maybe ill make a motor controller later on). ill have to read up more on the ADC before i can write the code for the charger.

heres the PWM code:
Code:
#include <avr/io.h>
#include <avr/wdt.h>

/*
 * wdt_off will get called before main() in case the watchdog
 * timer is accidentally set so short it runs out before main 
 * is called and the board goes on an infinite reset cycle.
 */
void wdt_off() __attribute__ ((naked)) __attribute__((section(".init3")));

void wdt_off()
{
	//disable the watchdog timer
	MCUCR = 0;
	wdt_disable();
}

int main()
{	
	//set system clock prescaler to 1(8MHz * 1 = 8MHz)
	CLKPR = 1 << CLKPCE;
	CLKPR = 0;
	
	//set OC1A(PB1) pin to output
	DDRB |= 1 << PB1;
	
	//for 8MHz main clock, 20khz PWM freq(8000000 / 20000 = 400)
	ICR1 = 400;
	//25% duty cycle, should see about 1.25V on PB1
	OCR1A = 100;
	
	//16-bit fast PWM mode, TOP=ICR1, prescale=1(8Mhz)
	TCCR1A |= 1 << COM1A1;
	TCCR1A |= 1 << WGM11;
	TCCR1B |= (1 << WGM13) | (1 << WGM12) | (1 << CS10);
	
	/*
	 * the timer will increment the 16-bit counter at 8MHz,
	 * starting from 0 the output will be high on OC1A, when
	 * counter == OCR1A  the output on OC1A goes low, when the
	 * counter reaches ICR1(0-65535) the counter wraps back
	 * to 0 and the output goes back high.
	 */
	while(1)
		;
	
	//never get here
	return 0;
}
 
well i added some stuff to the programming board to help test if the programs are actually working, but most of it comes down to testing the pins with a multimeter. i finished the charging program and it should work fine as it is right now, im surprised by the size too. the program is only 1020 bytes and the AVR has 16KB, so theres a whole lot more room for something really complex. someone else should try to make a brushless controller, it should be super cheap to build, a brushed controller would be even cheaper, AVR $2.00-$4.00, FETs < $20.00(for really good ones), and a bunch of other cheap stuff like op-amps, transistors, and diodes.

anyway, heres the lipo charger code:
Code:
#include <avr/io.h>
#include <avr/wdt.h>
#include <util/delay.h>
#include <stddef.h>

#define V_MAX 4096 //AVCC(5.02V)
/*
 * calculated based on measured ADC refrence voltage(5.02V)
 * possible to do in software but needs two accurate voltage refrences
 */
#define V_CUTOFF 3420 //4.2V
#define V_TOLERANCE 10 //12mV
#define V_HYST_CHARGE 8 //10mV
#define V_HYST_BAL 3 //4mV
#define V_MIN 2450 //3.0V
#define V_ABSENT 10 //12mV, treat this as there being no cell, jut in case of ADC errors

#define CELLS_MAX 4
uint8_t CELLS_COUNT;

/*
 * wdt_off will get called before main() in case the watchdog
 * timer is accidentally set so short it runs out before main 
 * is called and the board goes on an infinite reset cycle.
 */
void wdt_off() __attribute__ ((naked)) __attribute__((section(".init3")));

void wdt_off()
{
	//disable the watchdog timer
	MCUCR = 0;
	wdt_disable();
}

void get_cell_voltages(uint16_t cells[CELLS_MAX])
{
	uint8_t i, j, channel;
	uint16_t sample;
	uint32_t avg;
	
	for(channel = 0; channel < CELLS_COUNT; channel++)
	{
		//clear nybble 0 and set the new channel
		ADMUX = (ADMUX & 0xF0) | channel;
		
		avg = 0;
		//average out 32 12-bit oversamples
		for(i = 0; i < 32; i++)
		{
			sample = 0;
			
			//oversample 10-bit ADC to 12-bits
			for(j = 0; j < 16; j++)
			{
				//start AD conversion
				ADCSRA |= 1 << ADSC;
				
				//busy wait for ADC to complete
				while(!(ADCSRA & (1 << ADIF)))
					;
				
				//clear ADIF bit, i don't get it but thats what the datasheet says to do
				ADCSRA |= 1 << ADIF;
				sample += ADC;
			}
			
			//bring sample down to 12-bits
			sample >>= 2;
			avg += sample;
		}
		
		//store the oversampled and averaged result
		cells[channel] = avg / 32;
	}
}

void get_cell_states(uint16_t cells[CELLS_MAX], uint8_t *high, uint8_t *low)
{
	uint8_t i;
	
	*high = 0;
	for(i = 1; i < CELLS_COUNT; i++)
		*high = (cells[*high] < cells[i]) ? i : *high;
		
	*low = 0;
	for(i = 1; i < CELLS_COUNT; i++)
		*low = (cells[*low] > cells[i]) ? i : *low;
}

void begin_charge()
{
	/*
	 * not exactly sure how im going to do this but
	 * for now ill pretent PORTD bit-0 will control the charging
	 * 1 for charge and 0 for off
	 */
	PORTD |= 1 << PD0;
}

void end_charge()
{
	/*
	 * not exactly sure how im going to do this but
	 * for now ill pretent PORTD bit-0 will control the charging
	 * 1 for charge and 0 for off
	 */
	PORTD &= ~(1 << PD0);
}

void begin_balance(uint8_t cell)
{
	PORTB = (PORTB & 0xF0) | (1 << cell);
}

void end_balance()
{
	PORTB &= 0xF0;
}

//turn on a red LED or a siren or fireworks or something
void error(uint8_t code)
{
	PORTD |= 1 << code;
	
	for(;;)
		;
}

void init()
{
	uint8_t i, total;
	uint16_t cells[CELLS_MAX];
	
	//need to setup CELLS_COUNT like this first so get_cell_voltages works
	CELLS_COUNT = CELLS_MAX;
	get_cell_voltages(cells);
	
	//make sure the present cells are all at a sane voltage
	total = 0;
	for(i = 0; i < CELLS_MAX; i++)
		if(cells[i] > V_MIN && cells[i] < V_CUTOFF)
			total++;
		else if((cells[i] < V_MIN && cells[i] > V_ABSENT) || cells[i] > V_CUTOFF)
			error(1);
		
	//make sure the present cells are contiguous starting from 0
	for(i = 0; i < total; i++)
		if(! (cells[i] > V_MIN && cells[i] < V_CUTOFF))
			error(2);
			
	CELLS_COUNT = total;
}

int main()
{
	uint16_t cells[CELLS_MAX], diff, cutoff, charging, balancing, tolerance;
	uint8_t high, low;
	
    //set system clock prescaler to 1(8MHz * 1 = 8MHz)
    CLKPR = 1 << CLKPCE;
    CLKPR = 0;
	
	//set PORTB and PORTD to output
	DDRB = 0xFF;
	DDRD = 0xFF;
	//AD pins 4-6 output, 0-3 to input
	DDRC |= 0x30;
	DDRC &= ~0xF;
	//turn on internal pull-up resistors, resistance of my testing pot is too high for the pull-ups
	//PORTC |= 0xF;
	
	//PORTB 0:3 for draining high cell, and maybe some other stuff
	PORTB = 0;
	//PORTD, probably for the safety cutoff and other stuff
	PORTD = 0;
	
	//enable ADC, prescaler=64(125000 Hz)
	ADCSRA |= (1 << ADEN) | (1 << ADPS2) | (1 << ADPS1);
	
	//AVCC as VREF
	ADMUX |= 1 << REFS0;
	
	init();
	
	//begin_charge();
	charging = 0;
	balancing = 0;
	
	tolerance = V_TOLERANCE;
	cutoff = V_CUTOFF;
	for(;;)
	{
		get_cell_voltages(cells);
		get_cell_states(cells, &high, &low);
		diff = cells[high] - cells[low];
		
		/*
		 * check highest cell voltage, if it is over the cutoff terminate charging,
		 * reduce the cutoff voltage by V_HYST_CHARGE and wait till the voltage
		 * drops below the new cutoff voltage in case the cell is left charging
		 * for a long time, the hysteresis keeps it from toggling
		 * on and off quickly once it finishes charging.
		 */
		if((cells[high] > cutoff) && charging)
		{
			end_charge();
			charging = 0;
			cutoff = V_CUTOFF - V_HYST_CHARGE;
		}
		else if((cells[high] < cutoff) && (!charging))
		{
			begin_charge();
			charging = 1;
			cutoff = V_CUTOFF;
		}
		
		/*
		 * pretty much the same as above
		 * this should work ok
		 */
		if(diff > tolerance && (!balancing))
		{
			begin_balance(high);
			balancing = 1;
			tolerance = V_TOLERANCE - V_HYST_BAL;
		}
		else if(diff < tolerance && balancing)
		{
			end_balance();
			balancing = 0;
			tolerance = V_TOLERANCE;
		}
		
		/*
		 * could add some other stuff, not sure what yet
		 */
	}
	
	return 0;
}
 

Attachments

  • sprogrammer.jpg
    99.5 KB · Views: 1,187
cool.

I have an Atmel AVRISP programmer collecting dust in the garage. I think it will work with an Atmega168.

I just suck at writing code though.
 
yea it is a lot harder to program than a regular computer program, its hard to remember all the register names and stuff. i had to constantly look back and forth from the code to the data-sheet to see how to do stuff. im still not 100% sure about how im going to do all the analog circuitry but heres the basic idea, ill use the 5V regulator that powers the AVR as a voltage reference and have an op-amp as a voltage follower with a potentiometer in the feedback loop so i can precisely control the output voltage. there will be another op-amp connected to a current sense resistor and another potentiometer to set the current limit, in my original schematic there was a separate FET for that but there must be a way to be able to use the same one for current limiting too, the avr will watch the voltage on each cell and if the difference between the highest cell and the lowest cell is greater than 12mV it will turn on a transistor to bypass some current around that cell so the others can catch up, there is a little hysteresis so that once it gets 12mV from the lowest it will get balanced to within 9 mV then stop balancing. if any cell gets above 4.2V then the AVR will turn off the main FET but keep the balance transistor on if the cells are still out of balance, that way if they are badly out of balance that cell will get drained below 4.2V and the avr will turn the main charging FET back on and allow the other cells to gradually reach 4.2V over a few on/off cycles.

right now im trying to find some kind of easy circuit simulation program to make sure what i come up with actually works before i buy all the analog components. im also looking at LCD modules, they seem pretty easy to interface with and i could make some really cool stuff with them.
 
Back
Top