MotorWare f2806x Module API Documentation
float/park.h
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2014, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 #ifndef _PARK_H_
33 #define _PARK_H_
34 
40 
41 
42 // **************************************************************************
43 // the includes
44 #ifdef __TMS320C28XX_CLA__
46 #else
47 #include <math.h>
48 #endif
49 
50 // modules
52 
53 
58 
59 
60 
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
65 
66 // **************************************************************************
67 // the defines
68 
69 
70 
71 // **************************************************************************
72 // the typedefs
73 
76 typedef struct _PARK_Obj_
77 {
78 
81 
82 } PARK_Obj;
83 
84 
87 typedef struct _PARK_Obj_ *PARK_Handle;
88 
89 
90 // **************************************************************************
91 // the function prototypes
92 
96 static inline float_t PARK_getCosTh(PARK_Handle handle)
97 {
98  PARK_Obj *obj = (PARK_Obj *)handle;
99 
100  return(obj->cosTh);
101 } // end of PARK_getCosTh() function
102 
103 
107 static inline void PARK_getPhasor(PARK_Handle handle,MATH_vec2 *pPhasor)
108 {
109  PARK_Obj *obj = (PARK_Obj *)handle;
110 
111  pPhasor->value[0] = obj->cosTh;
112  pPhasor->value[1] = obj->sinTh;
113 
114  return;
115 } // end of PARK_getPhasor() function
116 
117 
121 static inline float_t PARK_getSinTh(PARK_Handle handle)
122 {
123  PARK_Obj *obj = (PARK_Obj *)handle;
124 
125  return(obj->sinTh);
126 } // end of PARK_getSinTh() function
127 
128 
133 extern PARK_Handle PARK_init(void *pMemory,const size_t numBytes);
134 
135 
140 #ifdef __TMS320C28XX_CLA__
141 #pragma FUNC_ALWAYS_INLINE(PARK_run)
142 #endif
143 static inline void PARK_run(PARK_Handle handle,const MATH_vec2 *pInVec,MATH_vec2 *pOutVec)
144 {
145  PARK_Obj *obj = (PARK_Obj *)handle;
146 
147  float_t sinTh = obj->sinTh;
148  float_t cosTh = obj->cosTh;
149 
150  float_t value_0 = pInVec->value[0];
151  float_t value_1 = pInVec->value[1];
152 
153  pOutVec->value[0] = (value_0 * cosTh) + (value_1 * sinTh);
154  pOutVec->value[1] = (value_1 * cosTh) - (value_0 * sinTh);
155 
156  return;
157 } // end of PARK_run() function
158 
159 
163 static inline void PARK_setCosTh(PARK_Handle handle,const float_t cosTh)
164 {
165  PARK_Obj *obj = (PARK_Obj *)handle;
166 
167  obj->cosTh = cosTh;
168 
169  return;
170 } // end of PARK_setCosTh() function
171 
172 
176 static inline void PARK_setPhasor(PARK_Handle handle,const MATH_vec2 *pPhasor)
177 {
178  PARK_Obj *obj = (PARK_Obj *)handle;
179 
180  obj->cosTh = pPhasor->value[0];
181  obj->sinTh = pPhasor->value[1];
182 
183  return;
184 } // end of PARK_setPhasor() function
185 
186 
190 static inline void PARK_setSinTh(PARK_Handle handle,const float_t sinTh)
191 {
192  PARK_Obj *obj = (PARK_Obj *)handle;
193 
194  obj->sinTh = sinTh;
195 
196  return;
197 } // end of PARK_setSinTh() function
198 
199 
203 #ifdef __TMS320C28XX_CLA__
204 #pragma FUNC_ALWAYS_INLINE(PARK_setup)
205 #endif
206 static inline void PARK_setup(PARK_Handle handle,const float_t Th)
207 {
208  PARK_Obj *obj = (PARK_Obj *)handle;
209 
210 #ifdef __TMS320C28XX_CLA__
211  obj->sinTh = CLAsin_inline(Th);
212  obj->cosTh = CLAcos_inline(Th);
213 #else
214  obj->sinTh = (float_t)sin((double_t)Th);
215  obj->cosTh = (float_t)cos((double_t)Th);
216 #endif
217 
218  return;
219 } // end of PARK_setup() function
220 
221 
222 #ifdef __cplusplus
223 }
224 #endif // extern "C"
225 
227 #endif // end of _PARK_H_ definition
228 
long double double_t
Defines the portable data type for 64 bit, signed floating-point data.
Definition: types.h:126
static void PARK_setSinTh(PARK_Handle handle, const float_t sinTh)
Sets the sine of the angle between the d,q and the alpha,beta coordinate systems. ...
Definition: float/park.h:190
static void PARK_setCosTh(PARK_Handle handle, const float_t cosTh)
Sets the cosine of the angle between the d,q and the alpha,beta coordinate systems.
Definition: float/park.h:163
static float_t PARK_getCosTh(PARK_Handle handle)
Gets the cosine of the angle between the d,q and the alpha,beta coordinate systems.
Definition: float/park.h:96
Contains the public interface to the math (MATH) module routines.
Defines a two element vector.
Definition: 32b/math.h:248
static void PARK_run(PARK_Handle handle, const MATH_vec2 *pInVec, MATH_vec2 *pOutVec)
Runs the Park transform module.
Definition: float/park.h:143
float_t cosTh
the cosine of the angle between the d,q and the alpha,beta coordinate systems
Definition: float/park.h:80
static void PARK_getPhasor(PARK_Handle handle, MATH_vec2 *pPhasor)
Gets the cosine/sine phasor for the Park transform.
Definition: float/park.h:107
_iq cosTh
the cosine of the angle between the d,q and the alpha,beta coordinate systems
Definition: 32b/park.h:77
_iq value[2]
Definition: 32b/math.h:251
Defines the PARK object.
Definition: 32b/park.h:73
static void PARK_setPhasor(PARK_Handle handle, const MATH_vec2 *pPhasor)
Sets the cosine/sine phasor for the inverse Park transform.
Definition: float/park.h:176
struct _PARK_Obj_ * PARK_Handle
Defines the PARK handle.
Definition: float/park.h:87
static void PARK_setup(PARK_Handle handle, const float_t Th)
Sets up the Park transform module.
Definition: float/park.h:206
struct _PARK_Obj_ PARK_Obj
Defines the PARK object.
_iq sinTh
the sine of the angle between the d,q and the alpha,beta coordinate systems
Definition: 32b/park.h:76
float_t sinTh
the sine of the angle between the d,q and the alpha,beta coordinate systems
Definition: float/park.h:79
PARK_Handle PARK_init(void *pMemory, const size_t numBytes)
Initializes the Park transform module.
Definition: 32b/park.c:55
float float_t
Defines the portable data type for 32 bit, signed floating-point data.
Definition: types.h:121
static float_t PARK_getSinTh(PARK_Handle handle)
Gets the sine of the angle between the d,q and the alpha,beta coordinate systems. ...
Definition: float/park.h:121