A PhotoVoltaic (PV) dependent maximum power point tracking controller is used, modeled, and assessed. It includes a study of system components and their modelling. The model is then tested and validated using more than one method. This article focuses on increasing energy extraction in grid-connected PV and isolated systems, damping system oscillations, and reducing its settling time. Tuning the PID controller and the fractional order PID controller is a challenging task that can be carried out by trial and error, Ziegler-Nichols method, or by optimization techniques. In this article; genetic algorithms and whale optimization algorithms are being used here to obtain desired controller response by minimizing the objective function. The objective function is the integral square error. A PV is proposed to use a Fractional Order PID (FOPID) controller then compared to its conventional PID controller. The results show that the output power has a faster response and eliminates oscillations around the maximum power point under steady-state conditions. The results confirm that the proposed controller with an energy storage system has improved energy extraction. All simulations were carried out using MATLAB/SIMULINK.