首页下载资源后端ST MCSDK 电机FOC库(添加中文注释)

ZIPST MCSDK 电机FOC库(添加中文注释)

qq_21537539254.85KB需要积分:1

资源文件列表:

MCSDK_v5.4.8.zip 大约有104个文件
  1. MCSDK_v5.4.8/MotorControl/
  2. MCSDK_v5.4.8/MotorControl/MCSDK/
  3. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/
  4. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/
  5. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/
  6. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/bus_voltage_sensor.h 3.27KB
  7. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/circle_limitation.h 2.24KB
  8. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/digital_output.h 3.21KB
  9. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/enc_align_ctrl.h 4.4KB
  10. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/encoder_speed_pos_fdbk.h 4.41KB
  11. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/fast_div.h 2.31KB
  12. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/feed_forward_ctrl.h 7.27KB
  13. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/flux_weakening_ctrl.h 7.42KB
  14. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/gap_gate_driver_ctrl.h 14.33KB
  15. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/hall_speed_pos_fdbk.h 10.1KB
  16. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/hifreqinj_fpu_ctrl.h 1.87KB
  17. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/ics_dd_pwmncurrfdbk.h 5.97KB
  18. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/inrush_current_limiter.h 3.3KB
  19. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/max_torque_per_ampere.h 2.18KB
  20. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/mc_tuning.h 26.86KB
  21. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/mc_type.h 10.58KB
  22. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/motor_power_measurement.h 3.8KB
  23. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/mp_one_touch_tuning.h 12.55KB
  24. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/mp_self_com_ctrl.h 19.78KB
  25. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/ntc_temperature_sensor.h 4.88KB
  26. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/open_loop.h 3.58KB
  27. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/pid_regulator.h 8.35KB
  28. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/pqd_motor_power_measurement.h 2.77KB
  29. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/pwm_common.h 2.49KB
  30. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/pwm_curr_fdbk.h 14.95KB
  31. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/r_divider_bus_voltage_sensor.h 3.88KB
  32. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/r1_dd_pwm_curr_fdbk.h 5.89KB
  33. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/ramp_ext_mngr.h 3.13KB
  34. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/revup_ctrl.h 8.62KB
  35. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/speed_pos_fdbk.h 4.77KB
  36. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/speed_torq_ctrl.h 8.66KB
  37. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/state_machine.h 9.14KB
  38. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/sto_cordic_speed_pos_fdbk.h 14.11KB
  39. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/sto_pll_speed_pos_fdbk.h 14.65KB
  40. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/sto_speed_pos_fdbk.h 2.5KB
  41. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/trajectory_ctrl.h 4.18KB
  42. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/virtual_bus_voltage_sensor.h 2.41KB
  43. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Inc/virtual_speed_sensor.h 6.04KB
  44. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/
  45. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/bus_voltage_sensor.c 3.34KB
  46. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/circle_limitation.c 4.34KB
  47. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/digital_output.c 2.46KB
  48. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/enc_align_ctrl.c 5.27KB
  49. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/encoder_speed_pos_fdbk.c 12.28KB
  50. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/fast_div.c 7.16KB
  51. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/feed_forward_ctrl.c 11.88KB
  52. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/flux_weakening_ctrl.c 10.89KB
  53. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/gap_gate_driver_ctrl.c 24.73KB
  54. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/hall_speed_pos_fdbk.c 25.85KB
  55. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/hifreqinj_fpu_ctrl.c 33.23KB
  56. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/inrush_current_limiter.c 5.21KB
  57. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/max_torque_per_ampere.c 5.25KB
  58. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/motor_power_measurement.c 4.02KB
  59. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/ntc_temperature_sensor.c 6.44KB
  60. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/open_loop.c 3.42KB
  61. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/pid_regulator.c 14KB
  62. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/pqd_motor_power_measurement.c 2.79KB
  63. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/pwm_common.c 5.68KB
  64. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/pwm_curr_fdbk.c 19.5KB
  65. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/r_divider_bus_voltage_sensor.c 5.8KB
  66. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/ramp_ext_mngr.c 8.02KB
  67. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/revup_ctrl.c 21.81KB
  68. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/speed_pos_fdbk.c 10.43KB
  69. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/speed_torq_ctrl.c 16.82KB
  70. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/state_machine.c 10.25KB
  71. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/sto_cordic_speed_pos_fdbk.c 34.41KB
  72. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/sto_pll_speed_pos_fdbk.c 35.25KB
  73. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/trajectory_ctrl.c 14.49KB
  74. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/virtual_bus_voltage_sensor.c 2.41KB
  75. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/Any/Src/virtual_speed_sensor.c 16.09KB
  76. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/G4xx/
  77. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/G4xx/Inc/
  78. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/G4xx/Inc/ics_g4xx_pwm_curr_fdbk.h 8.03KB
  79. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/G4xx/Inc/r1_g4xx_pwm_curr_fdbk.h 10.89KB
  80. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/G4xx/Inc/r3_2_g4xx_pwm_curr_fdbk.h 13.5KB
  81. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/G4xx/Inc/r3_3_g4xx_pwm_curr_fdbk.h 18.32KB
  82. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/G4xx/Src/
  83. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/G4xx/Src/ics_g4xx_pwm_curr_fdbk.c 25.25KB
  84. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/G4xx/Src/r1_g4xx_pwm_curr_fdbk.c 45.83KB
  85. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/G4xx/Src/r3_2_g4xx_pwm_curr_fdbk.c 55.33KB
  86. MCSDK_v5.4.8/MotorControl/MCSDK/MCLib/G4xx/Src/r3_3_g4xx_pwm_curr_fdbk.c 53.95KB
  87. MCSDK_v5.4.8/MotorControl/MCSDK/SystemDriveParams/
  88. MCSDK_v5.4.8/MotorControl/MCSDK/UILibrary/
  89. MCSDK_v5.4.8/MotorControl/MCSDK/UILibrary/Inc/
  90. MCSDK_v5.4.8/MotorControl/MCSDK/UILibrary/Inc/dac_common_ui.h 2.82KB
  91. MCSDK_v5.4.8/MotorControl/MCSDK/UILibrary/Inc/dac_rctimer_ui.h 1.61KB
  92. MCSDK_v5.4.8/MotorControl/MCSDK/UILibrary/Inc/dac_ui.h 1.67KB
  93. MCSDK_v5.4.8/MotorControl/MCSDK/UILibrary/Inc/frame_communication_protocol.h 7.07KB
  94. MCSDK_v5.4.8/MotorControl/MCSDK/UILibrary/Inc/ui_irq_handler.h 4.71KB
  95. MCSDK_v5.4.8/MotorControl/MCSDK/UILibrary/Inc/UIIRQHandlerClass.h 930B
  96. MCSDK_v5.4.8/MotorControl/MCSDK/UILibrary/Inc/UIIRQHandlerPrivate.h 1.21KB
  97. MCSDK_v5.4.8/MotorControl/MCSDK/UILibrary/Inc/unidirectional_fast_com.h 3.48KB
  98. MCSDK_v5.4.8/MotorControl/MCSDK/UILibrary/Inc/usart_frame_communication_protocol.h 2.83KB
  99. MCSDK_v5.4.8/MotorControl/MCSDK/UILibrary/Src/
  100. MCSDK_v5.4.8/MotorControl/MCSDK/UILibrary/Src/dac_common_ui.c 4.16KB
  101. MCSDK_v5.4.8/MotorControl/MCSDK/UILibrary/Src/frame_communication_protocol.c 3.58KB
  102. MCSDK_v5.4.8/MotorControl/MCSDK/UILibrary/Src/ui_irq_handler.c 5.04KB
  103. MCSDK_v5.4.8/MotorControl/MCSDK/UILibrary/Src/unidirectional_fast_com.c 4.68KB
  104. MCSDK_v5.4.8/MotorControl/MCSDK/UILibrary/Src/usart_frame_communication_protocol.c 8.43KB

