Control technique using PI is commonly use in power electronic. Here is a sample how to implement PI control in PSIM dll block. We will use it to control output current of Buck DC-DC conventer.
Actually PSIM has provided PI block itself. PI can write mathematically base on the picture below:
The controller output is given by
c code program is shown below:
------------------------------------------------------------------------------------------------
#include < math.h>
__declspec(dllexport) void simuser (t, delt, in, out)
// Note that all the variables must be defined as "double"
double t, delt;
double *in, *out;
{
static double Kp= 4.,T =2.28e-4, diff=0., integ = 0., erprev = 0., temp = 0;
static double iMax = 0., iMin = 0.0;
static double oMax = 1., oMin = 0.;
double err;
iMax = T/Kp;
err = in[0];
integ = integ + (err*delt);
if(integ > iMax)
integ = iMax;
else if (iMin > integ)
integ = iMin;
temp = (Kp*err) + (Kp*integ/T) ;
if(temp > oMax)
temp = oMax;
else if (oMin > temp)
temp = oMin;
out[0] = temp ;
erprev = err;
}
-------------------------------------------------------------------------------------------------
Here is a sample circuit and simulation result using PSIM. Dll block act as PI control to control output current of buck dc-dc conventer.
You can compare it with PSIM PI block with same parameters.
Read more
Actually PSIM has provided PI block itself. PI can write mathematically base on the picture below:
The controller output is given by
where Δ is the error or deviation of actual measured value (PV) from the set-point (SP).
- Δ = SP - PV
c code program is shown below:
------------------------------------------------------------------------------------------------
#include < math.h>
__declspec(dllexport) void simuser (t, delt, in, out)
// Note that all the variables must be defined as "double"
double t, delt;
double *in, *out;
{
static double Kp= 4.,T =2.28e-4, diff=0., integ = 0., erprev = 0., temp = 0;
static double iMax = 0., iMin = 0.0;
static double oMax = 1., oMin = 0.;
double err;
iMax = T/Kp;
err = in[0];
integ = integ + (err*delt);
if(integ > iMax)
integ = iMax;
else if (iMin > integ)
integ = iMin;
temp = (Kp*err) + (Kp*integ/T) ;
if(temp > oMax)
temp = oMax;
else if (oMin > temp)
temp = oMin;
out[0] = temp ;
erprev = err;
}
-------------------------------------------------------------------------------------------------
Here is a sample circuit and simulation result using PSIM. Dll block act as PI control to control output current of buck dc-dc conventer.
You can compare it with PSIM PI block with same parameters.