AC Induction Motor Example
The next few slides shows the coding of one particular block, PARK Transform, using floating-
point and "IQmath" approaches in C and C++:
AC Induction Motor Example
AC Induction Motor Example
Park Transform
Park Transform
-
-
floating
floating
-
-
point C code
point C code
#include
#include
“
“
math.h
math.h
”
”
#define TWO_PI 6.28318530717959
#define TWO_PI 6.28318530717959
void park_calc(PARK *v)
void park_calc(PARK *v)
{
{
float
float
cos
cos
_
_
ang
ang
, sin_
, sin_
ang
ang
;
;
sin_
sin_
ang
ang
= sin(TWO_PI * v
= sin(TWO_PI * v
-
-
>
>
ang
ang
);
);
cos
cos
_
_
ang
ang
=
=
cos
cos
(TWO_PI * v
(TWO_PI * v
-
-
>
>
ang
ang
);
);
v
v
-
-
>de = (v
>de = (v
-
-
>
>
ds
ds
*
*
cos
cos
_
_
ang
ang
) + (v
) + (v
-
-
>
>
qs
qs
* sin_
* sin_
ang
ang
);
);
v
v
-
-
>
>
qe
qe
= (v
= (v
-
-
>
>
qs
qs
*
*
cos
cos
_
_
ang
ang
)
)
-
-
(v
(v
-
-
>
>
ds
ds
* sin_
* sin_
ang
ang
);
);
}
}
AC Induction Motor Example
AC Induction Motor Example
Park Transform
Park Transform
-
-
converting to “
converting to “
IQmath
IQmath
” C code
” C code
#include
#include
“
“
math.h
math.h
”
”
#define TWO_PI 6.28318530717959
#define TWO_PI 6.28318530717959
void park_calc(PARK *v)
void park_calc(PARK *v)
{
{
float
float
cos
cos
_
_
ang
ang
, sin_
, sin_
ang
ang
;
;
sin_
sin_
ang
ang
= sin(TWO_PI * v
= sin(TWO_PI * v
-
-
>
>
ang
ang
);
);
cos
cos
_
_
ang
ang
=
=
cos
cos
(TWO_PI * v
(TWO_PI * v
-
-
>
>
ang
ang
);
);
v
v
-
-
>de = (v
>de = (v
-
-
>
>
ds
ds
*
*
cos
cos
_
_
ang
ang
) + (v
) + (v
-
-
>
>
qs
qs
* sin_
* sin_
ang
ang
);
);
v
v
-
-
>
>
qe
qe
= (v
= (v
-
-
>
>
qs
qs
*
*
cos
cos
_
_
ang
ang
)
)
-
-
(v
(v
-
-
>
>
ds
ds
* sin_
* sin_
ang
ang
);
);
}
}
#include “IQmathLib.h”
_IQ(6.28318530717959)
_iq
_IQsin(_IQmpy(TWO_PI , v->ang));
_IQcos(_IQmpy(TWO_PI , v->ang));
_IQmpy(v->ds , cos_ang) + _IQmpy(v->qs , sin_ang);
_IQmpy(v->qs , cos_ang) - _IQmpy(v->ds , sin_ang);
C28x - Numerical Concepts & IQmath
8 - 27
Summary of Contents for C28 Series
Page 64: ...Summary 3 16 C28x Peripheral Registers Header Files ...
Page 78: ...Interrupt Sources 4 14 C28x Reset and Interrupts ...
Page 218: ...Lab 9 DSP BIOS 9 22 C28x Using DSP BIOS ...
Page 244: ...Lab 10 Programming the Flash 10 26 C28x System Design ...
Page 273: ...Appendix A eZdsp F2812 C28x Appendix A eZdsp F2812 A 1 ...
Page 276: ...Appendix P2 Expansion Interface A 4 C28x Appendix A eZdsp F2812 ...
Page 277: ...Appendix P4 P8 P7 I O Interface C28x Appendix A eZdsp F2812 A 5 ...
Page 278: ...Appendix A 6 C28x Appendix A eZdsp F2812 ...
Page 279: ...Appendix P5 P9 Analog Interface C28x Appendix A eZdsp F2812 A 7 ...
Page 282: ...Appendix A 10 C28x Appendix A eZdsp F2812 TP1 TP2 Test Points ...