PDA

View Full Version : DIY Charger Analog Techniques


tblount70
Jul 21, 2004, 12:55 PM
I would like to build a PIC-based charger with integral RS232 so that I can log the charge profile to PC. My digital design and programming experience is pretty good, so the PIC, RS232, and PC parts of the project look fairly straightforward. The problem is, I don't know much about analog design. The actual charging profiles (constant V, constant A, etc.) are already published, so that isn't what I need.

Assuming I have the microcontroller section under control, what parts do I need to do the analog section of the charger? I think the following specs should do for most of my packs:

1) I want to be able to able to charge LiPo or NiMH packs

2) should be capable of constant current or constant voltage operation (LiPo)

3) should produce charging voltage sufficient for 3C LiPo packs with charge current in the range of 10mA trickle up to 3A (this should be sufficient for most parkflyer/shockflyer setups)

4) I want to be able to log voltage and current real-time during the charge cycle

So what I really want is a flexible analog section that can be regulated by the micro/software to achieve variable charge profiles.

Here's what I've read so far on rcgroups. I've seen the Tinker's charger (http://www.rcgroups.com/forums/showthread.php?t=130567&page=1&pp=15). This one is made of two voltage regulators with a couple of resistors to vary the voltage and current limits. How flexible is this within the voltage/current ranges set forth above? I've also seen a reference to a specialty chip that actually has charging algorithms on board. I don't want to use that method because I want the micro to control the algorithm. I've also seen a reference to a PIC-controlled NiCd charger, but that one uses the PIC solely as a timing mechanism to switch from fast charge to trickle.

Anyone got any wisdom to share? :rolleyes:

Tim

Comatose
Jul 21, 2004, 01:39 PM
Basically, what you need to make is called a "buck converter." If you're not looking to do high cell counts, then this can be done with just the PIC (the 10 bit A/D limits precision at high counts.) You'd need a high power resistor for current measurement, an inductor, a large electrolytic capacitor, a P channel FET, a shottkey diode and then the usual assortment of goodies. The you have the PIC running either a current control or a voltage control algorithm.

A buck converter is essentially just a high side PWM switch and then an LC low-pass filter. It steps voltages down only.

For the real gory details I suggest you try www.national.com as they have a good amount of switching power supply info.

If you need to step up then step down, the topology you want is either boostbuck or SEPIC, but you'll need to understand the basic buck first.

MartinFVS
Jul 22, 2004, 06:39 AM
I’ve done two of these now. Here’s what I think.

You need a boost regulator because the battery voltage will be greater than your minimum input voltage (12V). Use an LM2587-ADJ from national that should give 3A at lower voltages. Use the PIC to limit the current as the voltage increases.

To regulate the current use a FET or Bipolar transistor and op-amp as a linear current source driven from the PIC PWM. Use the PIC to protect the transistor at lower battery voltages where the voltage drop across the device is high.

The boost regulator uses the output of the current regulator as its feedback. This should be as low as possible so the power loss is minimum. This is also the battery negative. Battery positive goes to the boost output.

If you want to do NiMH and Li-poly then 10 bits is not enough. I’ve used a LTC1286 from Linear. It’s a serial 12-bit ADC and easy to interface to a PIC.

The PIC can now measure the voltages, control the current and protect the regulators.

To log the data output voltage and current values plus anything else you measured. If you capture the line with Hyper-terminal as a text file you can use Excel to plot a graph. Here’s one I did earlier:

tblount70
Jul 22, 2004, 10:30 AM
Comatose,

So the buck regulator would look something like this? If I limit charge current to 3A, the 1/3 ohm resistor would give me 5V that could be directly measured by the PIC?

tblount70
Jul 22, 2004, 10:31 AM
Comatose,

Whoops! That 5 ohm resistor in the schematic should read 1/3 ohm. 5W should do it, eh?

tblount70
Jul 22, 2004, 10:35 AM
MartinFVS,

Do I still need an inductor to do it that way? The op amp stuff is a little over my head (I slept through that class). But I'm checking it out...

Comatose
Jul 22, 2004, 12:38 PM
tblount, thats about it. You'll need a difference amp with a gain of 1 to bring your sense voltage down to 0-5v, with now it'd be foating above your battery voltage, and you'll need a voltage divider to scale Vsense. You probbaly don't need Vref.

Also, you need an input electrolytic capacitor between 24v and ground, and a ceramic bypass capacitor between input and ground.



The main difference between Martin's route and mine depends on your cell count and power supply situation. If you've got a 24V supply handy, or aren't using high cell count batteries, mine is easier. If you're using high cell count packs and only have 12v, martin's is easier.

MartinFVS
Jul 22, 2004, 01:59 PM
Yes you need an inductor for both designs. It should be readily available. The LM2587 datasheet has type numbers listed.

You may like to move the current sense resistor in your drawing to the negative end of the battery. It would make it easier to measure. The battery voltage then becomes Vsense-Isense.

If you can start with 24V then an alternative may be to just use a linear current regulator. All that is required is a big heat sink to dump 50W. Drive a logic level FET from the PWM filtered and put the sense resistor in the source to 0V. Measure the volts drop to regulate the current. Battery goes from drain to +24V, measure both to get the battery voltage. The issue would be getting enough PWM resolution to get down to 10mA. You wont get any simpler than that and no inductors!

tblount70
Jul 22, 2004, 02:55 PM
Comatose,

How's this look? Did I do the op amp right? Don't know about the p/n on the op amp yet... That's just what was handy in my schematic tool.

I'm assuming R2=R3=R4=R5=something big like 5K to prevent the charge current from dumping to ground.

If I seem lost on some of this, it's because I am. My formal training is mech engineering, not electronics.

Thanks
tblount

tblount70
Jul 22, 2004, 03:02 PM
Comatose,

Per Martin's comment, why not move the sense resistor between the negative pole of the target pack? Would this allow me to get rid of the op amp? Or would the extra voltage drop mess up my VSense point?

MartinFVS
Jul 22, 2004, 04:01 PM
It would be better if the op-amp had a gain of x5 to fully use the A/D. R3 = R5 = 25k.

You will also need to convert the logic level PWM to 24V to drive the FET.

Comatose
Jul 22, 2004, 06:22 PM
Hey, technically I'm a MechE too, so I understand. If I had to do some, say, fluid flow problems I'd be uncomfortable too.

There's technically nothing _wrong_ with the "dump 50 watts of heat solution", its just not neat and tidy. Easy, but not elegant.

As per moving the sense resistor. Yes, you can do that. I'd assumed there was a reason you put it on the high side. The only thing is you'll have to subtract the current sense voltage from Vsense. Either way its a subtract, low side you do the subtract in software instead of hardware.

Martin is right about the transistor switch, you'll have to do some level shifting. Is this going to be running from a "24v" battery or a regulated 24v supply? If its a supply, one can find P channel FETs that have a max gate voltage of +- 24v, so driving can be simply an NPN transistor in common emitter configuration and a resistor. If you mean a 24V battery, that has a maximum voltage of 30V, so a driver chip is probably required. An IR2117 from international rectifier would be the easy solution. They're about $2, and use an N channel FET.

tblount70
Jul 23, 2004, 09:23 AM
Comatose,

My supply will be a 24V regulated supply, but I'll probably go ahead with the FET driver route just in case.

Question: when I search MOSFET switches on digikey.com and then filter on P-channel, why is the current rating on 99% of the P-channel parts listed as -n A. What does a negative current rating mean? Current just flows backward through the switch?

tblount70
Jul 23, 2004, 09:26 AM
Martin,

The voltage reg idea is a good one, but I eventually want maybe six of these analog sections connected to one micro talking to my PC. I'd rather not deal with the heat issues associated with that arrangement.

tblount70
Jul 23, 2004, 09:40 AM
Here's the circuit with the sense resistor moved, but without the FET driver.

MartinFVS
Jul 23, 2004, 11:42 AM
That looks to be about as efficient as it can be. However there are a few points to watch.

As you plug the battery in you will get a huge current spike, perhaps over 30A. You can reduce it by ensuring that the PWM is off when no battery is connected but you can’t eliminate it. You should protect the A/D input with a series resistor and zener diode.

Also you will need a diode between C3 and the battery positive to stop the battery charging C3 when it connects causing a negative current spike.

These current spikes can generate a healthy spark when you plug the battery in. :eek:

Comatose
Jul 23, 2004, 01:12 PM
P channel mosfets conduct from source to drain. N channel mosfets conduct from drain to source. So, the convention is to say P channel fets have ngative current ratings. It doesn't actually change anything, its just a convention. If you use a high side driver, though, usually they drive an N channel fet.

I agree about the series resistors on the AD (I suggest 1k) but i don't think the zener is necessary. On a PIC all the input pins are already clamped. It doesn't hurt to have them, but its more parts.

MartinFVS
Jul 23, 2004, 03:11 PM
Its not good practice to rely on those port clamping diodes. They are only rated for 20mA and are for anti-static protection only. They also clamp to the supply rail so any spike energy will get dumped into the +5V so could destroy not only the PIC but everything. Use a 5.1V zener to dump the energy to ground.

Which reminds me. You should also add a capacitor to ground on the analogue input because these pins seem to pick up 4MHz noise from the OSC pins. Particularly AN0 and AN1, pins 17 and 18 on the 18 pin PICs. A 1nF or larger will do it.

And another thing…. The 0.33R resistor should be wire wound. Those current pulses can open carbon/metal film resistors like a fuse. Then you’ll be grateful you used a zener ! I learnt this one the hard way.

Mr.RC-CAM
Jul 23, 2004, 03:36 PM
I'm not sure if this has been discussed, but you should also think about how you will handle reversed battery installations. That silliness can happen. It will no doubt affect how you configure your hardware and software.

RC-CAM

MartinFVS
Jul 23, 2004, 04:24 PM
Good point….

As it stands C3 would explode with a reverse battery connection. I can’t see any way to protect it other than a reverse diode and fuse.

Protecting the A/D input is easy with a diode across the voltage divider.

E_ferret
Jul 23, 2004, 07:56 PM
Good point….

As it stands C3 would explode with a reverse battery connection. I can’t see any way to protect it other than a reverse diode and fuse.

Protecting the A/D input is easy with a diode across the voltage divider.

There is still the old faithful! the relay.
a diode to the relay armature wind, energized by the input 24V.
the 24V to the rest of the circuit made to pass through the relay NO contacts
I think the ORBIT chargers use that style of reverse input protection.

KreAture
Aug 14, 2005, 06:32 PM
Did this design ever go anywhere?
Old and classic as it may be, I have been fiddling a bit with it.

Turning it around, moving inductor to lower side and using a N-FET.
Reason was I wanted to see if I could do it that way at all... Any comments?

SlopeKing
Aug 14, 2005, 09:14 PM
<subscribed>