## Tutorial on how to implement a Holtek MPPT algorithm for solar panels

In this tutorial, we will see how to implement a Holtek MPPT algorithm for solar panels. The MPPT algorithm is a method used to maximize the power generated by a solar panel. Holtek offers a library based on the MPPT algorithm to implement it in its microcontrollers, both 8 and 32 bits. Using this library we can develop applications that depend on a solar panel and batteries as the only power source, such as applications for environmental monitoring, lighting systems, smart agriculture and even logistics and transportation.

### 1. Introduction

The power output of solar panels is mainly affected by factors such as lighting intensity, temperature and humidity. Therefore, any environmental change will always cause changes in power output in real applications. MPPT, i.e. Maximum Power Point Tracking, is a way to obtain maximum power from the solar panel to improve charging efficiency and maximize solar energy utilization.

In this tutorial we will see the principles and instructions of how to use Holtek's MPPT algorithm library for solar panels in detail, which will help users develop products related to MPPT solar charging.

### 2. Principles of operation

Holtek's MPPT algorithm library for solar panels adopts perturbation and observation method in MPPT algorithm as basic principles. Its tracking accuracy is ideally unrelated to voltage/current accuracy, and tracking efficiency can be up to more than 99%. This algorithm can be used in applications that use a solar panel and the use of MPPT is required to maximize efficiency.

The output voltage/current characteristics of the solar panel are determined by the manufacturing process and the IV characteristic curves are determined by the manufacturer. The corresponding PV characteristic curves, shown in Figure 1b and Figure 2b, can be plotted according to the IV characteristic curves, shown in Figure 1a and Figure 2a. With different lighting intensities and temperatures, the IV and PV characteristic curves of the solar panel will change and, specifically, a shift of the maximum power point will occur.

*Figure 1a. IV characteristic curves under different lighting intensities*

*Figure 1b. PV characteristic curves under different lighting intensities*

*Figure 2a. IV characteristic curves at different temperatures*

*Figure 2b. PV characteristic curves at different temperatures*

Figures 1 and 2 show the influence of different irradiances on the voltage, current and power of the panel.

From the characteristic curves it can be seen that the temperature mainly modifies the voltage point at maximum power and the irradiance mainly modifies the operating current of the panel.

We can see the location of the maximum power point on the PV characteristic curves, which have their corresponding voltage/current values. Peak power tracking is about making the system operate at its maximum power point. This means finding the operating voltage at the maximum power point.

### 3. Principles of the Perturbation and Observation method

The P&O method is a widely used MPPT algorithm. The algorithm introduces a disturbance to the panel operating voltage and then modifies the panel voltage by changing the duty cycle of the converter. The way it is implemented is important for some converter topologies.

From the PV characteristic curve, it can be seen that on the right side of the maximum power point, reducing the output voltage can increase the power. On the left side of the maximum power point, increasing the output voltage can increase the power. This is the main idea of the P&O method. This means that when the panel's operating voltage increases, the algorithm will compare the current power reading with the previous power reading. If the power increases then it keeps the same direction to increase the voltage, otherwise it changes the direction to reduce the voltage. This process will be repeated at each MPP tracking step until the MPP is reached. Once the MPP is reached, the algorithm will oscillate around the correct value.

The basic algorithm uses a fixed step size to increase or decrease the voltage. The step size determines the error between the MPP and the current value that oscillates near the MPP. Small steps help reduce wobble but reduce tracking speed. Large steps can accelerate the tracking speed to reach MPP more quickly, but increase power consumption during oscillation. Panel voltage and current measurement is required for applications to implement the P&O MPPT function.

*Figure 3*

### 4. Description of the library

The library developed by Holtek is mainly used to process the MPPT part of the solar panel and provides versions for 8-bit and 32-bit microcontrollers.

**Table 1. 8-bit version parameters**

*Table 2. 32-bit version parameters*

#### 4.1 Description of subroutines

The MPPT library contains two subroutines that can be called during battery charging. Below is the description of the subroutines, including the description of the 8-bit and 32-bit versions.

### 5. Mode of Use

- Before using the MPPT library, it is necessary to complete the basic initialization settings, including battery specification, battery operating voltage/current range, solar panel operating voltage/current range and other related settings. with MPPT, which is the most important step.
- Real-time sampling of voltage, current and temperature data. Voltage and current data must be converted to decimal data for backup.
- The battery charge state machine periodically calls the MPPT library function.
- The MPPT library already contains multiple protections such as OCP (open circuit potential) of the battery, OVP and UVP of the solar panel. The remaining protection functions must be implemented using methods other than the MPPT library.

### 6. Application example

This section presents a practical application example in combination with a solar LED lighting demonstration board.

This example application contains a DC-DC buck module, a voltage/current/temperature sampling module, a PIR motion detection module, a digital display, keys and other components.

#### 6.1 Demo App Main Specifications:

