Waiting for a sunny day

I couldn’t get to test my new solar charge controller coupled with a cheap 10W solar panel, and won’t be able to for a while as the weather forecast tells that it will be cloudy for the next week. So instead I decided to write some thoughts about my project.

Solar charge controller

The goal for the project is to generate 5V output with maximal efficiency from the ~20 volts the solar panel outputs with enough light. But the solar panel makes it a bit tricky, since if you pull too much current from the panel, the voltage comes quickly down lowering the total power \(P = IV\), and of course if you pull no current the total power is zero. So there is a sweep spot for I and V called maximum power point depending on the panel, the temperature, and the lighting conditions and so on. Hence in addition to the regular voltage converter business, you have to control the input current to output maximal power.

There are multiple ways of implementing MPPT (maximum power point tracking) ranging from simple to complex. The input power can be calculated by measuring the input current and voltage, and this can be used to determine the optimal point for them, at least in theory. In the first version I used the dumb method of trying to get the input voltage to 80% of its nominal open circuit voltage when loaded, but since I have a microcontroller doing the monitoring changing the algorithm is not that hard.

Flyback converter, CyrilB~commonswiki, CC BY-SA 3.0, Link

As my voltage converter topology I chose the flyback converter as it is relatively simple and common. The controller I decided to use was NCP1252C, and while it was cheap it certainly wasn’t designed for this application. For one, it is designed for isolated applications where the feedback is driven directly from an optocoupler making the non-isolated feedback more tricky to implement. And secondly, there is no direct way to regulate the input current.

The regulation in NCP1252 works by limiting the maximum primary current Is which is sensed by a shunt resistor Rs which is 0.33 ohms in this case. There are three different maximum limits for the current. One of them is the fault protection which kicks in when the voltage on the shunt resistor exceeds around one volt, making the absolute maximum current three amps. Then there is the maximum current derived from the output voltage, limiting the current to

\(I_{max} = \frac{V_{fb} – 0.7V}{3 * R_s} \).

And finally, there is the soft start derived maximum current, making the maximum voltage drop on the shunt resistor equal to the voltage applied on the SS pin. It is designed to be used only with a grounded capacitor as the chip includes a current source to charge the capacitor, slowly ramping up the voltage. But at the same time I saw this as a direct way to control the input current. Just connect the DAC in the microcontroller to the pin and now I can easily set the maximum input current. Also, the pin gets pulled down to ground when the chip is in reset mode, so it can be also used for monitoring the state of the chip, to get proper soft start even after reset.

If the controller is running in the DCM mode, i.e. the current in the inductor goes down to zero every cycle and all of the energy gets dumped into the load, we can easily calculate the output current. The maximum energy in the inductor is \(E = \frac12L_{pri}I_{max}^2\), and the power is then \(P = E/t = Ef_{sw}\) which equals the output power (assuming 100% efficiency) \(P = I_{out}V_{out}\). Thus setting the SS pin to Vss gives the input current

\(I_{in} = \frac{L_{pri} (\frac{V_{ss}}{R_s})^2 f_{sw}}{2V_{in}}\),

and similarly the output current

\(I_{out} = \frac{L_{pri} (\frac{V_{ss}}{R_s})^2 f_{sw}}{2V_{out}}\).

As it was my first time designing a flyback converter, I noticed that there’s surprisingly many parameters that need to be accounted for: the switching frequency, the transformer, the maximum duty cycle, the maximum output currents, and so on.

Also there you need to be careful that the components stay in their proper operation conditions. For example, the leakage inductance makes voltage in the primary of the transformer shoot up when the switching MOSFET is turned off, easily exceeding the maximum limits of the MOSFET. One way to protect the MOSFET is to use a RCD snubber circuit that dissipates some of energy and limits the maximum voltage swing of the drain of the MOSFET, but the resistor and capacitor must be sized so that they can do this even during the maximum load.

Also the magnetics parts is somewhat tricky. In the flyback the energy is stored in the transformer which acts more like a coupled inductor instead of a pure transformer. In this case after I had chosen the primary inductance to make the converter stay in the DCM mode in all conditions, it still wasn’t quite as easy as to calculate the turns by saying \( n = \sqrt{\frac{L}{A_L}}\). There are different kinds of transformer cores, and there are many possible combinations of size, type, and magnetic material.

