volt_calc.h
Go to the documentation of this file.
1 //#############################################################################
2 //
3 // FILE: volt_calc.h
4 //
5 // TITLE: C28x InstaSPIN Proportional-Integral (PI) controller library
6 // (floating point)
7 //
8 //#############################################################################
9 // $TI Release: $
10 // $Release Date: $
11 // $Copyright: $
12 //#############################################################################
13 
14 #ifndef VOLT_CAL_H
15 #define VOLT_CAL_H
16 
17 //*****************************************************************************
18 //
19 // If building with a C++ compiler, make all of the definitions in this header
20 // have a C binding.
21 //
22 //*****************************************************************************
23 #ifdef __cplusplus
24 extern "C"
25 {
26 #endif
27 
28 //*****************************************************************************
29 //
32 //
33 //*****************************************************************************
34 
35 #include "types.h"
37 
38 //*****************************************************************************
39 //
41 //
42 //*****************************************************************************
43 typedef struct _PHVOLC_Obj_
44 {
45  float32_t VphaseA; // Output: Phase voltage phase A (pu)
46  float32_t VphaseB; // Output: Phase voltage phase B (pu)
47  float32_t VphaseC; // Output: Phase voltage phase C (pu)
48  float32_t Valpha; // Output: Stationary d-axis phase voltage (pu)
49  float32_t Vbeta; // Output: Stationary q-axis phase voltage (pu)
50  uint16_t flagOutOfPhase; // Out of Phase adjustment (0 or 1)
51 } PHVOLC_Obj;
52 
53 //*****************************************************************************
54 //
56 //
57 //*****************************************************************************
58 typedef struct _PHVOLC_Obj_ *PHVOLC_Handle;
59 
60 //-----------------------------------------------------------------------------
61 // OutOfPhase = 0 for the out of phase correction if
62 // MfuncV1 is out of phase with PWM1,
63 // MfuncV2 is out of phase with PWM3,
64 // MfuncV3 is out of phase with PWM5,
65 // otherwise, set 0 if their phases are correct.
66 
67 #define VC_ONE_THIRD 0.33333333333333f
68 #define VC_TWO_THIRD 0.66666666666667f
69 #define VC_INV_SQRT3 0.57735026918963f
70 
71 
72 // Phase Voltage Calculation
73 static inline void
75  MATH_Vec3 *pVabc_pu, MATH_Vec2 *pVab_V)
76 {
77  PHVOLC_Obj *obj = (PHVOLC_Obj *)handle;
78  float32_t Vtemp;
79 
80  // Scale the incomming Modulation functions with the DC bus voltage value
81  // and calculate the 3 Phase voltages
82  Vtemp = Vdcbus * VC_ONE_THIRD;
83 
84  obj->VphaseA = Vtemp * (pVabc_pu->value[0] * 2.0f -
85  pVabc_pu->value[1] - pVabc_pu->value[2]);
86 
87  obj->VphaseB = Vtemp * (pVabc_pu->value[1] * 2.0f -
88  pVabc_pu->value[0] - pVabc_pu->value[2]);
89 
90  obj->VphaseC = Vtemp * (pVabc_pu->value[2] * 2.0f -
91  pVabc_pu->value[1] - pVabc_pu->value[0]);
92 
93  if(obj->flagOutOfPhase == 1)
94  {
95  obj->VphaseA = -obj->VphaseA;
96  obj->VphaseB = -obj->VphaseB;
97  obj->VphaseC = -obj->VphaseC;
98  }
99 
100  // Voltage transformation (a,b,c) -> (Alpha,Beta)
101  obj->Valpha = obj->VphaseA;
102  obj->Vbeta = (obj->VphaseA + obj->VphaseB * 2.0f) * VC_INV_SQRT3;
103 
104  return;
105 }
106 
107 //*****************************************************************************
108 //
109 // Close the Doxygen group.
111 //
112 //*****************************************************************************
113 
114 //*****************************************************************************
115 //
116 // Mark the end of the C bindings section for C++ compilers.
117 //
118 //*****************************************************************************
119 #ifdef __cplusplus
120 }
121 #endif
122 
123 #endif // end of VOLT_CAL_H defines
124 
125 
126 
127 
128 
129 
130 
131 
132 
133 
134 
135 
136 
137 
138 
139 
140 
141 
_MATH_Vec2_
Defines a two element vector.
Definition: math.h:218
_PHVOLC_Obj_::VphaseB
float32_t VphaseB
Definition: volt_calc.h:46
float32_t
float float32_t
Definition: sfra_f32.h:42
types.h
_PHVOLC_Obj_::VphaseC
float32_t VphaseC
Definition: volt_calc.h:47
VC_INV_SQRT3
#define VC_INV_SQRT3
Definition: volt_calc.h:69
_PHVOLC_Obj_::flagOutOfPhase
uint16_t flagOutOfPhase
Definition: volt_calc.h:50
PHVOLC_Obj
struct _PHVOLC_Obj_ PHVOLC_Obj
Defines the PHVOLC controller object.
math.h
_PHVOLC_Obj_
Defines the PHVOLC controller object.
Definition: volt_calc.h:43
_MATH_Vec3_::value
float32_t value[3]
Definition: math.h:232
_PHVOLC_Obj_::Valpha
float32_t Valpha
Definition: volt_calc.h:48
_PHVOLC_Obj_::Vbeta
float32_t Vbeta
Definition: volt_calc.h:49
PHVOLC_run
static void PHVOLC_run(PHVOLC_Handle handle, float32_t Vdcbus, MATH_Vec3 *pVabc_pu, MATH_Vec2 *pVab_V)
Definition: volt_calc.h:74
_PHVOLC_Obj_::VphaseA
float32_t VphaseA
Definition: volt_calc.h:45
VC_ONE_THIRD
#define VC_ONE_THIRD
Definition: volt_calc.h:67
PHVOLC_Handle
struct _PHVOLC_Obj_ * PHVOLC_Handle
Defines the PHVOLC handle.
Definition: volt_calc.h:58
_MATH_Vec3_
Defines a three element vector.
Definition: math.h:230

Copyright 2023, Texas Instruments Incorporated