I wanted to do a control system using PI control and for PI control to get zero-steady state error, the input has to be constant which is the purpose of doing the abc-dq transformation. I've did this for matlab simulink and is now translating the model to code. My inputs are three-phase sine waves. There is a "wt"/"theta" in the formula which I use Phase locked loop in matlab to obtain that variable. How do I do that in code without using any hardware? and able to code the transformation?

what do you mean by *How do I do that in code without using any hardware?*

are you looking for a system with hardware DSP support?

what development systems have you considered? what programming language?

you can use the math.h library (see more here: https://www.arduino.cc/en/Math/H)

from the transformation you provided you get (hope my math is not too rusty!):

I would code (not tested!) that as below:

```
#include <math.h>
const int F 50; //assuming that is your frequency in ω
const double w = 2*PI*F;
const double x=2/3;
void abc_dq_transformation{
int t=0;
double ua[F],ub[F],uc[F]; //I’ll let you initialise those input arrays. Can be static or you may create a routine to initialise them
double ud[F],uq[F],u0[F];
for(t=0; t<F;++t){ //using sample interval of one unit. You can change that if you need to
ud[t] = x*((ua[t]*cos(w*t))+ (ub[t]*cos((w*t)-(x*PI))+ (uc[t]*cos((w*t)+(x*PI)));
uq[t] = -1*x*((ua[t]*sin(w*t))+ (ub[t]*sin((w*t)-(x*PI))+ (uc[t]*sin((w*t)+(x*PI)));
u0[t] = 0.5*x*(ua[t]+ub[t]+uc[t]);
}
}
```

hope that helps

sherzaad:

you can use the math.h library (see more here: https://www.arduino.cc/en/Math/H)from the transformation you provided you get (hope my math is not too rusty!):

I would code (not tested!) that as below:

`#include <math.h>`

const int F 50; //assuming that is your frequency in ω

const double w = 2*PI*F;

const double x=2/3;

void abc_dq_transformation{

int t=0;

double ua[F],ub[F],uc[F]; //I’ll let you initialise those input arrays. Can be static or you may create a routine to initialise them

double ud[F],uq[F],u0[F];

for(t=0; t<F;++t){ //using sample interval of one unit. You can change that if you need to

ud[t] = x*((ua[t]*cos(w*t))+ (ub[t]*cos((w*t)-(x*PI))+ (uc[t] cos((wt)+(x*PI)));

uq[t] = -1

*x*((ua[t]

*sin(w*t))+ (ub[t]

*sin((w*t)-(x

*PI))+ (uc[t]*PI)));

*sin((w*t)+(xu0[t] = 0.5

*x*(ua[t]+ub[t]+uc[t]);

}

}

`hope that helps`

Thanks a lot.