Maker.io main logo

How To Build an MPPT Solar Charge Controller

2024-08-27 | By Zach Hipps

License: General Public License Energy Harvesting / Solar

Powering your electronics project using a solar panel can be fun, but how do you know if you're ‎extracting and utilizing all the power a panel can provide? I built a maximum power point tracking ‎solar charge controller to make sure I could extract all the power available from my solar panel.‎

 

 

TBSE2310BuildingAnMPPTSolarChargeController00_00_00_21

The best place to start when understanding maximum power point tracking is by looking at the ‎specs printed on the back of your solar panel. In my case, I'm using a 100-watt solar panel and ‎the specs listed on my panel will be different from the panel you might be using. ‎

TBSE2310BuildingAnMPPTSolarChargeController00_00_35_12

TBSE2310BuildingAnMPPTSolarChargeController00_00_51_15

TBSE2310BuildingAnMPPTSolarChargeController00_01_07_20

The first piece of information I want to know about this solar panel is its open circuit voltage. This ‎is the voltage that is measured across the terminals when no load is applied to the solar panel. In ‎my case, that's 24.3 volts. The second piece of information I want to know about my panel is the ‎short circuit current. If I take the positive and negative terminals of the solar panel and connect ‎them, the current that I measure running through the wire is the short circuit current. In my case, ‎that short circuit current is 5.2 amps. Now, these numbers aren't accurate because I have the ‎solar panel indoors. These values are what the panel would produce under standard test ‎conditions. However, in the real world, these numbers will be different depending on the amount ‎of sunlight, how many clouds there are in the sky, the temperature, and a bunch of other factors.‎

Solar panels operate on a power curve. That is to say, the amount of power that they can ‎produce is dependent on the amount of load attached to them and if you remember, power is ‎equal to voltage times current (P=VI). So, when there's no load attached to it, the voltage is at ‎‎24.3 volts and the current is at zero. Therefore, the power it's producing is zero. Similarly, if I ‎attach these two connectors and put an infinite load on the panel, the current goes up, but the ‎voltage drops to zero and therefore the power it's producing is also zero. To get power from a ‎solar panel, we want to be operating somewhere in the middle of that curve.‎

I installed some temporary mounts for the solar panel outside and attached a long enough cable ‎to feed through my window so that I could work inside. The first thing I want to do is measure the ‎open circuit voltage or VOC with no load attached to the solar panel. To do that I use a ‎multimeter and measure across the positive and negative terminals. So, in current conditions, ‎my VOC (my open circuit voltage), is 21.8 volts. Remember, this is the open circuit voltage right ‎now under these specific conditions. This is constantly changing depending on the conditions ‎outside. To measure current, I need to switch over to current mode on my multimeter, and I'm ‎going to short out the circuit using the multimeter and measure the current. My short circuit ‎current right now is 3.7 amps. So far, we haven't pulled any power out of the solar panel. To do ‎that, we need to hook up a load to the panel. To make things a lot easier, I've installed a little ‎electric energy meter in series with the panel. This will tell me the voltage and the current at any ‎given point.‎

TBSE2310BuildingAnMPPTSolarChargeController00_01_56_13

TBSE2310BuildingAnMPPTSolarChargeController00_02_28_04

TBSE2310BuildingAnMPPTSolarChargeController00_02_46_15

Once I connect the test load, I want to sweep it across its whole range and collect all the data ‎points so that I can put them into a spreadsheet. My goal is to be able to plot the points so that we ‎can see the power curve. To start, I'll attach a small load of 40 ohms, and you can see that the ‎voltage dropped a little bit, but I am pulling about 11 watts out of the solar panel. If I increase the ‎load, you'll see that the voltage will continue to drop, and I get 15 watts out of the solar panel. ‎Let's keep increasing the load. Now I'm getting 22 watts out of the panel. Let's keep increasing ‎the load. I'm at about 40 watts out of the panel. If I keep increasing the load, the voltage ‎continues to drop, but the power increases. I'm at 45 watts, 50 watts, and 53 watts; then if I keep ‎increasing this load, the voltage continues to drop. However, now the power is also dropping ‎instead of increasing like it was before. That tells me that we have reached that maximum power ‎point.‎

TBSE2310BuildingAnMPPTSolarChargeController00_03_25_01

TBSE2310BuildingAnMPPTSolarChargeController00_03_35_10

TBSE2310BuildingAnMPPTSolarChargeController00_03_55_16

