MotorWare f2806x Module API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

32b/user.c
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2 * Copyright (c) 2012, 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--*/
36
37
38 // **************************************************************************
39 // the includes
40
41 #include <math.h>
42 #include "user.h"
43 #include "sw/modules/ctrl/src/32b/ctrl.h"
44
45
46 // **************************************************************************
47 // the defines
48
49
50 // **************************************************************************
51 // the typedefs
52
53
54 // **************************************************************************
55 // the functions
56
57
58 void USER_setParams(USER_Params *pUserParams)
59 {
60 pUserParams->iqFullScaleCurrent_A = USER_IQ_FULL_SCALE_CURRENT_A;
61 pUserParams->iqFullScaleVoltage_V = USER_IQ_FULL_SCALE_VOLTAGE_V;
62
63 pUserParams->iqFullScaleFreq_Hz = USER_IQ_FULL_SCALE_FREQ_Hz;
64
65 pUserParams->numIsrTicksPerCtrlTick = USER_NUM_ISR_TICKS_PER_CTRL_TICK;
66 pUserParams->numCtrlTicksPerCurrentTick = USER_NUM_CTRL_TICKS_PER_CURRENT_TICK;
67 pUserParams->numCtrlTicksPerEstTick = USER_NUM_CTRL_TICKS_PER_EST_TICK;
68 pUserParams->numCtrlTicksPerSpeedTick = USER_NUM_CTRL_TICKS_PER_SPEED_TICK;
69 pUserParams->numCtrlTicksPerTrajTick = USER_NUM_CTRL_TICKS_PER_TRAJ_TICK;
70
71 pUserParams->numCurrentSensors = USER_NUM_CURRENT_SENSORS;
72 pUserParams->numVoltageSensors = USER_NUM_VOLTAGE_SENSORS;
73
74 pUserParams->offsetPole_rps = USER_OFFSET_POLE_rps;
75 pUserParams->fluxPole_rps = USER_FLUX_POLE_rps;
76
77 pUserParams->zeroSpeedLimit = USER_ZEROSPEEDLIMIT;
78
79 pUserParams->forceAngleFreq_Hz = USER_FORCE_ANGLE_FREQ_Hz;
80
81 pUserParams->maxAccel_Hzps = USER_MAX_ACCEL_Hzps;
82
83 pUserParams->maxAccel_est_Hzps = USER_MAX_ACCEL_EST_Hzps;
84
85 pUserParams->directionPole_rps = USER_DIRECTION_POLE_rps;
86
87 pUserParams->speedPole_rps = USER_SPEED_POLE_rps;
88
89 pUserParams->dcBusPole_rps = USER_DCBUS_POLE_rps;
90
91 pUserParams->fluxFraction = USER_FLUX_FRACTION;
92
93 pUserParams->indEst_speedMaxFraction = USER_SPEEDMAX_FRACTION_FOR_L_IDENT;
94
95 pUserParams->systemFreq_MHz = USER_SYSTEM_FREQ_MHz;
96
97 pUserParams->pwmPeriod_usec = USER_PWM_PERIOD_usec;
98
99 pUserParams->voltage_sf = USER_VOLTAGE_SF;
100
101 pUserParams->current_sf = USER_CURRENT_SF;
102
103 pUserParams->voltageFilterPole_rps = USER_VOLTAGE_FILTER_POLE_rps;
104
105 pUserParams->maxVsMag_pu = USER_MAX_VS_MAG_PU;
106
107 pUserParams->estKappa = USER_EST_KAPPAQ;
108
109 pUserParams->motor_type = USER_MOTOR_TYPE;
110 pUserParams->motor_numPolePairs = USER_MOTOR_NUM_POLE_PAIRS;
111 pUserParams->motor_ratedFlux = USER_MOTOR_RATED_FLUX;
112 pUserParams->motor_Rr = USER_MOTOR_Rr;
113 pUserParams->motor_Rs = USER_MOTOR_Rs;
114 pUserParams->motor_Ls_d = USER_MOTOR_Ls_d;
115 pUserParams->motor_Ls_q = USER_MOTOR_Ls_q;
116
117 if((pUserParams->motor_Rr > (float_t)0.0) && (pUserParams->motor_Rs > (float_t)0.0))
118 {
119 pUserParams->powerWarpGain = sqrt((float_t)1.0 + pUserParams->motor_Rr/pUserParams->motor_Rs);
120 }
121 else
122 {
123 pUserParams->powerWarpGain = USER_POWERWARP_GAIN;
124 }
125
126 pUserParams->maxCurrent_resEst = USER_MOTOR_RES_EST_CURRENT;
127 pUserParams->maxCurrent_indEst = USER_MOTOR_IND_EST_CURRENT;
128 pUserParams->maxCurrent = USER_MOTOR_MAX_CURRENT;
129
130 pUserParams->maxCurrentSlope = USER_MAX_CURRENT_SLOPE;
131 pUserParams->maxCurrentSlope_powerWarp = USER_MAX_CURRENT_SLOPE_POWERWARP;
132
133 pUserParams->IdRated = USER_MOTOR_MAGNETIZING_CURRENT;
134 pUserParams->IdRatedFraction_ratedFlux = USER_IDRATED_FRACTION_FOR_RATED_FLUX;
135 pUserParams->IdRatedFraction_indEst = USER_IDRATED_FRACTION_FOR_L_IDENT;
136 pUserParams->IdRated_delta = USER_IDRATED_DELTA;
137
138 pUserParams->fluxEstFreq_Hz = USER_MOTOR_FLUX_EST_FREQ_Hz;
139
140 pUserParams->ctrlWaitTime[CTRL_State_Error] = 0;
141 pUserParams->ctrlWaitTime[CTRL_State_Idle] = 0;
142 pUserParams->ctrlWaitTime[CTRL_State_OffLine] = (uint_least32_t)( 5.0 * USER_CTRL_FREQ_Hz);
143 pUserParams->ctrlWaitTime[CTRL_State_OnLine] = 0;
144
145 pUserParams->estWaitTime[EST_State_Error] = 0;
146 pUserParams->estWaitTime[EST_State_Idle] = 0;
147 pUserParams->estWaitTime[EST_State_RoverL] = (uint_least32_t)( 8.0 * USER_EST_FREQ_Hz);
148 pUserParams->estWaitTime[EST_State_Rs] = 0;
149 pUserParams->estWaitTime[EST_State_RampUp] = (uint_least32_t)((5.0 + USER_MOTOR_FLUX_EST_FREQ_Hz / USER_MAX_ACCEL_EST_Hzps) * USER_EST_FREQ_Hz);
150 pUserParams->estWaitTime[EST_State_IdRated] = (uint_least32_t)(30.0 * USER_EST_FREQ_Hz);
151 pUserParams->estWaitTime[EST_State_RatedFlux_OL] = (uint_least32_t)( 0.2 * USER_EST_FREQ_Hz);
152 pUserParams->estWaitTime[EST_State_RatedFlux] = 0;
153 pUserParams->estWaitTime[EST_State_RampDown] = (uint_least32_t)( 2.0 * USER_EST_FREQ_Hz);
154 pUserParams->estWaitTime[EST_State_LockRotor] = 0;
155 pUserParams->estWaitTime[EST_State_Ls] = 0;
156 pUserParams->estWaitTime[EST_State_Rr] = (uint_least32_t)(20.0 * USER_EST_FREQ_Hz);
157 pUserParams->estWaitTime[EST_State_MotorIdentified] = 0;
158 pUserParams->estWaitTime[EST_State_OnLine] = 0;
159
160 pUserParams->FluxWaitTime[EST_Flux_State_Error] = 0;
161 pUserParams->FluxWaitTime[EST_Flux_State_Idle] = 0;
162 pUserParams->FluxWaitTime[EST_Flux_State_CL1] = (uint_least32_t)(10.0 * USER_EST_FREQ_Hz);
163 pUserParams->FluxWaitTime[EST_Flux_State_CL2] = (uint_least32_t)( 0.2 * USER_EST_FREQ_Hz);
164 pUserParams->FluxWaitTime[EST_Flux_State_Fine] = (uint_least32_t)( 4.0 * USER_EST_FREQ_Hz);
165 pUserParams->FluxWaitTime[EST_Flux_State_Done] = 0;
166
167 pUserParams->LsWaitTime[EST_Ls_State_Error] = 0;
168 pUserParams->LsWaitTime[EST_Ls_State_Idle] = 0;
169 pUserParams->LsWaitTime[EST_Ls_State_RampUp] = (uint_least32_t)( 3.0 * USER_EST_FREQ_Hz);
170 pUserParams->LsWaitTime[EST_Ls_State_Init] = (uint_least32_t)( 3.0 * USER_EST_FREQ_Hz);
171 pUserParams->LsWaitTime[EST_Ls_State_Coarse] = (uint_least32_t)( 0.2 * USER_EST_FREQ_Hz);
172 pUserParams->LsWaitTime[EST_Ls_State_Fine] = (uint_least32_t)(30.0 * USER_EST_FREQ_Hz);
173 pUserParams->LsWaitTime[EST_Ls_State_Done] = 0;
174
175 pUserParams->RsWaitTime[EST_Rs_State_Error] = 0;
176 pUserParams->RsWaitTime[EST_Rs_State_Idle] = 0;
177 pUserParams->RsWaitTime[EST_Rs_State_RampUp] = (uint_least32_t)( 1.0 * USER_EST_FREQ_Hz);
178 pUserParams->RsWaitTime[EST_Rs_State_Coarse] = (uint_least32_t)( 2.0 * USER_EST_FREQ_Hz);
179 pUserParams->RsWaitTime[EST_Rs_State_Fine] = (uint_least32_t)( 7.0 * USER_EST_FREQ_Hz);
180 pUserParams->RsWaitTime[EST_Rs_State_Done] = 0;
181
182 pUserParams->ctrlFreq_Hz = USER_CTRL_FREQ_Hz;
183
184 pUserParams->estFreq_Hz = USER_EST_FREQ_Hz;
185
186 pUserParams->RoverL_estFreq_Hz = USER_R_OVER_L_EST_FREQ_Hz;
187
188 pUserParams->trajFreq_Hz = USER_TRAJ_FREQ_Hz;
189
190 pUserParams->ctrlPeriod_sec = USER_CTRL_PERIOD_sec;
191
192 pUserParams->maxNegativeIdCurrent_a = USER_MAX_NEGATIVE_ID_REF_CURRENT_A;
193
194 return;
195 } // end of USER_setParams() function
196
197
198 void USER_checkForErrors(USER_Params *pUserParams)
199 {
200 USER_setErrorCode(pUserParams, USER_ErrorCode_NoError);
201
202 if((USER_IQ_FULL_SCALE_CURRENT_A <= 0.0) ||
203 (USER_IQ_FULL_SCALE_CURRENT_A <= (0.02 * USER_MOTOR_MAX_CURRENT * USER_IQ_FULL_SCALE_FREQ_Hz / 128.0)) ||
204 (USER_IQ_FULL_SCALE_CURRENT_A <= (2.0 * USER_MOTOR_MAX_CURRENT * USER_IQ_FULL_SCALE_FREQ_Hz * USER_CTRL_PERIOD_sec / 128.0)))
205 {
206 USER_setErrorCode(pUserParams, USER_ErrorCode_iqFullScaleCurrent_A_Low);
207 }
208
209 if((USER_IQ_FULL_SCALE_CURRENT_A < USER_MOTOR_MAGNETIZING_CURRENT) ||
210 (USER_IQ_FULL_SCALE_CURRENT_A < USER_MOTOR_RES_EST_CURRENT) ||
211 (USER_IQ_FULL_SCALE_CURRENT_A < USER_MOTOR_IND_EST_CURRENT) ||
212 (USER_IQ_FULL_SCALE_CURRENT_A < USER_MOTOR_MAX_CURRENT))
213 {
214 USER_setErrorCode(pUserParams, USER_ErrorCode_iqFullScaleCurrent_A_Low);
215 }
216
217 if((USER_MOTOR_RATED_FLUX > 0.0) && (USER_MOTOR_TYPE == MOTOR_Type_Pm))
218 {
219 if(USER_IQ_FULL_SCALE_VOLTAGE_V >= ((float_t)USER_EST_FREQ_Hz * USER_MOTOR_RATED_FLUX * 0.7))
220 {
221 USER_setErrorCode(pUserParams, USER_ErrorCode_iqFullScaleVoltage_V_High);
222 }
223 }
224
225 if((USER_MOTOR_RATED_FLUX > 0.0) && (USER_MOTOR_TYPE == MOTOR_Type_Induction))
226 {
227 if(USER_IQ_FULL_SCALE_VOLTAGE_V >= ((float_t)USER_EST_FREQ_Hz * USER_MOTOR_RATED_FLUX * 0.05))
228 {
229 USER_setErrorCode(pUserParams, USER_ErrorCode_iqFullScaleVoltage_V_High);
230 }
231 }
232
233 if((USER_IQ_FULL_SCALE_VOLTAGE_V <= 0.0) ||
234 (USER_IQ_FULL_SCALE_VOLTAGE_V <= (0.5 * USER_MOTOR_MAX_CURRENT * USER_MOTOR_Ls_d * USER_VOLTAGE_FILTER_POLE_rps)) ||
235 (USER_IQ_FULL_SCALE_VOLTAGE_V <= (0.5 * USER_MOTOR_MAX_CURRENT * USER_MOTOR_Ls_q * USER_VOLTAGE_FILTER_POLE_rps)))
236 {
237 USER_setErrorCode(pUserParams, USER_ErrorCode_iqFullScaleVoltage_V_Low);
238 }
239
240 if((USER_IQ_FULL_SCALE_FREQ_Hz > (4.0 * USER_VOLTAGE_FILTER_POLE_Hz)) ||
241 (USER_IQ_FULL_SCALE_FREQ_Hz >= ((128.0 * USER_IQ_FULL_SCALE_CURRENT_A) / (0.02 * USER_MOTOR_MAX_CURRENT))) ||
242 (USER_IQ_FULL_SCALE_FREQ_Hz >= ((128.0 * USER_IQ_FULL_SCALE_CURRENT_A) / (2.0 * USER_MOTOR_MAX_CURRENT * USER_CTRL_PERIOD_sec))) ||
243 (USER_IQ_FULL_SCALE_FREQ_Hz >= (128.0 * (float_t)USER_MOTOR_NUM_POLE_PAIRS * 1000.0 / 60.0)))
244 {
245 USER_setErrorCode(pUserParams, USER_ErrorCode_iqFullScaleFreq_Hz_High);
246 }
247
248 if((USER_IQ_FULL_SCALE_FREQ_Hz < 50.0) ||
249 (USER_IQ_FULL_SCALE_FREQ_Hz < USER_MOTOR_FLUX_EST_FREQ_Hz) ||
250 (USER_IQ_FULL_SCALE_FREQ_Hz < USER_SPEED_POLE_rps) ||
251 (USER_IQ_FULL_SCALE_FREQ_Hz <= ((float_t)USER_MOTOR_NUM_POLE_PAIRS * 1000.0 / (60.0 * 128.0))) ||
252 (USER_IQ_FULL_SCALE_FREQ_Hz < (USER_MAX_ACCEL_Hzps / ((float_t)USER_TRAJ_FREQ_Hz))) ||
253 (USER_IQ_FULL_SCALE_FREQ_Hz < (USER_MAX_ACCEL_EST_Hzps / ((float_t)USER_TRAJ_FREQ_Hz))) ||
254 (USER_IQ_FULL_SCALE_FREQ_Hz < ((float_t)USER_R_OVER_L_EST_FREQ_Hz)))
255 {
256 USER_setErrorCode(pUserParams, USER_ErrorCode_iqFullScaleFreq_Hz_Low);
257 }
258
259 if(USER_NUM_PWM_TICKS_PER_ISR_TICK > 3)
260 {
261 USER_setErrorCode(pUserParams, USER_ErrorCode_numPwmTicksPerIsrTick_High);
262 }
263
264 if(USER_NUM_PWM_TICKS_PER_ISR_TICK < 1)
265 {
266 USER_setErrorCode(pUserParams, USER_ErrorCode_numPwmTicksPerIsrTick_Low);
267 }
268
269 if(USER_NUM_ISR_TICKS_PER_CTRL_TICK < 1)
270 {
271 USER_setErrorCode(pUserParams, USER_ErrorCode_numIsrTicksPerCtrlTick_Low);
272 }
273
274 if(USER_NUM_CTRL_TICKS_PER_CURRENT_TICK < 1)
275 {
276 USER_setErrorCode(pUserParams, USER_ErrorCode_numCtrlTicksPerCurrentTick_Low);
277 }
278
279 if(USER_NUM_CTRL_TICKS_PER_EST_TICK < 1)
280 {
281 USER_setErrorCode(pUserParams, USER_ErrorCode_numCtrlTicksPerEstTick_Low);
282 }
283
284 if((USER_NUM_CTRL_TICKS_PER_SPEED_TICK < 1) ||
285 (USER_NUM_CTRL_TICKS_PER_SPEED_TICK < USER_NUM_CTRL_TICKS_PER_CURRENT_TICK))
286 {
287 USER_setErrorCode(pUserParams, USER_ErrorCode_numCtrlTicksPerSpeedTick_Low);
288 }
289
290 if(USER_NUM_CTRL_TICKS_PER_TRAJ_TICK < 1)
291 {
292 USER_setErrorCode(pUserParams, USER_ErrorCode_numCtrlTicksPerTrajTick_Low);
293 }
294
295 if(USER_NUM_CURRENT_SENSORS > 3)
296 {
297 USER_setErrorCode(pUserParams, USER_ErrorCode_numCurrentSensors_High);
298 }
299
300 if(USER_NUM_CURRENT_SENSORS < 2)
301 {
302 USER_setErrorCode(pUserParams, USER_ErrorCode_numCurrentSensors_Low);
303 }
304
305 if(USER_NUM_VOLTAGE_SENSORS > 3)
306 {
307 USER_setErrorCode(pUserParams, USER_ErrorCode_numVoltageSensors_High);
308 }
309
310 if(USER_NUM_VOLTAGE_SENSORS < 3)
311 {
312 USER_setErrorCode(pUserParams, USER_ErrorCode_numVoltageSensors_Low);
313 }
314
315 if(USER_OFFSET_POLE_rps > ((float_t)USER_CTRL_FREQ_Hz))
316 {
317 USER_setErrorCode(pUserParams, USER_ErrorCode_offsetPole_rps_High);
318 }
319
320 if(USER_OFFSET_POLE_rps <= 0.0)
321 {
322 USER_setErrorCode(pUserParams, USER_ErrorCode_offsetPole_rps_Low);
323 }
324
325 if(USER_FLUX_POLE_rps > ((float_t)USER_EST_FREQ_Hz))
326 {
327 USER_setErrorCode(pUserParams, USER_ErrorCode_fluxPole_rps_High);
328 }
329
330 if(USER_FLUX_POLE_rps <= 0.0)
331 {
332 USER_setErrorCode(pUserParams, USER_ErrorCode_fluxPole_rps_Low);
333 }
334
335 if(USER_ZEROSPEEDLIMIT > 1.0)
336 {
337 USER_setErrorCode(pUserParams, USER_ErrorCode_zeroSpeedLimit_High);
338 }
339
340 if(USER_ZEROSPEEDLIMIT <= 0.0)
341 {
342 USER_setErrorCode(pUserParams, USER_ErrorCode_zeroSpeedLimit_Low);
343 }
344
345 if(USER_FORCE_ANGLE_FREQ_Hz > ((float_t)USER_EST_FREQ_Hz))
346 {
347 USER_setErrorCode(pUserParams, USER_ErrorCode_forceAngleFreq_Hz_High);
348 }
349
350 if(USER_FORCE_ANGLE_FREQ_Hz <= 0.0)
351 {
352 USER_setErrorCode(pUserParams, USER_ErrorCode_forceAngleFreq_Hz_Low);
353 }
354
355 if(USER_MAX_ACCEL_Hzps > ((float_t)USER_TRAJ_FREQ_Hz * USER_IQ_FULL_SCALE_FREQ_Hz))
356 {
357 USER_setErrorCode(pUserParams, USER_ErrorCode_maxAccel_Hzps_High);
358 }
359
360 if(USER_MAX_ACCEL_Hzps <= 0.0)
361 {
362 USER_setErrorCode(pUserParams, USER_ErrorCode_maxAccel_Hzps_Low);
363 }
364
365 if(USER_MAX_ACCEL_EST_Hzps > ((float_t)USER_TRAJ_FREQ_Hz * USER_IQ_FULL_SCALE_FREQ_Hz))
366 {
367 USER_setErrorCode(pUserParams, USER_ErrorCode_maxAccel_est_Hzps_High);
368 }
369
370 if(USER_MAX_ACCEL_EST_Hzps <= 0.0)
371 {
372 USER_setErrorCode(pUserParams, USER_ErrorCode_maxAccel_est_Hzps_Low);
373 }
374
375 if(USER_DIRECTION_POLE_rps > ((float_t)USER_EST_FREQ_Hz))
376 {
377 USER_setErrorCode(pUserParams, USER_ErrorCode_directionPole_rps_High);
378 }
379
380 if(USER_DIRECTION_POLE_rps <= 0.0)
381 {
382 USER_setErrorCode(pUserParams, USER_ErrorCode_directionPole_rps_Low);
383 }
384
385 if((USER_SPEED_POLE_rps > USER_IQ_FULL_SCALE_FREQ_Hz) ||
386 (USER_SPEED_POLE_rps > ((float_t)USER_EST_FREQ_Hz)))
387 {
388 USER_setErrorCode(pUserParams, USER_ErrorCode_speedPole_rps_High);
389 }
390
391 if(USER_SPEED_POLE_rps <= 0.0)
392 {
393 USER_setErrorCode(pUserParams, USER_ErrorCode_speedPole_rps_Low);
394 }
395
396 if(USER_DCBUS_POLE_rps > ((float_t)USER_EST_FREQ_Hz))
397 {
398 USER_setErrorCode(pUserParams, USER_ErrorCode_dcBusPole_rps_High);
399 }
400
401 if(USER_DCBUS_POLE_rps <= 0.0)
402 {
403 USER_setErrorCode(pUserParams, USER_ErrorCode_dcBusPole_rps_Low);
404 }
405
406 if(USER_FLUX_FRACTION > 1.2)
407 {
408 USER_setErrorCode(pUserParams, USER_ErrorCode_fluxFraction_High);
409 }
410
411 if(USER_FLUX_FRACTION < 0.05)
412 {
413 USER_setErrorCode(pUserParams, USER_ErrorCode_fluxFraction_Low);
414 }
415
416 if(USER_SPEEDMAX_FRACTION_FOR_L_IDENT > (USER_IQ_FULL_SCALE_CURRENT_A / USER_MOTOR_MAX_CURRENT))
417 {
418 USER_setErrorCode(pUserParams, USER_ErrorCode_indEst_speedMaxFraction_High);
419 }
420
421 if(USER_SPEEDMAX_FRACTION_FOR_L_IDENT <= 0.0)
422 {
423 USER_setErrorCode(pUserParams, USER_ErrorCode_indEst_speedMaxFraction_Low);
424 }
425
426 if(USER_POWERWARP_GAIN > 2.0)
427 {
428 USER_setErrorCode(pUserParams, USER_ErrorCode_powerWarpGain_High);
429 }
430
431 if(USER_POWERWARP_GAIN < 1.0)
432 {
433 USER_setErrorCode(pUserParams, USER_ErrorCode_powerWarpGain_Low);
434 }
435
436 if(USER_SYSTEM_FREQ_MHz > 90.0)
437 {
438 USER_setErrorCode(pUserParams, USER_ErrorCode_systemFreq_MHz_High);
439 }
440
441 if(USER_SYSTEM_FREQ_MHz <= 0.0)
442 {
443 USER_setErrorCode(pUserParams, USER_ErrorCode_systemFreq_MHz_Low);
444 }
445
446 if(USER_PWM_FREQ_kHz > (1000.0 * USER_SYSTEM_FREQ_MHz / 100.0))
447 {
448 USER_setErrorCode(pUserParams, USER_ErrorCode_pwmFreq_kHz_High);
449 }
450
451 if(USER_PWM_FREQ_kHz < (1000.0 * USER_SYSTEM_FREQ_MHz / 65536.0))
452 {
453 USER_setErrorCode(pUserParams, USER_ErrorCode_pwmFreq_kHz_Low);
454 }
455
456 if(USER_VOLTAGE_SF >= 128.0)
457 {
458 USER_setErrorCode(pUserParams, USER_ErrorCode_voltage_sf_High);
459 }
460
461 if(USER_VOLTAGE_SF < 0.1)
462 {
463 USER_setErrorCode(pUserParams, USER_ErrorCode_voltage_sf_Low);
464 }
465
466 if(USER_CURRENT_SF >= 128.0)
467 {
468 USER_setErrorCode(pUserParams, USER_ErrorCode_current_sf_High);
469 }
470
471 if(USER_CURRENT_SF < 0.1)
472 {
473 USER_setErrorCode(pUserParams, USER_ErrorCode_current_sf_Low);
474 }
475
476 if(USER_VOLTAGE_FILTER_POLE_Hz > ((float_t)USER_EST_FREQ_Hz / MATH_PI))
477 {
478 USER_setErrorCode(pUserParams, USER_ErrorCode_voltageFilterPole_Hz_High);
479 }
480
481 if(USER_VOLTAGE_FILTER_POLE_Hz < (USER_IQ_FULL_SCALE_FREQ_Hz / 4.0))
482 {
483 USER_setErrorCode(pUserParams, USER_ErrorCode_voltageFilterPole_Hz_Low);
484 }
485
486 if(USER_MAX_VS_MAG_PU > (4.0 / 3.0))
487 {
488 USER_setErrorCode(pUserParams, USER_ErrorCode_maxVsMag_pu_High);
489 }
490
491 if(USER_MAX_VS_MAG_PU <= 0.0)
492 {
493 USER_setErrorCode(pUserParams, USER_ErrorCode_maxVsMag_pu_Low);
494 }
495
496 if(USER_EST_KAPPAQ > 1.5)
497 {
498 USER_setErrorCode(pUserParams, USER_ErrorCode_estKappa_High);
499 }
500
501 if(USER_EST_KAPPAQ < 1.5)
502 {
503 USER_setErrorCode(pUserParams, USER_ErrorCode_estKappa_Low);
504 }
505
506 if((USER_MOTOR_TYPE != MOTOR_Type_Induction) && (USER_MOTOR_TYPE != MOTOR_Type_Pm))
507 {
508 USER_setErrorCode(pUserParams, USER_ErrorCode_motor_type_Unknown);
509 }
510
511 if(USER_MOTOR_NUM_POLE_PAIRS < 1)
512 {
513 USER_setErrorCode(pUserParams, USER_ErrorCode_motor_numPolePairs_Low);
514 }
515
516 if((USER_MOTOR_RATED_FLUX != 0.0) && (USER_MOTOR_TYPE == MOTOR_Type_Pm))
517 {
518 if(USER_MOTOR_RATED_FLUX > (USER_IQ_FULL_SCALE_FREQ_Hz * 65536.0 / (float_t)USER_EST_FREQ_Hz / 0.7))
519 {
520 USER_setErrorCode(pUserParams, USER_ErrorCode_motor_ratedFlux_High);
521 }
522
523 if(USER_MOTOR_RATED_FLUX < (USER_IQ_FULL_SCALE_VOLTAGE_V / (float_t)USER_EST_FREQ_Hz / 0.7))
524 {
525 USER_setErrorCode(pUserParams, USER_ErrorCode_motor_ratedFlux_Low);
526 }
527 }
528
529 if((USER_MOTOR_RATED_FLUX != 0.0) && (USER_MOTOR_TYPE == MOTOR_Type_Induction))
530 {
531 if(USER_MOTOR_RATED_FLUX > (USER_IQ_FULL_SCALE_FREQ_Hz * 65536.0 / (float_t)USER_EST_FREQ_Hz / 0.05))
532 {
533 USER_setErrorCode(pUserParams, USER_ErrorCode_motor_ratedFlux_High);
534 }
535
536 if(USER_MOTOR_RATED_FLUX < (USER_IQ_FULL_SCALE_VOLTAGE_V / (float_t)USER_EST_FREQ_Hz / 0.05))
537 {
538 USER_setErrorCode(pUserParams, USER_ErrorCode_motor_ratedFlux_Low);
539 }
540 }
541
542 if(USER_MOTOR_TYPE == MOTOR_Type_Pm)
543 {
544 if(USER_MOTOR_Rr > 0.0)
545 {
546 USER_setErrorCode(pUserParams, USER_ErrorCode_motor_Rr_High);
547 }
548
549 if(USER_MOTOR_Rr < 0.0)
550 {
551 USER_setErrorCode(pUserParams, USER_ErrorCode_motor_Rr_Low);
552 }
553 }
554
555 if((USER_MOTOR_Rr != 0.0) && (USER_MOTOR_TYPE == MOTOR_Type_Induction))
556 {
557 if(USER_MOTOR_Rr > (0.7 * 65536.0 * USER_IQ_FULL_SCALE_VOLTAGE_V / USER_IQ_FULL_SCALE_CURRENT_A))
558 {
559 USER_setErrorCode(pUserParams, USER_ErrorCode_motor_Rr_High);
560 }
561
562 if(USER_MOTOR_Rr < (0.7 * USER_IQ_FULL_SCALE_VOLTAGE_V / (USER_IQ_FULL_SCALE_CURRENT_A * 65536.0)))
563 {
564 USER_setErrorCode(pUserParams, USER_ErrorCode_motor_Rr_Low);
565 }
566 }
567
568 if(USER_MOTOR_Rs != 0.0)
569 {
570 if(USER_MOTOR_Rs > (0.7 * 65536.0 * USER_IQ_FULL_SCALE_VOLTAGE_V / USER_IQ_FULL_SCALE_CURRENT_A))
571 {
572 USER_setErrorCode(pUserParams, USER_ErrorCode_motor_Rs_High);
573 }
574
575 if(USER_MOTOR_Rs < (0.7 * USER_IQ_FULL_SCALE_VOLTAGE_V / (USER_IQ_FULL_SCALE_CURRENT_A * 65536.0)))
576 {
577 USER_setErrorCode(pUserParams, USER_ErrorCode_motor_Rs_Low);
578 }
579 }
580
581 if(USER_MOTOR_Ls_d != 0.0)
582 {
583 if(USER_MOTOR_Ls_d > (0.7 * 65536.0 * USER_IQ_FULL_SCALE_VOLTAGE_V / (USER_IQ_FULL_SCALE_CURRENT_A * USER_VOLTAGE_FILTER_POLE_rps)))
584 {
585 USER_setErrorCode(pUserParams, USER_ErrorCode_motor_Ls_d_High);
586 }
587
588 if(USER_MOTOR_Ls_d < (0.7 * USER_IQ_FULL_SCALE_VOLTAGE_V / (USER_IQ_FULL_SCALE_CURRENT_A * USER_VOLTAGE_FILTER_POLE_rps * 65536.0)))
589 {
590 USER_setErrorCode(pUserParams, USER_ErrorCode_motor_Ls_d_Low);
591 }
592 }
593
594 if(USER_MOTOR_Ls_q != 0.0)
595 {
596 if(USER_MOTOR_Ls_q > (0.7 * 65536.0 * USER_IQ_FULL_SCALE_VOLTAGE_V / (USER_IQ_FULL_SCALE_CURRENT_A * USER_VOLTAGE_FILTER_POLE_rps)))
597 {
598 USER_setErrorCode(pUserParams, USER_ErrorCode_motor_Ls_q_High);
599 }
600
601 if(USER_MOTOR_Ls_q < (0.7 * USER_IQ_FULL_SCALE_VOLTAGE_V / (USER_IQ_FULL_SCALE_CURRENT_A * USER_VOLTAGE_FILTER_POLE_rps * 65536.0)))
602 {
603 USER_setErrorCode(pUserParams, USER_ErrorCode_motor_Ls_q_Low);
604 }
605 }
606
607 if(USER_MOTOR_RES_EST_CURRENT > USER_MOTOR_MAX_CURRENT)
608 {
609 USER_setErrorCode(pUserParams, USER_ErrorCode_maxCurrent_resEst_High);
610 }
611
612 if(USER_MOTOR_RES_EST_CURRENT < 0.0)
613 {
614 USER_setErrorCode(pUserParams, USER_ErrorCode_maxCurrent_resEst_Low);
615 }
616
617 if(USER_MOTOR_TYPE == MOTOR_Type_Pm)
618 {
619 if(USER_MOTOR_IND_EST_CURRENT > 0.0)
620 {
621 USER_setErrorCode(pUserParams, USER_ErrorCode_maxCurrent_indEst_High);
622 }
623
624 if(USER_MOTOR_IND_EST_CURRENT < (-USER_MOTOR_MAX_CURRENT))
625 {
626 USER_setErrorCode(pUserParams, USER_ErrorCode_maxCurrent_indEst_Low);
627 }
628 }
629
630 if(USER_MOTOR_TYPE == MOTOR_Type_Induction)
631 {
632 if(USER_MOTOR_IND_EST_CURRENT > 0.0)
633 {
634 USER_setErrorCode(pUserParams, USER_ErrorCode_maxCurrent_indEst_High);
635 }
636
637 if(USER_MOTOR_IND_EST_CURRENT < 0.0)
638 {
639 USER_setErrorCode(pUserParams, USER_ErrorCode_maxCurrent_indEst_Low);
640 }
641 }
642
643 if(USER_MOTOR_MAX_CURRENT > USER_IQ_FULL_SCALE_CURRENT_A)
644 {
645 USER_setErrorCode(pUserParams, USER_ErrorCode_maxCurrent_High);
646 }
647
648 if(USER_MOTOR_MAX_CURRENT <= 0.0)
649 {
650 USER_setErrorCode(pUserParams, USER_ErrorCode_maxCurrent_Low);
651 }
652
653 if(USER_MAX_CURRENT_SLOPE > 1.0)
654 {
655 USER_setErrorCode(pUserParams, USER_ErrorCode_maxCurrentSlope_High);
656 }
657
658 if(USER_MAX_CURRENT_SLOPE <= 0.0)
659 {
660 USER_setErrorCode(pUserParams, USER_ErrorCode_maxCurrentSlope_Low);
661 }
662
663 if(USER_MAX_CURRENT_SLOPE_POWERWARP > 1.0)
664 {
665 USER_setErrorCode(pUserParams, USER_ErrorCode_maxCurrentSlope_powerWarp_High);
666 }
667
668 if(USER_MAX_CURRENT_SLOPE_POWERWARP <= 0.0)
669 {
670 USER_setErrorCode(pUserParams, USER_ErrorCode_maxCurrentSlope_powerWarp_Low);
671 }
672
673 if(USER_MOTOR_TYPE == MOTOR_Type_Pm)
674 {
675 if(USER_MOTOR_MAGNETIZING_CURRENT > 0.0)
676 {
677 USER_setErrorCode(pUserParams, USER_ErrorCode_IdRated_High);
678 }
679
680 if(USER_MOTOR_MAGNETIZING_CURRENT < 0.0)
681 {
682 USER_setErrorCode(pUserParams, USER_ErrorCode_IdRated_Low);
683 }
684 }
685
686 if(USER_MOTOR_TYPE == MOTOR_Type_Induction)
687 {
688 if(USER_MOTOR_MAGNETIZING_CURRENT > USER_MOTOR_MAX_CURRENT)
689 {
690 USER_setErrorCode(pUserParams, USER_ErrorCode_IdRated_High);
691 }
692
693 if(USER_MOTOR_MAGNETIZING_CURRENT < 0.0)
694 {
695 USER_setErrorCode(pUserParams, USER_ErrorCode_IdRated_Low);
696 }
697 }
698
699 if(USER_MOTOR_TYPE == MOTOR_Type_Induction)
700 {
701 if(USER_IDRATED_FRACTION_FOR_RATED_FLUX > (USER_IQ_FULL_SCALE_CURRENT_A / (1.2 * USER_MOTOR_MAX_CURRENT)))
702 {
703 USER_setErrorCode(pUserParams, USER_ErrorCode_IdRatedFraction_ratedFlux_High);
704 }
705
706 if(USER_IDRATED_FRACTION_FOR_RATED_FLUX < 0.1)
707 {
708 USER_setErrorCode(pUserParams, USER_ErrorCode_IdRatedFraction_ratedFlux_Low);
709 }
710 }
711
712 if(USER_MOTOR_TYPE == MOTOR_Type_Induction)
713 {
714 if(USER_IDRATED_FRACTION_FOR_L_IDENT > (USER_IQ_FULL_SCALE_CURRENT_A / USER_MOTOR_MAX_CURRENT))
715 {
716 USER_setErrorCode(pUserParams, USER_ErrorCode_IdRatedFraction_indEst_High);
717 }
718
719 if(USER_IDRATED_FRACTION_FOR_L_IDENT < 0.1)
720 {
721 USER_setErrorCode(pUserParams, USER_ErrorCode_IdRatedFraction_indEst_Low);
722 }
723 }
724
725 if(USER_MOTOR_TYPE == MOTOR_Type_Induction)
726 {
727 if(USER_IDRATED_DELTA > (USER_IQ_FULL_SCALE_CURRENT_A / ((float_t)USER_NUM_ISR_TICKS_PER_CTRL_TICK * USER_MOTOR_MAX_CURRENT)))
728 {
729 USER_setErrorCode(pUserParams, USER_ErrorCode_IdRated_delta_High);
730 }
731
732 if(USER_IDRATED_DELTA < 0.0)
733 {
734 USER_setErrorCode(pUserParams, USER_ErrorCode_IdRated_delta_Low);
735 }
736 }
737
738 if(USER_MOTOR_FLUX_EST_FREQ_Hz > USER_IQ_FULL_SCALE_FREQ_Hz)
739 {
740 USER_setErrorCode(pUserParams, USER_ErrorCode_fluxEstFreq_Hz_High);
741 }
742
743 if((USER_MOTOR_FLUX_EST_FREQ_Hz < 0.0) ||
744 (USER_MOTOR_FLUX_EST_FREQ_Hz < (USER_ZEROSPEEDLIMIT * USER_IQ_FULL_SCALE_FREQ_Hz)))
745 {
746 USER_setErrorCode(pUserParams, USER_ErrorCode_fluxEstFreq_Hz_Low);
747 }
748
749 if(USER_MOTOR_Ls_d != 0.0)
750 {
751 if(((float_t)USER_CTRL_FREQ_Hz >= (128.0 * USER_IQ_FULL_SCALE_VOLTAGE_V / (0.25 * (USER_MOTOR_Ls_d + 1e-9) * USER_IQ_FULL_SCALE_CURRENT_A))))
752 {
753 USER_setErrorCode(pUserParams, USER_ErrorCode_ctrlFreq_Hz_High);
754 }
755 }
756
757 if(USER_MOTOR_Ls_q != 0.0)
758 {
759 if(((float_t)USER_CTRL_FREQ_Hz >= (128.0 * USER_IQ_FULL_SCALE_VOLTAGE_V / (0.25 * (USER_MOTOR_Ls_q + 1e-9) * USER_IQ_FULL_SCALE_CURRENT_A))))
760 {
761 USER_setErrorCode(pUserParams, USER_ErrorCode_ctrlFreq_Hz_High);
762 }
763 }
764
765 if(((float_t)USER_CTRL_FREQ_Hz < USER_IQ_FULL_SCALE_FREQ_Hz) ||
766 ((float_t)USER_CTRL_FREQ_Hz < USER_OFFSET_POLE_rps) ||
767 ((float_t)USER_CTRL_FREQ_Hz < 250.0) ||
768 ((float_t)USER_CTRL_FREQ_Hz <= (2.0 * USER_IQ_FULL_SCALE_FREQ_Hz * USER_MOTOR_MAX_CURRENT / (128.0 * USER_IQ_FULL_SCALE_CURRENT_A))))
769 {
770 USER_setErrorCode(pUserParams, USER_ErrorCode_ctrlFreq_Hz_Low);
771 }
772
773 if((USER_MOTOR_Rs != 0.0) && (USER_MOTOR_Ls_d != 0.0) && (USER_MOTOR_Ls_q != 0.0))
774 {
775 if(((float_t)USER_CTRL_FREQ_Hz <= (USER_MOTOR_Rs / (USER_MOTOR_Ls_d + 1e-9))) ||
776 ((float_t)USER_CTRL_FREQ_Hz <= (USER_MOTOR_Rs / (USER_MOTOR_Ls_q + 1e-9))))
777 {
778 USER_setErrorCode(pUserParams, USER_ErrorCode_ctrlFreq_Hz_Low);
779 }
780 }
781
782 if(((float_t)USER_EST_FREQ_Hz < USER_FORCE_ANGLE_FREQ_Hz) ||
783 ((float_t)USER_EST_FREQ_Hz < USER_VOLTAGE_FILTER_POLE_rps) ||
784 ((float_t)USER_EST_FREQ_Hz < USER_DCBUS_POLE_rps) ||
785 ((float_t)USER_EST_FREQ_Hz < USER_FLUX_POLE_rps) ||
786 ((float_t)USER_EST_FREQ_Hz < USER_DIRECTION_POLE_rps) ||
787 ((float_t)USER_EST_FREQ_Hz < USER_SPEED_POLE_rps) ||
788 ((float_t)USER_EST_FREQ_Hz < 0.2))
789 {
790 USER_setErrorCode(pUserParams, USER_ErrorCode_estFreq_Hz_Low);
791 }
792
793 if(USER_R_OVER_L_EST_FREQ_Hz > USER_IQ_FULL_SCALE_FREQ_Hz)
794 {
795 USER_setErrorCode(pUserParams, USER_ErrorCode_RoverL_estFreq_Hz_High);
796 }
797
798 if(((float_t)USER_TRAJ_FREQ_Hz < 1.0) ||
799 ((float_t)USER_TRAJ_FREQ_Hz < USER_MAX_ACCEL_Hzps / USER_IQ_FULL_SCALE_FREQ_Hz) ||
800 ((float_t)USER_TRAJ_FREQ_Hz < USER_MAX_ACCEL_EST_Hzps / USER_IQ_FULL_SCALE_FREQ_Hz))
801 {
802 USER_setErrorCode(pUserParams, USER_ErrorCode_trajFreq_Hz_Low);
803 }
804
805 if(USER_MAX_NEGATIVE_ID_REF_CURRENT_A > 0.0)
806 {
807 USER_setErrorCode(pUserParams, USER_ErrorCode_maxNegativeIdCurrent_a_High);
808 }
809
810 if(USER_MAX_NEGATIVE_ID_REF_CURRENT_A < (-USER_MOTOR_MAX_CURRENT))
811 {
812 USER_setErrorCode(pUserParams, USER_ErrorCode_maxNegativeIdCurrent_a_Low);
813 }
814
815 return;
816 } // end of USER_checkForErrors() function
817
818
819 USER_ErrorCode_e USER_getErrorCode(USER_Params *pUserParams)
820 {
821 return(pUserParams->errorCode);
822 } // end of USER_getErrorCode() function
823
824
825 void USER_setErrorCode(USER_Params *pUserParams,const USER_ErrorCode_e errorCode)
826 {
827 pUserParams->errorCode = errorCode;
828
829 return;
830 } // end of USER_setErrorCode() function
831
832
833 void USER_softwareUpdate1p6(CTRL_Handle handle)
834 {
835 CTRL_Obj *obj = (CTRL_Obj *)handle;
836 float_t fullScaleInductance = USER_IQ_FULL_SCALE_VOLTAGE_V/(USER_IQ_FULL_SCALE_CURRENT_A*USER_VOLTAGE_FILTER_POLE_rps);
837 float_t Ls_coarse_max = _IQ30toF(EST_getLs_coarse_max_pu(obj->estHandle));
838 int_least8_t lShift = ceil(log(obj->motorParams.Ls_d_H/(Ls_coarse_max*fullScaleInductance))/log(2.0));
839 uint_least8_t Ls_qFmt = 30 - lShift;
840 float_t L_max = fullScaleInductance * pow(2.0,lShift);
841 _iq Ls_d_pu = _IQ30(obj->motorParams.Ls_d_H / L_max);
842 _iq Ls_q_pu = _IQ30(obj->motorParams.Ls_q_H / L_max);
843
844
845 // store the results
846 EST_setLs_d_pu(obj->estHandle,Ls_d_pu);
847 EST_setLs_q_pu(obj->estHandle,Ls_q_pu);
848 EST_setLs_qFmt(obj->estHandle,Ls_qFmt);
849
850 return;
851 } // end of softwareUpdate1p6() function
852
853
854 #ifndef NO_CTRL
855 void USER_calcPIgains(CTRL_Handle handle)
856 {
857 CTRL_Obj *obj = (CTRL_Obj *)handle;
858 float_t fullScaleCurrent = USER_IQ_FULL_SCALE_CURRENT_A;
859 float_t fullScaleVoltage = USER_IQ_FULL_SCALE_VOLTAGE_V;
860 float_t ctrlPeriod_sec = CTRL_getCtrlPeriod_sec(handle);
861 float_t Ls_d;
862 float_t Ls_q;
863 float_t Rs;
864 float_t RoverLs_d;
865 float_t RoverLs_q;
866 _iq Kp_Id;
867 _iq Ki_Id;
868 _iq Kp_Iq;
869 _iq Ki_Iq;
870 _iq Kd;
871
872 #ifdef __TMS320C28XX_FPU32__
873 int32_t tmp;
874
875 // when calling EST_ functions that return a float, and fpu32 is enabled, an integer is needed as a return
876 // so that the compiler reads the returned value from the accumulator instead of fpu32 registers
877 tmp = EST_getLs_d_H(obj->estHandle);
878 Ls_d = *((float_t *)&tmp);
879
880 tmp = EST_getLs_q_H(obj->estHandle);
881 Ls_q = *((float_t *)&tmp);
882
883 tmp = EST_getRs_Ohm(obj->estHandle);
884 Rs = *((float_t *)&tmp);
885 #else
886 Ls_d = EST_getLs_d_H(obj->estHandle);
887
888 Ls_q = EST_getLs_q_H(obj->estHandle);
889
890 Rs = EST_getRs_Ohm(obj->estHandle);
891 #endif
892
893 RoverLs_d = Rs/Ls_d;
894 Kp_Id = _IQ((0.25*Ls_d*fullScaleCurrent)/(ctrlPeriod_sec*fullScaleVoltage));
895 Ki_Id = _IQ(RoverLs_d*ctrlPeriod_sec);
896
897 RoverLs_q = Rs/Ls_q;
898 Kp_Iq = _IQ((0.25*Ls_q*fullScaleCurrent)/(ctrlPeriod_sec*fullScaleVoltage));
899 Ki_Iq = _IQ(RoverLs_q*ctrlPeriod_sec);
900
901 Kd = _IQ(0.0);
902
903 // set the Id controller gains
904 PID_setKi(obj->pidHandle_Id,Ki_Id);
905 CTRL_setGains(handle,CTRL_Type_PID_Id,Kp_Id,Ki_Id,Kd);
906
907 // set the Iq controller gains
908 PID_setKi(obj->pidHandle_Iq,Ki_Iq);
909 CTRL_setGains(handle,CTRL_Type_PID_Iq,Kp_Iq,Ki_Iq,Kd);
910
911 return;
912 } // end of calcPIgains() function
913 #endif
914
915
918 _iq USER_computeTorque_Ls_Id_Iq_pu_to_Nm_sf(void)
919 {
920 float_t FullScaleInductance = (USER_IQ_FULL_SCALE_VOLTAGE_V/(USER_IQ_FULL_SCALE_CURRENT_A*USER_VOLTAGE_FILTER_POLE_rps));
921 float_t FullScaleCurrent = (USER_IQ_FULL_SCALE_CURRENT_A);
922 float_t lShift = ceil(log(USER_MOTOR_Ls_d/(0.7*FullScaleInductance))/log(2.0));
923
924 return(_IQ(FullScaleInductance*FullScaleCurrent*FullScaleCurrent*USER_MOTOR_NUM_POLE_PAIRS*1.5*pow(2.0,lShift)));
925 } // end of USER_computeTorque_Ls_Id_Iq_pu_to_Nm_sf() function
926
927
930 _iq USER_computeTorque_Flux_Iq_pu_to_Nm_sf(void)
931 {
932 float_t FullScaleFlux = (USER_IQ_FULL_SCALE_VOLTAGE_V/(float_t)USER_EST_FREQ_Hz);
933 float_t FullScaleCurrent = (USER_IQ_FULL_SCALE_CURRENT_A);
934 float_t maxFlux = (USER_MOTOR_RATED_FLUX*((USER_MOTOR_TYPE==MOTOR_Type_Induction)?0.05:0.7));
935 float_t lShift = -ceil(log(FullScaleFlux/maxFlux)/log(2.0));
936
937 return(_IQ(FullScaleFlux/(2.0*MATH_PI)*FullScaleCurrent*USER_MOTOR_NUM_POLE_PAIRS*1.5*pow(2.0,lShift)));
938 } // end of USER_computeTorque_Flux_Iq_pu_to_Nm_sf() function
939
940
943 _iq USER_computeFlux_pu_to_Wb_sf(void)
944 {
945 float_t FullScaleFlux = (USER_IQ_FULL_SCALE_VOLTAGE_V/(float_t)USER_EST_FREQ_Hz);
946 float_t maxFlux = (USER_MOTOR_RATED_FLUX*((USER_MOTOR_TYPE==MOTOR_Type_Induction)?0.05:0.7));
947 float_t lShift = -ceil(log(FullScaleFlux/maxFlux)/log(2.0));
948
949 return(_IQ(FullScaleFlux/(2.0*MATH_PI)*pow(2.0,lShift)));
950 } // end of USER_computeFlux_pu_to_Wb_sf() function
951
952
955 _iq USER_computeFlux_pu_to_VpHz_sf(void)
956 {
957 float_t FullScaleFlux = (USER_IQ_FULL_SCALE_VOLTAGE_V/(float_t)USER_EST_FREQ_Hz);
958 float_t maxFlux = (USER_MOTOR_RATED_FLUX*((USER_MOTOR_TYPE==MOTOR_Type_Induction)?0.05:0.7));
959 float_t lShift = -ceil(log(FullScaleFlux/maxFlux)/log(2.0));
960
961 return(_IQ(FullScaleFlux*pow(2.0,lShift)));
962 } // end of USER_computeFlux_pu_to_VpHz_sf() function
963
964
967 _iq USER_computeFlux(CTRL_Handle handle, const _iq sf)
968 {
969 CTRL_Obj *obj = (CTRL_Obj *)handle;
970
971 return(_IQmpy(EST_getFlux_pu(obj->estHandle),sf));
972 } // end of USER_computeFlux() function
973
974
977 _iq USER_computeTorque_Nm(CTRL_Handle handle, const _iq torque_Flux_sf, const _iq torque_Ls_sf)
978 {
979 CTRL_Obj *obj = (CTRL_Obj *)handle;
980
981 _iq Flux_pu = EST_getFlux_pu(obj->estHandle);
982 _iq Id_pu = PID_getFbackValue(obj->pidHandle_Id);
983 _iq Iq_pu = PID_getFbackValue(obj->pidHandle_Iq);
984 _iq Ld_minus_Lq_pu = _IQ30toIQ(EST_getLs_d_pu(obj->estHandle)-EST_getLs_q_pu(obj->estHandle));
985 _iq Torque_Flux_Iq_Nm = _IQmpy(_IQmpy(Flux_pu,Iq_pu),torque_Flux_sf);
986 _iq Torque_Ls_Id_Iq_Nm = _IQmpy(_IQmpy(_IQmpy(Ld_minus_Lq_pu,Id_pu),Iq_pu),torque_Ls_sf);
987 _iq Torque_Nm = Torque_Flux_Iq_Nm + Torque_Ls_Id_Iq_Nm;
988
989 return(Torque_Nm);
990 } // end of USER_computeTorque_Nm() function
991
992
995 _iq USER_computeTorque_lbin(CTRL_Handle handle, const _iq torque_Flux_sf, const _iq torque_Ls_sf)
996 {
997 CTRL_Obj *obj = (CTRL_Obj *)handle;
998
999 _iq Flux_pu = EST_getFlux_pu(obj->estHandle);
1000 _iq Id_pu = PID_getFbackValue(obj->pidHandle_Id);
1001 _iq Iq_pu = PID_getFbackValue(obj->pidHandle_Iq);
1002 _iq Ld_minus_Lq_pu = _IQ30toIQ(EST_getLs_d_pu(obj->estHandle)-EST_getLs_q_pu(obj->estHandle));
1003 _iq Torque_Flux_Iq_Nm = _IQmpy(_IQmpy(Flux_pu,Iq_pu),torque_Flux_sf);
1004 _iq Torque_Ls_Id_Iq_Nm = _IQmpy(_IQmpy(_IQmpy(Ld_minus_Lq_pu,Id_pu),Iq_pu),torque_Ls_sf);
1005 _iq Torque_Nm = Torque_Flux_Iq_Nm + Torque_Ls_Id_Iq_Nm;
1006
1007 return(_IQmpy(Torque_Nm, _IQ(MATH_Nm_TO_lbin_SF)));
1008 } // end of USER_computeTorque_lbin() function
1009
1010
1011 // end of file
1012
USER_ErrorCode_motor_Rs_High
motor_Rs too high error code
Definition: fast/src/32b/userParams.h:149
USER_ErrorCode_ctrlFreq_Hz_High
ctrlFreq_Hz too high error code
Definition: fast/src/32b/userParams.h:175
USER_computeTorque_Ls_Id_Iq_pu_to_Nm_sf
_iq USER_computeTorque_Ls_Id_Iq_pu_to_Nm_sf(void)
Computes the scale factor needed to convert from torque created by Ld, Lq, Id and Iq...
Definition: 32b/user.c:918
_USER_Params_::iqFullScaleVoltage_V
float_t iqFullScaleVoltage_V
Defines the full scale voltage for the IQ variable, V.
Definition: fast/src/32b/userParams.h:196
_USER_Params_::fluxPole_rps
float_t fluxPole_rps
Defines the pole location for the flux estimation, rad/s.
Definition: fast/src/32b/userParams.h:208
USER_ErrorCode_voltageFilterPole_Hz_High
voltageFilterPole_Hz too high error code
Definition: fast/src/32b/userParams.h:136
USER_ErrorCode_IdRatedFraction_ratedFlux_Low
IdRatedFraction_ratedFlux too low error code.
Definition: fast/src/32b/userParams.h:170
_USER_Params_::fluxFraction
float_t fluxFraction
Defines the flux fraction for Id rated current estimation.
Definition: fast/src/32b/userParams.h:216
CTRL_State_Error
the controller error state
Definition: ctrl_states.h:35
EST_getLs_coarse_max_pu
_iq EST_getLs_coarse_max_pu(EST_Handle handle)
Gets the maximum stator inductance value during coarse estimation in the stator inductance estimator...
_USER_Params_::forceAngleFreq_Hz
float_t forceAngleFreq_Hz
Defines the force angle frequency, Hz.
Definition: fast/src/32b/userParams.h:210
USER_ErrorCode_motor_numPolePairs_Low
motor_numPolePairs too low error code
Definition: fast/src/32b/userParams.h:144
EST_State_LockRotor
lock the rotor
Definition: est_states.h:65
_USER_Params_::motor_Ls_q
float_t motor_Ls_q
Defines the quadrature stator inductance, H.
Definition: fast/src/32b/userParams.h:236
_USER_Params_::IdRated_delta
float_t IdRated_delta
Defines the Id rated delta current value, A.
Definition: fast/src/32b/userParams.h:245
EST_State_Ls
stator inductance estimation state
Definition: est_states.h:66
_USER_Params_::estWaitTime
uint_least32_t estWaitTime[EST_numStates]
Defines the wait times for each estimator state, estimator ticks.
Definition: fast/src/32b/userParams.h:249
EST_Ls_State_Idle
idle
Definition: est_Ls_states.h:48
USER_ErrorCode_systemFreq_MHz_Low
systemFreq_MHz too low error code
Definition: fast/src/32b/userParams.h:129
PID_setKi
static void PID_setKi(PID_Handle handle, const _iq Ki)
Sets the integral gain in the PID controller.
Definition: 32b/pid.h:329
USER_ErrorCode_motor_Rs_Low
motor_Rs too low error code
Definition: fast/src/32b/userParams.h:150
USER_ErrorCode_pwmFreq_kHz_Low
pwmFreq_kHz too low error code
Definition: fast/src/32b/userParams.h:131
USER_ErrorCode_numCurrentSensors_Low
numCurrentSensors too low error code
Definition: fast/src/32b/userParams.h:101
_USER_Params_::RsWaitTime
uint_least32_t RsWaitTime[EST_Rs_numStates]
Defines the wait times for each Rs estimator, estimator ticks.
Definition: fast/src/32b/userParams.h:252
USER_ErrorCode_maxAccel_Hzps_High
maxAccel_Hzps too high error code
Definition: fast/src/32b/userParams.h:112
_IQ
#define _IQ(A)
Definition: 32b/IQmathLib.h:319
_USER_Params_::iqFullScaleCurrent_A
float_t iqFullScaleCurrent_A
Defines the full scale current for the IQ variables, A.
Definition: fast/src/32b/userParams.h:195
EST_Flux_State_Idle
idle state
Definition: est_Flux_states.h:49
_USER_Params_::IdRated
float_t IdRated
Defines the Id rated current value, A.
Definition: fast/src/32b/userParams.h:242
EST_State_MotorIdentified
motor identified state
Definition: est_states.h:68
USER_ErrorCode_fluxFraction_High
fluxFraction too high error code
Definition: fast/src/32b/userParams.h:122
EST_State_RatedFlux_OL
estimate the open loop rated flux
Definition: est_states.h:62
USER_ErrorCode_powerWarpGain_Low
powerWarpGain too low error code
Definition: fast/src/32b/userParams.h:127
USER_ErrorCode_maxAccel_Hzps_Low
maxAccel_Hzps too low error code
Definition: fast/src/32b/userParams.h:113
_USER_Params_::motor_Rr
float_t motor_Rr
Defines the rotor resistance, ohm.
Definition: fast/src/32b/userParams.h:233
EST_Ls_State_RampUp
the ramp up state
Definition: est_Ls_states.h:49
USER_ErrorCode_ctrlFreq_Hz_Low
ctrlFreq_Hz too low error code
Definition: fast/src/32b/userParams.h:176
_USER_Params_::maxAccel_Hzps
float_t maxAccel_Hzps
Defines the maximum acceleration for the speed profiles, Hz/s.
Definition: fast/src/32b/userParams.h:211
EST_Rs_State_Done
the done state
Definition: est_Rs_states.h:42
_USER_Params_::maxNegativeIdCurrent_a
float_t maxNegativeIdCurrent_a
Defines the maximum negative current that the Id PID is allowed to go to, A.
Definition: fast/src/32b/userParams.h:260
USER_ErrorCode_motor_ratedFlux_High
motor_ratedFlux too high error code
Definition: fast/src/32b/userParams.h:145
USER_ErrorCode_motor_Ls_q_High
motor_Ls_q too high error code
Definition: fast/src/32b/userParams.h:153
_USER_Params_::ctrlPeriod_sec
float_t ctrlPeriod_sec
Defines the controller execution period, sec.
Definition: fast/src/32b/userParams.h:258
USER_ErrorCode_maxCurrentSlope_powerWarp_Low
maxCurrentSlope_powerWarp too low error code
Definition: fast/src/32b/userParams.h:164
_USER_Params_::systemFreq_MHz
uint_least16_t systemFreq_MHz
Defines the system clock frequency, MHz.
Definition: fast/src/32b/userParams.h:220
USER_ErrorCode_offsetPole_rps_High
offsetPole_rps too high error code
Definition: fast/src/32b/userParams.h:104
CTRL_getCtrlPeriod_sec
float_t CTRL_getCtrlPeriod_sec(CTRL_Handle handle)
Gets the controller execution period.
Definition: 32b/ctrl.h:161
_USER_Params_::LsWaitTime
uint_least32_t LsWaitTime[EST_Ls_numStates]
Defines the wait times for each Ls estimator, estimator ticks.
Definition: fast/src/32b/userParams.h:251
USER_ErrorCode_forceAngleFreq_Hz_Low
forceAngleFreq_Hz too low error code
Definition: fast/src/32b/userParams.h:111
USER_ErrorCode_NoError
no error error code
Definition: fast/src/32b/userParams.h:81
CTRL_State_Idle
the controller idle state
Definition: ctrl_states.h:36
USER_ErrorCode_iqFullScaleVoltage_V_Low
iqFullScaleVoltage_V too low error code
Definition: fast/src/32b/userParams.h:85
_CTRL_Obj_::pidHandle_Id
PID_Handle pidHandle_Id
the handle for the Id PID controller
Definition: 32b/ctrl_obj.h:165
USER_calcPIgains
void USER_calcPIgains(CTRL_Handle handle)
Definition: 32b/user.c:855
_USER_Params_::ctrlWaitTime
uint_least32_t ctrlWaitTime[CTRL_numStates]
Defines the wait times for each controller state, estimator ticks.
Definition: fast/src/32b/userParams.h:248
EST_State_IdRated
control Id and estimate the rated flux
Definition: est_states.h:61
_CTRL_Obj_
Defines the controller (CTRL) object.
Definition: 32b/ctrl_obj.h:144
_USER_Params_
Defines a structure for the user parameters.
Definition: fast/src/32b/userParams.h:193
USER_getErrorCode
USER_ErrorCode_e USER_getErrorCode(USER_Params *pUserParams)
Definition: 32b/user.c:819
_USER_Params_::numCurrentSensors
uint_least8_t numCurrentSensors
Defines the number of current sensors.
Definition: fast/src/32b/userParams.h:204
_USER_Params_::IdRatedFraction_ratedFlux
float_t IdRatedFraction_ratedFlux
Defines the fraction of Id rated current to use during rated flux estimation.
Definition: fast/src/32b/userParams.h:244
USER_ErrorCode_motor_Rr_Low
motor_Rr too low error code
Definition: fast/src/32b/userParams.h:148
USER_computeFlux_pu_to_Wb_sf
_iq USER_computeFlux_pu_to_Wb_sf(void)
Computes the scale factor needed to convert from per unit to Wb.
Definition: 32b/user.c:943
EST_Flux_State_Error
error state
Definition: est_Flux_states.h:48
_CTRL_Obj_::estHandle
EST_Handle estHandle
the handle for the parameter estimator
Definition: 32b/ctrl_obj.h:160
_USER_Params_::RoverL_estFreq_Hz
uint_least32_t RoverL_estFreq_Hz
Defines the R/L estimation frequency, Hz.
Definition: fast/src/32b/userParams.h:255
_USER_Params_::powerWarpGain
float_t powerWarpGain
Defines the PowerWarp gain for computing Id reference.
Definition: fast/src/32b/userParams.h:218
EST_Rs_State_Fine
the fine estimation state
Definition: est_Rs_states.h:41
EST_Flux_State_Done
done state
Definition: est_Flux_states.h:53
USER_ErrorCode_numCtrlTicksPerCurrentTick_Low
numCtrlTicksPerCurrentTick too low error code
Definition: fast/src/32b/userParams.h:93
PID_getFbackValue
static _iq PID_getFbackValue(PID_Handle handle)
Gets the feedback value in the PID controller.
Definition: 32b/pid.h:102
_USER_Params_::maxCurrent
float_t maxCurrent
Defines the maximum current value, A.
Definition: fast/src/32b/userParams.h:237
USER_ErrorCode_directionPole_rps_Low
directionPole_rps too low error code
Definition: fast/src/32b/userParams.h:117
_iq
long _iq
Definition: 32b/IQmathLib.h:223
USER_computeTorque_lbin
_iq USER_computeTorque_lbin(CTRL_Handle handle, const _iq torque_Flux_sf, const _iq torque_Ls_sf)
Computes Torque in Nm.
Definition: 32b/user.c:995
_USER_Params_::numCtrlTicksPerCurrentTick
uint_least16_t numCtrlTicksPerCurrentTick
Defines the number of controller clock ticks per current controller clock tick.
Definition: fast/src/32b/userParams.h:200
USER_ErrorCode_iqFullScaleFreq_Hz_High
iqFullScaleFreq_Hz too high error code
Definition: fast/src/32b/userParams.h:86
USER_ErrorCode_IdRated_delta_High
IdRated_delta too high error code.
Definition: fast/src/32b/userParams.h:171
MATH_PI
#define MATH_PI
Defines pi.
Definition: 32b/math.h:101
EST_State_RatedFlux
estimate the rated flux
Definition: est_states.h:63
EST_setLs_qFmt
void EST_setLs_qFmt(EST_Handle handle, const uint_least8_t Ls_qFmt)
Sets the stator inductance Q format in the estimator in 8 bit unsigned integer (uint_least8_t).
USER_ErrorCode_IdRatedFraction_indEst_Low
IdRatedFraction_indEst too low error code.
Definition: fast/src/32b/userParams.h:168
USER_ErrorCode_motor_Ls_q_Low
motor_Ls_q too low error code
Definition: fast/src/32b/userParams.h:154
USER_ErrorCode_maxAccel_est_Hzps_High
maxAccel_est_Hzps too high error code
Definition: fast/src/32b/userParams.h:114
EST_Rs_State_Coarse
the coarse estimation state
Definition: est_Rs_states.h:40
EST_State_Rs
Rs estimation state.
Definition: est_states.h:56
CTRL_setGains
void CTRL_setGains(CTRL_Handle handle, const CTRL_Type_e ctrlType, const _iq Kp, const _iq Ki, const _iq Kd)
Sets the gain values for the specified controller.
Definition: 32b/ctrl.c:262
USER_ErrorCode_numPwmTicksPerIsrTick_High
numPwmTicksPerIsrTick too high error code
Definition: fast/src/32b/userParams.h:88
EST_Ls_State_Fine
the fine estimation state
Definition: est_Ls_states.h:52
_USER_Params_::voltageFilterPole_rps
float_t voltageFilterPole_rps
Defines the analog voltage filter pole location, rad/s.
Definition: fast/src/32b/userParams.h:225
EST_State_RampDown
ramp down the speed
Definition: est_states.h:64
EST_getLs_d_pu
_iq EST_getLs_d_pu(EST_Handle handle)
Gets the direct stator inductance value in per unit (pu), IQ30.
USER_ErrorCode_current_sf_High
current_sf too high error code
Definition: fast/src/32b/userParams.h:134
ctrl.h
USER_ErrorCode_numCtrlTicksPerEstTick_Low
numCtrlTicksPerEstTick too low error code
Definition: fast/src/32b/userParams.h:95
USER_ErrorCode_motor_Rr_High
motor_Rr too high error code
Definition: fast/src/32b/userParams.h:147
EST_State_OnLine
online parameter estimation
Definition: est_states.h:69
EST_Rs_State_RampUp
the Id ramp up state
Definition: est_Rs_states.h:39
USER_ErrorCode_speedPole_rps_High
speedPole_rps too high error code
Definition: fast/src/32b/userParams.h:118
USER_ErrorCode_numCtrlTicksPerTrajTick_Low
numCtrlTicksPerTrajTick too low error code
Definition: fast/src/32b/userParams.h:99
EST_getLs_d_H
float_t EST_getLs_d_H(EST_Handle handle)
Gets the direct stator inductance value in Henries (H).
USER_ErrorCode_directionPole_rps_High
directionPole_rps too high error code
Definition: fast/src/32b/userParams.h:116
_USER_Params_::directionPole_rps
float_t directionPole_rps
Defines the pole location for the direction filter, rad/s.
Definition: fast/src/32b/userParams.h:213
MOTOR_Type_Pm
permanent magnet
Definition: 32b/motor.h:74
USER_ErrorCode_forceAngleFreq_Hz_High
forceAngleFreq_Hz too high error code
Definition: fast/src/32b/userParams.h:110
_USER_Params_::motor_type
MOTOR_Type_e motor_type
Defines the motor type.
Definition: fast/src/32b/userParams.h:229
_IQmpy
#define _IQmpy(A, B)
Definition: 32b/IQmathLib.h:809
USER_softwareUpdate1p6
void USER_softwareUpdate1p6(CTRL_Handle handle)
Definition: 32b/user.c:833
USER_ErrorCode_trajFreq_Hz_Low
trajFreq_Hz too low error code
Definition: fast/src/32b/userParams.h:182
USER_ErrorCode_fluxFraction_Low
fluxFraction too low error code
Definition: fast/src/32b/userParams.h:123
USER_ErrorCode_iqFullScaleVoltage_V_High
iqFullScaleVoltage_V too high error code
Definition: fast/src/32b/userParams.h:84
_USER_Params_::voltage_sf
float_t voltage_sf
Defines the voltage scale factor for the system.
Definition: fast/src/32b/userParams.h:223
USER_ErrorCode_voltageFilterPole_Hz_Low
voltageFilterPole_Hz too low error code
Definition: fast/src/32b/userParams.h:137
USER_setParams
void USER_setParams(USER_Params *pUserParams)
Definition: 32b/user.c:58
EST_Ls_State_Init
the init state
Definition: est_Ls_states.h:50
_USER_Params_::trajFreq_Hz
uint_least32_t trajFreq_Hz
Defines the trajectory frequency, Hz.
Definition: fast/src/32b/userParams.h:256
EST_getFlux_pu
_iq EST_getFlux_pu(EST_Handle handle)
Gets the flux value in per unit (pu), IQ24.
USER_ErrorCode_maxVsMag_pu_High
maxVsMag_pu too high error code
Definition: fast/src/32b/userParams.h:138
USER_computeFlux_pu_to_VpHz_sf
_iq USER_computeFlux_pu_to_VpHz_sf(void)
Computes the scale factor needed to convert from per unit to V/Hz.
Definition: 32b/user.c:955
_USER_Params_::numVoltageSensors
uint_least8_t numVoltageSensors
Defines the number of voltage sensors.
Definition: fast/src/32b/userParams.h:205
EST_getLs_q_H
float_t EST_getLs_q_H(EST_Handle handle)
Gets the stator inductance value in the quadrature coordinate direction in Henries (H)...
USER_ErrorCode_fluxEstFreq_Hz_Low
fluxEstFreq_Hz too low error code
Definition: fast/src/32b/userParams.h:174
EST_Ls_State_Error
error
Definition: est_Ls_states.h:47
USER_ErrorCode_estFreq_Hz_Low
estFreq_Hz too low error code
Definition: fast/src/32b/userParams.h:178
USER_ErrorCode_dcBusPole_rps_High
dcBusPole_rps too high error code
Definition: fast/src/32b/userParams.h:120
_IQ30toIQ
#define _IQ30toIQ(A)
Definition: 32b/IQmathLib.h:516
EST_Ls_State_Coarse
the coarse estimation state
Definition: est_Ls_states.h:51
_USER_Params_::offsetPole_rps
float_t offsetPole_rps
Defines the pole location for the voltage and current offset estimation, rad/s.
Definition: fast/src/32b/userParams.h:207
MOTOR_Type_Induction
induction
Definition: 32b/motor.h:73
USER_ErrorCode_maxCurrent_resEst_High
maxCurrent_resEst too high error code
Definition: fast/src/32b/userParams.h:157
USER_ErrorCode_motor_type_Unknown
motor type unknown error code
Definition: fast/src/32b/userParams.h:142
EST_State_RampUp
ramp up the speed
Definition: est_states.h:57
USER_ErrorCode_maxCurrent_indEst_Low
maxCurrent_indEst too low error code
Definition: fast/src/32b/userParams.h:160
USER_ErrorCode_speedPole_rps_Low
speedPole_rps too low error code
Definition: fast/src/32b/userParams.h:119
_USER_Params_::pwmPeriod_usec
float_t pwmPeriod_usec
Defines the Pulse Width Modulation (PWM) period, usec.
Definition: fast/src/32b/userParams.h:222
USER_ErrorCode_IdRated_High
IdRated too high error code.
Definition: fast/src/32b/userParams.h:165
CTRL_State_OnLine
the controller online state
Definition: ctrl_states.h:38
USER_ErrorCode_maxCurrentSlope_powerWarp_High
maxCurrentSlope_powerWarp too high error code
Definition: fast/src/32b/userParams.h:163
_USER_Params_::errorCode
USER_ErrorCode_e errorCode
Definition: fast/src/32b/userParams.h:262
_USER_Params_::zeroSpeedLimit
float_t zeroSpeedLimit
Defines the low speed limit for the flux integrator, pu.
Definition: fast/src/32b/userParams.h:209
_USER_Params_::current_sf
float_t current_sf
Defines the current scale factor for the system.
Definition: fast/src/32b/userParams.h:224
USER_ErrorCode_fluxPole_rps_High
fluxPole_rps too high error code
Definition: fast/src/32b/userParams.h:106
USER_ErrorCode_maxCurrent_High
maxCurrent too high error code
Definition: fast/src/32b/userParams.h:155
USER_ErrorCode_current_sf_Low
current_sf too low error code
Definition: fast/src/32b/userParams.h:135
EST_Flux_State_CL2
closed loop control stage 2
Definition: est_Flux_states.h:51
USER_ErrorCode_iqFullScaleCurrent_A_Low
iqFullScaleCurrent_A too low error code
Definition: fast/src/32b/userParams.h:83
USER_setErrorCode
void USER_setErrorCode(USER_Params *pUserParams, const USER_ErrorCode_e errorCode)
Definition: 32b/user.c:825
USER_ErrorCode_dcBusPole_rps_Low
dcBusPole_rps too low error code
Definition: fast/src/32b/userParams.h:121
_USER_Params_::indEst_speedMaxFraction
float_t indEst_speedMaxFraction
Defines the fraction of SpeedMax to use during inductance estimation.
Definition: fast/src/32b/userParams.h:217
_CTRL_Obj_::motorParams
MOTOR_Params motorParams
the motor parameters
Definition: 32b/ctrl_obj.h:189
_USER_Params_::fluxEstFreq_Hz
float_t fluxEstFreq_Hz
Defines the flux estimation frequency, Hz.
Definition: fast/src/32b/userParams.h:246
EST_getLs_q_pu
_iq EST_getLs_q_pu(EST_Handle handle)
Gets the stator inductance value in the quadrature coordinate direction in per unit (pu)...
_USER_Params_::IdRatedFraction_indEst
float_t IdRatedFraction_indEst
Defines the fraction of Id rated current to use during inductance estimation.
Definition: fast/src/32b/userParams.h:243
USER_ErrorCode_IdRatedFraction_indEst_High
IdRatedFraction_indEst too high error code.
Definition: fast/src/32b/userParams.h:167
USER_checkForErrors
void USER_checkForErrors(USER_Params *pUserParams)
Definition: 32b/user.c:198
USER_ErrorCode_fluxEstFreq_Hz_High
fluxEstFreq_Hz too high error code
Definition: fast/src/32b/userParams.h:173
EST_getRs_Ohm
float_t EST_getRs_Ohm(EST_Handle handle)
Gets the stator resistance value in Ohms ( ).
_USER_Params_::dcBusPole_rps
float_t dcBusPole_rps
Defines the pole location for the DC bus filter, rad/s.
Definition: fast/src/32b/userParams.h:215
_MOTOR_Params_::Ls_q_H
float_t Ls_q_H
Defines the quadrature stator inductance, H.
Definition: 32b/motor.h:89
_IQ30
#define _IQ30(A)
Definition: 32b/IQmathLib.h:269
USER_ErrorCode_IdRated_Low
IdRated too low error code.
Definition: fast/src/32b/userParams.h:166
_USER_Params_::numCtrlTicksPerTrajTick
uint_least16_t numCtrlTicksPerTrajTick
Defines the number of controller clock ticks per trajectory clock tick.
Definition: fast/src/32b/userParams.h:203
_CTRL_Obj_::pidHandle_Iq
PID_Handle pidHandle_Iq
the handle for the Iq PID controller
Definition: 32b/ctrl_obj.h:168
_USER_Params_::numCtrlTicksPerSpeedTick
uint_least16_t numCtrlTicksPerSpeedTick
Defines the number of controller clock ticks per speed controller clock tick.
Definition: fast/src/32b/userParams.h:202
USER_ErrorCode_numVoltageSensors_High
numVoltageSensors too high error code
Definition: fast/src/32b/userParams.h:102
_USER_Params_::maxCurrent_indEst
float_t maxCurrent_indEst
Defines the maximum current value for inductance estimation, A.
Definition: fast/src/32b/userParams.h:239
USER_ErrorCode_numPwmTicksPerIsrTick_Low
numPwmTicksPerIsrTick too low error code
Definition: fast/src/32b/userParams.h:89
EST_State_Error
error
Definition: est_states.h:53
USER_ErrorCode_maxCurrentSlope_High
maxCurrentSlope too high error code
Definition: fast/src/32b/userParams.h:161
_USER_Params_::maxCurrentSlope
float_t maxCurrentSlope
Defines the maximum current slope for Id current trajectory.
Definition: fast/src/32b/userParams.h:240
_MOTOR_Params_::Ls_d_H
float_t Ls_d_H
Defines the direct stator inductance, H.
Definition: 32b/motor.h:88
EST_Rs_State_Idle
idle
Definition: est_Rs_states.h:38
_USER_Params_::speedPole_rps
float_t speedPole_rps
Defines the pole location for the speed control filter, rad/s.
Definition: fast/src/32b/userParams.h:214
_USER_Params_::motor_Rs
float_t motor_Rs
Defines the stator resistance, ohm.
Definition: fast/src/32b/userParams.h:234
USER_ErrorCode_fluxPole_rps_Low
fluxPole_rps too low error code
Definition: fast/src/32b/userParams.h:107
USER_ErrorCode_motor_ratedFlux_Low
motor_ratedFlux too low error code
Definition: fast/src/32b/userParams.h:146
EST_State_Idle
idle
Definition: est_states.h:54
_USER_Params_::numIsrTicksPerCtrlTick
uint_least16_t numIsrTicksPerCtrlTick
Defines the number of Interrupt Service Routine (ISR) clock ticks per controller clock tick...
Definition: fast/src/32b/userParams.h:199
USER_ErrorCode_RoverL_estFreq_Hz_High
RoverL_estFreq_Hz too high error code.
Definition: fast/src/32b/userParams.h:179
USER_computeTorque_Flux_Iq_pu_to_Nm_sf
_iq USER_computeTorque_Flux_Iq_pu_to_Nm_sf(void)
Computes the scale factor needed to convert from torque created by flux and Iq, from per unit to Nm...
Definition: 32b/user.c:930
EST_State_RoverL
R/L estimation.
Definition: est_states.h:55
USER_ErrorCode_voltage_sf_High
voltage_sf too high error code
Definition: fast/src/32b/userParams.h:132
CTRL_Type_PID_Iq
PID Iq controller.
Definition: 32b/ctrl_obj.h:125
USER_ErrorCode_maxCurrent_indEst_High
maxCurrent_indEst too high error code
Definition: fast/src/32b/userParams.h:159
EST_setLs_q_pu
void EST_setLs_q_pu(EST_Handle handle, const _iq Ls_q_pu)
Sets the quadrature stator inductance value in the estimator in per unit (pu), IQ30.
_USER_Params_::ctrlFreq_Hz
uint_least32_t ctrlFreq_Hz
Defines the controller frequency, Hz.
Definition: fast/src/32b/userParams.h:253
USER_ErrorCode_numVoltageSensors_Low
numVoltageSensors too low error code
Definition: fast/src/32b/userParams.h:103
USER_computeTorque_Nm
_iq USER_computeTorque_Nm(CTRL_Handle handle, const _iq torque_Flux_sf, const _iq torque_Ls_sf)
Computes Torque in Nm.
Definition: 32b/user.c:977
USER_ErrorCode_maxVsMag_pu_Low
maxVsMag_pu too low error code
Definition: fast/src/32b/userParams.h:139
USER_ErrorCode_indEst_speedMaxFraction_Low
indEst_speedMaxFraction too low error code
Definition: fast/src/32b/userParams.h:125
EST_Flux_State_CL1
closed loop control stage 1
Definition: est_Flux_states.h:50
CTRL_Type_PID_Id
PID Id controller.
Definition: 32b/ctrl_obj.h:124
_USER_Params_::motor_numPolePairs
uint_least16_t motor_numPolePairs
Defines the number of pole pairs for the motor.
Definition: fast/src/32b/userParams.h:230
USER_ErrorCode_estKappa_Low
estKappa too low error code
Definition: fast/src/32b/userParams.h:141
_USER_Params_::numCtrlTicksPerEstTick
uint_least16_t numCtrlTicksPerEstTick
Defines the number of controller clock ticks per estimator clock tick.
Definition: fast/src/32b/userParams.h:201
EST_Ls_State_Done
the done state
Definition: est_Ls_states.h:53
USER_ErrorCode_motor_Ls_d_High
motor_Ls_d too high error code
Definition: fast/src/32b/userParams.h:151
_USER_Params_::maxCurrentSlope_powerWarp
float_t maxCurrentSlope_powerWarp
Defines the maximum current slope for Id current trajectory during PowerWarp.
Definition: fast/src/32b/userParams.h:241
USER_ErrorCode_pwmFreq_kHz_High
pwmFreq_kHz too high error code
Definition: fast/src/32b/userParams.h:130
USER_ErrorCode_e
USER_ErrorCode_e
Enumeration for the user error codes.
Definition: fast/src/32b/userParams.h:79
_USER_Params_::FluxWaitTime
uint_least32_t FluxWaitTime[EST_Flux_numStates]
Defines the wait times for each Ls estimator, estimator ticks.
Definition: fast/src/32b/userParams.h:250
_USER_Params_::maxAccel_est_Hzps
float_t maxAccel_est_Hzps
Defines the maximum acceleration for the estimation speed profiles, Hz/s.
Definition: fast/src/32b/userParams.h:212
USER_ErrorCode_zeroSpeedLimit_Low
zeroSpeedLimit too low error code
Definition: fast/src/32b/userParams.h:109
MATH_Nm_TO_lbin_SF
#define MATH_Nm_TO_lbin_SF
Defines conversion scale factor from N*m to lb*in.
Definition: 32b/math.h:69
_USER_Params_::estFreq_Hz
uint_least32_t estFreq_Hz
Defines the estimator frequency, Hz.
Definition: fast/src/32b/userParams.h:254
USER_ErrorCode_maxNegativeIdCurrent_a_High
maxNegativeIdCurrent_a too high error code
Definition: fast/src/32b/userParams.h:185
USER_ErrorCode_voltage_sf_Low
voltage_sf too low error code
Definition: fast/src/32b/userParams.h:133
USER_ErrorCode_motor_Ls_d_Low
motor_Ls_d too low error code
Definition: fast/src/32b/userParams.h:152
USER_ErrorCode_maxCurrentSlope_Low
maxCurrentSlope too low error code
Definition: fast/src/32b/userParams.h:162
EST_State_Rr
rotor resistance estimation state
Definition: est_states.h:67
USER_ErrorCode_maxAccel_est_Hzps_Low
maxAccel_est_Hzps too low error code
Definition: fast/src/32b/userParams.h:115
USER_ErrorCode_maxNegativeIdCurrent_a_Low
maxNegativeIdCurrent_a too low error code
Definition: fast/src/32b/userParams.h:186
USER_ErrorCode_IdRatedFraction_ratedFlux_High
IdRatedFraction_ratedFlux too high error code.
Definition: fast/src/32b/userParams.h:169
EST_Flux_State_Fine
fine estimate of flux
Definition: est_Flux_states.h:52
USER_ErrorCode_numIsrTicksPerCtrlTick_Low
numIsrTicksPerCtrlTick too low error code
Definition: fast/src/32b/userParams.h:91
USER_ErrorCode_systemFreq_MHz_High
systemFreq_MHz too high error code
Definition: fast/src/32b/userParams.h:128
_USER_Params_::estKappa
float_t estKappa
Defines the convergence factor for the estimator.
Definition: fast/src/32b/userParams.h:227
USER_ErrorCode_maxCurrent_Low
maxCurrent too low error code
Definition: fast/src/32b/userParams.h:156
USER_computeFlux
_iq USER_computeFlux(CTRL_Handle handle, const _iq sf)
Computes Flux in Wb or V/Hz depending on the scale factor sent as parameter.
Definition: 32b/user.c:967
CTRL_State_OffLine
the controller offline state
Definition: ctrl_states.h:37
USER_ErrorCode_indEst_speedMaxFraction_High
indEst_speedMaxFraction too high error code
Definition: fast/src/32b/userParams.h:124
USER_ErrorCode_IdRated_delta_Low
IdRated_delta too low error code.
Definition: fast/src/32b/userParams.h:172
USER_ErrorCode_estKappa_High
estKappa too high error code
Definition: fast/src/32b/userParams.h:140
_IQ30toF
float _IQ30toF(long A)
USER_ErrorCode_powerWarpGain_High
powerWarpGain too high error code
Definition: fast/src/32b/userParams.h:126
USER_ErrorCode_numCtrlTicksPerSpeedTick_Low
numCtrlTicksPerSpeedTick too low error code
Definition: fast/src/32b/userParams.h:97
USER_ErrorCode_numCurrentSensors_High
numCurrentSensors too high error code
Definition: fast/src/32b/userParams.h:100
EST_Rs_State_Error
error
Definition: est_Rs_states.h:37
USER_ErrorCode_offsetPole_rps_Low
offsetPole_rps too low error code
Definition: fast/src/32b/userParams.h:105
_USER_Params_::iqFullScaleFreq_Hz
float_t iqFullScaleFreq_Hz
Defines the full scale frequency for IQ variable, Hz.
Definition: fast/src/32b/userParams.h:197
EST_setLs_d_pu
void EST_setLs_d_pu(EST_Handle handle, const _iq Ls_d_pu)
Sets the direct stator inductance value in the estimator in per unit (pu), IQ30.
USER_ErrorCode_iqFullScaleFreq_Hz_Low
iqFullScaleFreq_Hz too low error code
Definition: fast/src/32b/userParams.h:87
USER_ErrorCode_zeroSpeedLimit_High
zeroSpeedLimit too high error code
Definition: fast/src/32b/userParams.h:108
float_t
float float_t
Defines the portable data type for 32 bit, signed floating-point data.
Definition: types.h:121
_USER_Params_::motor_Ls_d
float_t motor_Ls_d
Defines the direct stator inductance, H.
Definition: fast/src/32b/userParams.h:235
USER_ErrorCode_maxCurrent_resEst_Low
maxCurrent_resEst too low error code
Definition: fast/src/32b/userParams.h:158
_USER_Params_::maxCurrent_resEst
float_t maxCurrent_resEst
Defines the maximum current value for resistance estimation, A.
Definition: fast/src/32b/userParams.h:238
_USER_Params_::motor_ratedFlux
float_t motor_ratedFlux
Defines the rated flux of the motor, V/Hz.
Definition: fast/src/32b/userParams.h:232
_USER_Params_::maxVsMag_pu
float_t maxVsMag_pu
Defines the maximum voltage magnitude, pu.
Definition: fast/src/32b/userParams.h:226