# Implement Maximum Power Point Tracking Algorithms Using MATLAB and Simulink

In this video, I'm going to show how to implement three common MPPT algorithms using MATLAB and Simulink to control the duty cycle or the operating voltage of a PV system. If you would like to learn more about why MPPT algorithms are used, please watch the video Why Use MPPT?

First, I'll talk about the perturb and observe algorithm. Here is a simple flowchart representation of this algorithm. Perturb and observe algorithm is most widely used in the industry today. And as you can see, this algorithm involves perturbation of operating voltage, or the duty cycle, based on the comparison of the power generated to ensure maximum power point.

This algorithm can be implemented in Simulink using several methods. For this example, I used MATLAB function block, a standard block from Simulink library that lets you implement the algorithm using MATLAB language. When you simulate the model, this MATLAB code is converted into C code and is compiled along with other blocks in the model. Notice that it is very simple to implement this algorithm using conditional statements within MATLAB, as you can see here.

Next, I want to show the implementation of incremental conductance algorithm. Again, here is a flowchart that shows a simple representation of this algorithm. This algorithm is slightly complex and more robust in nature. And the central idea in this is that the incremental conductance is compared to the instantaneous conductance, and the duty cycle is adjusted accordingly.

For this example, I'm using a Stateflow chart within Simulink to implement the logic. Using Stateflow, you can represent state machines and logic charts. If you notice closely, the logic in the Stateflow diagram looks almost the same as it is in the flowchart. One of the cool things is that when I simulate the model, you can see that the graphical interface shows an animation of how the logic transitions are occurring.

For the last one, let me open the model which shows a complete system. As you can see, we have a PV array and a DC/DC converter that is being controlled by DC/DC buck controls which implements the MPPT algorithm. This algorithm is different from the first two and is called fractional open circuit voltage algorithm, which is based on the principle that the maximum power point voltage is always a constant fraction of the open circuit voltage. So the open circuit voltage of the cells in the photovoltaic array is measured and used as an input here. In this case, as you see, I'm using 82% of the open circuit voltage just the input.

Before I run the simulation, I would like to point out that I have chosen the irradiance input to be 800 watts per meter square using a Signal Builder block. And you will notice here that the table says the maximum power must be around 2,000 watts for 800 watts for meter square irradiance. Using the Signal Builder block, you can provide custom inputs to the model. You can also bring in real irradiance data and use it as an input for the simulation.

Now, if I hit the Play button, you will notice that the power generated is maximum at around 2,000 watts as expected. We have seen the implementation of three different maximum power point tracking algorithms, or MPPT algorithms, using MATLAB and Simulink in this video.