So, what we want to do with our charge controller is to find that maximum power point where ‎we're pulling out as much power as we can out of the panel, and always track that power point ‎because it's constantly changing. It's never going to be the same from minute to minute.‎

Let's see what that looks like on a graph. I plotted some of the points I saw, and here's what the ‎power output looks like as we adjusted the load. On the horizontal axis, I have voltage measured ‎in volts, and on the vertical axis is power measured in watts. When there wasn't a load attached, ‎the open circuit voltage was 21.8 volts. As I started to increase that load, the voltage started to ‎drop slightly, but it began producing power. As I continued to do that, the voltage continued to ‎drop slightly, but the power continued to increase until it got to 17.6 volts. The power output at ‎that point was 53 watts. As I continued to increase the load, our power started to come back ‎down. So the maximum power point for that particular situation was 53 watts, and it happened to ‎be at 17.6 volts. If I were to do this again, even just 10 minutes later, I would get a slightly ‎different curve. So this is a sweet spot for this particular panel under these conditions. The goal ‎of a maximum power point tracking solar charge controller is to make sure that that load always ‎stays at that sweet spot.‎

TBSE2310BuildingAnMPPTSolarChargeController00_04_56_07

Let's say we connected a buck converter to the solar panel and dropped the voltage down to 12 ‎volts to charge a battery. That buck converter will be operating at some fixed voltage, which is ‎not necessarily the maximum power point. So, you wouldn’t necessarily get the maximum power ‎out of that solar panel under those conditions. Previously, I made a video where I went into great ‎detail about how buck converters work. So, if you're not familiar with their operation, I ‎recommend watching that video as a refresher. A buck converter would work to do this as long ‎as you could control the duty cycle and thus control the output voltage. That's what I initially tried ‎to do. I built this buck converter switch mode power supply using an Arduino to control the duty ‎cycle of a MOSFET, but I couldn't get this to work very reliably.‎

TBSE2310BuildingAnMPPTSolarChargeController00_05_35_23

TBSE2310BuildingAnMPPTSolarChargeController00_05_51_28

TBSE2310BuildingAnMPPTSolarChargeController00_06_07_02

Instead, I went on to the DigiKey website and searched for maximum power point tracking ‎integrated circuits, and of course, I found one. The chip I will use to design my maximum power ‎point tracking (MPPT) charge controller is the BQ24650. I opened up the data sheet and found ‎the typical applications circuit, and at its heart, it looks very much like a buck converter with a ‎few extra parts. From there, I can use the typical application and design my own custom PCB. ‎For the schematic layout, I just put down the BQ24650, followed the typical application circuit, ‎and placed all the necessary components. The benefit of using this chip is that I can program the ‎maximum power point by providing a voltage on the MPP set pin. The voltage is controlled by ‎this voltage divider, and all I have to do to change the voltage is to use a digital potentiometer and ‎a microcontroller. The microcontroller that I chose to use for this project is the Adafruit ESP32 ‎Reverse TFT Feather Board. It has a TFT display as well as three buttons, so I can write a nice ‎little UI for it.‎

I want to be able to measure and monitor the voltage as well as the current. I'm going to use the ‎ADC pins on the microcontroller to measure voltages, and then I'm going to throw some current ‎sensors on there that the microcontroller will use to read the current. The board layout took a little ‎bit of extra care because there are some high-speed signals required, and when there are high-‎speed signals, you need to make sure that you're following good PCB layout practices. There ‎are a lot of good notes in the datasheet for this, and I just followed those carefully as I laid out the ‎components.‎

TBSE2310BuildingAnMPPTSolarChargeController00_07_36_24

TBSE2310BuildingAnMPPTSolarChargeController00_06_36_25

TBSE2310BuildingAnMPPTSolarChargeController00_06_57_21

TBSE2310BuildingAnMPPTSolarChargeController00_07_14_10

When I ordered the boards, I also ordered a solder stencil along with it. It's time to apply the ‎solder paste to the boards so I'll use the stencil that I ordered. Normally I would get some old ‎PCBs and line them up and give myself a frame or a little jig to put my PCB in. Then I would ‎have to manually align the solder stencil with the pads on the PCB, but this time I decided to try ‎something new. I designed and 3D printed a little jig that I can stick the PCB in, and then it ‎automatically aligns the stencil right where it needs to go. I'm not sure if this is going to work, this ‎is the first time I've tried it. Of course, if it doesn't work, I can just go back to my old method, but ‎I figured it was worth a shot.‎

