AM263x Digital Power SDK  09.01.00
sfra_f32.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 //
34 // FILE: sfra_f32.h
35 //
36 //#############################################################################
37 
38 
39 #ifndef SFRA_F32_H
40 #define SFRA_F32_H
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
58 //
59 // the includes & defines
60 //
61 
62 #ifndef IEEE754_TYPES
63 #define IEEE754_TYPES
64 
65 typedef float float32_t;
66 typedef double float64_t;
67 
68 #endif //IEEE754_TYPES
69 
70 #include <stdint.h>
71 #include <stdlib.h>
72 #include <stddef.h>
73 #include <math.h>
74 
75 
76 
82 typedef struct{
94  int16_t start;
95  int16_t state;
96  int16_t status;
97  int16_t vecLength;
98  int16_t freqIndex;
99  int16_t storeH;
100  int16_t storeGH;
101  int16_t storeCL;
102  int16_t speed;
103 }SFRA_F32;
104 
108 extern void SFRA_F32_reset(SFRA_F32 *SFRA_F_obj);
109 
127 extern void SFRA_F32_config(SFRA_F32 *SFRA_F_obj,
128  float32_t isrFrequency,
129  float32_t injectionAmplitude,
130  int16_t noFreqPoints,
131  float32_t fraSweepStartFreq,
132  float32_t freqStep,
133  float32_t *h_magVect,
134  float32_t *h_phaseVect,
135  float32_t *gh_magVect,
136  float32_t *gh_phaseVect,
137  float32_t *cl_magVect,
138  float32_t *cl_phaseVect,
139  float32_t *freqVect,
140  int16_t speed);
141 
148  float32_t fra_sweep_start_freq,
149  float32_t freqStep);
150 
155 extern void SFRA_F32_resetFreqRespArray(SFRA_F32 *SFRA_F_obj);
156 
162  float32_t new_injection_amplitude);
163 
170 extern float SFRA_F32_inject(float ref);
171 
181 extern void SFRA_F32_collect(float *control_output, float *feedback);
182 
188 extern void SFRA_F32_runBackgroundTask(SFRA_F32 *SFRA_F_obj);
189 
190 // Close the Doxygen group.
193 #ifdef __cplusplus
194 }
195 #endif // extern "C"
196 
197 #endif // end of SFRA_F32_H definition
SFRA_F32_reset
void SFRA_F32_reset(SFRA_F32 *SFRA_F_obj)
Resets internal data of SFRA_F32 module.
SFRA_F32
Defines the SFRA_F32 structure.
Definition: sfra_f32.h:82
SFRA_F32::freqVect
float32_t * freqVect
Frequency Vector.
Definition: sfra_f32.h:89
SFRA_F32::speed
int16_t speed
variable to change the speed of the sweep
Definition: sfra_f32.h:102
SFRA_F32::storeCL
int16_t storeCL
Flag to indicate if CL vector is stored.
Definition: sfra_f32.h:101
SFRA_F32_runBackgroundTask
void SFRA_F32_runBackgroundTask(SFRA_F32 *SFRA_F_obj)
Runs the background task, this routine executes the state machine when a frequency sweep is started a...
SFRA_F32_resetFreqRespArray
void SFRA_F32_resetFreqRespArray(SFRA_F32 *SFRA_F_obj)
Resets the response data stored in the ol and plant phase and mag vector.
SFRA_F32::storeH
int16_t storeH
Flag to indicate if H vector is stored.
Definition: sfra_f32.h:99
SFRA_F32::h_phaseVect
float32_t * h_phaseVect
Plant Phase SFRA Vector.
Definition: sfra_f32.h:84
float32_t
float float32_t
Definition: sfra_f32.h:65
SFRA_F32::cl_phaseVect
float32_t * cl_phaseVect
Closed Loop Phase SFRA Vector.
Definition: sfra_f32.h:88
SFRA_F32::freqIndex
int16_t freqIndex
Index of the frequency vector.
Definition: sfra_f32.h:98
SFRA_F32::amplitude
float32_t amplitude
Injection Amplitude.
Definition: sfra_f32.h:90
SFRA_F32::freqStart
float32_t freqStart
Start frequency of SFRA sweep.
Definition: sfra_f32.h:92
SFRA_F32_inject
float SFRA_F32_inject(float ref)
Injects small signal disturbance into the control loop.
SFRA_F32::cl_magVect
float32_t * cl_magVect
Closed Loop Mag SFRA Vector.
Definition: sfra_f32.h:87
SFRA_F32_config
void SFRA_F32_config(SFRA_F32 *SFRA_F_obj, float32_t isrFrequency, float32_t injectionAmplitude, int16_t noFreqPoints, float32_t fraSweepStartFreq, float32_t freqStep, float32_t *h_magVect, float32_t *h_phaseVect, float32_t *gh_magVect, float32_t *gh_phaseVect, float32_t *cl_magVect, float32_t *cl_phaseVect, float32_t *freqVect, int16_t speed)
Configures the SFRA_F32 module.
SFRA_F32::status
int16_t status
Status of SFRA.
Definition: sfra_f32.h:96
SFRA_F32::freqStep
float32_t freqStep
Log space between frequency points (optional)
Definition: sfra_f32.h:93
SFRA_F32::storeGH
int16_t storeGH
Flag to indicate if GH vector is stored.
Definition: sfra_f32.h:100
SFRA_F32::h_magVect
float32_t * h_magVect
Plant Mag SFRA Vector.
Definition: sfra_f32.h:83
SFRA_F32::isrFreq
float32_t isrFreq
SFRA ISR frequency.
Definition: sfra_f32.h:91
SFRA_F32::vecLength
int16_t vecLength
No. of Points in the SFRA.
Definition: sfra_f32.h:97
SFRA_F32::gh_phaseVect
float32_t * gh_phaseVect
Open Loop Phase SFRA Vector.
Definition: sfra_f32.h:86
SFRA_F32_collect
void SFRA_F32_collect(float *control_output, float *feedback)
Collects the response of the loop because of small signal disturbance injected.
SFRA_F32::state
int16_t state
State of SFRA.
Definition: sfra_f32.h:95
SFRA_F32_initFreqArrayWithLogSteps
void SFRA_F32_initFreqArrayWithLogSteps(SFRA_F32 *SFRA_F_obj, float32_t fra_sweep_start_freq, float32_t freqStep)
Initailizes the freq vectors with points that are log step apart.
SFRA_F32::gh_magVect
float32_t * gh_magVect
Open Loop Mag SFRA Vector.
Definition: sfra_f32.h:85
SFRA_F32_updateInjectionAmplitude
void SFRA_F32_updateInjectionAmplitude(SFRA_F32 *SFRA_F_obj, float32_t new_injection_amplitude)
Updates injection amplitude.
float32_t
float float32_t
Defines single,double precision data type. Note: Assumes ABI to be TI_EABI, does not support legacy T...
Definition: dcl_common.h:54
float64_t
double float64_t
Definition: sfra_f32.h:66
SFRA_F32::start
int16_t start
Command to start SFRA.
Definition: sfra_f32.h:94