123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- /************************************************************************
- Project: Welling Motor Control Paltform
- Filename: flxwkn.h
- Partner Filename: flxwkn.c
- Description: The header file of flxwkn.c
- Complier: IAR Embedded Workbench for ARM 7.80.4
- CPU TYPE : GD32F3x0
- *************************************************************************
- Copyright (c) 2018 Welling Motor Technology(Shanghai) Co. Ltd.
- All rights reserved.
- *************************************************************************
- *************************************************************************
- Revising History (ECL of this file):
- Fjy create this file;
- ************************************************************************/
- #include "typedefine.h"
- /************************************************************************
- Beginning of File, do not put anything above here except notes
- Compiler Directives:
- *************************************************************************/
- #ifndef FLXWKN_H
- #define FLXWKN_H
- /************************************************************************
- Compiler Directives (N/A)
- ************************************************************************/
- #ifdef _FLXWKN_C_
- #define _FLXWKN_EXT
- #else
- #define _FLXWKN_EXT extern
- #endif
- /************************************************************************
- Definitions & Macros
- ************************************************************************/
- #define FW_CTRL_COEF_DEFAULT \
- { \
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \
- } // Default value of FW_CTRL_COEF
- #define FW_CTRL_OUT_DEFAULT \
- { \
- 0, 0, 0, 0 \
- } // Default value of FW_CTRL_OUT
- /************************************************************************
- TypeDefs & Structure Defines
- ************************************************************************/
- typedef struct
- {
- UWORD uwPWMDutyMax; // Q0, Max modulation ratio in flux weakening
- UWORD uwIdRegKpPu; // Q16, Kp for d axis current
- UWORD uwIdRegKiPu; // Q16, Ki for d axis current
- SWORD swIdPIOutMinAp; // Q0, Min Id of PI out
- UWORD uwVdcMinCalcTmMs; // Q0, period of Vdc fluctuate
- UWORD uwVdcLpfFreqHz; // Q0, Frequency of Vdc LPF
- UWORD uwCharCurDampRatio; // Q0, Charactoristic current Damping Ratio
- UWORD uwCharCurCrossFreqHz; // Q0, Charactoristic current Cross Frequence
- UWORD uwFwCurLimAp; // Q0, Current Limit
- UWORD uwIdMinLimRatio; // Q0, Ratio of Min d axis current (Charactoristic current)
- SWORD swIdMaxAp; // Q0, Max d axis current
- SWORD swIdMinAp; // Q0, Min d axis current (Charactoristic current)
- UWORD uwRsOhm; // Q0, Phase resistance
- UWORD uwFreqTbcHz; // Q0, TBC freq
- UWORD uwIBaseAp; // Q0, Base Current
- UWORD uwFBaseHz; // Q0, Base Frequency
- UWORD uwUbVt; // Q0, Voltage base
- } FW_CTRL_COEFIN;
- typedef struct
- {
- UWORD uwVdcPu; // Q14, DC bus Voltage
- SWORD swUalphaPu; // Q14, alpha-axis Voltage
- SWORD swUbetaPu; // Q14, beta-axis Voltage
- SWORD swIqRefPu; // Q14, q-axis Current
- SWORD swUqRefPu; // Q14, q-axis Voltage
- } FW_CTRL_IN;
- typedef struct
- {
- UWORD uwVdcRatioPu; // Q14, Vdc ration
- UWORD uwIdRegKpPu; // Q16, d-axis Current regulation Kp
- UWORD uwIdRegKitPu; // Q16, d-axis Current regulation Kit
- UWORD uwIqRegKpPu; // Q15, q-axis Current regulation Kp
- SWORD swIqLimMaxPu; // Q14, q-axis Currentlimit value used for speed loop out
- SLONG slIdMaxPu; // Q30, d-axis Current max
- SLONG slIdMinPu; // Q30, d-axis Current min
- SLONG slIdMinLimPu; // Q30, d-axis Current min limit
- UWORD uwVdcAvgLpfCoef; // Q15, DC bus Voltage LowPass filter coefficient
- UWORD uwVdcMinCalcTm; // Q0, period of Vdc fluctuate
- SLONG slIdPIOutMinPu; // Q30, Min Id of PI out
- UWORD uwKpPu; // Q16, Estimate Min d-axis Current regulation Kp
- SLONG slKitPu; // Q25, Estimate Min d-axis Current regulation Kit
- UWORD uwFwCurLimPu; // Q14, Current Limit
- UWORD uwRsPu; // Q15, Motor phase resistance
- } FW_CTRL_COEF;
- typedef struct
- {
- SLONG slIdSumPu; // Q30, d-axis Current PI regulation output before limitation
- SWORD swIqLimPu; // Q14, q-axis Currentlimit value used for speed loop out
- SWORD swIdRefPu; // Q14, d-axis Current reference value used for current loop regulation
- SLONG slIdMinEstPu; // Q30, d-axis Current Estimate Min
- } FW_CTRL_OUT;
- /************************************************************************
- Constant Table
- *************************************************************************/
- /************************************************************************
- Exported Variables
- ************************************************************************/
- #ifdef _FLXWKN_C_
- _FLXWKN_EXT FW_CTRL_OUT flx_stCtrlOut = FW_CTRL_OUT_DEFAULT;
- _FLXWKN_EXT FW_CTRL_COEF flx_stCtrlCoef = FW_CTRL_COEF_DEFAULT;
- #else
- _FLXWKN_EXT FW_CTRL_OUT flx_stCtrlOut;
- _FLXWKN_EXT FW_CTRL_COEF flx_stCtrlCoef;
- #endif
- /************************************************************************
- RAM ALLOCATION
- ************************************************************************/
- #define flx_stCtrlIn (*(FW_CTRL_IN *)TBC_BUFFER)
- #define flx_stCtrlCoefIn (*(FW_CTRL_COEFIN *)MN_BUFFER)
- /************************************************************************
- Exported Function Call Prototypes
- ************************************************************************/
- #ifdef _FLXWKN_C_
- _FLXWKN_EXT void flx_voInit(void);
- _FLXWKN_EXT void flx_voCoef(FW_CTRL_COEFIN *in, FW_CTRL_COEF *out);
- _FLXWKN_EXT void flx_voCtrl(FW_CTRL_IN *in, FW_CTRL_COEF *coef, FW_CTRL_OUT *out);
- #else
- _FLXWKN_EXT void flx_voInit(void);
- _FLXWKN_EXT void flx_voCoef(FW_CTRL_COEFIN *in, FW_CTRL_COEF *out);
- _FLXWKN_EXT void flx_voCtrl(FW_CTRL_IN *in, FW_CTRL_COEF *coef, FW_CTRL_OUT *out);
- #endif
- /************************************************************************
- Flag Define (N/A)
- ************************************************************************/
- /***********************************************************************/
- #endif
- /************************************************************************
- Copyright (c) 2018 Welling Motor Technology(Shanghai) Co. Ltd.
- All rights reserved.
- *************************************************************************
- End of this File (EOF):
- Do not put anything after this part!
- ************************************************************************/
|