123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- /**
- * @file cmdgen.h
- * @author Zhang, Kai(zhangkai71@midea.com)
- * @brief Time task control
- * @version 0.1
- * @date 2021-09-27
- *
- * @copyright Copyright (c) 2021
- *
- */
- #ifndef CMDGEN_H
- #define CMDGEN_H
- #include "typedefine.h"
- /****************************************
- *
- * Definitions & Macros
- *
- ****************************************/
- #define CMD_GEN_OUT_DEFAULT \
- { \
- 0, 0, 0, 1, 1, Constant \
- } // Default value of CMD_GEN_OUT
- #define CMD_GEN_COF_DEFAULT \
- { \
- 36864, 2730, 16384, 2730, 16384, 33408, 22272, 13344, 33408, 22272, 13344, 55924, 33554, 0 \
- } // Default value of CMD_GEN_COF
- /***************************************
- *
- * Type Definations
- *
- ***************************************/
- /**
- * @brief torque command input
- *
- */
- typedef struct
- {
- SLONG slRefRpm; // unit: rpm
- SWORD swAccRpmps; // unit: rpm/s
- } CMD_GEN_IN;
- /**
- * @brief torque command coefficient input
- *
- */
- typedef struct
- {
- UWORD uwRefMaxRpm; // unit: rpm, Maximum speed
- UWORD uwAccSw1Rpm; // unit: rpm, Speed switch 1 in acceleration
- UWORD uwAccSw2Rpm; // unit: rpm, Speed switch 2 in acceleration
- UWORD uwDecSw1Rpm; // unit: rpm, Speed switch 1 in deceleration
- UWORD uwDecSw2Rpm; // unit: rpm, Speed switch 2 in deceleration
- SWORD swAccLim1Rpmps; // unit: rpm/s, Speed acceleration limit 1
- SWORD swAccLim2Rpmps; // unit: rpm/s, Speed acceleration limit 2
- SWORD swAccLim3Rpmps; // unit: rpm/s, Speed acceleration limit 3
- SWORD swDecLim1Rpmps; // unit: rpm/s, Speed deceleration limit 1
- SWORD swDecLim2Rpmps; // unit: rpm/s, Speed deceleration limit 2
- SWORD swDecLim3Rpmps; // unit: rpm/s, Speed deceleration limit 3
- UWORD uwFTbsHz; // unit: Hz , TBS freq
- UWORD uwBaseRpm; // unit: rpm , Speed base
- } CMD_GEN_COFIN;
- typedef enum CmdDpdSta
- {
- Decelerate = 0,
- Accelerate = 1,
- Constant = 2
- } CMD_SPD_STATUS;
- /**
- * @brief torque command output
- *
- */
- typedef struct
- {
- SWORD swSpdCmdRefPu; // Q15, Speed Pu reference from uart
- SWORD swSpdRefPu; // Q15, Speed reference output per tbs
- SLONG slSpdRefPu; // Q31, Speed reference output per tbs
- SWORD swSpdCmdDir; // speed command direction
- SWORD swSpdRefDirNow; // Current speed reference direction
- CMD_SPD_STATUS enSpdStatus; // Speed status
- } CMD_GEN_OUT;
- /**
- * @brief torque command coefficient
- *
- */
- typedef struct
- {
- ULONG ulSpdRefMaxPu; // Q15, Maximum speed
- ULONG ulAccSpdSw1Pu; // Q15, Speed switch 1 in acceleration
- ULONG ulAccSpdSw2Pu; // Q15, Speed switch 2 in acceleration
- ULONG ulDecSpdSw1Pu; // Q15, Speed switch 1 in deceleration
- ULONG ulDecSpdSw2Pu; // Q15, Speed switch 2 in deceleration
- SLONG slAccLim1Pu; // Q31, Speed acceleration limit 1
- SLONG slAccLim2Pu; // Q31, Speed acceleration limit 2
- SLONG slAccLim3Pu; // Q31, Speed acceleration limit 3
- SLONG slDecLim1Pu; // Q31, Speed deceleration limit 1
- SLONG slDecLim2Pu; // Q31, Speed deceleration limit 2
- SLONG slDecLim3Pu; // Q31, Speed deceleration limit 3
- // UWORD uwFTbsHz; //unit: Hz , TBS freq
- UWORD uwFTbsHzInv; // Q25, Tbs frequence inverse
- UWORD uwBaseRpmInv; // Q25, Speed base inverse
- UWORD uwBaseRpm; // Q0,Speed base
- } CMD_GEN_COF;
- typedef struct
- {
- CMD_GEN_COF Coef; ///< Coefficient of current PI controller
- CMD_GEN_OUT Out; ///< Output of current PU controller
- } CMD_CONTROL;
- /****************************************
- *
- * Exported variable
- *
- ****************************************/
- /****************************************
- *
- * RAM ALLOCATION (N/A)
- *
- ****************************************/
- /***************************************
- *
- * Function Definations
- *
- ***************************************/
- /**
- * @brief
- *
- * @param in
- * @param coef
- * @param out
- */
- void cmd_voCmdGen(CMD_GEN_IN *in, CMD_CONTROL *s);
- void cmd_voCmdDirGen(CMD_GEN_IN *in, CMD_CONTROL *s);
- void cmd_voCmdGenCoef(CMD_GEN_COFIN *in, CMD_CONTROL *s);
- void cmd_voCmdGenInit(CMD_CONTROL *s);
- #endif
|