Close

Software requirements for MPPT controller V3.1

A project log for ARDUINO MPPT SOLAR CHARGE CONTROLLER

An Arduino based Solar MPPT charge controller.

open-green-energyOpen Green Energy 08/30/2015 at 15:062 Comments

Software requirements for MPPT controller V3.1

Draft by Keith Hungerford, updated 12th September 2015

Charging states

The charger operates in one of several charging states, depending on the sunlight level.

Charger OFF state

At nil or low sunlight levels, as indicated by solar voltage below battery voltage + 0.5 Volts, the charger state is OFF.

Transition from the OFF state occurs when

a) if battery voltage is greater than 11.5 volts and solar voltage rises above battery voltage + 0.5 Volts

b) if battery voltage is less than 11.5 volts and solar voltage rises above 12.5 volts.

When either of these voltage conditions is met the charger goes into one of the following states:

i) Float state if the battery voltage is greater than the Float voltage;

ii) Boost state if the battery voltage is less than the Float voltage and the Boost time since the last night time is less than [1 hour];

iii) Bulk state if the battery voltage is less than the Float voltage and the Boost time since the last night time is greater than [1 hour]

In all 3 cases initially the controller will use the DCM charging algorithm.

Boost DCM and Bulk DCM states

When in the Boost DCM or Bulk DCM state, the charger can go to OFF state if the solar voltage falls below (battery voltage + 0.5 Volts).

The charger can go to Boost CCM or Bulk CCM state if the Solar Power rises above 10% of the rated power.

The charger can go to the Float state if Battery voltage rises above Float.

The charger can go from Boost DCM to Bulk DCM if the Boost time since the last night is greater than Boost duration.

Boost CCM and Bulk CCM states

When in the Boost CCM or Bulk CCM state the charger can go to Boost DCM or Bulk DCM if the Solar Power falls below 10% of rated power.


Float state

The float state is functionally the same as Bulk state when the battery voltage reaches Float.

When in Float state the charger keeps just sufficient current flowing to the battery to maintain the battery voltage at Float.

Charging algorithms


CCM algorithm

Continuous Current Mode (CCM) applies when the available solar power is more than 10% of the rated power (strictly, when the current in the inductor always flows towards the battery, but this is difficult to measure directly in the software so we use the power level as a proxy estimate).

In this mode, the PWM period is set at 12 microseconds. The PWM duty cycle is set either at a value that achieves maximum power, or to meet the charging voltage required by the battery (see battery management conditions below). When it is required to reduce the charging rate so as to limit the battery voltage, the PWM duty is reduced, thereby increasing the panel voltage above the maximum power point and reducing the current accordingly.

The Fast PWM mode of the Arduino is used to generate this PWM. The PWM period of 12 microseconds is 192 clock cycles at 16 MHz. The PWM period is divided into a Panel Connect phase followed by an Earth Connect phase. The length of the Panel Connect phase is controlled by PWM Duty.

When maximising power, the power level is measured approximately every 0.5 milliseconds and is compared to the previous power level measurement. The PWM duty cycle is changed up or down by 1 CPU clock cycle after every measurement. After the first measurement, the PWM duty cycle is increased. On subsequent measurements, if the power level is increased or is the same as the previous measurement, the PWM duty cycle is changed in the same direction as in the previous cycle. If the power level is decreased from the previous cycle, the PWM duty cycle is changed to go in the opposite direction to that in the previous cycle.

When tracking the allowable battery voltage, the battery voltage is measured approximately every 0.5 milliseconds and is compared to the target value. If the new value is within +0.1 volts of the target value, the PWM duty is left unchanged. If the new value is higher than the target value by more than 0.1 volts, the PWM duty is increased by one step. If the new value is lower than the target value by more than 0.1 volts, the PWM duty is decreased by one step.

Whether maximising power or tracking battery voltate, the battery charging current must not be allowed to exceed 105% of the rated current. If the battery charging current voltage reaches 105% of the rated current, the charging rate is reduced to keep within that limit.