资源介绍:

自己看ST的FOC库时,添加了一些代码注释,可以辅助理解代码
/** ****************************************************************************** * @file r3_2_g4xx_pwm_curr_fdbk.c * @author Motor Control SDK Team, ST Microelectronics * @brief This file provides firmware functions that implement current sensor * class to be stantiated when the three shunts current sensing * topology is used. It is specifically designed for STM32F30X * microcontrollers and implements the successive sampling of two motor * current using shared ADC. * + MCU peripheral and handle initialization function * + three shunts current sensing * + space vector modulation function * + ADC sampling function * ****************************************************************************** * @attention * *

© Copyright (c) 2019 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license * SLA0044, the "License"; You may not use this file except in compliance with * the License. You may obtain a copy of the License at: * www.st.com/SLA0044 * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "r3_2_g4xx_pwm_curr_fdbk.h" #include "pwm_common.h" #include "mc_type.h" /** @addtogroup MCSDK * @{ */ /** @addtogroup pwm_curr_fdbk * @{ */ /** * @defgroup R3_2_G4XX_pwm_curr_fdbk R3 2 ADCs G4 PWM & Current Feedback * * @brief STM32G4, Shared Resources, 3-Shunt PWM & Current Feedback implementation * * This component is used in applications based on an STM32G4 MCU, using a three * shunt resistors current sensing topology and 2 ADC peripherals to acquire the current * values. * * * @todo: TODO: complete documentation. * * @{ */ /* Private defines -----------------------------------------------------------*/ #define TIMxCCER_MASK_CH123 ((uint16_t) (LL_TIM_CHANNEL_CH1|LL_TIM_CHANNEL_CH1N|\ LL_TIM_CHANNEL_CH2|LL_TIM_CHANNEL_CH2N|\ LL_TIM_CHANNEL_CH3|LL_TIM_CHANNEL_CH3N)) /* Private typedef -----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ static void R3_2_TIMxInit( TIM_TypeDef * TIMx, PWMC_Handle_t * pHdl ); static void R3_2_ADCxInit( ADC_TypeDef * ADCx ); __STATIC_INLINE uint16_t R3_2_WriteTIMRegisters( PWMC_Handle_t * pHdl, uint16_t hCCR4Reg ); static void R3_2_HFCurrentsPolarizationAB( PWMC_Handle_t * pHdl,ab_t * Iab ); static void R3_2_HFCurrentsPolarizationC( PWMC_Handle_t * pHdl, ab_t * Iab ); static void R3_2_SetAOReferenceVoltage( uint32_t DAC_Channel, DAC_TypeDef * DACx, uint16_t hDACVref ); uint16_t R3_2_SetADCSampPointPolarization( PWMC_Handle_t * pHdl) ; static void R3_2_RLGetPhaseCurrents( PWMC_Handle_t * pHdl, ab_t * pStator_Currents ); static void R3_2_RLTurnOnLowSides( PWMC_Handle_t * pHdl ); static void R3_2_RLSwitchOnPWM( PWMC_Handle_t * pHdl ); /** * @brief It initializes TIMx, ADC, GPIO, DMA1 and NVIC for current reading * in three shunt topology using STM32F30X and shared ADC * @param pHandle: handler of the current instance of the PWM component * @retval none */ __weak void R3_2_Init( PWMC_R3_2_Handle_t * pHandle ) { R3_3_OPAMPParams_t * OPAMPParams = pHandle->pParams_str->OPAMPParams; COMP_TypeDef * COMP_OCPAx = pHandle->pParams_str->CompOCPASelection; COMP_TypeDef * COMP_OCPBx = pHandle->pParams_str->CompOCPBSelection; COMP_TypeDef * COMP_OCPCx = pHandle->pParams_str->CompOCPCSelection; COMP_TypeDef * COMP_OVPx = pHandle->pParams_str->CompOVPSelection; DAC_TypeDef * DAC_OCPAx = pHandle->pParams_str->DAC_OCP_ASelection; DAC_TypeDef * DAC_OCPBx = pHandle->pParams_str->DAC_OCP_BSelection; DAC_TypeDef * DAC_OCPCx = pHandle->pParams_str->DAC_OCP_CSelection; DAC_TypeDef * DAC_OVPx = pHandle->pParams_str->DAC_OVP_Selection; TIM_TypeDef * TIMx = pHandle->pParams_str->TIMx; ADC_TypeDef * ADCx_1 = pHandle->pParams_str->ADCx_1; ADC_TypeDef * ADCx_2 = pHandle->pParams_str->ADCx_2; /*Check that _Super is the first member of the structure PWMC_R3_2_Handle_t */ if ( ( uint32_t )pHandle == ( uint32_t )&pHandle->_Super ) { /* disable IT and flags in case of LL driver usage * workaround for unwanted interrupt enabling done by LL driver 清除和关闭不需要的ADC中断*/ LL_ADC_DisableIT_EOC( ADCx_1 ); LL_ADC_ClearFlag_EOC( ADCx_1 ); LL_ADC_DisableIT_JEOC( ADCx_1 ); LL_ADC_ClearFlag_JEOC( ADCx_1 ); LL_ADC_DisableIT_EOC( ADCx_2 ); LL_ADC_ClearFlag_EOC( ADCx_2 ); LL_ADC_DisableIT_JEOC( ADCx_2 ); LL_ADC_ClearFlag_JEOC( ADCx_2 ); if ( TIMx == TIM1 ) { /* TIM1 Counter Clock stopped when the core is halted DEBUG下暂停run时,定时器停止工作*/ LL_DBGMCU_APB2_GRP1_FreezePeriph( LL_DBGMCU_APB2_GRP1_TIM1_STOP ); } else { /* TIM8 Counter Clock stopped when the core is halted */ LL_DBGMCU_APB2_GRP1_FreezePeriph( LL_DBGMCU_APB2_GRP1_TIM8_STOP ); } if ( OPAMPParams != NULL ) {//内部运放,未使用 /* Testing of all OPAMP one by one is required as 2 or 3 OPAMPS cfg may exist*/ if (OPAMPParams -> OPAMPx_1 != NULL ) { LL_OPAMP_Enable( OPAMPParams->OPAMPx_1 ); } if (OPAMPParams -> OPAMPx_2 != NULL ) { LL_OPAMP_Enable( OPAMPParams->OPAMPx_2 ); } if (OPAMPParams -> OPAMPx_3 != NULL ) { LL_OPAMP_Enable( OPAMPParams->OPAMPx_3 ); } } /* Over current protection phase A 内部过流保护,未使用 */ if ( COMP_OCPAx != NULL ) { /* Inverting input*/ if (( pHandle->pParams_str->CompOCPAInvInput_MODE != EXT_MODE ) && (DAC_OCPAx != MC_NULL)) { R3_2_SetAOReferenceVoltage( pHandle->pParams_str->DAC_Channel_OCPA, DAC_OCPAx, ( uint16_t )( pHandle->pParams_str->DAC_OCP_Threshold ) ); } /* Output */ LL_COMP_Enable ( COMP_OCPAx ); LL_COMP_Lock( COMP_OCPAx ); } /* Over current protection phase B 内部过流保护,未使用 */ if ( COMP_OCPBx != NULL ) { if (( pHandle->pParams_str->CompOCPBInvInput_MODE != EXT_MODE ) && (DAC_OCPBx != MC_NULL)) { R3_2_SetAOReferenceVoltage( pHandle->pParams_str->DAC_Channel_OCPB, DAC_OCPBx,( uint16_t )( pHandle->pParams_str->DAC_OCP_Threshold ) ); } LL_COMP_Enable ( COMP_OCPBx ); LL_COMP_Lock( COMP_OCPBx ); } /* Over current protection phase C 内部过流保护,未使用 */ if ( COMP_OCPCx != NULL ) { if (( pHandle->pParams_str->CompOCPCInvInput_MODE != EXT_MODE ) && (DAC_OCPCx != MC_NULL)) { R3_2_SetAOReferenceVoltage( pHandle->pParams_str->DAC_Channel_OCPC, DAC_OCPCx,( uint16_t )( pHandle->pParams_str->DAC_OCP_Threshold ) ); } LL_COMP_Enable ( COMP_OCPCx ); LL_COMP_Lock( COMP_OCPCx ); } /* Over voltage protection 内部过压保护,未使用 */ if ( COMP_OVPx != NULL ) { /* Inverting input*/ if (( pHandle->pParams_str->CompOVPInvInput_MODE != EXT_MODE ) && (DAC_OVPx != MC_NULL)) { R3_2_SetAOReferenceVoltage( pHandle->pParams_str->DAC_Channel_OVP, DAC_OVPx,( uint16_t )( pHandle->pParams_str->DAC_OVP_Threshold ) ); } /* Output */ LL_COMP_Enable ( COMP_OVPx ); LL_COMP_Lock( COMP_OVPx ); } if (LL_ADC_IsEnabled (ADCx_1) == 0) { R3_2_ADCxInit (ADCx_1); /* Only the Interrupt of the first ADC is enabled. * As Both ADCs are fired by HW at the same moment * It is safe to consider that both conversion are ready at the same
100+评论
captcha