stm32f10x_svpwm_3shunt.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef __STM32F10X_SVPWM_3SHUNT_H
  2. #define __STM32F10X_SVPWM_3SHUNT_H
  3. #include "stm32f1xx_hal.h"
  4. #include "MC_type.h"
  5. #include "var.h"
  6. #define TW_AFTER ((uint16_t)(((DEADTIME_NS+MAX_TNTR_NS)*72ul)/1000ul))
  7. #define TW_BEFORE (((uint16_t)(((((uint16_t)(SAMPLING_TIME_NS)))*72ul)/1000ul))+1)
  8. #define TW_DT_TN_TS ((uint16_t)(((DEADTIME_NS+MAX_TNTR_NS+SAMPLING_TIME_NS)*72ul)/1000ul))
  9. #define TW_DT_TR_TS ((uint16_t)(((DEADTIME_NS+TRISE_NS+SAMPLING_TIME_NS)*72ul)/1000ul))
  10. #define TW_DT_TN_TS_HALF ((uint16_t)(TW_DT_TN_TS/2))
  11. #define SAMPLING_TIME_NS 700 //700ns
  12. #if (SAMPLING_TIME_NS == 700)
  13. #define SAMPLING_TIME_CK ADC_SampleTime_1Cycles5
  14. #elif (SAMPLING_TIME_NS == 1200)
  15. #define SAMPLING_TIME_CK ADC_SampleTime_7Cycles5
  16. #elif (SAMPLING_TIME_NS == 2400)
  17. #define SAMPLING_TIME_CK ADC_SampleTime_13Cycles5
  18. #warning "Sampling time is not a possible value"
  19. #endif
  20. #define TNOISE_NS 1550 //2.55usec
  21. #define TRISE_NS 1550 //2.55usec
  22. #define SAMPLING_TIME (uint16_t)(((uint16_t)(SAMPLING_TIME_NS) * 72uL)/1000uL)
  23. #define TNOISE (uint16_t)((((uint16_t)(TNOISE_NS)) * 72uL)/1000uL)
  24. #define TRISE (uint16_t)((((uint16_t)(TRISE_NS)) * 72uL)/1000uL)
  25. #define TDEAD (uint16_t)((DEADTIME_NS * 72uL)/1000uL)
  26. #if (TNOISE_NS > TRISE_NS)
  27. #define MAX_TNTR_NS TNOISE_NS
  28. #else
  29. #define MAX_TNTR_NS TRISE_NS
  30. #endif
  31. #define T (PWM_PERIOD * 4)
  32. #define T_SQRT3 (uint16_t)(T * SQRT_3)
  33. #define SECTOR_1 ((uint8_t)1)
  34. #define SECTOR_2 ((uint8_t)2)
  35. #define SECTOR_3 ((uint8_t)3)
  36. #define SECTOR_4 ((uint8_t)4)
  37. #define SECTOR_5 ((uint8_t)5)
  38. #define SECTOR_6 ((uint8_t)6)
  39. extern void SVPWM_3ShuntCurrentReadingCalibration(MC_ErrorCode_Struct_t* p_MC_ErrorCode);
  40. extern void CurrentReadingCalibration(MC_ErrorCode_Struct_t* p_MC_ErrorCode);
  41. extern void SVPWM_3ShuntCalcDutyCycles (Volt_Components Stat_Volt_Input);
  42. extern Curr_Components SVPWM_3ShuntGetPhaseCurrentValues(void);
  43. extern int16_t GetCurrentValues(void);
  44. #endif