MPPT Solar Charger Design

I’m currently waiting for the boards for my Ultrasonic Anemometer Rev B to arrive from Hong Kong and this gives me some time to write about the MPPT Solar Charger design that I did quite some time ago. I published a series of posts on a Arduino MPPT Solar Charger Shield and got a lot of encouraging feedback. But that shield was more of a proof-of-concept than a finished product.  While it generally performed well it drew way too much current when idle to actually be deployed unless you can count on plenty of sunshine every day.

SolarChargerEagleTop

Aiming for very low power consumption

While I like the Arduino platform I had to admit that it’s probably not ideal for a low-power design. Yes there are some things you can do to reduce the 50mA or the Arduino draws but it will never be truely low power. So I designed a stand alone version with plenty of extra features that I hope to draw only a small fraction of the current. I particularly care about the idle current, i.e. the current it pulls when the solar panel is not producing any energy. In winter, the panel might be covered by snow for weeks and you don’t want your charger to drain the battery during that time. With this new design I’m aiming for an idle current in the tens of microamps. Even if it ends up being 100 microamps that is still 500 times less than an Arduino uses just by itself. And that means it draws less than 1Ah (ampere-hour) per year so you will never drain the battery no matter how little sunshine there is.

SolarChargerSchematic1

PIC18 series microcontroller

At the core of the design is a PIC18F26J50 in a 28 pin SOIC package. It’s capable of running at down to 2.15 volts and consumes extremely little power when running at lower clock speeds. And apart from that it features USB so we can have all the benefits of USB without any external components except, of course, a USB socket.

The PIC has two crystals at its disposal. A 8MHz crystal which will be boosted up to 32MHz by its internal PLL. That’s what the PIC will run on when there is work to do. And then there is a 32.768kHz crystal that will be used to run its real-time clock (RTC). When there is little to no work to do this low-frequency clock will also be used to run the CPU which will greatly reduce power consumption. Power consumption is approximately linear in frequency so this should cut power consumption by a factor of about 1000 compared to full-speed operation.

SolarChargerSchematic2

Switch mode power supply

Now we can run the microcontroller at only a few volts but our power supply is a 12 volt battery. So one of the most straight forward things to do in order to save power was to use a switch mode step-down regulator aka buck.

I looked around and found the Texas TPS62120. It’s only capable of providing 75mA but that’s more than enough for us in this case. It works at a switching frequency of 800kHz and only consumes a bit more than 10 microamps with no load at its output.

It needs a 18uH inductor as well as some ceramic capacitors to work. The output voltage is set via a pair of resistors acting as a voltage divider. I’ve added a n-channel mosfet that allows the PIC to increase the output voltage from 2.2 volts to 3.3 volts when needed. Because while the PIC can run on down to 2.15 volts the display can’t. And even the PIC needs 3.0 to 3.6 volts for USB operation.

Synchronous / asynchronous operation

The actual MPPT converter has changed only little. I’ve changed the mosfet driver to a MIC4605.  Unlike the IR2104 used last time, this model has adaptive dead-time (as opposed to the longish 540ns fixed) and separate inputs for each mosfet. This will allow us to either operate in synchronous (using both mosfets) or asynchronous (only using the upper fet and relying on the diode) mode. Asynchronous operation has a certain efficiency advantage at low power levels so this might come in handy.

The MIC4605 consumes quite little quiescent current for a mosfet driver, only 100uA typical. But that’s still too much for our purpose. So the PIC can power the whole thing off via a NPN transistor and a p-channel mosfet. That BUCK_ON signal also serves as the supply voltage for the INA213 current sensors already used in the last version. So the entire converter can be powered off and should consume precisely zero current when not in use.

What about the voltage divider necessary to measure the battery voltage? That’s been taken care of, too. That divider is interrupted by a (low threshold voltage) n-channel mosfet unless a signal from the PIC turns on the mosfet and closes the circuit.

SolarChargerSchematic3

Port expansion

I soon ran out of GPIO pins with that PIC so I had to add an I2C port expander (MCP23008) to gain another 8 I/O pins. I’ve also added a PCA9546 I2C switch in order to translate between different voltage levels.

It’s probably not the most elegant solution and a future version might trade these 3 chips for a higher pin-count PIC. But I had all components here already so that’s what I’ll use for now.

Precise measurements

In order to precisely measure input and output voltages and currents there is now a MCP3424 4-channel 18-bit ADC. To be sure, we don’t need 18 bits of precision here but we’ll trade some of that precision for speed and work with 14 or 16 bits.

The ADC has its on-board voltage reference and PGA with gains up to 8.  Since it only consumes a maximum of 1uA in standby mode it is always powered on.

