AM243x Motor Control SDK  09.02.00
vs_freq.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2024 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * 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
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef VS_FREQ_H
34 #define VS_FREQ_H
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 // **************************************************************************
41 // the includes
42 
43 #include <stdlib.h>
44 #include <math.h>
45 
46 #include "math_types.h"
47 
59 typedef struct _VS_FREQ_Obj_
62 {
72  MATH_Vec2 Vdq_gain;
73  MATH_Vec2 Vdq_out;
74 } VS_FREQ_Obj, *VS_FREQ_Handle;
75 
76 // **************************************************************************
77 // the function prototypes
78 
79 //*****************************************************************************
85 //*****************************************************************************
86 static inline float32_t VS_FREQ_getVd_out(VS_FREQ_Handle handle)
87 {
88  VS_FREQ_Obj *obj = (VS_FREQ_Obj *)handle;
89 
90  return(obj->Vdq_out.value[0]);
91 } // end of VS_FREQ_getVd_pu() function
92 
93 //*****************************************************************************
98 //*****************************************************************************
99 static inline float32_t VS_FREQ_getVq_out(VS_FREQ_Handle handle)
100 {
101  VS_FREQ_Obj *obj = (VS_FREQ_Obj *)handle;
102 
103  return(obj->Vdq_out.value[1]);
104 } // end of VS_FREQ_getVq_pu() function
105 
106 //*****************************************************************************
112 //*****************************************************************************
113 static inline void VS_FREQ_setMaxFreq(VS_FREQ_Handle handle,
114  float32_t maxFreq)
115 {
116  VS_FREQ_Obj *obj = (VS_FREQ_Obj *)handle;
117 
118  obj->MaxFreq = maxFreq;
119 
120  return;
121 } // end of ANGLE_COMP_setParams() function
122 
123 //*****************************************************************************
129 //*****************************************************************************
130 static inline void VS_FREQ_setVsMagPu(VS_FREQ_Handle handle,
131  float32_t maxVsMag_pu)
132 {
133  VS_FREQ_Obj *obj = (VS_FREQ_Obj *)handle;
134 
135  obj->maxVsMag_pu = maxVsMag_pu;
136 
137  return;
138 } // end of ANGLE_COMP_setParams() function
139 
140 //*****************************************************************************
149 //*****************************************************************************
150 extern void VS_FREQ_setProfile(VS_FREQ_Handle handle,
151  float32_t LowFreq, float32_t HighFreq,
152  float32_t VoltMin, float32_t VoltMax);
153 
154 //*****************************************************************************
163 //*****************************************************************************
164 extern VS_FREQ_Handle VS_FREQ_init(void *pMemory,const size_t numBytes);
165 
166 //*****************************************************************************
175 //*****************************************************************************
176 static __attribute__((always_inline))
177 void VS_FREQ_run(VS_FREQ_Handle handle,const float32_t Freq_pu)
178 {
179  VS_FREQ_Obj *obj = (VS_FREQ_Obj *)handle;
180 
181  obj->Freq = fabsf(Freq_pu);
182 
183  if(obj->Freq <= obj->LowFreq)
184  {
185  obj->Vs_out = obj->VoltMin;
186  }
187  else if(obj->Freq >= obj->HighFreq)
188  {
189  obj->Vs_out = obj->VoltMax;
190  }
191  else
192  {
193  obj->Vs_out = obj->VoltMin + obj->VfSlope * (obj->Freq - obj->LowFreq);
194  }
195 
196  obj->Vdq_out.value[0] = obj->Vs_out * obj->Vdq_gain.value[0];
197 
198  if(obj->Freq > 0.0f)
199  {
200  obj->Vdq_out.value[1] = obj->Vs_out * obj->Vdq_gain.value[1];
201  }
202  else
203  {
204  obj->Vdq_out.value[1] = -obj->Vs_out * obj->Vdq_gain.value[1];
205  }
206 
207  return;
208 } // end of VS_FREQ_run()
209 
210 #ifdef __cplusplus
211 }
212 #endif // extern "C"
213 
215 
216 #endif // end of VS_FREQ_H definition
217 
VS_FREQ_Obj
Defines the angle generator (ANGLE_COMP) object.
Definition: vs_freq.h:62
VS_FREQ_Obj::HighFreq
float32_t HighFreq
Parameter: High Frequency at rated voltage (pu)
Definition: vs_freq.h:66
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:130
VS_FREQ_Obj::VfSlope
float32_t VfSlope
Variable.
Definition: vs_freq.h:70
VS_FREQ_Obj::MaxFreq
float32_t MaxFreq
Parameter: Maximum Frequency (pu)
Definition: vs_freq.h:67
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::maxVsMag_pu
float32_t maxVsMag_pu
Definition: vs_freq.h:63
VS_FREQ_Obj::Vdq_out
MATH_Vec2 Vdq_out
Output: Output voltage (pu)
Definition: vs_freq.h:73
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:86
VS_FREQ_Obj::Vdq_gain
MATH_Vec2 Vdq_gain
Variable.
Definition: vs_freq.h:72
VS_FREQ_Obj::Freq
float32_t Freq
Input: Input Frequency (pu)
Definition: vs_freq.h:64
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:71
VS_FREQ_Obj::LowFreq
float32_t LowFreq
Parameter: Low Frequency (pu)
Definition: vs_freq.h:65
VS_FREQ_getVq_out
static float32_t VS_FREQ_getVq_out(VS_FREQ_Handle handle)
Definition: vs_freq.h:99
VS_FREQ_Obj::VoltMin
float32_t VoltMin
Parameter: Voltage at low Frequency range (pu)
Definition: vs_freq.h:68
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:177
VS_FREQ_Obj::VoltMax
float32_t VoltMax
Parameter: Rated voltage (pu)
Definition: vs_freq.h:69
VS_FREQ_setMaxFreq
static void VS_FREQ_setMaxFreq(VS_FREQ_Handle handle, float32_t maxFreq)
Sets the parameters maximum frequency.
Definition: vs_freq.h:113
float32_t
float float32_t
Definition: dcl_common.h:58