DCM algorithm

Discontinuous Current Mode (DCM) applies when the available solar power is less than 10% of the rated power.

In this mode, the PWM period is set at 100 microseconds which is 1600 clock cycles at 16 MHz. The PWM period is divided into three phases: a Panel Connect phase, followed by an Earth Connect phase, followed by a Null phase. The length of the Panel Connect phase is controlled by PWM Duty through setting a “1” on both IN and SD pins of driver IC No. 2 (which drives Q2 and Q3). The length of the Earth Connect phase is controlled by setting a “0” on IN and a “1” on SD pins of driver IC No. 2. The Null phase is the remainder of the PWM period, during which time the SD pin of driver No. 2 are both “0”, so that both transistors are OFF.

In this mode the length of the Earth Connect phase is set to be Panel Connect phase multiplied by the ratio of (Panel voltage - Battery voltage) to Panel voltage. Thus if the battery voltage is 13 and the panel voltage is 19.5 volts, the Earth Connect phase is (19.5-13)/19.5 = 1/3 of the Panel Connect phase. So if the Panel connect phase lasts 9 microseconds, the Earth connect phase will last 3 microseconds. In this case the Null phase will be (100 – 9 – 3) = 88 microseconds.

When maximising power, the power level is measured approximately every 0.5 milliseconds and is compared to the previous power level measurement. The Panel Connect time is changed up or down by 1 CPU clock cycle after every measurement. The Earth Connect time is changed to follow the Panel Connect time. After the first measurement, the Panel connect time is increased. On subsequent measurements, if the power level is increased or is the same as the previous measurement, the Panel connect time is changed in the same direction as in the previous cycle. If the power level is decreased from the previous cycle, the Panel connect time is changed to go in the opposite direction to that in the previous cycle. Once the new Panel connect time is known, the corresponding Earth connect time is calculated.

Since the Panel connect time and Earth connect time are defined in integer numbers of clock cycles, it will often not be possible to make the Earth connect time the exact multiple of the Panel connect time required for the ratio of (Panel voltage - Battery voltage) / Panel voltage. In this case the Earth connect time should be made the next lowest integer of clock cycles, below the exact value.

When tracking the allowable battery voltage, the battery voltage is measured approximately every 0.5 milliseconds and is compared to the target value. If the new value is within +0.1 volts of the target value, the Panel connect time is left unchanged. If the new value is higher than the target value by more than 0.1 volts, the Panel connect time is increased by one step. If the new value is lower than the target value by more than 0.1 volts, the Panel connect time is decreased by one step. Then the corresponding Earth connect time is determined as defined for CCM.

Float algorithm

The algorithm for tracking the float voltage is the same as defined for DCM.

Off algorithm

All MOSFETs (Q1, Q2 and Q3) are turned OFF in this state.

Battery management

Float charging :

When battery voltage exceeds the Float value, the charger goes into a Float Charging state which provides just enough current to keep the battery within 0.1 volts of the Float value.

Bulk charging :

When sufficient solar power is available, the charger goes into a Bulk Charging state using the appropriate algorithms (DCM or CCM). In this state the battery voltage will be allowed to go up to Float voltage and the battery charging current must not be allowed to exceed 105% of the rated current. If the battery voltage reaches Float voltage – 0.1 volts, or the current reaches the rated current, the charging rate is reduced to stay below those limits.

Boost charging :

For a maximum of Boost Duration in each daily charging cycle, the battery voltage will be allowed to go up to Boost Voltage, provided the battery voltage has fallen below the Boost Reconnect voltage since the previous boost charging period. During this state, the battery charging current must not be allowed to exceed 105% of the rated current. If the battery voltage reaches Boost Voltage, or the charging current reaches the rated current, the charging rate is reduced to stay below those limits.

Battery management parameters

The controller will use the following parameters to manage the battery charge and discharge:

Float voltage 13.8 volts

Boost voltage 14.2 volts

Boost reconnect voltage 13.2 volts

Low Voltage Disconnect 11.1 volts

