vs_freq.h
Go to the documentation of this file.
1 //#############################################################################
2 // $TI Release: MotorControl SDK v1.00.00.00 $
3 // $Release Date: Mon Mar 11 18:37:40 CDT 2019 $
4 // $Copyright:
5 // Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
9 // are met:
10 //
11 // Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 //
14 // Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in the
16 // documentation and/or other materials provided with the
17 // distribution.
18 //
19 // Neither the name of Texas Instruments Incorporated nor the names of
20 // its contributors may be used to endorse or promote products derived
21 // from this software without specific prior written permission.
22 //
23 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 // $
35 //#############################################################################
36 
37 #ifndef VS_FREQ_H
38 #define VS_FREQ_H
39 
45 
46 
47 // **************************************************************************
48 // the includes
49 #ifdef __TMS320C28XX_CLA__
50 #include "libraries/math/include/CLAmath.h"
51 #else
52 #include <math.h>
53 #endif // __TMS320C28XX_CLA__
54 
56 
60 
61 
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65 
66 
69 typedef struct _VS_FREQ_Obj_
70 {
82 } VS_FREQ_Obj;
83 
86 typedef struct _VS_FREQ_Obj_ *VS_FREQ_Handle;
87 
88 
89 // **************************************************************************
90 // the function prototypes
91 
96 {
97  VS_FREQ_Obj *obj = (VS_FREQ_Obj *)handle;
98 
99  return(obj->Vdq_out.value[0]);
100 } // end of VS_FREQ_getVd_pu() function
101 
105 {
106  VS_FREQ_Obj *obj = (VS_FREQ_Obj *)handle;
107 
108  return(obj->Vdq_out.value[1]);
109 } // end of VS_FREQ_getVq_pu() function
110 
111 
116 extern VS_FREQ_Handle VS_FREQ_init(void *pMemory,const size_t numBytes);
117 
118 
124 static inline void VS_FREQ_run(VS_FREQ_Handle handle,const float32_t Freq_pu)
125 {
126  VS_FREQ_Obj *obj = (VS_FREQ_Obj *)handle;
127 
128  obj->Freq = fabsf(Freq_pu);
129 
130  if(obj->Freq <= obj->LowFreq)
131  {
132  obj->Vs_out = obj->VoltMin;
133  }
134  else if(obj->Freq >= obj->HighFreq)
135  {
136  obj->Vs_out = obj->VoltMax;
137  }
138  else
139  {
140  obj->Vs_out = obj->VoltMin + obj->VfSlope * (obj->Freq - obj->LowFreq);
141  }
142 
143  obj->Vdq_out.value[0] = obj->Vs_out * obj->Vdq_gain.value[0];
144 
145  if(obj->Freq > 0.0f)
146  {
147  obj->Vdq_out.value[1] = obj->Vs_out * obj->Vdq_gain.value[1];
148  }
149  else
150  {
151  obj->Vdq_out.value[1] = -obj->Vs_out * obj->Vdq_gain.value[1];
152  }
153 
154  return;
155 } // end of VS_FREQ_run()
156 
157 
161 static inline void VS_FREQ_setVsMagPu(VS_FREQ_Handle handle,
163 {
164  VS_FREQ_Obj *obj = (VS_FREQ_Obj *)handle;
165 
166  obj->maxVsMag_pu = maxVsMag_pu;
167 
168  return;
169 } // end of ANGLE_COMP_setParams() function
170 
171 
175 static inline void VS_FREQ_setMaxFreq(VS_FREQ_Handle handle,
176  float32_t maxFreq)
177 {
178  VS_FREQ_Obj *obj = (VS_FREQ_Obj *)handle;
179 
180  obj->MaxFreq = maxFreq;
181 
182  return;
183 } // end of ANGLE_COMP_setParams() function
184 
191 extern void VS_FREQ_setProfile(VS_FREQ_Handle handle,
194 
195 
196 #ifdef __cplusplus
197 }
198 #endif // extern "C"
199 
201 
202 #endif // end of VS_FREQ_H definition
203 
_VS_FREQ_Obj_::VoltMin
float32_t VoltMin
Parameter: Voltage at low Frequency range (pu)
Definition: vs_freq.h:76
_MATH_Vec2_
Defines a two element vector.
Definition: math.h:218
VS_FREQ_Handle
struct _VS_FREQ_Obj_ * VS_FREQ_Handle
Defines the VS_FREQ_obj handle.
Definition: vs_freq.h:86
float32_t
float float32_t
Definition: sfra_f32.h:42
_VS_FREQ_Obj_
Defines the angle generator (ANGLE_COMP) object.
Definition: vs_freq.h:69
_VS_FREQ_Obj_::VoltMax
float32_t VoltMax
Parameter: Rated voltage (pu)
Definition: vs_freq.h:77
VS_FREQ_run
static void VS_FREQ_run(VS_FREQ_Handle handle, const float32_t Freq_pu)
Generates an output command voltage for a specific input command frequency according to the specified...
Definition: vs_freq.h:124
_VS_FREQ_Obj_::Vdq_gain
MATH_Vec2 Vdq_gain
Variable.
Definition: vs_freq.h:80
VS_FREQ_setMaxFreq
static void VS_FREQ_setMaxFreq(VS_FREQ_Handle handle, float32_t maxFreq)
Sets the parameters maximum frequency.
Definition: vs_freq.h:175
_VS_FREQ_Obj_::Freq
float32_t Freq
Input: Input Frequency (pu)
Definition: vs_freq.h:72
VS_FREQ_getVq_out
static float32_t VS_FREQ_getVq_out(VS_FREQ_Handle handle)
Definition: vs_freq.h:104
VS_FREQ_setProfile
void VS_FREQ_setProfile(VS_FREQ_Handle handle, float32_t LowFreq, float32_t HighFreq, float32_t VoltMin, float32_t VoltMax)
Sets the parameters.
_VS_FREQ_Obj_::Vs_out
float32_t Vs_out
Output: Output voltage (pu)
Definition: vs_freq.h:79
math.h
VS_FREQ_setVsMagPu
static void VS_FREQ_setVsMagPu(VS_FREQ_Handle handle, float32_t maxVsMag_pu)
Sets the parameters VsMag_pu.
Definition: vs_freq.h:161
_VS_FREQ_Obj_::VfSlope
float32_t VfSlope
Variable.
Definition: vs_freq.h:78
_VS_FREQ_Obj_::Vdq_out
MATH_Vec2 Vdq_out
Output: Output voltage (pu)
Definition: vs_freq.h:81
_VS_FREQ_Obj_::maxVsMag_pu
float32_t maxVsMag_pu
Definition: vs_freq.h:71
_VS_FREQ_Obj_::HighFreq
float32_t HighFreq
Parameter: High Frequency at rated voltage (pu)
Definition: vs_freq.h:74
_VS_FREQ_Obj_::LowFreq
float32_t LowFreq
Parameter: Low Frequency (pu)
Definition: vs_freq.h:73
VS_FREQ_init
VS_FREQ_Handle VS_FREQ_init(void *pMemory, const size_t numBytes)
Initializes the angle generator (VS_FREQ) module.
VS_FREQ_Obj
struct _VS_FREQ_Obj_ VS_FREQ_Obj
Defines the angle generator (ANGLE_COMP) object.
VS_FREQ_getVd_out
static float32_t VS_FREQ_getVd_out(VS_FREQ_Handle handle)
Gets the Vd output value in VS_FREQ.
Definition: vs_freq.h:95
_VS_FREQ_Obj_::MaxFreq
float32_t MaxFreq
Parameter: Maximum Frequency (pu)
Definition: vs_freq.h:75
_MATH_Vec2_::value
float32_t value[2]
Definition: math.h:220

Copyright 2023, Texas Instruments Incorporated