Regarding Perturb and Observe Implementatuion Using C block

Is it possible to implement Perturb and Observe algorithm using C block in PSIM?

Will following code work for Perturb and Observe algorithm in C Block?

If (Power_new-Power_old>0)
Vref=Vref+0.1;

else
Vref=Vref-0.1;

Is it correct to Equate V*I to Power_old by using one time step delay?

You will be able to implement your MPPT algorithm with the C block. I will not comment on the accuracy of your code.

Some comments about the c block,
Static variables will only be initialized once at the beginning and can be used to hold remember a value from a previous timestep. A regular variable definition will cause the variable to be re-initialized every time step. Also the c block will run at every time step, if you want to define a sampling rate for the c block you should put a ZOH element on all of the inputs to the c block which will force it to execute at the defined rate.

Is it possible to use sample and hold element for all the inputs to C block? Will it force C block to execute at the defined rate?

use the ZOH hold block on the inputs to the c block to force the c block to execute at a defined sample rate.

Do NOT USE the sample and hold block to accomplish this, it needs to be the ZOH.

Please download go to the below link, and the download the file, it contains your request:
https://www.researchgate.net/publication/313368387_MPPT_under_PSIM?ev=prf_high

Please go to the below link, and the download the file, it contains your request:
https://www.researchgate.net/publication/313368387_MPPT_under_PSIM?ev=prf_high