You need to take care that the transformer core material works properly at the switching frequency as the power losses in the core grow with increasing frequency while the inductance also drops. At the same time, a core material with higher magnetic permeability (µ) requires less turns of wire around the core to get to the required inductance.

However, the magnetic flux density in the core should be kept low enough that the core will not be saturated, with 200 mT being apparently a reasonable for maximum for many materials.

Ampère’s law states that \( nI = Hl \) where n is the number of turns in the coil, I is the current, H is the magnetic field, and \(l\) is the path length of the magnetic field. In a material with relative permeability \(u_r\), we have \( B = \mu H = \mu_r \mu_0 H \) and putting them together we get

\( I_{max} = \frac{Hl}{n} = \frac{B_{max}l}{\mu_r \mu_0 n} = \frac{0.2T * 46 mm}{2000 *4\pi10^{-7} H/m *5} = 0.73A,\)

with my transformer core resulting in about 36µH of inductance at five turns. This results in a maximum input power of

\( P_{inmax} = \frac12 L I_{max}^2 f_{sw} = \frac12 * 36uH * (0.73A)^2 * 100kHz = 0.96W,\)

which is only a fraction of the desired maximum input power of 10W. Thus our transformer saturates way too quickly. We can either increase the primary inductance, the primary maximum current, or the switching frequency to allow more input power. The problem with increasing the inductance or the frequency is that we might go into the CCM operation instead of the DCM we want to be in.

Assuming that we don’t want to change them leaves as the only possibility increasing the maximum saturation current of the core. Note that the number of turns affects both the maximum saturation current and the inductance, as we have roughly

\( I_{max} \sim \frac{l}{n \mu_r}, L \sim \frac{\mu_r n^2A}{l},\)

where A is the cross-section area of the transformer core. Thus increasing the size of the core helps, but a common method used with flyback converters is to make an air gap in the core, in effect decreasing \(\mu_r\) by a value depending on the path length and the gap length. By holding \(L\) constant and decreasing \(\mu_r\) and correspondingly increasing \(n\), we get a higher maximum current.

While manufacturers make cores that already have a gap, and the inductance can also be approximated by calculating, the way I did in in this project was to use a non-gapped core consisting of two EF cores, winding a certain number of turns, and then grinding a gap slowly until the measured inductance reached the value I was aiming for.

And finally, there is the business of the feedback. This involves a simulating the gain and the phase of the feedback network at different frequencies and then compensating them so that the regulator doesn’t turn into a oscillator. In isolated flyback converters the compensating is usually done by cleverly using an op amp built into the TL431 voltage reference, and apparently the optocoupler understandably has a large effect on the feedback network so you need to take it into account.

I tried to make a feedback network using a version of the old 358 op amp, but it didn’t really turn out well. The problem is that while NCP1252 includes a 3.3kΩ pullup resistor in its feedback as it is designed to be used with an optocoupler, a 358 can’t really pull it into the ground. NCP1252 has a cycle-skip feature that starts working at about 0.3V that when we have no load we stop pumping current to the output. But 358 output to ground consists of a NPN+PNP transistor pair combined with a 50µA current sink, and it really can’t pull the feedback below about 0.7 volts. This resulted in a 5.8V output instead of 5V which the circuit was aiming for.

As a a quick hack I added a resistor to help pull down the feedback voltage and a load resistor of 1kΩ, which appears to help enough. But it isn’t really a satisfactory solution, so I’ll have to see if I can get my hands on a proper op amp that can pull the output properly to the ground.

Also, there managed to mix up the terminals T1 and T2 of the triac in the crowbar circuit that prevents the output voltage going above 6V. Well, that’s probably what I get for not doing quadruple checking the first time I use a triac. Though since this triac was packaged in a TO220 casing, it was luckily a simple task to bend two legs so that they cross each other.

All that said and done, this project wasn’t really designed for minimal input power, and instead could work with a 20W solar panel too. I’ll have to wait for a proper sunlight to really test it out with a solar panel instead of my bench power supply.

Leave a Comment