This paper proposes a flexible power generation scheme based on model predictive control (MPC). The proposed method combines maximum power point tracking (MPPT) operation with constant power generation (CPG), where the maximum power is extracted from the photovoltaic (PV) system. However, if the extracted power exceeds a certain threshold, the power generation will then be limited. A modified version of the perturb and observe (P&O) method is proposed to enhance the efficiency of the PV system. After that, the reference generated will be sent to the MPC loop, which decides the optimal switching state according to the cost function design. Different operating conditions confirm the superiority of the suggested technique, while comparison with the conventional method highlights the main benefits.