For the last one and a half year I have been trying to design a MPPT controller for my solar panels. Most of the time has gone in to learning electronics and especially mosfets, mosfet drivers and inductors have proven to be a tough subject to grasp.
I will show you my latest attempt at mastering this project.
MPPT and buck-boost
An MPPT controller has to be able to control the amount of current taken from a solar power so the voltage level of the panel stays at a level where it produces the most power. So for this I need the controller to have buck functionality. Buck means I can turn the current coming from a solar panel on and off whenever needed.
Keeping the solar panel at optimal voltage is one part of the job. The other part is converting the output voltage of the panel in a useful voltage for whatever it is I want to do with it. For this I need buck-boost functionality to either lower or raise the voltage.
This will later turn into a balancing act for the microcontroller attached to the circuit. It has to do buck to keep the panel happy and buck or boost to keep my random appliance happy. Thankfully it never needs to do buck and boost at the same time.
There are many ways to construct buck-boost converters. Wikipedia has an article on the many designs possible. I have one requirement for this converter being it has to work and therefore it has to be simple. I am willing to sacrifice other aspects like efficiency and safety at this point.
The most simple design I found on Wikipedia is an inverting-buck-boost-converter. I consist of a diode, inductor and a mosfet. I used it as a base for my circuit but also modified it to make it even simpler to use.
This is the schematic I created. I highlighted the different sections and will now give you a brief description of all of them.
I am not yet sure on how many indicators I need. Because I have more than enough digital output pins available I will start with four, at the very least that will make my life easier when debugging the device.
Because I need to monitor both the input and output voltage I added two resistor dividers. This will help me read voltages higher than the maximum 5V the ATMEGA can handle. The resistor divider is 5 kOhms on 95 kOhm.
I wanted to be able to read a maximum of 100V. Now if I make 1V represented by 1 kOhm this will make it very easy to set up. The first 5 kOhms is the first 5V the ADC can read, this makes the first resistor. One end goes to ground, the other to the analog input. Then, also tied to the analog input is the second resistor, with 95 kOhms for the remaining 95V I need to measure. And at the other end of that resistor is the actual input or output voltage I want to measure.
Because the inputs positive is equal to the outputs negative, I only need to measure this once.
I choose the DS0026CN MOS driver as my low side mosfet gate driver. Although it is designed as generic MOS driver it is more than capable enough to do the job. The only thing it requires is a 12V power source and input signal, that’s all.
The power supply consists of two linear regulators, a 5 volt one for the microcontroller and a 12 volt one for the MOS driver to control the mosfets gate. At this point I only feed them from the input side of the circuit where the solar panel is going to be attached.
I choose to use an ATMEGA328P for my microcontroller. My main reason for this is debugging. I can simply put an Arduino UNO next to the board and wire it to the empty socket on the board for testing different things. Then once I get everything to work I can simply put the ATMEGA328P in the socket and program it with the exact same code.
I used the 6 pin 3×2 ICSP header for my programming interface because I have some experience with it, but anything would be fine here. I could even program it outside of the board and not have a programming interface at all.
The center piece of the circuit is the buck-boost section. I cut it out of the circuit and marked both current paths so you can see how it works.
The top left is the input side of the converter. Current comes in and goes through the inductor. The output on the right has a negative side that is always the same voltage as the input voltage, the positive on the output however has a diode to make sure only current can come in and therefore the positive is always equal or higher than the input voltage.
As you can see, the output side has a negative or ground that is not equal to the ground on the input side. This is one of the drawbacks of this design. Even though there is not a common ground on the output, its voltage difference can still be used, just like a battery has no common ground and still can power things.
When the mosfet on the bottom left is open current through the inductor can go to ground (blue arrow) and the inductor can charge up.
Then when the mosfet closes the inductor wants to keep the current going because of the charged it had built up, this causes voltage to build up. When the voltage becomes higher than the output voltage positive, it can finally pass the diode and create a higher output voltage (yellow arrow).
I already attempted to make the circuit on a prototype board. This was not a huge success for me. I can only get small circuits to work properly and always end up with connection issues on larger projects. Therefore, I decided to do bigger projects on PCB’s. They are pretty cheap to get made in China anyway.
The board is made up of only through hole components. The high current traces are on the top only for the moment. If I need to handle more current I can double those traces at the bottom also, if that is still not enough I can upgrade the board from 1oz to 2oz copper thickness.
To make routing easier I put a copper pour on the top being a ground plane. And 5V copper pour at the bottom. Since those are the most used connections in this project, it saves me a lot of traces.
Now I need to wait for my PCB’s to arrive from China. In the meanwhile I will show you the components I intend to use. These I already have from my previous attempts.
I will show you the components I have chosen to use for this project, all of these were ordered on alliexpress.com. I order my components there because their standard shipping gets me the component delivered within two weeks at most. The downside of that is it is not free shipping.
Small components like resistors, caps and diodes I do not buy each project but rather in bulk so I always have them at hand and can easily change to other values if needed.
LEDs are a good example of those bulk components. Just buy one or more of these boxes for a few dollar and you will be good for years.
Package from China
Five days after ordering DHL delivered me this package. You can also choose delivery by Chinese airmail which is cheaper but also takes about two weeks to arive in my country.
The package is filled with bubble wrap plastic to protect the PCBs. They also included a few LEDs for free.
After soldering everything up, I make a list off all the mistakes I made and update the PCB.
I failed to notice the MOS driver IC was an inverting driver. As soon as the circuit started the mosfet gate went high and all current went out leaving no power for the circuit. I now have a non-inverting driver, the TC427CPA.
The gate-to-source-resistor for the mosfet was accidentally made into a gate-to-drain-resistor. I had to patch this up at the bottom side of the PCB.
Also mosfet related; I had de mosfet in the circuit backwards causing a swap between drain and source pin.
The ceramic capacitor was to small and also were the pads for the electrolytic capacitors.
I messed up the ICSP connector by mistaken the Arduino pin numbers for action IC pins.
For the same reason as above I have Timer 0 when I wanted to use Timer 2. Actualy I am lucky the actual pin had a timer at all.
It appeared most ATMEGA328P ICs I have do not have the internal oscillator enabled so I decided to add a 20Mhz crystal.
After fixing al these issues on the PCB layout I need to order new PCBs from EasyEDA.com. But first I will make this thing work as it is.
I finally got the circuit to work! It manages to guestimate the MPP point for the power source and is able to protect it. It will not lett the input voltage go any lower. Except when there is not enough to even power the circuit ofcource, then it goes into shutfdown mode.
The output target voltage is maintained also as long as input voltage does not go under MPP voltage.
Even when shorting out the output voltages, the input voltage hovers at MPP voltage.
The projects source files
The firmware is also there under the attachments