123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- /************************************************************************
- Project: Welling Motor Control Paltform
- Filename: pwrlim.h
- Partner Filename: pwrlim.c
- Description: The header file of pwrlim.c
- Complier: IAR Embedded Workbench for ARM 7.80, IAR Systems.
- 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;
- ************************************************************************/
- /************************************************************************
- Beginning of File, do not put anything above here except notes
- Compiler Directives:
- *************************************************************************/
- #ifndef PWRLIM_H
- #define PWRLIM_H
- /************************************************************************
- Compiler Directives (N/A)
- ************************************************************************/
- #ifdef _PWRLIM_C_
- #define _PWRLIM_EXT
- #else
- #define _PWRLIM_EXT extern
- #endif
- /************************************************************************
- Definitions & Macros
- ************************************************************************/
- #define PWRLIM_COF_DEFAULT \
- { \
- 0, 0, 0, 0, 0, 0, 0, 0 \
- } // Default value of PWRLIM_COF
- #define PWRLIM_OUT_DEFAULT \
- { \
- 0 \
- } // Default value of PWRLIM_OUT
- #define PWRLIM_START_BATCAP 20
- #define PWRLIM_END_BATCAP 5
- /************************************************************************
- TypeDefs & Structure Defines
- ************************************************************************/
- typedef struct // Input of " pwr_voPwrLimCof "
- {
- SWORD swPwrLimW; /**< 功率限制值,单位:W */
- UWORD uwPwrErrW; /**< 功率开始限制值与功率限制值差值,单位:W */
- SWORD swIqMaxAp; /**< q轴电流最大值,单位:0.01A */
- UWORD uwIBaseAp; /**< 电流基值,单位:0.01A */
- UWORD uwUbVt; /**< 电压基值,单位:0.1V */
- UWORD uwPwrLimPIKp; /**< PI功率限制Kp,PuQ15 */
- UWORD uwPwrLimPIKi; /**< PI功率限制Ki,PuQ15 */
- UWORD uwPwrLimSTARTCe; /**< 开始限制功率的PCB温度,单位:摄氏度 */
- UWORD uwPwrLimENDCe; /**< 结束限制功率的PCB温度,单位:摄氏度 */
- UWORD uwPwrLimMotTempSTARTCe; /**< 开始限制功率的MOTOR温度,单位:摄氏度 */
- UWORD uwPwrLimMotTempENDCe; /**< 结束限制功率的MOTOR温度,单位:摄氏度 */
- UWORD uwPwrLimStartBatCap; /**< 开始限制功率的电量,单位:% */
- UWORD uwPwrLimEndBatCap; /**< 结束限制功率的电量,单位:% */
- } PWRLIM_COFIN;
- typedef struct // Output of " pwr_voPwrLimCof "
- {
- UWORD uwPwrLimKp; /**< 根据功率线性限制电流系数,PuQ5 */
- UWORD uwPwrLimPIKp; /**< 根据功率PI限制电流系数Kp,PuQ15 */
- UWORD uwPwrLimPIKi; /**< 根据功率PI限制电流系数Ki,PuQ15 */
- SWORD swIqMaxPu; /**< q轴电流最大值,PuQ14 */
- SWORD swMotorPwrLimitPu; /**< 功率限制值,PuQ15 */
- SWORD swPwrLimStartThresholdTemp; /**< 开始限制功率的PCB温度,单位:摄氏度 */
- SWORD swPwrLimENDThresholdTemp; /**< 结束限制功率的PCB温度,单位:摄氏度 */
- SWORD swCurLimTempGain; /**< 根据PCB温度线性限制电流系数,PuQ14 */
- SWORD swPwrLimTempGain; /**< 根据PCB温度线性限制功率系数,PuQ15 */
- SWORD swPwrLimMotorStartThresholdTemp; /**< 开始限制功率的MOTOR温度,单位:摄氏度 */
- SWORD swPwrLimMotorENDThresholdTemp; /**< 结束限制功率的MOTOR温度,单位:摄氏度 */
- SWORD swCurLimMotorTempGain; /**< 根据MOTOR温度线性限制电流系数,PuQ14 */
- UWORD uwPwrLimStartBatCap; /**< 开始限制功率的电池电量,单位:100% */
- UWORD uwPwrLimEndBatCap; /**< 结束限制功率的电池电量,单位:100% */
- UWORD uwPwrlimBatCapCof; /**< 根据电量线性限制功率系数,PuQ15 */
- } PWRLIM_COF;
- typedef struct // Input of " pwr_voPwrLim "
- {
- SWORD swSpdPu; /**< 电机转速,PuQ15 */
- SWORD swMotorPwrPu; /**< 电机计算功率,PuQ15 */
- SWORD swPCBTemp; /**< PCB温度,单位:摄氏度 */
- SWORD swMotorTemp; /**< MOTOR温度,单位:摄氏度 */
- UWORD uwBatCap; /**< 电池电量 */
- SWORD swMotoriqref; /**< MOTOR温度,单位:摄氏度 */
- SWORD swMotoriqfdb; /**< MOTOR温度,单位:摄氏度 */
- } PWRLIM_IN;
- typedef struct // Output of " pwr_voPwrLim "
- {
- SWORD swMotorPwrLimitActualPu; /**< 实际功率限制值,PuQ15 */
- SWORD swIqLimPu; /**< q轴电流限制值,PuQ14 */
- SWORD swErrorZ1; /**< 功率限制值与功率间的误差,PuQ15 */
- SLONG slIqLimDetaSum; /**< q轴电流限制减小值,PuQ30 */
- SWORD swIqLimDetaSum; /**< q轴电流限制减小值,PuQ14 */
- UWORD uwfisrttime;
- UWORD Mortor_time;
- } PWRLIM_OUT;
- /************************************************************************
- Constant Table
- *************************************************************************/
- /************************************************************************
- Exported Variables
- ************************************************************************/
- #ifdef _PWRLIM_C_
- _PWRLIM_EXT PWRLIM_OUT pwr_stPwrLimOut = PWRLIM_OUT_DEFAULT;
- _PWRLIM_EXT PWRLIM_COF pwr_stPwrLimCof = PWRLIM_COF_DEFAULT;
- _PWRLIM_EXT PWRLIM_OUT pwr_stPwrLimOut2 = PWRLIM_OUT_DEFAULT;
- #else
- _PWRLIM_EXT PWRLIM_OUT pwr_stPwrLimOut;
- _PWRLIM_EXT PWRLIM_COF pwr_stPwrLimCof;
- _PWRLIM_EXT PWRLIM_OUT pwr_stPwrLimOut2;
- #endif
- /************************************************************************
- RAM ALLOCATION:
- ************************************************************************/
- #define pwr_stPwrLimIn (*(PWRLIM_IN *)TBC_BUFFER)
- #define pwr_stPwrLimCofIn (*(PWRLIM_COFIN *)MN_BUFFER)
- /************************************************************************
- Exported Function Call Prototypes (N/A)
- ************************************************************************/
- #ifdef _PWRLIM_C_
- _PWRLIM_EXT void pwr_voPwrLimInit(void);
- _PWRLIM_EXT void pwr_voPwrLimCof(PWRLIM_COFIN *in, PWRLIM_COF *out);
- _PWRLIM_EXT void pwr_voPwrLim(PWRLIM_IN *in, PWRLIM_COF *cof, PWRLIM_OUT *out);
- _PWRLIM_EXT void pwr_voPwrLimPI(PWRLIM_IN *in, PWRLIM_COF *cof, PWRLIM_OUT *out);
- #else
- _PWRLIM_EXT void pwr_voPwrLimInit(void);
- _PWRLIM_EXT void pwr_voPwrLimCof(PWRLIM_COFIN *in, PWRLIM_COF *out);
- _PWRLIM_EXT void pwr_voPwrLim(PWRLIM_IN *in, PWRLIM_COF *cof, PWRLIM_OUT *out);
- _PWRLIM_EXT void pwr_voPwrLimPI(PWRLIM_IN *in, PWRLIM_COF *cof, PWRLIM_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!
- ************************************************************************/
|