drive_parameters.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /**
  2. ******************************************************************************
  3. * @file drive_parameters.h
  4. * @author Motor Control SDK Team, ST Microelectronics
  5. * @brief This file contains the parameters needed for the Motor Control SDK
  6. * in order to configure a motor drive.
  7. *
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  12. * All rights reserved.</center></h2>
  13. *
  14. * This software component is licensed by ST under Ultimate Liberty license
  15. * SLA0044, the "License"; You may not use this file except in compliance with
  16. * the License. You may obtain a copy of the License at:
  17. * www.st.com/SLA0044
  18. *
  19. ******************************************************************************
  20. */
  21. /* Define to prevent recursive inclusion -------------------------------------*/
  22. #ifndef __DRIVE_PARAMETERS_H
  23. #define __DRIVE_PARAMETERS_H
  24. /************************
  25. *** Motor Parameters ***
  26. ************************/
  27. /******** MAIN AND AUXILIARY SPEED/POSITION SENSOR(S) SETTINGS SECTION ********/
  28. /*** Speed measurement settings ***/
  29. #define MAX_APPLICATION_SPEED_RPM 4000 /*!< rpm, mechanical */
  30. #define MIN_APPLICATION_SPEED_RPM 0 /*!< rpm, mechanical,
  31. absolute value */
  32. #define MEAS_ERRORS_BEFORE_FAULTS 3 /*!< Number of speed
  33. measurement errors before
  34. main sensor goes in fault */
  35. /****** Hall sensors ************/
  36. #define HALL_MEAS_ERRORS_BEFORE_FAULTS 3 /*!< Number of failed
  37. derived class specific speed
  38. measurements before main sensor
  39. goes in fault */
  40. #define HALL_AVERAGING_FIFO_DEPTH 6 /*!< depth of the FIFO used to
  41. average mechanical speed in
  42. 0.1Hz resolution */
  43. #define HALL_MTPA false
  44. /* USER CODE BEGIN angle reconstruction M1 */
  45. #define REV_PARK_ANGLE_COMPENSATION_FACTOR 0
  46. /* USER CODE END angle reconstruction M1 */
  47. /************************** DRIVE SETTINGS SECTION **********************/
  48. /* PWM generation and current reading */
  49. #define PWM_FREQUENCY 16000
  50. #define PWM_FREQ_SCALING 1
  51. #define LOW_SIDE_SIGNALS_ENABLING LS_PWM_TIMER
  52. #define SW_DEADTIME_NS 800 /*!< Dead-time to be inserted
  53. by FW, only if low side
  54. signals are enabled */
  55. /* Torque and flux regulation loops */
  56. #define REGULATION_EXECUTION_RATE 1 /*!< FOC execution rate in
  57. number of PWM cycles */
  58. /* Gains values for torque and flux control loops */
  59. #define PID_TORQUE_KP_DEFAULT 1200
  60. #define PID_TORQUE_KI_DEFAULT 600
  61. #define PID_TORQUE_KD_DEFAULT 100
  62. #define PID_FLUX_KP_DEFAULT 1200
  63. #define PID_FLUX_KI_DEFAULT 600
  64. #define PID_FLUX_KD_DEFAULT 100
  65. /* Torque/Flux control loop gains dividers*/
  66. #define TF_KPDIV 8192
  67. #define TF_KIDIV 16384
  68. #define TF_KDDIV 8192
  69. #define TF_KPDIV_LOG LOG2(8192)
  70. #define TF_KIDIV_LOG LOG2(16384)
  71. #define TF_KDDIV_LOG LOG2(8192)
  72. #define TFDIFFERENTIAL_TERM_ENABLING DISABLE
  73. /* Speed control loop */
  74. #define SPEED_LOOP_FREQUENCY_HZ 1000 /*!<Execution rate of speed
  75. regulation loop (Hz) */
  76. #define PID_SPEED_KP_DEFAULT 400/(SPEED_UNIT/10) /* Workbench compute the gain for 01Hz unit*/
  77. #define PID_SPEED_KI_DEFAULT 200/(SPEED_UNIT/10) /* Workbench compute the gain for 01Hz unit*/
  78. #define PID_SPEED_KD_DEFAULT 0/(SPEED_UNIT/10) /* Workbench compute the gain for 01Hz unit*/
  79. /* Speed PID parameter dividers */
  80. #define SP_KPDIV 16
  81. #define SP_KIDIV 256
  82. #define SP_KDDIV 16
  83. #define SP_KPDIV_LOG LOG2(16)
  84. #define SP_KIDIV_LOG LOG2(256)
  85. #define SP_KDDIV_LOG LOG2(16)
  86. /* USER CODE BEGIN PID_SPEED_INTEGRAL_INIT_DIV */
  87. #define PID_SPEED_INTEGRAL_INIT_DIV 1 /* */
  88. /* USER CODE END PID_SPEED_INTEGRAL_INIT_DIV */
  89. #define SPD_DIFFERENTIAL_TERM_ENABLING DISABLE
  90. #define IQMAX 17872
  91. /* Default settings */
  92. #define DEFAULT_CONTROL_MODE STC_SPEED_MODE /*!< STC_TORQUE_MODE or
  93. STC_SPEED_MODE */
  94. #define DEFAULT_TARGET_SPEED_RPM 1000
  95. #define DEFAULT_TARGET_SPEED_UNIT (DEFAULT_TARGET_SPEED_RPM*SPEED_UNIT/_RPM)
  96. #define DEFAULT_TORQUE_COMPONENT 0
  97. #define DEFAULT_FLUX_COMPONENT 0
  98. /************************** FIRMWARE PROTECTIONS SECTION *****************/
  99. #define OV_VOLTAGE_PROT_ENABLING ENABLE
  100. #define UV_VOLTAGE_PROT_ENABLING ENABLE
  101. #define OV_VOLTAGE_THRESHOLD_V 32 /*!< Over-voltage
  102. threshold */
  103. #define UD_VOLTAGE_THRESHOLD_V 18 /*!< Under-voltage
  104. threshold */
  105. #if 0
  106. #define ON_OVER_VOLTAGE TURN_OFF_PWM /*!< TURN_OFF_PWM,
  107. TURN_ON_R_BRAKE or
  108. TURN_ON_LOW_SIDES */
  109. #endif /* 0 */
  110. #define R_BRAKE_SWITCH_OFF_THRES_V 26
  111. #define OV_TEMPERATURE_THRESHOLD_C 70 /*!< Celsius degrees */
  112. #define OV_TEMPERATURE_HYSTERESIS_C 10 /*!< Celsius degrees */
  113. #define HW_OV_CURRENT_PROT_BYPASS DISABLE /*!< In case ON_OVER_VOLTAGE
  114. is set to TURN_ON_LOW_SIDES
  115. this feature may be used to
  116. bypass HW over-current
  117. protection (if supported by
  118. power stage) */
  119. /****************************** START-UP PARAMETERS **********************/
  120. #define TRANSITION_DURATION 25 /* Switch over duration, ms */
  121. /****************************** BUS VOLTAGE Motor 1 **********************/
  122. #define M1_VBUS_SAMPLING_TIME LL_ADC_SAMPLING_CYCLE(1)
  123. /****************************** Current sensing Motor 1 **********************/
  124. #define ADC_SAMPLING_CYCLES (1 + SAMPLING_CYCLE_CORRECTION)
  125. /****************************** ADDITIONAL FEATURES **********************/
  126. /*** On the fly start-up ***/
  127. /**************************
  128. *** Control Parameters ***
  129. **************************/
  130. /* ##@@_USER_CODE_START_##@@ */
  131. /* ##@@_USER_CODE_END_##@@ */
  132. #endif /*__DRIVE_PARAMETERS_H*/
  133. /******************* (C) COPYRIGHT 2019 STMicroelectronics *****END OF FILE****/