BEMFDetect.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**************************** (C) COPYRIGHT 2018 Fortiortech shenzhen *****************************
  2. * File Name : BEMFDetect.h
  3. * Author : Bruce, Fortiortech Hardware
  4. * Version : V1.0
  5. * Date : 2017-12-27
  6. * Description : This file contains all the common data types used for
  7. * Motor Control.
  8. ***************************************************************************************************
  9. * All Rights Reserved
  10. **************************************************************************************************/
  11. #ifndef __BEMFDETECT_H_
  12. #define __BEMFDETECT_H_
  13. #include <FU68xx_5.h>
  14. #include <Customer.h>
  15. #include <MotorControl.h>
  16. /****************************BEMF参数变量**************************/
  17. #define BEMF_FR_CCW (0xA0) //
  18. #define BEMF_FR_CW (0xB0) //
  19. #define BEMF_FR_ERR (0xC0) //
  20. #define BEMF_FORWARD (1)
  21. #define BEMF_REVERSE (2)
  22. #define BEMF_STATIC (3)
  23. #define BEMF_DETECTING (0)
  24. #define BEMFSpeedCalBase (int32)(32767.0 / 8.0 * (TIM2_Fre * 60 / Pole_Pairs / MOTOR_SPEED_BASE))
  25. #define BEMFSpeedCalMinPeriod (int32)(1.0/8.0 * (TIM2_Fre * 60 / Pole_Pairs / MOTOR_SPEED_BASE)) + 1
  26. //定义使用BEMF启动时ATO_BW值
  27. #define ATO_BW_BEMF_START (400.0)
  28. #define OBSW_KP_GAIN_BEMF_START _Q12(2 * _2PI * ATT_COEF * ATO_BW_BEMF_START / BASE_FREQ)
  29. #define OBSW_KI_GAIN_BEMF_START _Q12(_2PI * ATO_BW_BEMF_START * ATO_BW_BEMF_START * TPWM_VALUE / BASE_FREQ)
  30. //定义使用BEMF启动时DKI QKI值
  31. #define DKI_BEMF_START _Q12(1.0)
  32. #define QKI_BEMF_START _Q12(1.0)
  33. //定义使用BEMF启动最低转速,ROM
  34. #define BEMFMotorStartSpeed _Q15(2500.0 / MOTOR_SPEED_BASE)
  35. #define BEMFMotorStartSpeedHigh _Q15(12000.0 / MOTOR_SPEED_BASE)
  36. typedef struct
  37. {
  38. int16 BEMFSpeed; //反电动势检测的速度
  39. uint32 BEMFSpeedBase; //反电动势检测的速度基准
  40. uint8 Status; // bemf检测状态
  41. uint8 FR_SET;
  42. uint8 FR ; // 当前转向
  43. uint8 FRPre; // 上一次转向
  44. int8 FRCount; // 正确转向计数,正数为CW,负数为CCW
  45. uint8 SpeedUpdate; ///< 速度更新标志
  46. uint8 HighSpdStart;
  47. uint16 PeriodTime; //转一圈的周期计数值/8,因除数只能是16位的
  48. uint16 SectorTime[6]; // 60度扇区时间
  49. }BEMFDetect_TypeDef;
  50. extern BEMFDetect_TypeDef xdata mcBemf;
  51. extern void BEMFDetectInit(void);
  52. extern void BemfProcess(void);
  53. extern void BEMFFOCCloseLoopStart(void);
  54. extern MotStateType Bemf_Start_Process(void);
  55. #endif