function y = fcn(a,b,c) %#eml alpha = a - b/2 - c/2; beta = sqrt(3)/2 * (b - c); y = (2/3)*[alpha;beta];
function y = fcn(alpha,beta) %#eml a = alpha; b = -1/2 * alpha + sqrt(3)/2 * beta; c = -1/2 * alpha - sqrt(3)/2 * beta; y = [a;b;c];
function y = fcn(alpha,beta, c) %#eml d = cos(c)* alpha + sin(c)*beta; q = -sin(c)* alpha + cos(c)*beta; y=[d;q];
function y = fcn(d,q, c) %#eml alpha = cos(c) * d - sin(c)*q; beta = sin(c) * d + cos(c)*q; y=[alpha;beta];
/* ================================================================================= File name: CLARKE.H ===================================================================================*/ #ifndef __CLARKE_H__ #define __CLARKE_H__ typedef struct { _iq As; // Input: phase-a stator variable _iq Bs; // Input: phase-b stator variable _iq Cs; // Input: phase-c stator variable _iq Alpha; // Output: stationary d-axis stator variable _iq Beta; // Output: stationary q-axis stator variable } CLARKE; /*----------------------------------------------------------------------------- Default initalizer for the CLARKE object. -----------------------------------------------------------------------------*/ #define CLARKE_DEFAULTS { 0, \ 0, \ 0, \ 0, \ 0, \ } /*------------------------------------------------------------------------------ CLARKE Transformation Macro Definition ------------------------------------------------------------------------------*/ // 1/sqrt(3) = 0.57735026918963 #define ONEbySQRT3 0.57735026918963 /* 1/sqrt(3) */ // Clarke transform macro (with 2 currents) //========================================== #define CLARKE_MACRO(v) \ v.Alpha = v.As; \ v.Beta = _IQmpy((v.As +_IQmpy2(v.Bs)),_IQ(ONEbySQRT3)); // Clarke transform macro (with 3 currents) //========================================== #define CLARKE1_MACRO(v) \ v.Alpha = v.As; \ v.Beta = _IQmpy((v.Bs - v.Cs),_IQ(ONEbySQRT3)); #endif // __CLARKE_H__
/* ================================================================================= File name: PARK.H ===================================================================================*/ #ifndef __PARK_H__ #define __PARK_H__ typedef struct { _iq Alpha; // Input: stationary d-axis stator variable _iq Beta; // Input: stationary q-axis stator variable _iq Angle; // Input: rotating angle (pu) _iq Ds; // Output: rotating d-axis stator variable _iq Qs; // Output: rotating q-axis stator variable _iq Sine; _iq Cosine; } PARK; /*----------------------------------------------------------------------------- Default initalizer for the PARK object. -----------------------------------------------------------------------------*/ #define PARK_DEFAULTS { 0, \ 0, \ 0, \ 0, \ 0, \ 0, \ 0, \ } /*------------------------------------------------------------------------------ PARK Transformation Macro Definition ------------------------------------------------------------------------------*/ #define PARK_MACRO(v) \ \ v.Ds = _IQmpy(v.Alpha,v.Cosine) + _IQmpy(v.Beta,v.Sine); \ v.Qs = _IQmpy(v.Beta,v.Cosine) - _IQmpy(v.Alpha,v.Sine); #endif // __PARK_H__
/* ================================================================================= File name: IPARK.H ===================================================================================*/ #ifndef __IPARK_H__ #define __IPARK_H__ typedef struct { _iq Alpha; // Output: stationary d-axis stator variable _iq Beta; // Output: stationary q-axis stator variable _iq Angle; // Input: rotating angle (pu) _iq Ds; // Input: rotating d-axis stator variable _iq Qs; // Input: rotating q-axis stator variable _iq Sine; // Input: Sine term _iq Cosine; // Input: Cosine term } IPARK; /*----------------------------------------------------------------------------- Default initalizer for the IPARK object. -----------------------------------------------------------------------------*/ #define IPARK_DEFAULTS { 0, \ 0, \ 0, \ 0, \ 0, \ 0, \ 0, \ } /*------------------------------------------------------------------------------ Inverse PARK Transformation Macro Definition ------------------------------------------------------------------------------*/ #define IPARK_MACRO(v) \ \ v.Alpha = _IQmpy(v.Ds,v.Cosine) - _IQmpy(v.Qs,v.Sine); \ v.Beta = _IQmpy(v.Qs,v.Cosine) + _IQmpy(v.Ds,v.Sine); #endif // __IPARK_H__