MotorWare f2806x Module API Documentation
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"
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 
199 {
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  {
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  {
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  {
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  {
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  {
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  {
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  {
257  }
258 
259  if(USER_NUM_PWM_TICKS_PER_ISR_TICK > 3)
260  {
262  }
263 
264  if(USER_NUM_PWM_TICKS_PER_ISR_TICK < 1)
265  {
267  }
268 
269  if(USER_NUM_ISR_TICKS_PER_CTRL_TICK < 1)
270  {
272  }
273 
274  if(USER_NUM_CTRL_TICKS_PER_CURRENT_TICK < 1)
275  {
277  }
278 
279  if(USER_NUM_CTRL_TICKS_PER_EST_TICK < 1)
280  {
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  {
288  }
289 
290  if(USER_NUM_CTRL_TICKS_PER_TRAJ_TICK < 1)
291  {
293  }
294 
295  if(USER_NUM_CURRENT_SENSORS > 3)
296  {
298  }
299 
300  if(USER_NUM_CURRENT_SENSORS < 2)
301  {
303  }
304 
305  if(USER_NUM_VOLTAGE_SENSORS > 3)
306  {
308  }
309 
310  if(USER_NUM_VOLTAGE_SENSORS < 3)
311  {
313  }
314 
315  if(USER_OFFSET_POLE_rps > ((float_t)USER_CTRL_FREQ_Hz))
316  {
318  }
319 
320  if(USER_OFFSET_POLE_rps <= 0.0)
321  {
323  }
324 
325  if(USER_FLUX_POLE_rps > ((float_t)USER_EST_FREQ_Hz))
326  {
328  }
329 
330  if(USER_FLUX_POLE_rps <= 0.0)
331  {
333  }
334 
335  if(USER_ZEROSPEEDLIMIT > 1.0)
336  {
338  }
339 
340  if(USER_ZEROSPEEDLIMIT <= 0.0)
341  {
343  }
344 
345  if(USER_FORCE_ANGLE_FREQ_Hz > ((float_t)USER_EST_FREQ_Hz))
346  {
348  }
349 
350  if(USER_FORCE_ANGLE_FREQ_Hz <= 0.0)
351  {
353  }
354 
355  if(USER_MAX_ACCEL_Hzps > ((float_t)USER_TRAJ_FREQ_Hz * USER_IQ_FULL_SCALE_FREQ_Hz))
356  {
358  }
359 
360  if(USER_MAX_ACCEL_Hzps <= 0.0)
361  {
363  }
364 
365  if(USER_MAX_ACCEL_EST_Hzps > ((float_t)USER_TRAJ_FREQ_Hz * USER_IQ_FULL_SCALE_FREQ_Hz))
366  {
368  }
369 
370  if(USER_MAX_ACCEL_EST_Hzps <= 0.0)
371  {
373  }
374 
375  if(USER_DIRECTION_POLE_rps > ((float_t)USER_EST_FREQ_Hz))
376  {
378  }
379 
380  if(USER_DIRECTION_POLE_rps <= 0.0)
381  {
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  {
389  }
390 
391  if(USER_SPEED_POLE_rps <= 0.0)
392  {
394  }
395 
396  if(USER_DCBUS_POLE_rps > ((float_t)USER_EST_FREQ_Hz))
397  {
399  }
400 
401  if(USER_DCBUS_POLE_rps <= 0.0)
402  {
404  }
405 
406  if(USER_FLUX_FRACTION > 1.2)
407  {
409  }
410 
411  if(USER_FLUX_FRACTION < 0.05)
412  {
414  }
415 
416  if(USER_SPEEDMAX_FRACTION_FOR_L_IDENT > (USER_IQ_FULL_SCALE_CURRENT_A / USER_MOTOR_MAX_CURRENT))
417  {
419  }
420 
421  if(USER_SPEEDMAX_FRACTION_FOR_L_IDENT <= 0.0)
422  {
424  }
425 
426  if(USER_POWERWARP_GAIN > 2.0)
427  {
429  }
430 
431  if(USER_POWERWARP_GAIN < 1.0)
432  {
434  }
435 
436  if(USER_SYSTEM_FREQ_MHz > 90.0)
437  {
439  }
440 
441  if(USER_SYSTEM_FREQ_MHz <= 0.0)
442  {
444  }
445 
446  if(USER_PWM_FREQ_kHz > (1000.0 * USER_SYSTEM_FREQ_MHz / 100.0))
447  {
449  }
450 
451  if(USER_PWM_FREQ_kHz < (1000.0 * USER_SYSTEM_FREQ_MHz / 65536.0))
452  {
454  }
455 
456  if(USER_VOLTAGE_SF >= 128.0)
457  {
459  }
460 
461  if(USER_VOLTAGE_SF < 0.1)
462  {
464  }
465 
466  if(USER_CURRENT_SF >= 128.0)
467  {
469  }
470 
471  if(USER_CURRENT_SF < 0.1)
472  {
474  }
475 
476  if(USER_VOLTAGE_FILTER_POLE_Hz > ((float_t)USER_EST_FREQ_Hz / MATH_PI))
477  {
479  }
480 
481  if(USER_VOLTAGE_FILTER_POLE_Hz < (USER_IQ_FULL_SCALE_FREQ_Hz / 4.0))
482  {
484  }
485 
486  if(USER_MAX_VS_MAG_PU > (4.0 / 3.0))
487  {
489  }
490 
491  if(USER_MAX_VS_MAG_PU <= 0.0)
492  {
494  }
495 
496  if(USER_EST_KAPPAQ > 1.5)
497  {
499  }
500 
501  if(USER_EST_KAPPAQ < 1.5)
502  {
504  }
505 
506  if((USER_MOTOR_TYPE != MOTOR_Type_Induction) && (USER_MOTOR_TYPE != MOTOR_Type_Pm))
507  {
509  }
510 
511  if(USER_MOTOR_NUM_POLE_PAIRS < 1)
512  {
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  {
521  }
522 
523  if(USER_MOTOR_RATED_FLUX < (USER_IQ_FULL_SCALE_VOLTAGE_V / (float_t)USER_EST_FREQ_Hz / 0.7))
524  {
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  {
534  }
535 
536  if(USER_MOTOR_RATED_FLUX < (USER_IQ_FULL_SCALE_VOLTAGE_V / (float_t)USER_EST_FREQ_Hz / 0.05))
537  {
539  }
540  }
541 
542  if(USER_MOTOR_TYPE == MOTOR_Type_Pm)
543  {
544  if(USER_MOTOR_Rr > 0.0)
545  {
547  }
548 
549  if(USER_MOTOR_Rr < 0.0)
550  {
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  {
560  }
561 
562  if(USER_MOTOR_Rr < (0.7 * USER_IQ_FULL_SCALE_VOLTAGE_V / (USER_IQ_FULL_SCALE_CURRENT_A * 65536.0)))
563  {
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  {
573  }
574 
575  if(USER_MOTOR_Rs < (0.7 * USER_IQ_FULL_SCALE_VOLTAGE_V / (USER_IQ_FULL_SCALE_CURRENT_A * 65536.0)))
576  {
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  {
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  {
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  {
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  {
604  }
605  }
606 
607  if(USER_MOTOR_RES_EST_CURRENT > USER_MOTOR_MAX_CURRENT)
608  {
610  }
611 
612  if(USER_MOTOR_RES_EST_CURRENT < 0.0)
613  {
615  }
616 
617  if(USER_MOTOR_TYPE == MOTOR_Type_Pm)
618  {
619  if(USER_MOTOR_IND_EST_CURRENT > 0.0)
620  {
622  }
623 
624  if(USER_MOTOR_IND_EST_CURRENT < (-USER_MOTOR_MAX_CURRENT))
625  {
627  }
628  }
629 
630  if(USER_MOTOR_TYPE == MOTOR_Type_Induction)
631  {
632  if(USER_MOTOR_IND_EST_CURRENT > 0.0)
633  {
635  }
636 
637  if(USER_MOTOR_IND_EST_CURRENT < 0.0)
638  {
640  }
641  }
642 
643  if(USER_MOTOR_MAX_CURRENT > USER_IQ_FULL_SCALE_CURRENT_A)
644  {
646  }
647 
648  if(USER_MOTOR_MAX_CURRENT <= 0.0)
649  {
651  }
652 
653  if(USER_MAX_CURRENT_SLOPE > 1.0)
654  {
656  }
657 
658  if(USER_MAX_CURRENT_SLOPE <= 0.0)
659  {
661  }
662 
663  if(USER_MAX_CURRENT_SLOPE_POWERWARP > 1.0)
664  {
666  }
667 
668  if(USER_MAX_CURRENT_SLOPE_POWERWARP <= 0.0)
669  {
671  }
672 
673  if(USER_MOTOR_TYPE == MOTOR_Type_Pm)
674  {
675  if(USER_MOTOR_MAGNETIZING_CURRENT > 0.0)
676  {
678  }
679 
680  if(USER_MOTOR_MAGNETIZING_CURRENT < 0.0)
681  {
683  }
684  }
685 
686  if(USER_MOTOR_TYPE == MOTOR_Type_Induction)
687  {
688  if(USER_MOTOR_MAGNETIZING_CURRENT > USER_MOTOR_MAX_CURRENT)
689  {
691  }
692 
693  if(USER_MOTOR_MAGNETIZING_CURRENT < 0.0)
694  {
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  {
704  }
705 
706  if(USER_IDRATED_FRACTION_FOR_RATED_FLUX < 0.1)
707  {
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  {
717  }
718 
719  if(USER_IDRATED_FRACTION_FOR_L_IDENT < 0.1)
720  {
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  {
730  }
731 
732  if(USER_IDRATED_DELTA < 0.0)
733  {
735  }
736  }
737 
738  if(USER_MOTOR_FLUX_EST_FREQ_Hz > USER_IQ_FULL_SCALE_FREQ_Hz)
739  {
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  {
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  {
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  {
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  {
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  {
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  {
791  }
792 
793  if(USER_R_OVER_L_EST_FREQ_Hz > USER_IQ_FULL_SCALE_FREQ_Hz)
794  {
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  {
803  }
804 
805  if(USER_MAX_NEGATIVE_ID_REF_CURRENT_A > 0.0)
806  {
808  }
809 
810  if(USER_MAX_NEGATIVE_ID_REF_CURRENT_A < (-USER_MOTOR_MAX_CURRENT))
811  {
813  }
814 
815  return;
816 } // end of USER_checkForErrors() function
817 
818 
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 
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
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 
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 
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 
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 
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 
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 
motor_Rs too high error code
ctrlFreq_Hz too high error code
_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
float_t iqFullScaleVoltage_V
Defines the full scale voltage for the IQ variable, V.
float_t fluxPole_rps
Defines the pole location for the flux estimation, rad/s.
voltageFilterPole_Hz too high error code
IdRatedFraction_ratedFlux too low error code.
float_t fluxFraction
Defines the flux fraction for Id rated current estimation.
the controller error state
Definition: ctrl_states.h:35
_iq EST_getLs_coarse_max_pu(EST_Handle handle)
Gets the maximum stator inductance value during coarse estimation in the stator inductance estimator...
float_t forceAngleFreq_Hz
Defines the force angle frequency, Hz.
motor_numPolePairs too low error code
lock the rotor
Definition: est_states.h:65
float_t motor_Ls_q
Defines the quadrature stator inductance, H.
float_t IdRated_delta
Defines the Id rated delta current value, A.
stator inductance estimation state
Definition: est_states.h:66
uint_least32_t estWaitTime[EST_numStates]
Defines the wait times for each estimator state, estimator ticks.
systemFreq_MHz too low error code
static void PID_setKi(PID_Handle handle, const _iq Ki)
Sets the integral gain in the PID controller.
Definition: 32b/pid.h:329
motor_Rs too low error code
pwmFreq_kHz too low error code
numCurrentSensors too low error code
uint_least32_t RsWaitTime[EST_Rs_numStates]
Defines the wait times for each Rs estimator, estimator ticks.
maxAccel_Hzps too high error code
#define _IQ(A)
float_t iqFullScaleCurrent_A
Defines the full scale current for the IQ variables, A.
float_t IdRated
Defines the Id rated current value, A.
motor identified state
Definition: est_states.h:68
fluxFraction too high error code
estimate the open loop rated flux
Definition: est_states.h:62
powerWarpGain too low error code
maxAccel_Hzps too low error code
float_t motor_Rr
Defines the rotor resistance, ohm.
the ramp up state
Definition: est_Ls_states.h:49
ctrlFreq_Hz too low error code
float_t maxAccel_Hzps
Defines the maximum acceleration for the speed profiles, Hz/s.
the done state
Definition: est_Rs_states.h:42
float_t maxNegativeIdCurrent_a
Defines the maximum negative current that the Id PID is allowed to go to, A.
motor_ratedFlux too high error code
motor_Ls_q too high error code
float_t ctrlPeriod_sec
Defines the controller execution period, sec.
maxCurrentSlope_powerWarp too low error code
uint_least16_t systemFreq_MHz
Defines the system clock frequency, MHz.
offsetPole_rps too high error code
float_t CTRL_getCtrlPeriod_sec(CTRL_Handle handle)
Gets the controller execution period.
Definition: 32b/ctrl.h:161
uint_least32_t LsWaitTime[EST_Ls_numStates]
Defines the wait times for each Ls estimator, estimator ticks.
forceAngleFreq_Hz too low error code
the controller idle state
Definition: ctrl_states.h:36
iqFullScaleVoltage_V too low error code
PID_Handle pidHandle_Id
the handle for the Id PID controller
Definition: 32b/ctrl_obj.h:165
void USER_calcPIgains(CTRL_Handle handle)
Definition: 32b/user.c:855
uint_least32_t ctrlWaitTime[CTRL_numStates]
Defines the wait times for each controller state, estimator ticks.
control Id and estimate the rated flux
Definition: est_states.h:61
Defines the controller (CTRL) object.
Definition: 32b/ctrl_obj.h:144
Defines a structure for the user parameters.
USER_ErrorCode_e USER_getErrorCode(USER_Params *pUserParams)
Definition: 32b/user.c:819
uint_least8_t numCurrentSensors
Defines the number of current sensors.
float_t IdRatedFraction_ratedFlux
Defines the fraction of Id rated current to use during rated flux estimation.
motor_Rr too low error code
_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_Handle estHandle
the handle for the parameter estimator
Definition: 32b/ctrl_obj.h:160
uint_least32_t RoverL_estFreq_Hz
Defines the R/L estimation frequency, Hz.
float_t powerWarpGain
Defines the PowerWarp gain for computing Id reference.
the fine estimation state
Definition: est_Rs_states.h:41
numCtrlTicksPerCurrentTick too low error code
static _iq PID_getFbackValue(PID_Handle handle)
Gets the feedback value in the PID controller.
Definition: 32b/pid.h:102
float_t maxCurrent
Defines the maximum current value, A.
directionPole_rps too low error code
long _iq
_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
uint_least16_t numCtrlTicksPerCurrentTick
Defines the number of controller clock ticks per current controller clock tick.
iqFullScaleFreq_Hz too high error code
IdRated_delta too high error code.
#define MATH_PI
Defines pi.
Definition: 32b/math.h:101
estimate the rated flux
Definition: est_states.h:63
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).
IdRatedFraction_indEst too low error code.
motor_Ls_q too low error code
maxAccel_est_Hzps too high error code
the coarse estimation state
Definition: est_Rs_states.h:40
Rs estimation state.
Definition: est_states.h:56
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
numPwmTicksPerIsrTick too high error code
the fine estimation state
Definition: est_Ls_states.h:52
float_t voltageFilterPole_rps
Defines the analog voltage filter pole location, rad/s.
ramp down the speed
Definition: est_states.h:64
_iq EST_getLs_d_pu(EST_Handle handle)
Gets the direct stator inductance value in per unit (pu), IQ30.
current_sf too high error code
numCtrlTicksPerEstTick too low error code
motor_Rr too high error code
online parameter estimation
Definition: est_states.h:69
the Id ramp up state
Definition: est_Rs_states.h:39
speedPole_rps too high error code
numCtrlTicksPerTrajTick too low error code
float_t EST_getLs_d_H(EST_Handle handle)
Gets the direct stator inductance value in Henries (H).
directionPole_rps too high error code
float_t directionPole_rps
Defines the pole location for the direction filter, rad/s.
permanent magnet
Definition: 32b/motor.h:74
forceAngleFreq_Hz too high error code
MOTOR_Type_e motor_type
Defines the motor type.
#define _IQmpy(A, B)
void USER_softwareUpdate1p6(CTRL_Handle handle)
Definition: 32b/user.c:833
trajFreq_Hz too low error code
fluxFraction too low error code
iqFullScaleVoltage_V too high error code
float_t voltage_sf
Defines the voltage scale factor for the system.
voltageFilterPole_Hz too low error code
void USER_setParams(USER_Params *pUserParams)
Definition: 32b/user.c:58
the init state
Definition: est_Ls_states.h:50
uint_least32_t trajFreq_Hz
Defines the trajectory frequency, Hz.
_iq EST_getFlux_pu(EST_Handle handle)
Gets the flux value in per unit (pu), IQ24.
maxVsMag_pu too high error code
_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
uint_least8_t numVoltageSensors
Defines the number of voltage sensors.
float_t EST_getLs_q_H(EST_Handle handle)
Gets the stator inductance value in the quadrature coordinate direction in Henries (H)...
fluxEstFreq_Hz too low error code
estFreq_Hz too low error code
dcBusPole_rps too high error code
#define _IQ30toIQ(A)
the coarse estimation state
Definition: est_Ls_states.h:51
float_t offsetPole_rps
Defines the pole location for the voltage and current offset estimation, rad/s.
maxCurrent_resEst too high error code
motor type unknown error code
ramp up the speed
Definition: est_states.h:57
maxCurrent_indEst too low error code
speedPole_rps too low error code
float_t pwmPeriod_usec
Defines the Pulse Width Modulation (PWM) period, usec.
IdRated too high error code.
the controller online state
Definition: ctrl_states.h:38
maxCurrentSlope_powerWarp too high error code
USER_ErrorCode_e errorCode
float_t zeroSpeedLimit
Defines the low speed limit for the flux integrator, pu.
float_t current_sf
Defines the current scale factor for the system.
fluxPole_rps too high error code
maxCurrent too high error code
current_sf too low error code
closed loop control stage 2
iqFullScaleCurrent_A too low error code
void USER_setErrorCode(USER_Params *pUserParams, const USER_ErrorCode_e errorCode)
Definition: 32b/user.c:825
dcBusPole_rps too low error code
float_t indEst_speedMaxFraction
Defines the fraction of SpeedMax to use during inductance estimation.
MOTOR_Params motorParams
the motor parameters
Definition: 32b/ctrl_obj.h:189
float_t fluxEstFreq_Hz
Defines the flux estimation frequency, Hz.
_iq EST_getLs_q_pu(EST_Handle handle)
Gets the stator inductance value in the quadrature coordinate direction in per unit (pu)...
float_t IdRatedFraction_indEst
Defines the fraction of Id rated current to use during inductance estimation.
IdRatedFraction_indEst too high error code.
void USER_checkForErrors(USER_Params *pUserParams)
Definition: 32b/user.c:198
fluxEstFreq_Hz too high error code
float_t EST_getRs_Ohm(EST_Handle handle)
Gets the stator resistance value in Ohms ( ).
float_t dcBusPole_rps
Defines the pole location for the DC bus filter, rad/s.
float_t Ls_q_H
Defines the quadrature stator inductance, H.
Definition: 32b/motor.h:89
#define _IQ30(A)
IdRated too low error code.
uint_least16_t numCtrlTicksPerTrajTick
Defines the number of controller clock ticks per trajectory clock tick.
PID_Handle pidHandle_Iq
the handle for the Iq PID controller
Definition: 32b/ctrl_obj.h:168
uint_least16_t numCtrlTicksPerSpeedTick
Defines the number of controller clock ticks per speed controller clock tick.
numVoltageSensors too high error code
float_t maxCurrent_indEst
Defines the maximum current value for inductance estimation, A.
numPwmTicksPerIsrTick too low error code
maxCurrentSlope too high error code
float_t maxCurrentSlope
Defines the maximum current slope for Id current trajectory.
float_t Ls_d_H
Defines the direct stator inductance, H.
Definition: 32b/motor.h:88
float_t speedPole_rps
Defines the pole location for the speed control filter, rad/s.
float_t motor_Rs
Defines the stator resistance, ohm.
fluxPole_rps too low error code
motor_ratedFlux too low error code
uint_least16_t numIsrTicksPerCtrlTick
Defines the number of Interrupt Service Routine (ISR) clock ticks per controller clock tick...
RoverL_estFreq_Hz too high error code.
_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
R/L estimation.
Definition: est_states.h:55
voltage_sf too high error code
PID Iq controller.
Definition: 32b/ctrl_obj.h:125
maxCurrent_indEst too high error code
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.
uint_least32_t ctrlFreq_Hz
Defines the controller frequency, Hz.
numVoltageSensors too low error code
_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
maxVsMag_pu too low error code
indEst_speedMaxFraction too low error code
closed loop control stage 1
PID Id controller.
Definition: 32b/ctrl_obj.h:124
uint_least16_t motor_numPolePairs
Defines the number of pole pairs for the motor.
estKappa too low error code
uint_least16_t numCtrlTicksPerEstTick
Defines the number of controller clock ticks per estimator clock tick.
the done state
Definition: est_Ls_states.h:53
motor_Ls_d too high error code
float_t maxCurrentSlope_powerWarp
Defines the maximum current slope for Id current trajectory during PowerWarp.
pwmFreq_kHz too high error code
USER_ErrorCode_e
Enumeration for the user error codes.
uint_least32_t FluxWaitTime[EST_Flux_numStates]
Defines the wait times for each Ls estimator, estimator ticks.
float_t maxAccel_est_Hzps
Defines the maximum acceleration for the estimation speed profiles, Hz/s.
zeroSpeedLimit too low error code
#define MATH_Nm_TO_lbin_SF
Defines conversion scale factor from N*m to lb*in.
Definition: 32b/math.h:69
uint_least32_t estFreq_Hz
Defines the estimator frequency, Hz.
maxNegativeIdCurrent_a too high error code
voltage_sf too low error code
motor_Ls_d too low error code
maxCurrentSlope too low error code
rotor resistance estimation state
Definition: est_states.h:67
maxAccel_est_Hzps too low error code
maxNegativeIdCurrent_a too low error code
IdRatedFraction_ratedFlux too high error code.
fine estimate of flux
numIsrTicksPerCtrlTick too low error code
systemFreq_MHz too high error code
float_t estKappa
Defines the convergence factor for the estimator.
maxCurrent too low error code
_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
the controller offline state
Definition: ctrl_states.h:37
indEst_speedMaxFraction too high error code
IdRated_delta too low error code.
estKappa too high error code
float _IQ30toF(long A)
powerWarpGain too high error code
numCtrlTicksPerSpeedTick too low error code
numCurrentSensors too high error code
offsetPole_rps too low error code
float_t iqFullScaleFreq_Hz
Defines the full scale frequency for IQ variable, Hz.
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.
iqFullScaleFreq_Hz too low error code
zeroSpeedLimit too high error code
float float_t
Defines the portable data type for 32 bit, signed floating-point data.
Definition: types.h:121
float_t motor_Ls_d
Defines the direct stator inductance, H.
maxCurrent_resEst too low error code
float_t maxCurrent_resEst
Defines the maximum current value for resistance estimation, A.
float_t motor_ratedFlux
Defines the rated flux of the motor, V/Hz.
float_t maxVsMag_pu
Defines the maximum voltage magnitude, pu.