Low Voltage Reconnect 12.6 volts

Boost duration 1 hour

The values given above are the default for 25 degrees Celsius. If a temperature sensor is installed, these voltages should all be adjusted by minus 0.018 volts per degree Celsius. For example, at 0 degrees C the Float voltage would become 13.8 + 25*0.018 = 14.25 volts.

Load control states

This function controls the load MOSFET(Q4).

Via the serial monitor, the user can select either After Dark Lighting mode or Continuous mode.

Load control algorithms

1. Battery discharge protection

If the battery voltage falls below Low Voltage Disconnect voltage the load is disconnected.

Once the battery voltage rises to the Low Voltage Reconnect voltage the load is reconnected.

2. After dark Lighting

ON: Turn on loads at night (when the solar panel is producing less than 5% power) and the battery voltage is not disconnected due to the Low Voltage Disconnect logic.

OFF: Turn off loads in day time as well as due to the Low Voltage Disconnect logic.

3. Continuous

Turn on the load at all times subject to the Low Voltage Disconnect logic.

LED display

This function display the current state of charge of the battery via LED as follows:

  1. YELLOW means overvoltage (over Float voltage)
  1. RED means undervoltage (disconnected due to battery voltage falling below Low Voltage Disconnect, and still below Low Voltage Reconnect voltage)
  2. GREEN is Normal, ie above LVD / LVR and at or below Float voltage.


LCD display

This function is used to display the status of solar panel, battery and load of the controller on a 20X4 character I2C LCD display.


WiFi data logging

This function sends parameters (sol voltage, current, power & battery voltage, charging current etc) to the www.thingspeak.com via a ESP8266 wifi module.

First the wifi module will connect to the wifi router automatically (User has to set the SSID, Router Password and Thingspeak API key).

If the Wifi module connects successfully, it will transmit data to wifi @ 15sec intervals (this may be greatly reduced after development is complete, to maybe once every 15 minutes or even once per hour).

Current Status : Working but wifi module has to be first connected to the router by using a separate program and using AT command from serial monitor.


Serial monitor

This function prints software parameters on a computer connected via the Arduino USB port useful for debugging.

It also provides a command line interface for changing settable parameters in the controller. Settable parameters are:

Load control mode (After Dark or Continuous);

Battery management values (see battery management section).

In basic operation the default mode is to output data to the serial monitor. The user can put in a command such as "stop" which will stop the stream of serial data and print a single line with a prompt such as "type LIST for a list of commands, type START to restart data logging".

If the user types "LIST” or list" the serial monitor puts out a list of parameters and their current values. The user can then put in a command to change any value.


Hardware interfaces

The following pins will be used for interfacing to the various hardware devices.

// A0 - Voltage divider (solar) 150K / 20 K scale factor 0.04150390625

// A1 - ACS 712 Solar current scale factors for 5A unit: current 0.026393581 Offset 13.5135135

// A2 - Voltage divider (battery) 100K / 20 K scale factor 0.029296875

// A3 - ACS 712 Battery current scale factors for 5A unit: current 0.026393581 Offset 13.5135135

// A4 - LCD SDA

// A5 - LCD SCL

// A6 - ACS 712 Battery current scale factors for 5A unit: current 0.026393581 Offset 13.5135135

// A7 - not used

// D0, D1 - reserved, USB port

// D2 - ESP8266 Tx

// D3 - ESP8266 Rx through the voltage divider

// D4 - temperature from DS18B20 probe

// D5 - LCD back light control button

// D6 - Load Control

// D7 - not used

// D8 - not used

// D9 – IR2104 MOSFET driver IN

// D10 – IR2104 MOSFET driver SD

// D11- Green LED

// D12- Yellow LED

// D13- Red LED

Discussions

Resonance Cole wrote 07/05/2020 at 04:27 point

Good day, can you please share the updated code for the V3.1 Thanks

  Are you sure? yes | no

waqas sahi wrote 04/14/2016 at 06:48 point

updated code plz share of V3.1

  Are you sure? yes | no