123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- /**
- * @file switchhall.c
- * @author
- * @brief
- * @version
- * @date 2021-11-22
- *
- * @copyright Copyright (c) 2021
- *
- */
- /************************************************************************
- Beginning of File, do not put anything above here except notes
- Compiler Directives:
- *************************************************************************/
- #ifndef SWITCHHALL_H
- #define SWITCHHALL_H
- #include "typedefine.h"
- #ifdef __cplusplus
- extern "C" {
- #endif // __cplusplus
- /************************************************************************
- Compiler Directives (N/A)
- *************************************************************************/
- //#ifdef _SWITCHHALL_C_
- // #define _SWITCHHALL_EXT
- //#else
- // #define _SWITCHHALL_EXT extern
- //#endif
- /****************************************
- *
- * Definitions & Macros
- *
- ****************************************/
- #define HALL3_SPD_CAL_COEF ((((SQWORD)TIM2CNTCLK_KHZ * 1000 / FBASE)<< 15) / 6 ) // pi/3*(7200kHz) PU(pi/3)=2^15/6
- #define HALL1_SPD_CAL_COEF (((SQWORD)TIM2CNTCLK_KHZ * 1000 / FBASE)<< 15)
- #define HALL3_SPD_CAP_LEVEL1 (TIM2CNTCLK_KHZ*1000/((2)*6)) // electrical frequency 2Hz 6 hal edge pules per electrical cycle
- #define HALL3_SPD_CAP_LEVEL2 (TIM2CNTCLK_KHZ*1000/((1500)*6)) //motor electrical frequency 1500Hz 6 hal edge pules per electrical cycle
- #define HALL3_SPD_CAP_STARTUP_LEVEL (TIM2CNTCLK_KHZ*1000/((5)*6)) //motor electrical frequency 5Hz 6 hal edge pules per electrical cycle
- #define HALL_SPD_SWITCH_LEVEL (TIM2CNTCLK_KHZ*1000/((20)*6)) //motor electrical frequency 5Hz 6 hal edge pules per electrical cycle
-
- #define HALL_THETEA_OFFSET 7357 // (X)/360*2^15
- #define HALL_THETEA_OFFSET_FANXIANG 0 // (X)/360*2^15
- #define SWITCHHALL_CAP_DEFAULT \
- { \
- 0, 0, 0 \
- }
- #define SWITCHHALL_OUT_DEFAULT \
- { \
- 0, 0, 0, 0, 0, 0, 0, 0 \
- }
- /***************************************
- *
- * Type Definations
- *
- ***************************************/
- typedef struct
- {
- ULONG ulCapValue;
- SLONG slCapValueDelta;
- ULONG ulCapValuePre;
- SLONG slDeltaPre;
- UWORD uwCaptureOverFlowCnt;
-
- ULONG ulHighCapValue;
- SLONG slHighCapValueDelta;
- ULONG ulHighCapValuePre;
- UWORD uwHighCapOverFlowCnt;
-
- UWORD uwState;
- } SWITCHHALL_CAP;
- typedef struct
- {
- UWORD uwSectorNum;
- UWORD uwSectorNumPre;
- SWORD swSpdCWorCCW;
- SLONG slLowThetaPu;
- UWORD uwLowThetaPu;
- SLONG slInitThetaPu;
- SWORD swLowSpdPu;
- SWORD swLowSpdLpfPu;
- SWORD swLowThetaOffsetPu;
-
- SLONG slHighThetaPu;
- UWORD uwHighThetaPu;
- SWORD swHighSpdPu;
- SWORD swHighSpdLpfPu;
- } SWITCHHALL_OUT;
- /****************************************
- *
- * Exported Variables
- *
- ****************************************/
- extern SWITCHHALL_OUT switchhall_stOut;
- /***************************************
- *
- * Function Definations
- *
- ***************************************/
- void switchhall_voInit(void);
- void switchhall_voTim3Int(void);
- void switchhall_voPosCalTbc(void);
- /************************************************************************/
- #ifdef __cplusplus
- }
- #endif // __cplusplus
- #endif
- /************************************************************************
- End of this File (EOF):
- Do not put anything after this part!
- *************************************************************************/
|