-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathuser2.h
More file actions
275 lines (207 loc) · 10.6 KB
/
Copy pathuser2.h
File metadata and controls
275 lines (207 loc) · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#ifndef _USER_MTR2_H_
#define _USER_MTR2_H_
/* --COPYRIGHT--,BSD
* Copyright (c) 2012, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --/COPYRIGHT--*/
//! \file solutions/instaspin_foc/boards/boostxldrv8301_revB/f28x/f2806xF/src/user.h
//! \brief Contains the public interface for user initialization data for the CTRL, HAL, and EST modules
//!
//! (C) Copyright 2012, Texas Instruments, Inc.
// **************************************************************************
// the includes
// modules
#include "sw/modules/types/src/types.h"
#include "sw/modules/motor/src/32b/motor.h"
#include "sw/modules/est/src/32b/est.h"
#include "sw/modules/est/src/est_states.h"
#include "sw/modules/est/src/est_Flux_states.h"
#include "sw/modules/est/src/est_Ls_states.h"
#include "sw/modules/est/src/est_Rs_states.h"
// platforms
#include "sw/modules/fast/src/32b/userParams_eou.h"
#include "user_mtr_on_j5.h"
//!
//!
//! \defgroup USER USER
//!
//@{
#ifdef __cplusplus
extern "C" {
#endif
// **************************************************************************
// the defines
//! \brief CURRENTS AND VOLTAGES
// **************************************************************************
//! \brief Defines the voltage scale factor for the system
//! \brief Compile time calculation for scale factor (ratio) used throughout the system
#define USER_VOLTAGE_SF_2 ((float_t)((USER_ADC_FULL_SCALE_VOLTAGE_V_2)/(USER_IQ_FULL_SCALE_VOLTAGE_V_2)))
//! \brief Defines the current scale factor for the system
//! \brief Compile time calculation for scale factor (ratio) used throughout the system
#define USER_CURRENT_SF_2 ((float_t)((USER_ADC_FULL_SCALE_CURRENT_A_2)/(USER_IQ_FULL_SCALE_CURRENT_A_2)))
//! \brief CLOCKS & TIMERS
// **************************************************************************
//! \brief Defines the system clock frequency, MHz
#define USER_SYSTEM_FREQ_MHz_2 (90.0)
//! \brief Defines the direct voltage (Vd) scale factor
//!
#define USER_VD_SF_2 (0.95)
//! \brief Defines the Pulse Width Modulation (PWM) period, usec
//! \brief Compile time calculation
#define USER_PWM_PERIOD_usec_2 (1000.0/USER_PWM_FREQ_kHz_2)
//! \brief Defines the Interrupt Service Routine (ISR) frequency, Hz
//!
#define USER_ISR_FREQ_Hz_2 ((float_t)USER_PWM_FREQ_kHz_2 * 1000.0 / (float_t)USER_NUM_PWM_TICKS_PER_ISR_TICK_2)
//! \brief Defines the Interrupt Service Routine (ISR) period, usec
//!
#define USER_ISR_PERIOD_usec_2 (USER_PWM_PERIOD_usec_2 * (float_t)USER_NUM_PWM_TICKS_PER_ISR_TICK_2)
//! \brief DECIMATION
// **************************************************************************
//! \brief Defines the controller frequency, Hz
//! \brief Compile time calculation
#define USER_CTRL_FREQ_Hz_2 (uint_least32_t)(USER_ISR_FREQ_Hz_2/USER_NUM_ISR_TICKS_PER_CTRL_TICK_2)
//! \brief Defines the estimator frequency, Hz
//! \brief Compile time calculation
#define USER_EST_FREQ_Hz_2 (uint_least32_t)(USER_CTRL_FREQ_Hz_2/USER_NUM_CTRL_TICKS_PER_EST_TICK_2)
//! \brief Defines the trajectory frequency, Hz
//! \brief Compile time calculation
#define USER_TRAJ_FREQ_Hz_2 (uint_least32_t)(USER_CTRL_FREQ_Hz_2/USER_NUM_CTRL_TICKS_PER_TRAJ_TICK_2)
//! \brief Defines the controller execution period, usec
//! \brief Compile time calculation
#define USER_CTRL_PERIOD_usec_2 (USER_ISR_PERIOD_usec_2 * USER_NUM_ISR_TICKS_PER_CTRL_TICK_2)
//! \brief Defines the controller execution period, sec
//! \brief Compile time calculation
#define USER_CTRL_PERIOD_sec_2 ((float_t)USER_CTRL_PERIOD_usec_2/(float_t)1000000.0)
//! \brief LIMITS
// **************************************************************************
//! \brief Defines the maximum current slope for Id trajectory during PowerWarp
//! \brief For Induction motors only, controls how fast Id input can change under PowerWarp control
#define USER_MAX_CURRENT_SLOPE_POWERWARP_2 (0.3*USER_MOTOR_RES_EST_CURRENT_2/USER_IQ_FULL_SCALE_CURRENT_A_2/USER_TRAJ_FREQ_Hz_2) // 0.3*RES_EST_CURRENT / IQ_FULL_SCALE_CURRENT / TRAJ_FREQ Typical to produce 1-sec rampup/down
//! \brief Defines the starting maximum acceleration AND deceleration for the speed profiles, Hz/s
//! \brief Updated in run-time through user functions
//! \brief Inverter, motor, inertia, and load will limit actual acceleration capability
#define USER_MAX_ACCEL_Hzps_2 (15.0) // Given by excel spreadsheet. Default: 20.0
//! \brief Defines maximum acceleration for the estimation speed profiles, Hz/s
//! \brief Only used during Motor ID (commission)
#define USER_MAX_ACCEL_EST_Hzps_2 (5.0) // 5.0 Default, don't change
//! \brief Defines the maximum current slope for Id trajectory during estimation
#define USER_MAX_CURRENT_SLOPE_2 (USER_MOTOR_RES_EST_CURRENT_2/USER_IQ_FULL_SCALE_CURRENT_A_2/USER_TRAJ_FREQ_Hz_2) // USER_MOTOR_RES_EST_CURRENT/USER_IQ_FULL_SCALE_CURRENT_A/USER_TRAJ_FREQ_Hz Default, don't change
//! \brief Defines the fraction of IdRated to use during rated flux estimation
//!
#define USER_IDRATED_FRACTION_FOR_RATED_FLUX_2 (1.0) // 1.0 Default, don't change
//! \brief Defines the fraction of IdRated to use during inductance estimation
//!
#define USER_IDRATED_FRACTION_FOR_L_IDENT_2 (1.0) // 1.0 Default, don't change
//! \brief Defines the IdRated delta to use during estimation
//!
#define USER_IDRATED_DELTA_2 (0.00002)
//! \brief Defines the fraction of SpeedMax to use during inductance estimation
//!
#define USER_SPEEDMAX_FRACTION_FOR_L_IDENT_2 (1.0) // 1.0 Default, don't change
//! \brief Defines flux fraction to use during inductance identification
//!
#define USER_FLUX_FRACTION_2 (1.0) // 1.0 Default, don't change
//! \brief Defines the PowerWarp gain for computing Id reference
//! \brief Induction motors only
#define USER_POWERWARP_GAIN_2 (1.0) // 1.0 Default, don't change
//! \brief POLES
// **************************************************************************
//! \brief Defines the analog voltage filter pole location, rad/s
//! \brief Compile time calculation from Hz to rad/s
#define USER_VOLTAGE_FILTER_POLE_rps_2 (2.0 * MATH_PI * USER_VOLTAGE_FILTER_POLE_Hz_2)
//! \brief Defines the software pole location for the voltage and current offset estimation, rad/s
//! \brief Should not be changed from default of (20.0)
#define USER_OFFSET_POLE_rps_2 (20.0) // 20.0 Default, do not change
//! \brief Defines the software pole location for the flux estimation, rad/s
//! \brief Should not be changed from default of (100.0)
#define USER_FLUX_POLE_rps_2 (100.0) // 100.0 Default, do not change
//! \brief Defines the software pole location for the direction filter, rad/s
#define USER_DIRECTION_POLE_rps_2 (6.0) // 6.0 Default, do not change
//! \brief Defines the software pole location for the speed control filter, rad/s
#define USER_SPEED_POLE_rps_2 (100.0) // 100.0 Default, do not change
//! \brief Defines the software pole location for the DC bus filter, rad/s
#define USER_DCBUS_POLE_rps_2 (100.0) // 100.0 Default, do not change
//! \brief Defines the convergence factor for the estimator
//! \brief Do not change from default for FAST
#define USER_EST_KAPPAQ_2 (1.5) // 1.5 Default, do not change
// **************************************************************************
// end the defines
//! \brief USER MOTOR & ID SETTINGS
// **************************************************************************
// this section defined in user_j1.h or user_j5.h
#ifndef USER_MOTOR_2
#error Motor is not defined in user.h
#endif
#ifndef USER_MOTOR_TYPE_2
#error The motor type is not defined in user.h
#endif
#ifndef USER_MOTOR_NUM_POLE_PAIRS_2
#error Number of motor pole pairs is not defined in user.h
#endif
#ifndef USER_MOTOR_Rr_2
#error The rotor resistance is not defined in user.h
#endif
#ifndef USER_MOTOR_Rs_2
#error The stator resistance is not defined in user.h
#endif
#ifndef USER_MOTOR_Ls_d_2
#error The direct stator inductance is not defined in user.h
#endif
#ifndef USER_MOTOR_Ls_q_2
#error The quadrature stator inductance is not defined in user.h
#endif
#ifndef USER_MOTOR_RATED_FLUX_2
#error The rated flux of motor is not defined in user.h
#endif
#ifndef USER_MOTOR_MAGNETIZING_CURRENT_2
#error The magnetizing current is not defined in user.h
#endif
#ifndef USER_MOTOR_RES_EST_CURRENT_2
#error The resistance estimation current is not defined in user.h
#endif
#ifndef USER_MOTOR_IND_EST_CURRENT_2
#error The inductance estimation current is not defined in user.h
#endif
#ifndef USER_MOTOR_MAX_CURRENT_2
#error The maximum current is not defined in user.h
#endif
#ifndef USER_MOTOR_FLUX_EST_FREQ_Hz_2
#error The flux estimation frequency is not defined in user.h
#endif
// **************************************************************************
// the functions
//! \brief Sets the user parameter values
//! \param[in] pUserParams The pointer to the user param structure
extern void USER_setParamsMtr2(USER_Params *pUserParams);
#ifdef __cplusplus
}
#endif // extern "C"
//@} // ingroup
#endif // end of _USER_MTR2_H_ definition