Switching Solar Charge Controller

In the last post we looked at a basic overview of solar power systems. We looked at the various components of solar power systems as well as choosing the best components for your own system. One such component we looked at were solar charge controllers. These charge controllers are of many different types including On/Off also formally called switching type controllers, PWM type controllers and MPPT type controllers. In this post we will design the simplest and cheapest type of charge controller, the switching type controller. The design is based around the powerful PIC16F18855 microcontroller.


Review of Switching Type Controllers

Let us have a review of switching type solar charge controllers. In general solar charge controllers are designed to keep your batteries from over charging.

To keep our controller at minimum cost and maximum simplicity, the type of switching controller we will be designing in this post is known as a single stage switching charge controller. These type of controllers are designed in such a way that the charging circuit charges the battery up to a certain voltage, and when the battery reaches a certain point, it turns off the circuit and allows the battery to discharge to a certain preset point, once the battery reaches this lower voltage, the charging circuit turns on again and charges the battery up to its maximum preset point. There are also dual stage charge controllers which maintain the battery at a “floating” stage after the voltage reaches a certain amount. If you need to use a dual stage charger it would be more wise to use a PWM based solar charge controller.

There are many disadvantages to these type of controllers, such as they are known to reduce battery capacity compared to other types of charge controllers and thus negatively impact battery health. However they have the advantages of being extremely cost effective and reliable as there is very little to go wrong.


 

Switching Type Controller Circuit Design

As was noted in the previous post on solar power systems, I recommend switching type circuits for small systems (5A and below) where you would have a single panel or very small panels in parallel. Generally the circuit designed in this post is to be used with a single small panel (50W recommended) and a single battery (40 Ah max recommended).

Here are the specifications:

System Voltage: 12v

Charge Current: 5A Maximum

High Limit Disconnect: 14.2 v

Low Limit Connect: 12.8 v

Max Panel Voltage: 27v

Panel Power: 80 W max (50 W recommended, absolute maximum 100 W)

Battery Type: Lead Acid (Gel recommended)

The Circuit:

12V Single Stage Switching Solar Charge Controller Design 

Going from left to right you will see that the max input of the solar panel is expected to be around 25v (though up to 30V can be handled by the charge controller) which is more than above the average of 18-21v expected on most 12v panels, this voltage was chosen to be in line with the open circuit voltage of the panel. There is a 12A fuse connected to the panel for over current protection, which is less than the usually 15A max series fuse recommendation given by most manufacturers.

There is also a diode to provide wrong polarity protection on the solar panel. This diode is dependent on the type of application you are looking at, however the MBR2045 Schottky diode will provide adequate reverse polarity protection.

A Zener diode with transistor buffer clamp to provide over voltage protection for the circuit could be utilized but was omitted to keep costs down.

You will notice a relay provides the on off switching. Though most switching controllers would employ some sort of shunt transistor to charge the battery, I opted to use a relay. The flyback diode connected across the relay was chosen to be a 1N4007 which has a PIV of 1000V which should be more than enough to stop any voltage spike that occurs across the relay. The relay chosen was the readily available Songle SRU-12VDC-SL-C which is rated for 10A at 30 v DC, more than enough for out application. The coil resistance of these relays were tested at 411 ohms.

Since the resistance of the coil is 411 ohms, the current flowing from the collector to the emitter at a battery voltage of 14.2 v (cut off voltage) would be 35 mA. The transistor I selected is the 2N2222A which can handle up to 600 mA at 40 volts. You can also substitute this transistor for the  2N3904 which is readily available and can handle up to 200 mA and 40v.

The voltage divider connected to the analog input pin has a capacitor and zener diode connected across it to ensure stability in readings and the zener diode would not interfere in an functioning of the voltage divider until the voltage crosses 2.73v (for 30v max) at which point it will clamp the voltage and prevent any damage to the microcontroller. The voltage divider consists of a 20k and 2k resistor chosen to within 1% accuracy. This means that for every volt we would read 0.091 volts output from that voltage divider.

The microcontroller is of course the PIC16F18855 because it contains exactly what we need and more, it is also possible to utilize the ADC with computation module on board and add things such as a display, temperature sensors and whatever else you may wish to design into the circuit. The voltage regulator was chosen to a buck converter being the MCP16301H which has a typical efficiency of 96% and provides up to 600mA of current at 3.3v which is enough to power the microcontroller. The configuration of the buck converter comes directly from the datasheet.

The charge controller circuit can be used for low voltage and cost sensitive applications.

Full Bill of Materials:

With exactly 20 components and a cost as low as US $5 if you use surface mount components and buy in bulk, you can have your own solar charge controller!


C Code

 

#include "mcc_generated_files/mcc.h"

#define RELAY RB0
#define ON 1
#define OFF 0

uint16_t convertedValue;
double voltage;
double final_voltage;
float offset = 0.28;  // offset for correct voltage reading
float vout_div_vin = 0.09091; // voltage divider ratio
float high_voltage = 14.2; // high voltage cut off point
float low_voltage = 12.8; // low voltage

/*
                         Main application
 */
void main(void)
{
    // initialize the device
    SYSTEM_Initialize();

    // When using interrupts, you need to set the Global and Peripheral Interrupt Enable bits
    // Use the following macros to:

    // Enable the Global Interrupts
    //INTERRUPT_GlobalInterruptEnable();

    // Enable the Peripheral Interrupts
    //INTERRUPT_PeripheralInterruptEnable();

    // Disable the Global Interrupts
    //INTERRUPT_GlobalInterruptDisable();

    // Disable the Peripheral Interrupts
    //INTERRUPT_PeripheralInterruptDisable();

    // set charge LED's
    CHARGE_LED = OFF;
    DISCHARGE_LED = OFF;

    while (1)
    {
       // read ADC value
       convertedValue = ADCC_GetSingleConversion(channel_ANC7);

       // convert to voltage
       voltage = convertedValue * 0.0032;

       // get real voltage

       final_voltage = (voltage / vout_div_vin) + offset;


       // print final voltage
       printf("Voltage: %.2f\n", final_voltage);


       // if voltage high, turn relay off
       if (final_voltage >= high_voltage)
       {
           RELAY = OFF;
       }

       // if voltage low, turn relay on
       if (final_voltage <= low_voltage)
       {
           RELAY = ON;
       }

        __delay_ms(1000);

    }
}
/**
 End of File
*/


The code is very simple and straightforward. Firstly we declare variables for our high and low voltages, offset voltages and voltage divider ratio voltage. Then we read the value from the ADC converter and convert it to voltage, with the offset applied the voltmeter is fairly accurate being at most 0.05 to 0.20 volts off the reading my multimeter gives, however considering the cost, it is not that bad.

 


 

Results

The Finished Circuit

 

The Circuit Testing with Lamp

When I finished building and testing the circuit the sun was not available, so I put a small panel (5 W) into the circuit and used a bright lamp which gave 15v output from the panel. Though the battery was charging at a very slow rate. to speed things up I replaced the panel input with a bench power supply, and put my trusty 5w, 15 ohm resistor in series with the diode to limit the current and tested the charger, as soon as it reach ~14.2 v, the relay turned off, I discharged the batter with a 12v motor and when it dropped low, the relay turned on again allowing the battery to charge. The battery I used was a 12v 3Ah lead acid battery.


Conclusion

In this post we designed and built a simple switching solar charge controller that can handle small loads reasonably well. Though as stated above there are many deficiencies associated with using these types of controllers such as a negative impact on battery health and poor efficiency. This charge controller is however very reliable and robust and will happily provide many years to you of charging small batteries.

Download code files Here

 

Leave a Reply

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