MotorWare f2806x Module API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

ipd_hfi.h
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2 * Copyright (c) 2013, Texas Instruments Incorporated
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the 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 "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * --/COPYRIGHT--*/
32
33 #ifndef _IPD_HFI_H_
34 #define _IPD_HFI_H_
35
41
42
43 // **************************************************************************
44 // the includes
45
46 // modules
47 #include "sw/modules/types/src/types.h"
48 #include "sw/modules/iqmath/src/32b/IQmathLib.h"
49
50 #include "sw/modules/filter/src/32b/filter_fo.h"
51 #include "sw/modules/math/src/32b/math.h"
52 #include "sw/modules/park/src/32b/park.h"
53 #include "sw/modules/pid/src/32b/pid.h"
54
55
60
61
62 // Include the algorithm overview defined in modules/<module>/docs/doxygen/doxygen.h
64
65
66 // **************************************************************************
67 // the typedefs
68
69
72 typedef enum
73 {
74 IPD_HFI_State_Error = 0,
75 IPD_HFI_State_Idle = 1,
76 IPD_HFI_State_Coarse = 2,
77 IPD_HFI_State_Fine = 3,
78 IPD_HFI_State_OnLine = 4,
79 IPD_HFI_State_NumStates = 5
80 } IPD_HFI_State_e;
81
82
85 typedef enum
86 {
87 IPD_HFI_TRAJ_State_Idle = 0,
88 IPD_HFI_TRAJ_State_Coarse = 1,
89 IPD_HFI_TRAJ_State_Fine = 2,
90 IPD_HFI_TRAJ_State_NumStates = 3
91 } IPD_HFI_TRAJ_State_e;
92
93
96 typedef struct IPD_HFI_Obj *IPD_HFI_Handle;
97
98
99 // **************************************************************************
100 // the globals
101
102
103 // **************************************************************************
104 // the functions
105
106
110 static inline void IPD_HFI_computePhasor(const _iq angle_pu,MATH_vec2 *pPhasor)
111 {
112
113 pPhasor->value[0] = _IQcosPU(angle_pu);
114 pPhasor->value[1] = _IQsinPU(angle_pu);
115
116 return;
117 } // end of IPD_HFI_computePhasor() function
118
119
122 extern void IPD_HFI_disable(IPD_HFI_Handle handle);
123
124
127 extern void IPD_HFI_enable(IPD_HFI_Handle handle);
128
129
133 extern _iq IPD_HFI_getAngle_pu(IPD_HFI_Handle handle);
134
135
139 extern _iq IPD_HFI_getKspd_pu(IPD_HFI_Handle handle);
140
141
145 extern _iq IPD_HFI_getSpeed_pu(IPD_HFI_Handle handle);
146
147
151 extern _iq IPD_HFI_getSpeed_lp_pu(IPD_HFI_Handle handle);
152
153
154
158 extern IPD_HFI_State_e IPD_HFI_getState(IPD_HFI_Handle handle);
159
160
164 extern _iq IPD_HFI_getVdValue(IPD_HFI_Handle handle);
165
166
171 extern IPD_HFI_Handle IPD_HFI_init(void);
172
173
177 extern bool IPD_HFI_isEnabled(IPD_HFI_Handle handle);
178
179
182 extern bool IPD_HFI_isOnLine(IPD_HFI_Handle handle);
183
184
188 extern void IPD_HFI_run(IPD_HFI_Handle handle,const MATH_vec2 *pIab_pu);
189
190
194 extern void IPD_HFI_setAngle_pu(IPD_HFI_Handle handle,const _iq angle_pu);
195
196
200 void IPD_HFI_setFlag_motorSpinning(IPD_HFI_Handle handle,const bool value);
201
202
213 extern void IPD_HFI_setHpf_Idq_Params(IPD_HFI_Handle handle,
214 const _iq b0,const _iq b1,const _iq a1,
215 const _iq x1,const _iq y1);
216
217
221 extern void IPD_HFI_setId_sum(IPD_HFI_Handle handle,const _iq Id_sum_pu);
222
223
227 extern void IPD_HFI_setKspd_pu(IPD_HFI_Handle handle,const _iq Kspd_pu);
228
229
240 extern void IPD_HFI_setLpf_spd_Params(IPD_HFI_Handle handle,
241 const _iq b0,const _iq b1,const _iq a1,
242 const _iq x1,const _iq y1);
243
244
257 extern void IPD_HFI_setParams(IPD_HFI_Handle handle,
258 float_t estFreq_Hz,
259 float_t excFreq_Hz,
260 float_t lpFilterCutOffFreq_Hz,
261 float_t hpFilterCutOffFreq_Hz,
262 float_t iqFullScaleFreq_Hz,
263 float_t Kspd,
264 float_t excMag_coarse_pu,
265 float_t excMag_fine_pu,
266 float_t waitTime_coarse_sec,
267 float_t waitTime_fine_sec);
268
269
273 extern void IPD_HFI_setSpeed_pu(IPD_HFI_Handle handle,const _iq speed_pu);
274
275
279 extern void IPD_HFI_setSpeed_lp_pu(IPD_HFI_Handle handle,const _iq speed_lp_pu);
280
281
286 extern void IPD_HFI_setTrajMags(IPD_HFI_Handle handle,const _iq *pMags);
287
288
294 extern void IPD_HFI_setTrajParams(IPD_HFI_Handle handle,
295 const uint_least32_t period,const uint_least32_t targetPeriod,
296 const _iq *pTrajMags,const uint_least32_t *pTrajPeriods);
297
298
302 extern void IPD_HFI_setTrajPeriods(IPD_HFI_Handle handle,const uint_least32_t *pPeriods);
303
304
308 extern void IPD_HFI_setWaitTimes(IPD_HFI_Handle handle,const uint_least32_t *pWaitTimes);
309
310
313 extern void IPD_HFI_updateState(IPD_HFI_Handle handle);
314
315
316 // end of file
317
318 #ifdef __cplusplus
319 }
320 #endif // extern "C"
321
323
324 #endif // end of _IPD_HFI_H_ definition
IPD_HFI_State_Coarse
the coarse angle detection state
Definition: ipd_hfi.h:76
_IQsinPU
#define _IQsinPU(A)
Definition: 32b/IQmathLib.h:1379
IPD_HFI_getState
IPD_HFI_State_e IPD_HFI_getState(IPD_HFI_Handle handle)
Gets the estimator state.
types.h
Contains the public interface to the types definitions.
IPD_HFI_TRAJ_State_Idle
the idle trajectory state
Definition: ipd_hfi.h:87
IPD_HFI_setSpeed_lp_pu
void IPD_HFI_setSpeed_lp_pu(IPD_HFI_Handle handle, const _iq speed_lp_pu)
Sets the low pass filtered speed value in the estimator.
IPD_HFI_setFlag_motorSpinning
void IPD_HFI_setFlag_motorSpinning(IPD_HFI_Handle handle, const bool value)
Sets the value of the motor spinning flag.
IPD_HFI_TRAJ_State_Coarse
the coarse trajectory state
Definition: ipd_hfi.h:88
_MATH_vec2_
Defines a two element vector.
Definition: 32b/math.h:248
pid.h
Contains the public interface to the Proportional-Integral-Derivative (PID) controller module routine...
IPD_HFI_setTrajParams
void IPD_HFI_setTrajParams(IPD_HFI_Handle handle, const uint_least32_t period, const uint_least32_t targetPeriod, const _iq *pTrajMags, const uint_least32_t *pTrajPeriods)
Sets the trajectory parameters in the estimator.
IPD_HFI_State_NumStates
the total number of states
Definition: ipd_hfi.h:79
_IQcosPU
#define _IQcosPU(A)
Definition: 32b/IQmathLib.h:1745
IPD_HFI_State_OnLine
the online state
Definition: ipd_hfi.h:78
IPD_HFI_isOnLine
bool IPD_HFI_isOnLine(IPD_HFI_Handle handle)
Denotes whether the module is online (true) or not (false)
IPD_HFI_State_Error
the error state
Definition: ipd_hfi.h:74
IPD_HFI_State_e
IPD_HFI_State_e
Defines the initial position detection, high frequency injection (IPD_HFI) states.
Definition: ipd_hfi.h:72
IPD_HFI_disable
void IPD_HFI_disable(IPD_HFI_Handle handle)
Disables the initial position detection, high frequency injection (IPD_HFI) module.
IPD_HFI_setTrajPeriods
void IPD_HFI_setTrajPeriods(IPD_HFI_Handle handle, const uint_least32_t *pPeriods)
Sets the periods for each trajectory state.
_iq
long _iq
Definition: 32b/IQmathLib.h:223
IPD_HFI_State_Idle
the idle state
Definition: ipd_hfi.h:75
IPD_HFI_computePhasor
static void IPD_HFI_computePhasor(const _iq angle_pu, MATH_vec2 *pPhasor)
Computes a phasor for a given angle.
Definition: ipd_hfi.h:110
IPD_HFI_setAngle_pu
void IPD_HFI_setAngle_pu(IPD_HFI_Handle handle, const _iq angle_pu)
Sets the angle value in the module.
IPD_HFI_getSpeed_lp_pu
_iq IPD_HFI_getSpeed_lp_pu(IPD_HFI_Handle handle)
Gets the low pass filtered speed value from the estimator.
IPD_HFI_getVdValue
_iq IPD_HFI_getVdValue(IPD_HFI_Handle handle)
Gets the current trajectory magnitude value.
IPD_HFI_setHpf_Idq_Params
void IPD_HFI_setHpf_Idq_Params(IPD_HFI_Handle handle, const _iq b0, const _iq b1, const _iq a1, const _iq x1, const _iq y1)
Sets the Idq high pass filter parameters.
IPD_HFI_setLpf_spd_Params
void IPD_HFI_setLpf_spd_Params(IPD_HFI_Handle handle, const _iq b0, const _iq b1, const _iq a1, const _iq x1, const _iq y1)
Sets the speed low pass filter parameters.
IPD_HFI_TRAJ_State_NumStates
the total number of states
Definition: ipd_hfi.h:90
IPD_HFI_TRAJ_State_e
IPD_HFI_TRAJ_State_e
Defines the trajectory states.
Definition: ipd_hfi.h:85
IPD_HFI_run
void IPD_HFI_run(IPD_HFI_Handle handle, const MATH_vec2 *pIab_pu)
Runs the initial position detection, high frequency injection (IPD_HFI) algorithm.
IPD_HFI_setWaitTimes
void IPD_HFI_setWaitTimes(IPD_HFI_Handle handle, const uint_least32_t *pWaitTimes)
Sets the wait times for each estimator state.
_MATH_vec2_::value
_iq value[2]
Definition: 32b/math.h:251
IPD_HFI_setSpeed_pu
void IPD_HFI_setSpeed_pu(IPD_HFI_Handle handle, const _iq speed_pu)
Sets the speed value in the estimator.
IPD_HFI_setParams
void IPD_HFI_setParams(IPD_HFI_Handle handle, float_t estFreq_Hz, float_t excFreq_Hz, float_t lpFilterCutOffFreq_Hz, float_t hpFilterCutOffFreq_Hz, float_t iqFullScaleFreq_Hz, float_t Kspd, float_t excMag_coarse_pu, float_t excMag_fine_pu, float_t waitTime_coarse_sec, float_t waitTime_fine_sec)
Sets the initial position detection, high frequency injection (IPD_HFI) parameters.
math.h
Contains the public interface to the math (MATH) module routines.
IPD_HFI_getKspd_pu
_iq IPD_HFI_getKspd_pu(IPD_HFI_Handle handle)
Gets the speed gain value.
IPD_HFI_init
IPD_HFI_Handle IPD_HFI_init(void)
Initializes the initial position detection, high frequency injection (IPD_HFI) module.
IPD_HFI_getAngle_pu
_iq IPD_HFI_getAngle_pu(IPD_HFI_Handle handle)
Gets the angle value from the estimator.
IPD_HFI_Handle
struct IPD_HFI_Obj * IPD_HFI_Handle
Defines the IPD_HFI handle.
Definition: ipd_hfi.h:96
IPD_HFI_isEnabled
bool IPD_HFI_isEnabled(IPD_HFI_Handle handle)
Returns a boolean value denoting if the module is enabled (true) or not (false)
park.h
Contains the public interface to the Park transform module routines.
IPD_HFI_setKspd_pu
void IPD_HFI_setKspd_pu(IPD_HFI_Handle handle, const _iq Kspd_pu)
Sets the speed gain value.
IPD_HFI_getSpeed_pu
_iq IPD_HFI_getSpeed_pu(IPD_HFI_Handle handle)
Gets the speed value from the estimator.
IPD_HFI_updateState
void IPD_HFI_updateState(IPD_HFI_Handle handle)
Updates the state.
IPD_HFI_TRAJ_State_Fine
the fine trajectory state
Definition: ipd_hfi.h:89
IQmathLib.h
IPD_HFI_State_Fine
the fine angle detection state
Definition: ipd_hfi.h:77
IPD_HFI_setId_sum
void IPD_HFI_setId_sum(IPD_HFI_Handle handle, const _iq Id_sum_pu)
Sets the integral value for the direct current in the estimator.
IPD_HFI_setTrajMags
void IPD_HFI_setTrajMags(IPD_HFI_Handle handle, const _iq *pMags)
Sets the trajectory magnitudes in the estimator.
IPD_HFI_enable
void IPD_HFI_enable(IPD_HFI_Handle handle)
Enables the initial position detection, high frequency injection (IPD_HFI) module.
filter_fo.h
Contains the public interface to the first-order filter (FILTER_FO) module routines.
float_t
float float_t
Defines the portable data type for 32 bit, signed floating-point data.
Definition: types.h:121