instaspin_foc
user.h
Go to the documentation of this file.
1 #ifndef _USER_H_
2 #define _USER_H_
3 /* --COPYRIGHT--,BSD
4  * Copyright (c) 2015, Texas Instruments Incorporated
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  *
14  * * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the distribution.
17  *
18  * * Neither the name of Texas Instruments Incorporated nor the names of
19  * its contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
26  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
32  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  * --/COPYRIGHT--*/
34 
39 
40 
41 // **************************************************************************
42 // the includes
43 
44 // modules
46 #include "sw/modules/motor/src/32b/motor.h"
47 #include "sw/modules/est/src/32b/est.h"
52 #include "sw/modules/ctrl/src/32b/ctrl_obj.h"
53 
54 
55 // platforms
56 #include "sw/modules/fast/src/32b/userParams.h"
57 
62 
63 
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
69 // **************************************************************************
70 // the defines
71 
72 
74 // **************************************************************************
78 #define USER_IQ_FULL_SCALE_FREQ_Hz (800.0) // 800 Example with buffer for 8-pole 6 KRPM motor to be run to 10 KRPM with field weakening; Hz =(RPM * Poles) / 120
79 
88 #define USER_IQ_FULL_SCALE_VOLTAGE_V (24.0) // 24.0 Set to Vbus
89 
93 #define USER_ADC_FULL_SCALE_VOLTAGE_V (44.30) // BOOSTXL-DRV8305EVM = 44.30 V
94 
97 #define USER_VOLTAGE_SF ((float_t)((USER_ADC_FULL_SCALE_VOLTAGE_V)/(USER_IQ_FULL_SCALE_VOLTAGE_V)))
98 
102 #define USER_IQ_FULL_SCALE_CURRENT_A (20.0) // BOOSTXL-DRV8305EVM = 20.0 A
103 
107 #define USER_ADC_FULL_SCALE_CURRENT_A (47.14) // BOOSTXL-DRV8305EVM = 47.14 A
108 
111 #define USER_CURRENT_SF ((float_t)((USER_ADC_FULL_SCALE_CURRENT_A)/(USER_IQ_FULL_SCALE_CURRENT_A)))
112 
116 #define USER_NUM_CURRENT_SENSORS (3) // 3 Preferred setting for best performance across full speed range, allows for 100% duty cycle
117 
120 #define USER_NUM_VOLTAGE_SENSORS (3) // 3 Required
121 
125 #define I_A_offset (1.210729778) // BOOSTXL-DRV8305EVM = 1.047175646
126 #define I_B_offset (1.209441483) // BOOSTXL-DRV8305EVM = 1.044038892
127 #define I_C_offset (1.209092796) // BOOSTXL-DRV8305EVM = 1.040363491
128 
132 #define V_A_offset (0.5084558129) // BOOSTXL-DRV8305EVM = 0.5256254077
133 #define V_B_offset (0.5074239969) // BOOSTXL-DRV8305EVM = 0.5250559449
134 #define V_C_offset (0.5065535307) // BOOSTXL-DRV8305EVM = 0.5247237682
135 
136 
138 // **************************************************************************
140 #define USER_SYSTEM_FREQ_MHz (60.0)
141 
147 #define USER_PWM_FREQ_kHz (45.0) //30.0 Example, 8.0 - 30.0 KHz typical; 45-80 KHz may be required for very low inductance, high speed motors
148 
157 #define USER_MAX_VS_MAG_PU (2.0/3.0) // Set to 0.5 if a current reconstruction technique is not used. Look at the module svgen_current in lab10a-x for more info.
158 
161 #define USER_EST_HANDLE_ADDRESS (0x600)
162 
165 #define USER_VD_SF (0.95)
166 
169 #define USER_PWM_PERIOD_usec (1000.0/USER_PWM_FREQ_kHz)
170 
173 #define USER_ISR_FREQ_Hz ((float_t)USER_PWM_FREQ_kHz * 1000.0 / (float_t)USER_NUM_PWM_TICKS_PER_ISR_TICK)
174 
177 #define USER_ISR_PERIOD_usec (USER_PWM_PERIOD_usec * (float_t)USER_NUM_PWM_TICKS_PER_ISR_TICK)
178 
179 
181 // **************************************************************************
184 #define USER_NUM_PWM_TICKS_PER_ISR_TICK (3)
185 
193 #define USER_NUM_ISR_TICKS_PER_CTRL_TICK (1) // 2 Example, controller clock rate (CTRL) runs at PWM / 2; ex 30 KHz PWM, 15 KHz control
194 
197 #define USER_NUM_CTRL_TICKS_PER_CURRENT_TICK (1) // 1 Typical, Forward FOC current controller (Iq/Id/IPARK/SVPWM) runs at same rate as CTRL.
198 
202 #define USER_NUM_CTRL_TICKS_PER_EST_TICK (1) // 1 Typical, FAST estimator runs at same rate as CTRL;
203 
206 #define USER_NUM_CTRL_TICKS_PER_SPEED_TICK (15) // 15 Typical to match PWM, ex: 15KHz PWM, controller, and current loop, 1KHz speed loop
207 
211 #define USER_NUM_CTRL_TICKS_PER_TRAJ_TICK (15) // 15 Typical to match PWM, ex: 10KHz controller & current loop, 1KHz speed loop, 1 KHz Trajectory
212 
215 #define USER_CTRL_FREQ_Hz (uint_least32_t)(USER_ISR_FREQ_Hz/USER_NUM_ISR_TICKS_PER_CTRL_TICK)
216 
219 #define USER_EST_FREQ_Hz (uint_least32_t)(USER_CTRL_FREQ_Hz/USER_NUM_CTRL_TICKS_PER_EST_TICK)
220 
223 #define USER_TRAJ_FREQ_Hz (uint_least32_t)(USER_CTRL_FREQ_Hz/USER_NUM_CTRL_TICKS_PER_TRAJ_TICK)
224 
227 #define USER_CTRL_PERIOD_usec (USER_ISR_PERIOD_usec * USER_NUM_ISR_TICKS_PER_CTRL_TICK)
228 
231 #define USER_CTRL_PERIOD_sec ((float_t)USER_CTRL_PERIOD_usec/(float_t)1000000.0)
232 
233 
235 // **************************************************************************
239 #define USER_MAX_NEGATIVE_ID_REF_CURRENT_A (-0.5 * USER_MOTOR_MAX_CURRENT) // -0.5 * USER_MOTOR_MAX_CURRENT Example, adjust to meet safety needs of your motor
240 
244 #define USER_ZEROSPEEDLIMIT (0.5 / USER_IQ_FULL_SCALE_FREQ_Hz) // 0.002 pu, 1-5 Hz typical; Hz = USER_ZEROSPEEDLIMIT * USER_IQ_FULL_SCALE_FREQ_Hz
245 
249 #define USER_FORCE_ANGLE_FREQ_Hz (2.0 * USER_ZEROSPEEDLIMIT * USER_IQ_FULL_SCALE_FREQ_Hz) // Default will keep FREQ >= 2.0 * low speed limit for the flux integrator
250 
253 #define USER_MAX_CURRENT_SLOPE_POWERWARP (0.3*USER_MOTOR_RES_EST_CURRENT/USER_IQ_FULL_SCALE_CURRENT_A/USER_TRAJ_FREQ_Hz) // 0.3*RES_EST_CURRENT / IQ_FULL_SCALE_CURRENT / TRAJ_FREQ Typical to produce 1-sec rampup/down
254 
258 #define USER_MAX_ACCEL_Hzps (20.0) // 20.0 Default
259 
262 #define USER_MAX_ACCEL_EST_Hzps (5.0) // 5.0 Default, don't change
263 
265 #define USER_MAX_CURRENT_SLOPE (USER_MOTOR_RES_EST_CURRENT/USER_IQ_FULL_SCALE_CURRENT_A/USER_TRAJ_FREQ_Hz) // USER_MOTOR_RES_EST_CURRENT/USER_IQ_FULL_SCALE_CURRENT_A/USER_TRAJ_FREQ_Hz Default, don't change
266 
269 #define USER_IDRATED_FRACTION_FOR_RATED_FLUX (1.0) // 1.0 Default, don't change
270 
273 #define USER_IDRATED_FRACTION_FOR_L_IDENT (1.0) // 1.0 Default, don't change
274 
277 #define USER_IDRATED_DELTA (0.00002)
278 
281 #define USER_SPEEDMAX_FRACTION_FOR_L_IDENT (1.0) // 1.0 Default, don't change
282 
285 #define USER_FLUX_FRACTION (1.0) // 1.0 Default, don't change
286 
289 #define USER_POWERWARP_GAIN (1.0) // 1.0 Default, don't change
290 
294 #define USER_R_OVER_L_EST_FREQ_Hz (300) // 300 Default for high speed motors, can reduce to 100 if RoverL from Motor ID is < 2000
295 
296 
298 // **************************************************************************
301 #define USER_VOLTAGE_FILTER_POLE_Hz (344.62) // BOOSTXL-DRV8305 = 344.62 Hz
302 
305 #define USER_VOLTAGE_FILTER_POLE_rps (2.0 * MATH_PI * USER_VOLTAGE_FILTER_POLE_Hz)
306 
309 #define USER_OFFSET_POLE_rps (20.0) // 20.0 Default, do not change
310 
313 #define USER_FLUX_POLE_rps (100.0) // 100.0 Default, do not change
314 
316 #define USER_DIRECTION_POLE_rps (6.0) // 6.0 Default, do not change
317 
319 #define USER_SPEED_POLE_rps (100.0) // 100.0 Default, do not change
320 
322 #define USER_DCBUS_POLE_rps (100.0) // 100.0 Default, do not change
323 
326 #define USER_EST_KAPPAQ (1.5) // 1.5 Default, do not change
327 
328 // **************************************************************************
329 // end the defines
330 
331 
333 // **************************************************************************
334 
336 // BLDC & SMPM motors
337 #define Estun_EMJ_04APB22 101
338 #define Anaheim_BLY172S 102
339 #define My_Motor 104
340 #define hobby_3p5T 105
341 #define hobby_4p5T 106
342 #define small_hobby 107
343 #define teknic_2310P 108
344 #define hobbywing_ezrun_8p5T 109
345 #define eflite_helicopter_420 110
346 #define Bodine_34B3FEBL 114
347 #define Pittman_elcom_5233B599 115
348 #define medical_instrument 117
349 #define Test_Motor 118
350 // IPM motors
351 // If user provides separate Ls-d, Ls-q
352 // else treat as SPM with user or identified average Ls
353 #define Belt_Drive_Washer_IPM 201
354 
355 // ACIM motors
356 #define Marathon_5K33GN2A 301
357 #define Kinetek_YDQ1p3_4 302
358 #define LPKF_CAD_CAM 303
359 
363 //#define USER_MOTOR Estun_EMJ_04APB22
364 #define USER_MOTOR Anaheim_BLY172S
365 //#define USER_MOTOR hobby_3p5T
366 //#define USER_MOTOR hobby_4p5T
367 //#define USER_MOTOR My_Motor
368 //#define USER_MOTOR small_hobby
369 //#define USER_MOTOR Belt_Drive_Washer_IPM
370 //#define USER_MOTOR Marathon_5K33GN2A
371 //#define USER_MOTOR teknic_2310P
372 //#define USER_MOTOR hobbywing_ezrun_8p5T
373 //#define USER_MOTOR eflite_helicopter_420
374 //#define USER_MOTOR Bodine_34B3FEBL
375 //#define USER_MOTOR Pittman_elcom_5233B599
376 //#define USER_MOTOR medical_instrument
377 //#define USER_MOTOR Test_Motor
378 //#define USER_MOTOR Kinetek_YDQ1p3_4
379 //#define USER_MOTOR LPKF_CAD_CAM
380 
381 
382 #if (USER_MOTOR == Estun_EMJ_04APB22) // Name must match the motor #define
383 #define USER_MOTOR_TYPE MOTOR_Type_Pm // Motor_Type_Pm (All Synchronous: BLDC, PMSM, SMPM, IPM) or Motor_Type_Induction (Asynchronous ACI)
384 #define USER_MOTOR_NUM_POLE_PAIRS (4) // PAIRS, not total poles. Used to calculate user RPM from rotor Hz only
385 #define USER_MOTOR_Rr (NULL) // Induction motors only, else NULL
386 #define USER_MOTOR_Rs (2.303403) // Identified phase to neutral resistance in a Y equivalent circuit (Ohms, float)
387 #define USER_MOTOR_Ls_d (0.008464367) // For PM, Identified average stator inductance (Henry, float)
388 #define USER_MOTOR_Ls_q (0.008464367) // For PM, Identified average stator inductance (Henry, float)
389 #define USER_MOTOR_RATED_FLUX (0.38) // Identified TOTAL flux linkage between the rotor and the stator (V/Hz)
390 #define USER_MOTOR_MAGNETIZING_CURRENT (NULL) // Induction motors only, else NULL
391 #define USER_MOTOR_RES_EST_CURRENT (1.0) // During Motor ID, maximum current (Amperes, float) used for Rs estimation, 10-20% rated current
392 #define USER_MOTOR_IND_EST_CURRENT (-1.0) // During Motor ID, maximum current (negative Amperes, float) used for Ls estimation, use just enough to enable rotation
393 #define USER_MOTOR_MAX_CURRENT (3.82) // CRITICAL: Used during ID and run-time, sets a limit on the maximum current command output of the provided Speed PI Controller to the Iq controller
394 #define USER_MOTOR_FLUX_EST_FREQ_Hz (20.0) // During Motor ID, maximum commanded speed (Hz, float), ~10% rated
395 
396 #elif (USER_MOTOR == Anaheim_BLY172S)
397 #define USER_MOTOR_TYPE MOTOR_Type_Pm
398 #define USER_MOTOR_NUM_POLE_PAIRS (4)
399 #define USER_MOTOR_Rr (NULL)
400 #define USER_MOTOR_Rs (0.3968007)
401 #define USER_MOTOR_Ls_d (0.0006708066)
402 #define USER_MOTOR_Ls_q (0.0006708066)
403 #define USER_MOTOR_RATED_FLUX (0.03433958)
404 #define USER_MOTOR_MAGNETIZING_CURRENT (NULL)
405 #define USER_MOTOR_RES_EST_CURRENT (1.0)
406 #define USER_MOTOR_IND_EST_CURRENT (-1.0)
407 #define USER_MOTOR_MAX_CURRENT (5.0)
408 #define USER_MOTOR_FLUX_EST_FREQ_Hz (20.0)
409 
410 #elif (USER_MOTOR == small_hobby)
411 #define USER_MOTOR_TYPE MOTOR_Type_Pm
412 #define USER_MOTOR_NUM_POLE_PAIRS (6)
413 #define USER_MOTOR_Rr (NULL)
414 #define USER_MOTOR_Rs (1.277921)
415 #define USER_MOTOR_Ls_d (0.0001230481)
416 #define USER_MOTOR_Ls_q (0.0001230481)
417 #define USER_MOTOR_RATED_FLUX (0.004417491)
418 #define USER_MOTOR_MAGNETIZING_CURRENT (NULL)
419 #define USER_MOTOR_RES_EST_CURRENT (0.5)
420 #define USER_MOTOR_IND_EST_CURRENT (-0.5)
421 #define USER_MOTOR_MAX_CURRENT (5.0)
422 #define USER_MOTOR_FLUX_EST_FREQ_Hz (200.0)
423 
424 #elif (USER_MOTOR == teknic_2310P)
425 #define USER_MOTOR_TYPE MOTOR_Type_Pm
426 #define USER_MOTOR_NUM_POLE_PAIRS (4)
427 #define USER_MOTOR_Rr (NULL)
428 #define USER_MOTOR_Rs (0.3654691)
429 #define USER_MOTOR_Ls_d (0.0002068772)
430 #define USER_MOTOR_Ls_q (0.0002068772)
431 #define USER_MOTOR_RATED_FLUX (0.04052209)
432 #define USER_MOTOR_MAGNETIZING_CURRENT (NULL)
433 #define USER_MOTOR_RES_EST_CURRENT (1.0)
434 #define USER_MOTOR_IND_EST_CURRENT (-1.0)
435 #define USER_MOTOR_MAX_CURRENT (5.0)
436 #define USER_MOTOR_FLUX_EST_FREQ_Hz (20.0)
437 
438 #elif (USER_MOTOR == hobby_3p5T)
439 #define USER_MOTOR_TYPE MOTOR_Type_Pm
440 #define USER_MOTOR_NUM_POLE_PAIRS (4)
441 #define USER_MOTOR_Rr (NULL)
442 #define USER_MOTOR_Rs (0.0149275)
443 #define USER_MOTOR_Ls_d (2.575126e-06)
444 #define USER_MOTOR_Ls_q (2.575126e-06)
445 #define USER_MOTOR_RATED_FLUX (0.003589415)
446 #define USER_MOTOR_MAGNETIZING_CURRENT (NULL)
447 #define USER_MOTOR_RES_EST_CURRENT (15.0)
448 #define USER_MOTOR_IND_EST_CURRENT (-5.0)
449 #define USER_MOTOR_MAX_CURRENT (30.0)
450 #define USER_MOTOR_FLUX_EST_FREQ_Hz (60.0)
451 
452 #elif (USER_MOTOR == hobby_4p5T)
453 #define USER_MOTOR_TYPE MOTOR_Type_Pm
454 #define USER_MOTOR_NUM_POLE_PAIRS (4)
455 #define USER_MOTOR_Rr (NULL)
456 #define USER_MOTOR_Rs (0.01420126)
457 #define USER_MOTOR_Ls_d (6.466606e-06)
458 #define USER_MOTOR_Ls_q (6.466606e-06)
459 #define USER_MOTOR_RATED_FLUX (0.004845501)
460 #define USER_MOTOR_MAGNETIZING_CURRENT (NULL)
461 #define USER_MOTOR_RES_EST_CURRENT (5.0)
462 #define USER_MOTOR_IND_EST_CURRENT (-5.0)
463 #define USER_MOTOR_MAX_CURRENT (10.0)
464 #define USER_MOTOR_FLUX_EST_FREQ_Hz (60.0)
465 
466 #elif (USER_MOTOR == hobbywing_ezrun_8p5T)
467 #define USER_MOTOR_TYPE MOTOR_Type_Pm
468 #define USER_MOTOR_NUM_POLE_PAIRS (1)
469 #define USER_MOTOR_Rr (NULL)
470 #define USER_MOTOR_Rs (0.01366183)
471 #define USER_MOTOR_Ls_d (1.556967e-05)
472 #define USER_MOTOR_Ls_q (1.556967e-05)
473 #define USER_MOTOR_RATED_FLUX (0.009272549)
474 #define USER_MOTOR_MAGNETIZING_CURRENT (NULL)
475 #define USER_MOTOR_RES_EST_CURRENT (3.0)
476 #define USER_MOTOR_IND_EST_CURRENT (-2.0)
477 #define USER_MOTOR_MAX_CURRENT (10.0)
478 #define USER_MOTOR_FLUX_EST_FREQ_Hz (60.0)
479 
480 #elif (USER_MOTOR == eflite_helicopter_420)
481 #define USER_MOTOR_TYPE MOTOR_Type_Pm
482 #define USER_MOTOR_NUM_POLE_PAIRS (3)
483 #define USER_MOTOR_Rr (NULL)
484 #define USER_MOTOR_Rs (0.01953091)
485 #define USER_MOTOR_Ls_d (2.998549e-06)
486 #define USER_MOTOR_Ls_q (2.998549e-06)
487 #define USER_MOTOR_RATED_FLUX (0.003449948)
488 #define USER_MOTOR_MAGNETIZING_CURRENT (NULL)
489 #define USER_MOTOR_RES_EST_CURRENT (3.0)
490 #define USER_MOTOR_IND_EST_CURRENT (-3.0)
491 #define USER_MOTOR_MAX_CURRENT (15.0)
492 #define USER_MOTOR_FLUX_EST_FREQ_Hz (80.0)
493 
494 #elif (USER_MOTOR == Bodine_34B3FEBL)
495 #define USER_MOTOR_TYPE MOTOR_Type_Pm
496 #define USER_MOTOR_NUM_POLE_PAIRS (2)
497 #define USER_MOTOR_Rr (NULL)
498 #define USER_MOTOR_Rs (0.1749963)
499 #define USER_MOTOR_Ls_d (0.000843199)
500 #define USER_MOTOR_Ls_q (0.000843199)
501 #define USER_MOTOR_RATED_FLUX (0.1139098)
502 #define USER_MOTOR_MAGNETIZING_CURRENT (NULL)
503 #define USER_MOTOR_RES_EST_CURRENT (1.0)
504 #define USER_MOTOR_IND_EST_CURRENT (-1.0)
505 #define USER_MOTOR_MAX_CURRENT (10.0)
506 #define USER_MOTOR_FLUX_EST_FREQ_Hz (20.0)
507 
508 #elif (USER_MOTOR == Pittman_elcom_5233B599)
509 #define USER_MOTOR_TYPE MOTOR_Type_Pm
510 #define USER_MOTOR_NUM_POLE_PAIRS (2)
511 #define USER_MOTOR_Rr (NULL)
512 #define USER_MOTOR_Rs (0.3675933)
513 #define USER_MOTOR_Ls_d (0.0001611779)
514 #define USER_MOTOR_Ls_q (0.0001611779)
515 #define USER_MOTOR_RATED_FLUX (0.1274101)
516 #define USER_MOTOR_MAGNETIZING_CURRENT (NULL)
517 #define USER_MOTOR_RES_EST_CURRENT (0.5)
518 #define USER_MOTOR_IND_EST_CURRENT (-0.5)
519 #define USER_MOTOR_MAX_CURRENT (5.0)
520 #define USER_MOTOR_FLUX_EST_FREQ_Hz (20.0)
521 
522 #elif (USER_MOTOR == medical_instrument)
523 #define USER_MOTOR_TYPE MOTOR_Type_Pm
524 #define USER_MOTOR_NUM_POLE_PAIRS (2)
525 #define USER_MOTOR_Rr (NULL)
526 #define USER_MOTOR_Rs (0.3858043)
527 #define USER_MOTOR_Ls_d (9.675411e-06)
528 #define USER_MOTOR_Ls_q (9.675411e-06)
529 #define USER_MOTOR_RATED_FLUX (0.006834516)
530 #define USER_MOTOR_MAGNETIZING_CURRENT (NULL)
531 #define USER_MOTOR_RES_EST_CURRENT (0.5)
532 #define USER_MOTOR_IND_EST_CURRENT (-0.5)
533 #define USER_MOTOR_MAX_CURRENT (10.0)
534 #define USER_MOTOR_FLUX_EST_FREQ_Hz (100.0)
535 
536 #elif (USER_MOTOR == Test_Motor)
537 #define USER_MOTOR_TYPE MOTOR_Type_Pm
538 #define USER_MOTOR_NUM_POLE_PAIRS (6)
539 #define USER_MOTOR_Rr (NULL)
540 #define USER_MOTOR_Rs (0.05910907)
541 #define USER_MOTOR_Ls_d (7.49289e-06)
542 #define USER_MOTOR_Ls_q (7.49289e-06)
543 #define USER_MOTOR_RATED_FLUX (0.003744936)
544 #define USER_MOTOR_MAGNETIZING_CURRENT (NULL)
545 #define USER_MOTOR_RES_EST_CURRENT (1.5)
546 #define USER_MOTOR_IND_EST_CURRENT (-1.0)
547 #define USER_MOTOR_MAX_CURRENT (8.0)
548 #define USER_MOTOR_FLUX_EST_FREQ_Hz (100.0)
549 
550 #elif (USER_MOTOR == My_Motor)
551 #define USER_MOTOR_TYPE MOTOR_Type_Pm
552 #define USER_MOTOR_NUM_POLE_PAIRS (2)
553 #define USER_MOTOR_Rr (NULL)
554 #define USER_MOTOR_Rs (0.3918252)
555 #define USER_MOTOR_Ls_d (0.00023495)
556 #define USER_MOTOR_Ls_q (0.00023495)
557 #define USER_MOTOR_RATED_FLUX (0.03955824)
558 #define USER_MOTOR_MAGNETIZING_CURRENT (NULL)
559 #define USER_MOTOR_RES_EST_CURRENT (3.0)
560 #define USER_MOTOR_IND_EST_CURRENT (-0.5)
561 #define USER_MOTOR_MAX_CURRENT (20.0)
562 #define USER_MOTOR_FLUX_EST_FREQ_Hz (20.0)
563 
564 #elif (USER_MOTOR == Belt_Drive_Washer_IPM)
565 #define USER_MOTOR_TYPE MOTOR_Type_Pm
566 #define USER_MOTOR_NUM_POLE_PAIRS (4)
567 #define USER_MOTOR_Rr (NULL)
568 #define USER_MOTOR_Rs (2.832002)
569 #define USER_MOTOR_Ls_d (0.0115)
570 #define USER_MOTOR_Ls_q (0.0135)
571 #define USER_MOTOR_RATED_FLUX (0.5022156)
572 #define USER_MOTOR_MAGNETIZING_CURRENT (NULL)
573 #define USER_MOTOR_RES_EST_CURRENT (1.0)
574 #define USER_MOTOR_IND_EST_CURRENT (-1.0)
575 #define USER_MOTOR_MAX_CURRENT (4.0)
576 #define USER_MOTOR_FLUX_EST_FREQ_Hz (20.0)
577 
578 #elif (USER_MOTOR == Marathon_5K33GN2A) // Name must match the motor #define
579 #define USER_MOTOR_TYPE MOTOR_Type_Induction // Motor_Type_Pm (All Synchronous: BLDC, PMSM, SMPM, IPM) or Motor_Type_Induction (Asynchronous ACI)
580 #define USER_MOTOR_NUM_POLE_PAIRS (2) // PAIRS, not total poles. Used to calculate user RPM from rotor Hz only
581 #define USER_MOTOR_Rr (5.508003) // Identified phase to neutral in a Y equivalent circuit (Ohms, float)
582 #define USER_MOTOR_Rs (10.71121) // Identified phase to neutral in a Y equivalent circuit (Ohms, float)
583 #define USER_MOTOR_Ls_d (0.05296588) // For Induction, Identified average stator inductance (Henry, float)
584 #define USER_MOTOR_Ls_q (0.05296588) // For Induction, Identified average stator inductance (Henry, float)
585 #define USER_MOTOR_RATED_FLUX (0.8165*220.0/60.0) // sqrt(2/3)* Rated V (line-line) / Rated Freq (Hz)
586 #define USER_MOTOR_MAGNETIZING_CURRENT (1.378) // Identified magnetizing current for induction motors, else NULL
587 #define USER_MOTOR_RES_EST_CURRENT (0.5) // During Motor ID, maximum current (Amperes, float) used for Rs estimation, 10-20% rated current
588 #define USER_MOTOR_IND_EST_CURRENT (NULL) // not used for induction
589 #define USER_MOTOR_MAX_CURRENT (2.0) // CRITICAL: Used during ID and run-time, sets a limit on the maximum current command output of the provided Speed PI Controller to the Iq controller
590 #define USER_MOTOR_FLUX_EST_FREQ_Hz (5.0) // During Motor ID, maximum commanded speed (Hz, float). Should always use 5 Hz for Induction.
591 
592 #elif (USER_MOTOR == Kinetek_YDQ1p3_4)
593 #define USER_MOTOR_TYPE MOTOR_Type_Induction
594 #define USER_MOTOR_NUM_POLE_PAIRS (2)
595 #define USER_MOTOR_Rr (0.0)
596 #define USER_MOTOR_Rs (0.0)
597 #define USER_MOTOR_Ls_d (0.0)
598 #define USER_MOTOR_Ls_q (USER_MOTOR_Ls_d)
599 #define USER_MOTOR_RATED_FLUX (0.8165*16.0/120.0 - USER_MOTOR_Ls_d*USER_MOTOR_MAGNETIZING_CURRENT*2*MATH_PI)
600 #define USER_MOTOR_MAGNETIZING_CURRENT (0.0)
601 #define USER_MOTOR_RES_EST_CURRENT (20.0)
602 #define USER_MOTOR_IND_EST_CURRENT (NULL)
603 #define USER_MOTOR_MAX_CURRENT (40.0)
604 #define USER_MOTOR_FLUX_EST_FREQ_Hz (5.0)
605 
606 #elif (USER_MOTOR == LPKF_CAD_CAM)
607 #define USER_MOTOR_TYPE MOTOR_Type_Induction
608 #define USER_MOTOR_NUM_POLE_PAIRS (1)
609 #define USER_MOTOR_Rr (0.1832338)
610 #define USER_MOTOR_Rs (0.2610424)
611 #define USER_MOTOR_Ls_d (1.370321e-09)
612 #define USER_MOTOR_Ls_q (USER_MOTOR_Ls_d)
613 #define USER_MOTOR_RATED_FLUX (0.8165*30.0/1000.0 - USER_MOTOR_Ls_d*USER_MOTOR_MAGNETIZING_CURRENT*2*MATH_PI)
614 #define USER_MOTOR_MAGNETIZING_CURRENT (3.386112)
615 #define USER_MOTOR_RES_EST_CURRENT (3.0)
616 #define USER_MOTOR_IND_EST_CURRENT (NULL)
617 #define USER_MOTOR_MAX_CURRENT (5.0)
618 #define USER_MOTOR_FLUX_EST_FREQ_Hz (20.0)
619 
620 
621 #else
622 #error No motor type specified
623 #endif
624 
625 #ifndef USER_MOTOR
626 #error Motor is not defined in user.h
627 #endif
628 
629 #ifndef USER_MOTOR_TYPE
630 #error The motor type is not defined in user.h
631 #endif
632 
633 #ifndef USER_MOTOR_NUM_POLE_PAIRS
634 #error Number of motor pole pairs is not defined in user.h
635 #endif
636 
637 #ifndef USER_MOTOR_Rr
638 #error The rotor resistance is not defined in user.h
639 #endif
640 
641 #ifndef USER_MOTOR_Rs
642 #error The stator resistance is not defined in user.h
643 #endif
644 
645 #ifndef USER_MOTOR_Ls_d
646 #error The direct stator inductance is not defined in user.h
647 #endif
648 
649 #ifndef USER_MOTOR_Ls_q
650 #error The quadrature stator inductance is not defined in user.h
651 #endif
652 
653 #ifndef USER_MOTOR_RATED_FLUX
654 #error The rated flux of motor is not defined in user.h
655 #endif
656 
657 #ifndef USER_MOTOR_MAGNETIZING_CURRENT
658 #error The magnetizing current is not defined in user.h
659 #endif
660 
661 #ifndef USER_MOTOR_RES_EST_CURRENT
662 #error The resistance estimation current is not defined in user.h
663 #endif
664 
665 #ifndef USER_MOTOR_IND_EST_CURRENT
666 #error The inductance estimation current is not defined in user.h
667 #endif
668 
669 #ifndef USER_MOTOR_MAX_CURRENT
670 #error The maximum current is not defined in user.h
671 #endif
672 
673 #ifndef USER_MOTOR_FLUX_EST_FREQ_Hz
674 #error The flux estimation frequency is not defined in user.h
675 #endif
676 
677 
678 // **************************************************************************
679 // the functions
680 
681 
684 extern void USER_setParams(USER_Params *pUserParams);
685 
686 
689 extern void USER_checkForErrors(USER_Params *pUserParams);
690 
691 
695 extern USER_ErrorCode_e USER_getErrorCode(USER_Params *pUserParams);
696 
697 
701 extern void USER_setErrorCode(USER_Params *pUserParams,const USER_ErrorCode_e errorCode);
702 
703 
706 extern void USER_softwareUpdate1p6(CTRL_Handle handle);
707 
708 
711 extern void USER_calcPIgains(CTRL_Handle handle);
712 
713 
717 
718 
722 
723 
726 extern _iq USER_computeFlux_pu_to_Wb_sf(void);
727 
728 
732 
733 
738 extern _iq USER_computeFlux(CTRL_Handle handle, const _iq sf);
739 
740 
746 extern _iq USER_computeTorque_Nm(CTRL_Handle handle, const _iq torque_Flux_sf, const _iq torque_Ls_sf);
747 
748 
754 extern _iq USER_computeTorque_lbin(CTRL_Handle handle, const _iq torque_Flux_sf, const _iq torque_Ls_sf);
755 
756 
757 #ifdef __cplusplus
758 }
759 #endif // extern "C"
760 
762 #endif // end of _USER_H_ definition
763 
_iq USER_computeFlux_pu_to_Wb_sf(void)
Computes the scale factor needed to convert from per unit to Wb.
USER_ErrorCode_e USER_getErrorCode(USER_Params *pUserParams)
Gets the error code in the user parameters.
_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...
void USER_setErrorCode(USER_Params *pUserParams, const USER_ErrorCode_e errorCode)
Sets the error code in the user parameters.
_iq USER_computeFlux(CTRL_Handle handle, const _iq sf)
Computes Flux in Wb or V/Hz depending on the scale factor sent as parameter.
void USER_checkForErrors(USER_Params *pUserParams)
Checks for errors in the user parameter values.
_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...
long _iq
void USER_softwareUpdate1p6(CTRL_Handle handle)
Recalculates Inductances with the correct Q Format.
void USER_calcPIgains(CTRL_Handle handle)
Updates Id and Iq PI gains.
_iq USER_computeTorque_lbin(CTRL_Handle handle, const _iq torque_Flux_sf, const _iq torque_Ls_sf)
Computes Torque in lbin.
_iq USER_computeFlux_pu_to_VpHz_sf(void)
Computes the scale factor needed to convert from per unit to V/Hz.
_iq USER_computeTorque_Nm(CTRL_Handle handle, const _iq torque_Flux_sf, const _iq torque_Ls_sf)
Computes Torque in Nm.
USER_ErrorCode_e
void USER_setParams(USER_Params *pUserParams)
Sets the user parameter values.