sfra_f32.h
Go to the documentation of this file.
1 //###########################################################################
2 //
3 // FILE: sfra_f32.h
4 //
5 // TITLE: Prototypes and Definitions for the C28x FPU SFRA Library
6 //
7 // AUTHOR: Manish Bhardwaj (C2000 Systems Solutions, Houston , TX)
8 //
9 //#############################################################################
10 // $TI Release: C2000 Software Frequency Response Analyzer Library v1.40.00.00 $
11 // $Release Date: Fri Feb 10 15:53:13 CST 2023 $
12 // $Copyright:
13 // Copyright (C) 2023 Texas Instruments Incorporated - http://www.ti.com/
14 //
15 // ALL RIGHTS RESERVED
16 // $
17 //#############################################################################
18 
19 #ifndef SFRA_F32_H
20 #define SFRA_F32_H
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 //*****************************************************************************
27 //
30 //
31 //*****************************************************************************
32 
33 //
34 // the includes & defines
35 //
36 #ifndef C2000_IEEE754_TYPES
37 #define C2000_IEEE754_TYPES
38 #ifdef _TI_EABI_
39 typedef float float32_t;
40 typedef double float64_t;
41 #else // TI COFF
42 typedef float float32_t;
43 typedef long double float64_t;
44 #endif // _TI_EABI_
45 #endif // C2000_IEEE754_TYPES}}
46 
47 #include <stdint.h>
48 #include <stddef.h>
49 #include <math.h>
50 
51 #ifdef __TI_EABI__
52 #define SFRA_F32_inject __SFRA_F32_inject
53 #define SFRA_F32_collect __SFRA_F32_collect
54 #else
55 #define SFRA_F32_inject _SFRA_F32_inject
56 #define SFRA_F32_collect _SFRA_F32_collect
57 #endif
58 typedef struct{
75  int16_t start;
76  int16_t state;
77  int16_t status;
78  int16_t vecLength;
79  int16_t freqIndex;
80  int16_t storeH;
81  int16_t storeGH;
82  int16_t storeCL;
83  int16_t speed;
84 }SFRA_F32;
85 
90 extern void SFRA_F32_reset(SFRA_F32 *SFRA_F_obj);
91 
110 extern void SFRA_F32_config(SFRA_F32 *SFRA_F_obj,
111  float32_t isrFrequency,
112  float32_t injectionAmplitude,
113  int16_t noFreqPoints,
114  float32_t fraSweepStartFreq,
115  float32_t freqStep,
116  float32_t *h_magVect,
117  float32_t *h_phaseVect,
118  float32_t *gh_magVect,
119  float32_t *gh_phaseVect,
120  float32_t *cl_magVect,
121  float32_t *cl_phaseVect,
122  float32_t *freqVect,
123  int16_t speed);
124 
131 extern void SFRA_F32_initFreqArrayWithLogSteps(SFRA_F32 *SFRA_F_obj,
132  float32_t fra_sweep_start_freq,
133  float32_t freqStep);
134 
140 extern void SFRA_F32_resetFreqRespArray(SFRA_F32 *SFRA_F_obj);
141 
147 extern void SFRA_F32_updateInjectionAmplitude(SFRA_F32 *SFRA_F_obj,
148  float32_t new_injection_amplitude);
149 
156 extern float SFRA_F32_inject(float ref);
157 
168 extern void SFRA_F32_collect(float *control_output, float *feedback);
169 
176 extern void SFRA_F32_runBackgroundTask(SFRA_F32 *SFRA_F_obj);
177 
178 //*****************************************************************************
179 //
180 // Close the Doxygen group.
182 //
183 //*****************************************************************************
184 
185 #ifdef __cplusplus
186 }
187 #endif // extern "C"
188 
189 #endif // end of SFRA_F32_H definition
SFRA_F32::start
int16_t start
Command to start SFRA.
Definition: sfra_f32.h:75
SFRA_F32::amplitude
float32_t amplitude
Injection Amplitude.
Definition: sfra_f32.h:71
float32_t
float float32_t
Definition: sfra_f32.h:42
SFRA_F32_reset
void SFRA_F32_reset(SFRA_F32 *SFRA_F_obj)
Resets internal data of SFRA_F32 module.
SFRA_F32::freqStep
float32_t freqStep
Log space between frequency points (optional)
Definition: sfra_f32.h:74
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::gh_phaseVect
float32_t * gh_phaseVect
Open Loop Phase SFRA Vector.
Definition: sfra_f32.h:67
float64_t
long double float64_t
Definition: sfra_f32.h:43
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::h_phaseVect
float32_t * h_phaseVect
Plant Phase SFRA Vector.
Definition: sfra_f32.h:65
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.
math.h
SFRA_F32::speed
int16_t speed
variable to change the speed of the sweep
Definition: sfra_f32.h:83
SFRA_F32::h_magVect
float32_t * h_magVect
Plant Mag SFRA Vector.
Definition: sfra_f32.h:64
SFRA_F32::state
int16_t state
State of SFRA.
Definition: sfra_f32.h:76
SFRA_F32::cl_magVect
float32_t * cl_magVect
Closed Loop Mag SFRA Vector.
Definition: sfra_f32.h:68
SFRA_F32::freqVect
float32_t * freqVect
Frequency Vector.
Definition: sfra_f32.h:70
SFRA_F32::storeGH
int16_t storeGH
Flag to indicate if GH vector is stored.
Definition: sfra_f32.h:81
SFRA_F32
Defines the SFRA_F32 structure.
Definition: sfra_f32.h:63
SFRA_F32::gh_magVect
float32_t * gh_magVect
Open Loop Mag SFRA Vector.
Definition: sfra_f32.h:66
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::vecLength
int16_t vecLength
No. of Points in the SFRA.
Definition: sfra_f32.h:78
SFRA_F32::storeCL
int16_t storeCL
Flag to indicate if CL vector is stored.
Definition: sfra_f32.h:82
SFRA_F32::storeH
int16_t storeH
Flag to indicate if H vector is stored.
Definition: sfra_f32.h:80
SFRA_F32::cl_phaseVect
float32_t * cl_phaseVect
Closed Loop Phase SFRA Vector.
Definition: sfra_f32.h:69
SFRA_F32_updateInjectionAmplitude
void SFRA_F32_updateInjectionAmplitude(SFRA_F32 *SFRA_F_obj, float32_t new_injection_amplitude)
Updates injection amplitude.
SFRA_F32::status
int16_t status
Status of SFRA.
Definition: sfra_f32.h:77
SFRA_F32_collect
#define SFRA_F32_collect
Definition: sfra_f32.h:56
SFRA_F32::freqStart
float32_t freqStart
Start frequency of SFRA sweep.
Definition: sfra_f32.h:73
SFRA_F32::isrFreq
float32_t isrFreq
SFRA ISR frequency.
Definition: sfra_f32.h:72
SFRA_F32_inject
#define SFRA_F32_inject
Definition: sfra_f32.h:55
SFRA_F32::freqIndex
int16_t freqIndex
Index of the frequency vector.
Definition: sfra_f32.h:79

Copyright 2023, Texas Instruments Incorporated