MotorWare f2806x Module API Documentation
float/svgen.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 _SVGEN_H_
33 #define _SVGEN_H_
34 
40 
41 
42 // **************************************************************************
43 // the includes
44 
45 // modules
48 
49 
54 
55 
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 
62 // **************************************************************************
63 // the defines
64 
67 #define SVGEN_SQRT3_OVER_2 ((float_t)(0.8660254038))
68 
69 
70 // **************************************************************************
71 // the typedefs
72 
75 typedef struct _SVGEN_Obj_
76 {
77 
79 
80 } SVGEN_Obj;
81 
82 
85 typedef struct _SVGEN_Obj_ *SVGEN_Handle;
86 
87 
88 // **************************************************************************
89 // the function prototypes
90 
94 static inline float_t SVGEN_getOneOverDcBus_invV(SVGEN_Handle handle)
95 {
96  SVGEN_Obj *obj = (SVGEN_Obj *)handle;
97 
98  return(obj->oneOverDcBus_invV);
99 } // end of SVGEN_getOneOverDcBus_invV() function
100 
101 
106 extern SVGEN_Handle SVGEN_init(void *pMemory,const size_t numBytes);
107 
108 
113 static inline void SVGEN_run(SVGEN_Handle handle,const MATH_vec2 *pVab_V,MATH_vec3 *pVabc_pu)
114 {
115  float_t Vmax_pu=0,Vmin_pu=0,Vcom_pu;
117 
118  float_t Valpha_V = pVab_V->value[0];
119  float_t Vbeta_V = pVab_V->value[1];
120 
121  float_t Va_pu = Valpha_V * oneOverDcBus_invV;
122  float_t Vbeta_pu = Vbeta_V * oneOverDcBus_invV;
123 
124  float_t Va_tmp = (float_t)(0.5) * (-Va_pu);
125  float_t Vb_tmp = SVGEN_SQRT3_OVER_2 * Vbeta_pu;
126  float_t Vb_pu = Va_tmp + Vb_tmp; // -0.5*Valpha + sqrt(3)/2 * Vbeta;
127  float_t Vc_pu = Va_tmp - Vb_tmp; // -0.5*Valpha - sqrt(3)/2 * Vbeta;
128 
129 
130  // find Vmax and Vmin
131  if(Va_pu > Vb_pu)
132  {
133  Vmax_pu = Va_pu;
134  Vmin_pu = Vb_pu;
135  }
136  else
137  {
138  Vmax_pu = Vb_pu;
139  Vmin_pu = Va_pu;
140  }
141 
142  if(Vc_pu > Vmax_pu)
143  {
144  Vmax_pu = Vc_pu;
145  }
146  else if(Vc_pu < Vmin_pu)
147  {
148  Vmin_pu = Vc_pu;
149  }
150  else
151  {
152  // do nothing as if now
153  ;
154  }
155 
156  // compute Vcom
157  Vcom_pu = (float_t)0.5 * (Vmax_pu + Vmin_pu); // 0.5*(Vmax+Vmin)
158 
159 
160  // Subtract common-mode term to achieve SV modulation
161  pVabc_pu->value[0] = (Va_pu - Vcom_pu);
162  pVabc_pu->value[1] = (Vb_pu - Vcom_pu);
163  pVabc_pu->value[2] = (Vc_pu - Vcom_pu);
164 
165  return;
166 } // end of SVGEN_run() function
167 
168 
172 static inline void SVGEN_setOneOverDcBus_invV(SVGEN_Handle handle,const float_t oneOverDcBus_invV)
173 {
174  SVGEN_Obj *obj = (SVGEN_Obj *)handle;
175 
177 
178  return;
179 } // end of SVGEN_setOneOverDcBus_invV() function
180 
181 
185 static inline void SVGEN_setup(SVGEN_Handle handle,const float_t oneOverDcBus_invV)
186 {
187 
188  SVGEN_setOneOverDcBus_invV(handle,oneOverDcBus_invV);
189 
190  return;
191 } // end of SVGEN_setup() function
192 
193 
194 #ifdef __cplusplus
195 }
196 #endif // extern "C"
197 
199 #endif // end of _SVGEN_H_ definition
200 
Contains the public interface to the types definitions.
Contains the public interface to the math (MATH) module routines.
Defines a two element vector.
Definition: 32b/math.h:248
_iq value[3]
Definition: 32b/math.h:261
static void SVGEN_setup(SVGEN_Handle handle, const float_t oneOverDcBus_invV)
Sets up the space vector generator (SVGEN) module.
Definition: float/svgen.h:185
Defines the Space Vector Generator object.
Definition: 32b/svgen.h:88
struct _SVGEN_Obj_ SVGEN_Obj
Defines the Space Vector Generator (SVGEN) object.
float_t oneOverDcBus_invV
The inverse DC bus voltage value, 1/V.
Definition: float/svgen.h:78
static void SVGEN_setOneOverDcBus_invV(SVGEN_Handle handle, const float_t oneOverDcBus_invV)
Sets the one over DC bus voltage value.
Definition: float/svgen.h:172
#define SVGEN_SQRT3_OVER_2
Defines sqrt(3)/2.
Definition: float/svgen.h:67
_iq value[2]
Definition: 32b/math.h:251
Defines a three element vector.
Definition: 32b/math.h:258
struct _SVGEN_Obj_ * SVGEN_Handle
Defines the SVGEN handle.
Definition: float/svgen.h:85
static float_t SVGEN_getOneOverDcBus_invV(SVGEN_Handle handle)
Gets the one over DC bus voltage value.
Definition: float/svgen.h:94
SVGEN_Handle SVGEN_init(void *pMemory, const size_t numBytes)
Initializes the space vector generator module.
Definition: 32b/svgen.c:55
static void SVGEN_run(SVGEN_Handle handle, const MATH_vec2 *pVab_V, MATH_vec3 *pVabc_pu)
Implements a SVM that saturates at the level of MaxModulation.
Definition: float/svgen.h:113
float float_t
Defines the portable data type for 32 bit, signed floating-point data.
Definition: types.h:121