I think the proper technique is to get all the solder paste in one squeegee wipe, but I'm not that ‎good at this, so I have to go over it multiple times, kind of cleaning up and filling in spots. Before ‎lifting the stencil, I looked at it under the microscope to make sure that all the solder pads had ‎plenty of solder paste in them. Honestly, that 3D-printed jig worked pretty well! I'll probably be ‎using that technique in the future.‎

I've got a box full of components, and now it's time to start putting all of these onto the boards. ‎One thing I am doing differently this time is using the interactive BOM (Bill of Materials) plugin ‎for the KiCAD software. It's just like a regular BOM, but when you click on a part, it highlights ‎everything on the board to show you exactly where they are. There are boxes you can check ‎when you source the parts, and then after you've placed them.‎

TBSE2310BuildingAnMPPTSolarChargeController00_08_04_05

TBSE2310BuildingAnMPPTSolarChargeController00_08_33_26

TBSE2310BuildingAnMPPTSolarChargeController00_08_57_23

TBSE2310BuildingAnMPPTSolarChargeController00_09_22_26

Here's the moment of truth. I just finished assembling the custom PCB, and I'm ready to test it to ‎see if it works. Instead of immediately connecting this to a solar panel, I'm going to use a ‎benchtop power supply. It’s worth mentioning that a benchtop power supply doesn't have the ‎same power characteristics as a solar panel, but it'll work just fine for testing purposes.‎

TBSE2310BuildingAnMPPTSolarChargeController00_10_07_12

As I mentioned before, the plan is to control the maximum power point by adjusting the ‎resistance using a digital potentiometer and a microcontroller. For now, I just have it set at a ‎constant value for testing purposes. When I plug this in, I'm expecting the charging indicator LED ‎to turn on and that will tell me that this thing is working. Let's go ahead and set the bench top ‎power supply to 24 volts and connect that to the board. Oh no, there's a problem… The charging ‎LED is not coming on, and that tells me that the MPPT chip isn't behaving the way it's supposed ‎to be. Something is not right, so I need to start troubleshooting this. After looking at my ‎schematic for a couple of minutes, I immediately realized one problem. The current limiting ‎resistors I had in series with those LEDs were not the right value. They were way too high, which ‎meant the LEDs were too dim to even light up. So, I went ahead and swapped out those current ‎limiting resistors. Now, the LED should light up. Okay, it does not light up... That means that that ‎wasn't the issue. I think it was a little bit wishful thinking that it was going to be that simple, but it's ‎not. Clearly, something else is wrong, so I'm going to keep going through my schematic and look ‎through the datasheet to see if I can find something that I did wrong.‎

After a couple of hours of looking through the datasheet, and looking at my schematic, I think I'm ‎on to something. Looking through the datasheet, I found a list of all the conditions that need to be ‎met for the chip to function properly. It's like a preflight checklist. I started going through each ‎one and I verified that all of them were working, except for the very last one. That's the battery ‎temperature fault. The battery temperature circuitry just uses a voltage divider and a thermistor. ‎When the thermistor gets too hot, the voltage goes down and it causes that fault. However, I ‎missed a critical piece of information. I need an additional resistor in parallel with the lower ‎resistor of the voltage divider. Since I was missing that resistor, the chip thought that the battery ‎temperature was out of range so it would not go into charging mode. I think the solution is pretty ‎simple. I need to add a 10K resistor in parallel with the lower half of that voltage divider, and I ‎think the fault should go away. I soldered the 10K resistor onto the board, and it's pretending to ‎be the battery temperature thermistor.‎

TBSE2310BuildingAnMPPTSolarChargeController00_11_11_24

TBSE2310BuildingAnMPPTSolarChargeController00_11_42_09

When I plug it in, I expect that charging light to finally turn on. The charging LED has turned on, ‎which tells me the MPPT chip is working, and I can keep moving forward! I'm so relieved that ‎that fixed the problem. Now I can install the microcontroller and start writing some firmware for ‎my MPPT algorithm.‎

TBSE2310BuildingAnMPPTSolarChargeController00_12_10_07

The algorithm is pretty straightforward. If you want to take a closer look at it, I will have the code ‎and all the design files available on my GitHub page.‎

