Electronic – Solar controller with BJT transistor and PIC24 microcontroller to charge 3.6V NiMH batteries

battery-chargingbjtmicrocontrollersolar celltransistors

I'm designing a solar controller circuit and am having some confusion about how to switch the BJT on and off. I have a single solar panel charging a battery. The BJT is there to prevent over-charging the battery. I have a microcontroller to monitor the battery voltage and current, and use this feedback to switch the transistor off and on. The microcontroller is powered by those same batteries.

Here's a simplified circuit schematic:

schematic

simulate this circuit – Schematic created using CircuitLab

Do I need to figure out the collector current (I_C drawn from the solar panel) based on the current coming out of the microcontroller (I_B)? Or vice versa?

I'm not sure which comes first. I know that I_B is what turns the transistor on and off to allow I_C through.. but I'm confused how to get values for each.

Here's the data on the components:
The solar panel typically outputs 5.5V and 170 mA. It has an open-circuit voltage of 8.2 V and a maximum load voltage of 6.4V. (linked here)

The batteries are rechargeable NiMH with 2450 mAh and 3.6 V. (datasheet here)

The microcontroller is the PIC24, which can source up to 25 mA through its I/O port. (datasheet here)

Here's what I'm stuck on:

Typical solar values:
V_solar = 5.5 V
I_solar = 170 mA

Values for beta, base current, and base-emitter voltage:
B=100
I_B = 1 mA (from microcontroller datasheet?)
V_BE = .7 V

B*I_B = I_C
100 * 1 mA = 100 mA

I_B = (1.6 – .7) / R = 1 mA
R = .9 V / 1 mA = 900 ohms
Since I_B > 1 mA, R > 900 ohms = 1k ohm

I obtained I_B from the PIC24 datasheet, where it says output high from an I/O pin is at least 1.6 V when the PIC24 is powered by 2 V, and the current associated with these numbers is 1mA. Is this the correct way to obtain these values from the datasheet?

Revised Circuit (2/10/15):

schematic

simulate this circuit

Best Answer

tl,dr: In your case, you don't seem to need charge control at all, and it is more complicated than you seem to sink because of various reasons. Just put a 1N4001 between the solar cell and the battery.


The NiMH battery is a quite low impedance, pulling as much current from the solar cell as available at the cell voltage. During charging, it is likely around 1.4V/cell. This is an output voltage of 4.2 Volts, so in bright sunlight, you likely exceed the 170mA quoted for the maximum power point, expect something like 200-220mA, which is below C/10 of the cells. I have no idea how you want to do NiMH charging control at widely varying charging currents that never exceed C/10 (no -deltaU, no dT/T seems applicable, but let's ignore that).

First thing to notice: Your circuit will not work as drawn. You drew a NPN transistor. It needs a voltage at the base that exceeds the emitter voltage (by around 0.6V) to make it conductive, but the uC has no access to provided the needed 4.8V (battery voltage + 0.6V). You need an PNP transistor instead. In that case, you need to to provide current from the base terminal to a more negative sink. Also, you would connect the emitter to the solar cell in that case. Note that to turn off the transistor, you need the base voltage to go up to 0.5V below the unloaded solar cell voltage, this is around 8V.

Start with the desired collector current (220mA maximum cell output) and take a look into the transistor data sheet. Let's choose a BC327 for it's higher current rating compared to the typical 100mA transistors. Take a look at figure 4 (Saturation region) if you want to have low losses on the transistor, which seems like a good idea now (but see later). They have curves for 100mA and 300mA collector current. As we don't have a lot of energy to waste, choosing a base current at the low end of the neary flat end of the saturation voltage curve is a good idea, which yields something around 4mA if you interpolate between the 100mA and the 300mA curve. To turn in the transistor, at 4.4V solar cell voltage, 200mV transistor drop, and 4.2V battery voltage, you need to sink 4mA at 4.4V-0.6V (emitter-base voltage). To turn it off, base must rise to 8V (see above). This means, you need a pull-up resistor between base and emitter, providing the turn-off voltage from the cell instead of the uC and a diode (1N4148 will do) to protect the uC from that high voltage.

So the circuit looks like this: PNP with emitter to solar cell, and collector to the battery. A resistor connecting emitter with base (the value does not matter much, and something around 100k will provide enough pull-off effect without disturbing the circuit while the transistor is on), a diode and a resistor in series to the uC. The uC needs to sink 4mA to turn the transistor on. This results in an output voltage of 0.4V. So the resistor has to sink 4mA while having 0.4V above ground on the uC end and 3.8V above ground on the diode end. 4mA at 3.4V is 850 ohms. So 900 Ohms in your circuit does not seem off that much.

You will not be happy at all with that circuit for different reasons, though: Constantly sinking 4mA takes too much of the charging current (getting 220mA outdoor on a bright sunny summer day is one thing, on cloudy days, being inside, expect something like 10mA maximum), and you are wasting 4mA of that just to turn that transistor on. Furthermore, when it gets dark, the solar cells draw power due to their leakage current and discharge the battery by operating the transistor in reverse mode (collector acts as emitter, base current is provided by the solar cells and the 100k resistor meant as pull-up, and the emitter acts as collector). Common wisdow is you need to protect against that, for example by putting a diode between the collector and the battery. You will lose voltage there, though. Another possiblity would be a "secondary pull-up" that will pull the base up, even if the emitter supply (the solar cell) fails to provide power, by connecting a resistor from collector to the base terminal. This resistor has to be low enough to pull the base up against the 100k that pulls it down, so go for something like 20k there. Of course adding all these resistors doesn't make the thing more efficient.

Actually, your charging current is very low compared to cell capacity. As estimated above, you only get to C/12 on extraordinary good conditions, you the charging current can safely be considered as "trickle charging" unless you put the device into the beam of a bright headlight 24/7. You don't need any charge control. You just need to prevent discharge through cell leakage, and this can be povided by a single diode between solar cell and battery.