There are also a total of 3  LMT86 temperature sensors, one on the board and 2 external ones. The external ones are intended to measure the temperature of the panel and battery, respectively. The maximum voltage for a battery is quite dependent on temperature so that’s a useful information to have. The inputs from the temperature sensors are measured directly by the PIC.  For that purpose there’s also a ADR361 2.5V voltage reference.

Measuring temperatures requires the board voltage to be high, 3.3 volts nominally. So both the voltage reference and the temperature sensors are only powered on when then VCC_HIGH signal is set.

User interface

To communicate with a human user there is a 4×20 LCD display that is controlled via I2C in order to save some I/O pins. There are quite a few external components needed to run it at 3.3 volts so it has its own PCB and connects via a 5-pole wire. There is 3.3 volts and ground for power, SCL and SCD for I2C communication and a PWM singal in order to control the display brightness. Because that’s a rather universal board I will document that as a separate post.

As an input device there’s a rotary encoder with push button. Together with the display (and some decent software) that should allow for a pleasant user experience.

The inputs from the encoder are debounced in hardware via a 74HC126 that serves a double purpose. With its 3-state outputs it allows us to use the pins that are otherwise used for in-circuit programming of the PIC.

Both the rotary encoder (except the push button) and the entire display unit can be powered off when not in use. The push button is always powered on so the user can wake up the user interface at any time by pressing the button. When the user interface is not actively powered on the 74HC126’s outputs are in high-impedance mode and the PIC can be programmed without being affected by the rotary encoder.

SolarChargerSchematic4

Data logging

One might be interested how much energy has been harvested by the solar charger over the last hours, days, weeks or months. So there’s some non-volatile storage as well. The 24FC256 connects via I2C and offers 256kBit of memory. It consumes only 100nA in standby so it can stay powered on at all times.

Fan control

As mentioned, there’s a temperature sensor on the board. If it gets too hot, a fan can be powered on via the FAN_ON signal controlling an n-channel mosfet.

Outputs

There are 4 power outputs, each controlled by a separate signal from the PIC. There should be some PWM modules left on the PIC so some (two I think) can be PWM controlled. A typical application would be LED lighting which can be controlled and dimmed directly from the solar charger via the rotary encoder. Each output channel has a beefy  mosfet of the same type as the MPPT switcher (IPB136N08N3).

Each has its own FAN3111E mosfet driver. They have a separate input for the reference voltage so the PIC can easily control them when running at only 2.2 volts. The FAN3111 should only draw 5uA (10uA max) when idle but there are 4 of them so they can be powered off (all togeher, not individually) when not in use.

SolarChargerSchematic5

USB charging ports

One of the first thing one wants to do when there is power is to charge one’s cell phone or similar device. So there are two USB charging ports capable of delivering some 2 amps of current at 5 volts in total.

They are powered from the 12V batter via a TPS54231 buck converter. So there are a total of 3 buck converters on this board… It is always connected to the 12V rail but the PIC can turn it off when not in use. The regulator’s shutdown current consumption is only 1uA typical (4uA max) so that should be adequate.

Manufacturers of mobile devices have all come up with nasty ways of making their devices incompatible with other manufacturer’s chargers. They basically abuse the otherwise unused (for charging purposes) data lines to recognize their own chargers and discriminate against any others. That might mean they won’t charge at all or only at a slow rate.  So there are two charging ports on this board, one emulating an iPad charger and the other one a popular Samsung scheme. So pretty much any device should be able to charge on at least one of these ports at a reasonable speed.

Summary

As you can see, there’s a lot of functionality in this new design just waiting to be unlocked by some clever software.  I’ve already milled a board and I’m looking forward to populating it and bringing it to life. I guess that will be quite a bit of work but I think its well worth it. Thanks to all of you who have kept asking about this project – I very much appreciate all your feedback.

There are only Eagle files (including PDFs of the layout and schematics) at this point. They can be downloaded on the overview page. There’s now also a prototype. First test results are presented here.