The first thing I do is read the solar panel voltage using the ADC pin. Next, I read the current ‎coming from the solar panel. When I multiply those two values together, I get the power of the ‎solar panel. The next step is to set the digital potentiometer, which sets the maximum power ‎point of the chip. From there, I can just loop through those two steps over and over. I measure ‎the power coming from the panel, and then set the maximum power point voltage. This is called ‎the perturb and observe algorithm. I adjust the maximum power point voltage, and then I see ‎how that affects the power. If the current power I'm measuring is greater than the previous ‎power that I measured, then I know I'm on the right track. I just need to determine whether that ‎increase in solar panel power was a result of increasing the VMP or decreasing the VMP. ‎Whichever it was, I keep going in that same direction. The other possibility is that the current ‎power being measured is less than the previous time. That tells me that I'm going in the wrong ‎direction. If I increased the VMP last time, then I need to decrease it this time and vice versa. It's ‎worth mentioning that the perturb and observe algorithm is not the only way to approach ‎maximum power point tracking, but it is probably the easiest to implement.‎

I'm feeling good with how this algorithm is working so far on my bench. So now it's time to ‎connect it to an actual solar panel to see if it works. Back over at the window next to the solar ‎panel outside, I connected the panel to the MPPT charge controller.‎

TBSE2310BuildingAnMPPTSolarChargeController00_12_44_20

TBSE2310BuildingAnMPPTSolarChargeController00_13_25_24

Looking at the TFT display, I've got four values listed from left to right, top to bottom. They are ‎the solar panel voltage, the solar panel current, the solar panel power, and then the fourth value ‎is the digital potentiometer value, and it is a seven-bit value that ranges from 0 to 127. That digital ‎potentiometer is what sets the voltage of the solar panel. For the load, I'm going to be charging a ‎large lead-acid battery. Right now, the battery is not connected to the charge controller.‎

You can see that my current is close to zero and my open circuit voltage is about 21.5 volts. It ‎looks like it's a little bit overcast today, and so the VOC value is going to change from minute to ‎minute. I’ll connect up the lead acid battery and see that charge controller kick into action.‎

I’m looking at the fourth value, the digital potentiometer, watching the potentiometer value ‎change as the power increases, increases, increases, and then it'll overshoot, and the power will ‎go back down. Then it backtracks and tries to correct itself. During testing, there was a 30-‎second period when the sun came out and got very bright. The MPPT charge controller jumped ‎all over it and started pulling more power from that panel. A traditional charge controller would ‎have struggled and not been able to adjust like that. This illustrates why you need an MPPT ‎charge controller on a solar panel. ‎

TBSE2310BuildingAnMPPTSolarChargeController00_14_05_08

TBSE2310BuildingAnMPPTSolarChargeController00_14_45_05

TBSE2310BuildingAnMPPTSolarChargeController00_15_04_26

There's so much more that this custom PCB can do. If you remember looking at the schematic, ‎I also added power-measuring circuitry to the load side. That allows me to measure the power ‎coming from the panel as well as the power going to the load. If I compare those two numbers, I ‎can calculate the efficiency of the charge controller. I also added separate terminal blocks for ‎the battery as well as the load. I can turn on or off the load with a MOSFET that I added to the ‎board. That means I can have both a 12-volt battery and a 12-volt load connected to the charge ‎controller at the same time, and I can turn the load on or off as needed.‎‎

This project ended up being quite challenging, and I think I bit off a little bit more than I could ‎chew, but that's how I learn and grow as an engineer. If you want to take a closer peek at the ‎design files or the code I used, I'll have all of it available on GitHub; and you can find the full ‎bill of materials here.

制造商零件编号 BQ24650EVM-639
EVAL BOARD FOR BQ24650
Texas Instruments
制造商零件编号 BQ24650RVAR
IC BATT CHG MULTI-CHEM 16VQFN
Texas Instruments
制造商零件编号 5691
ESP32-S3 REVERSE TFT FEATHER
Adafruit Industries LLC
制造商零件编号 ACS71240LLCBTR-010B3
SENSOR CURRENT HALL 10A 8SOIC
Allegro MicroSystems
制造商零件编号 AP63203WU-7
IC REG BUCK 3.3V 2A TSOT23-6
Diodes Incorporated
制造商零件编号 MCP4018T-503E/LT
IC DGTL POT 50KOHM 128TAP SC70-6
Microchip Technology
Add all DigiKey Parts to Cart
TechForum

Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.

Visit TechForum