AM263x Motor Control SDK  09.02.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 
53 //
54 // the includes & defines
55 //
56 
57 #ifndef IEEE754_TYPES
58 #define IEEE754_TYPES
59 
60 typedef float float32_t;
61 typedef double float64_t;
62 
63 #endif //IEEE754_TYPES
64 
65 #include <stdint.h>
66 #include <stdlib.h>
67 #include <stddef.h>
68 #include <math.h>
69 
70 
71 
77 typedef struct{
89  int16_t start;
90  int16_t state;
91  int16_t status;
92  int16_t vecLength;
93  int16_t freqIndex;
94  int16_t storeH;
95  int16_t storeGH;
96  int16_t storeCL;
97  int16_t speed;
98 }SFRA_F32;
99 
103 extern void SFRA_F32_reset(SFRA_F32 *SFRA_F_obj);
104 
122 extern void SFRA_F32_config(SFRA_F32 *SFRA_F_obj,
123  float32_t isrFrequency,
124  float32_t injectionAmplitude,
125  int16_t noFreqPoints,
126  float32_t fraSweepStartFreq,
127  float32_t freqStep,
128  float32_t *h_magVect,
129  float32_t *h_phaseVect,
130  float32_t *gh_magVect,
131  float32_t *gh_phaseVect,
132  float32_t *cl_magVect,
133  float32_t *cl_phaseVect,
134  float32_t *freqVect,
135  int16_t speed);
136 
143  float32_t fra_sweep_start_freq,
144  float32_t freqStep);
145 
150 extern void SFRA_F32_resetFreqRespArray(SFRA_F32 *SFRA_F_obj);
151 
157  float32_t new_injection_amplitude);
158 
165 extern float SFRA_F32_inject(float ref);
166 
176 extern void SFRA_F32_collect(float *control_output, float *feedback);
177 
183 extern void SFRA_F32_runBackgroundTask(SFRA_F32 *SFRA_F_obj);
184 
185 // Close the Doxygen group.
188 #ifdef __cplusplus
189 }
190 #endif // extern "C"
191 
192 #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:77
SFRA_F32::freqVect
float32_t * freqVect
Frequency Vector.
Definition: sfra_f32.h:84
SFRA_F32::speed
int16_t speed
variable to change the speed of the sweep
Definition: sfra_f32.h:97
SFRA_F32::storeCL
int16_t storeCL
Flag to indicate if CL vector is stored.
Definition: sfra_f32.h:96
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:94
SFRA_F32::h_phaseVect
float32_t * h_phaseVect
Plant Phase SFRA Vector.
Definition: sfra_f32.h:79
float32_t
float float32_t
Definition: sfra_f32.h:60
SFRA_F32::cl_phaseVect
float32_t * cl_phaseVect
Closed Loop Phase SFRA Vector.
Definition: sfra_f32.h:83
SFRA_F32::freqIndex
int16_t freqIndex
Index of the frequency vector.
Definition: sfra_f32.h:93
SFRA_F32::amplitude
float32_t amplitude
Injection Amplitude.
Definition: sfra_f32.h:85
SFRA_F32::freqStart
float32_t freqStart
Start frequency of SFRA sweep.
Definition: sfra_f32.h:87
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:82
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:91
SFRA_F32::freqStep
float32_t freqStep
Log space between frequency points (optional)
Definition: sfra_f32.h:88
SFRA_F32::storeGH
int16_t storeGH
Flag to indicate if GH vector is stored.
Definition: sfra_f32.h:95
SFRA_F32::h_magVect
float32_t * h_magVect
Plant Mag SFRA Vector.
Definition: sfra_f32.h:78
SFRA_F32::isrFreq
float32_t isrFreq
SFRA ISR frequency.
Definition: sfra_f32.h:86
SFRA_F32::vecLength
int16_t vecLength
No. of Points in the SFRA.
Definition: sfra_f32.h:92
SFRA_F32::gh_phaseVect
float32_t * gh_phaseVect
Open Loop Phase SFRA Vector.
Definition: sfra_f32.h:81
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:90
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:80
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
Definition: dcl_common.h:58
float64_t
double float64_t
Definition: sfra_f32.h:61
SFRA_F32::start
int16_t start
Command to start SFRA.
Definition: sfra_f32.h:89