20 thoughts on “MPPT Solar Charger Design”

  1. Hi Lukas,

    Thank you for sharing your work.

    I’ve found your website while looking around for ideas for making my own MPPT charger. I could reasonably follow rev. 1 in design, but i’m having a harder time understanding rev. 2. But that’s my lack of understanding the circuit.

    What are the solar power in/out specs the rev. 2 board should be able to handle?

    I’m curious as to see what the results of the rev. 2 board will be! 😉

    Regards,

    Mario

    1. Hi Mario
      Yes, rev 2 is quite bit more involved. I originally designed rev a for an input power of 30 watts but my tests have shown that it can handle quite a bit more than that. Actually, my lab power supply can only supply 2.2 amps@17volts so I had to stop there with my testing. But it can probably handle some 40 watts before the coil starts saturating.
      With rev 2 i’m using a different coil so the power rating is somewhat higher power, say 50 watts. I’ll know once I’ve done some testing with a more powerful supply.
      Also note that using a more powerful panel won’t do any harm. The controller is smart enough not to draw more power than it can handle. So you can safely attach a (say) 100W panel which might even make sense since the panel’s power rating is the peak power it will produce at very high sun intensity.
      Regards
      Lukas

  2. Hi, Excellent work ! Thank You for posting it ! Any testing yet ? PIC18F code for download ? I am interested in duplicating your work and testing. I have worked some similar portions of the project – but NOT finished it: Last fall I studied the Arduino MPPT Rev 1, 2 & 3 from Deba168 which all seem to have different problems (especially FET burnout) and built (redrew schematic and created PCB in ancient P-CAD system I had, and made buck converter board at home by iron on toner transfer & copper etch) most of a version based on his work & controlled by Arduino UNO & blended with comments from Bandis1 in that thread, contributed over a few months. I also compared that design to a Texas Instruments MPPT Reference Design which could easily be adapted for higher voltage and current PV panels, but cost more in parts (especially $10 each for 2 inductors), and did not seem to have much online support. I have a bit of familiarity with your PIC ‘F877 series uControllers. I have access to some PV panels ranging from 7 to 100 watts for testing. SO … I want to try your new Rev2 PIC18F based version. Can you post any of the PIC code ?

    1. oops: minor clarification: I have familiarity with PIC ‘F877 but NOT your selected 18F series.

    2. Hi John
      Thanks for your comment. I’m still working on populating the board and writing code. I will definitely make the code as well as any test results available on the blog. There are many features and many components so it takes some time to get it all up-and-running. But I’m working on it. There will most likely be further version for which I will order a professionally produced PCB and might even make it available as a kit or so. But I don’t have a timeline for that yet.

      So far I’ve never had any issues with burned-out FETs and I hope to continue that history…

      regards
      lukas

  3. Hi,
    Thank you for posting the schematics it is always nice to see how another head goes into the details.

    Having done similar work I was curious about the use of the converter (IC4) between the solar input and the battery. I alwaysfigured that a panel with an output voltage near the battery voltage is probably best with a direct connection., through current limits of course. While batteries are anything but constant voltage devices they are fairly flat during most of the charging period. When a battery voltage is significantly lower than the panel MPPT I agree the converter makes sense. But if there is only a 3 – 4 volt difference I am not so sure.

    When I designed this into my SunDuino product I used a linear constant current regulator to replace IC4 and IC2. The current level was set to something reasonable for the battery and panel. With a low battery I do get some heat dump but in general it is very little.

    Thanks again for the look at the schematic. You can see what I did on the link below. (www.sunduino.com)

    Thanks,
    Bob K.

  4. Thanks Lukas for this,,, I got same question as Jonh, I realy tried all those timnolan mppt project from deba168, n never works.

    will nee update on your code for pic 18F.. too, Thanks in advance.

    1. Hi Nepembe

      in the mean time i have populated the board and got most features except USB working. The code is very preliminary still but I’ll soon be ready to post some first results together with the code

    1. I have to solder the PIC first in order to program it. It’s simple, just connect a suitable programmer (Microchip PICKit3 or Mikroelektronika MikroProg for PIC, for example) to the ICSP (in-circuit serial programming) header and re-program the PIC.

    1. Thank you for that useful hint. I’ll check and correct that. I don’t have any Apple device so I wouldn’t have noticed for a while probably. Thanks for pointing this out to me.

      1. Be aware, I haven’t tested it and I’m not sure either (haven’t an iPhone either). But it’s probably a point worth to verify. Anyways no big deal as it wouldn’t change the board 🙂

    1. Hi Rahul

      The design was made with 12V lead-acid batteries in mind. However, all the charger characteristics like maximum charge current, maximum charging voltage and so on are just parameters in the software so you could easily modify it to work with, say, 3-cell (11.1V) LiPo batteries. Even 2-cell (7.4V) should work. Generally, if the battery has a nominal voltage in the range of, say 6 to 13 volts you should work if programmed correctly.

  5. Solution for the USB charging schemes: I designed an autoranging USB charging port, using a simple chip
    https://oshpark.com/shared_projects/sTExw1i9
    It uses the TPS2513 chip, a very interesting and capable chip
    The one I designed is a stand alone plugin that goes on the end of a USB cable to charge, but you can easily incorporate it into the charging ports on your board.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.