**Solar panel:**20W @ 6V/3,3A, open circuit voltage 7,2V, short circuit current 4A.**Battery:**3,2V@20Ah lithium iron phosphate battery, operating voltage from 2,5V to 3,6V.

### Configuring MPPT Library Parameters

The MPPT library parameters must be configured according to the specifications of the solar panel and the battery. The demo application mentioned above uses an HT8 MCU as the master controller, the BP45FH4NB, so the HT8 version library will be taken as an example.

- The only parameter related to the solar panel is MPPT_PV_V_min. Because the battery used is LFP battery and the voltage is 2,8V when the battery capacity is low, the MPPT_PV_V_min can be set to 300 since the steps are 10mV each. When the voltage of the solar panel is less than 3V, the solar panel will exit the MPPT charging process. The reference setting range of this parameter is 280~360.
- The battery charge termination voltage is about 3,65V, so MPPT_CHG_BATV_Max can be adjusted to 360 with 10mV steps and MPPT_CHG_BATV_MaxAdjust can be adjusted to 355 with 10mV steps.
- The battery capacity is 20Ah and the maximum current is 6A at 0,3C. MPPT_CHG_BATI_Max can be set to 600 in 10mA steps and MPPT_CHG_BATI_MaxAdjust can be set to 580.
- The MPPT_CHG_DeltaBat_Imin with a value of 10mA is the minimum variation of the battery current, which is a key basis for analyzing the operating voltage direction of the PV panel. This value should not be less than the current value corresponding to the 1-bit A/D value, but should not be too large, otherwise the MPPT tracking efficiency will be reduced. If the solar panel current at the maximum operating power point is 3.3A, it is 33mA calculated by 1%, and the battery current is estimated to be about 50~100mA, therefore the MPPT_CHG_DeltaBat_Imin can be in the range of 5~10.
- The battery structure is four single-cell batteries connected in parallel. If the minimum current is calculated at 50mA per branch, the MPPT_CHG_BATI_Min will be set to 20, in steps of 10mA.
- The switching frequency of the topology is determined by MPPT_Duty_sum, the setting of which is limited by the MCU register bits. For example, if the switching frequency f is set to 100K, then according to the conditions where MPPT_Duty_sum=fh/f, fh =30M and MPPT_Duty_sum=300, MPPT_Duty_min and MPPT_Duty_max are the lower limit and upper limit of duty. Obviously, under the above conditions, the lower limit cannot be less than 0 and the upper limit cannot be more than 300.
- Dutysize is the step size of the duty setting. Too small a step size will cause low MPPT tracking speed and too large a step size will cause low tracking accuracy and poor system stability. Dutysize can be selected as 1 or 2 in the applications.
- The MPPT_PNO_Time is the MPPT disturbance time. When the duration for which the system is at the maximum power point exceeds this time, the system will begin to change the service value due to the disturbance. Too small a value will cause poor system stability. If the timing is too large, the tracking speed will be slow and will not be able to keep up with environmental changes. The timing can be adjusted between 5s and 10s.

### 7. Test data

Voltage and current measurement point and test item description.

- Input voltage: positive terminal of the photovoltaic panel.
- Input current: The sampling resistance at the negative terminal of the PV panel.
- Output voltage: positive terminal of the lithium battery.
- Output current: sampling resistance at the negative terminal of the lithium battery.
- Points 1~4 are short-term tests and points 5~6 are long-term tests. The system uses a 3.2V@20000mAh type LFP battery and the maximum charging current is set to 4A.

- Charging power and efficiency – simulates a 20W@6V, 3.33A photovoltaic panel with a maximum output power of 10W.
- Charging power and efficiency: Simulation of a 20W@6V 3,33A photovoltaic panel with a maximum output power of 20W.

- Charging power and efficiency: Simulation of a 10W@6V 1,66A photovoltaic panel with a maximum output power of 5W.

- Charging power and efficiency: simulation of a 10W@6V and 1,66A photovoltaic panel with a maximum output power of 10W.

- Charging curve: The battery is charged from 2,9 V to full capacity with a maximum current of 4 A.

6. Charging curve: The battery is charged from 2,9V to full capacity with a maximum input power of 10W.

### Conclusion

In this application note, which you can consult in the following links an0617en y WAS-20C1EN_ReferenceDesign, the MPPT algorithm library is based on the principles of the perturbation and observation method. Here, the battery voltage and current are detected during charging to determine the direction of change of the solar panel's output power and track its maximum power value. This improves the charging efficiency of the battery and makes full use of the solar panel's power output for better performance. Users can modify the library parameters according to their actual application requirements and can use it in products with a wide variety of specifications to shorten development time. Due to different requirements of products, users should check and calibrate product functions in detail to get the best effects from the library.

Source of information: https://anatronic.com/tutorial-sobre-como-implementar-un-algoritmo-mppt-de-holtek-para-paneles-solares/