/************************************************************************ Project: Welling Motor Control Paltform Filename: asr.h Partner Filename: asr.c Description: The header file of asr.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): ************************************************************************/ #include "typedefine.h" /************************************************************************ Beginning of File, do not put anything above here except notes Compiler Directives: *************************************************************************/ #ifndef ASR_H #define ASR_H /************************************************************************ Compiler Directives (N/A) *************************************************************************/ #ifdef _ASR_C_ #define _ASR_EXT #else #define _ASR_EXT extern #endif /************************************************************************ Definitions & Macros (#define ...) *************************************************************************/ #define ASR_SPDPI_COF_DEFAULT \ { \ 0, 0, 0 \ } // Default value of ASR_SPDPI_COF #define ASR_SPDPI_OUT_DEFAULT \ { \ 0, 0, 0, 0 \ } // Default value of ASR_SPDPI_OUT #define MOTOR_SPEED_OUT_DEFAULT \ { \ 0,0 \ }// Default value of MOTOR_SPEED_OUT #define MOTOR_SPEED_IN_DEFAULT \ { \ 0,0,5000,5000 \ } // Default value of MOTOR_SPEED_IN /************************************************************************ global varibles Macros (#define ...) *************************************************************************/ /************************************************************************ TypeDefs & Structure defines *************************************************************************/ typedef struct // Input of "asr_voSpdPI" { SWORD swSpdRefPu; // Q15, Speed reference SWORD swSpdFdbPu; // Q15, Speed feedback SWORD swIqMaxPu; // Q14, Iq output maximum limit SWORD swIqMinPu; // Q14, Iq output minimum limit } ASR_SPDPI_IN; typedef struct // Output of "asr_voSpdPI" { SLONG slIqiPu; // Q30, Integration of previous step SLONG slIqSumPu; // Q21, PI output before limitation SLONG slIqRefPu; // Q21, PI output after limitation SWORD swIqRefPu; // Q14, PI output after limitation SWORD swErrZ1Pu; // Q15, Error recorder } ASR_SPDPI_OUT; typedef struct // Input of "asr_voSpdPI" { UWORD uwKpPu; // Q4, Kp UWORD uwKitPu; // Q15, Kit UWORD uwKbPu; // Q8, Kb } ASR_SPDPI_COF; /************************************************************************ TypeDefs & Structure defines *************************************************************************/ typedef struct { UWORD uwRatioJm; // Q0, Ratio of load inertia and motor inertia UWORD uwMcoef; // Q0, Damping factor UWORD uwMtJm; // Motor rotational inertia UWORD uwMtFlxWb; // unit: 0.01mWb, Flux linkage UWORD uwUbVt; // unit: 0.1V, Voltage base UWORD uwIbAp; // unit: 0.01A, Current base UWORD uwFbHz; // unit: Hz, Frequency base UWORD uwFTbsHz; // TBS frequency UWORD uwPairs; // Pole pairs base UWORD uwWvcHz; // unit: Hz, Speed loop bandwidth } ASR_SPDPI_COFIN; /************************************************************************ TypeDefs & Structure defines *************************************************************************/ /************************************************************************ Constant Table *************************************************************************/ /************************************************************************ Exported Variables: *************************************************************************/ #ifdef _ASR_C_ _ASR_EXT ASR_SPDPI_OUT asr_stSpdPIOut = ASR_SPDPI_OUT_DEFAULT; _ASR_EXT ASR_SPDPI_COF asr_stSpdPICoef = ASR_SPDPI_COF_DEFAULT; #else _ASR_EXT ASR_SPDPI_OUT asr_stSpdPIOut; _ASR_EXT ASR_SPDPI_COF asr_stSpdPICoef; #endif /************************************************************************ RAM ALLOCATION: *************************************************************************/ #define asr_stSpdPICoefIn (*(ASR_SPDPI_COFIN *)MN_BUFFER) #define asr_stSpdPIIn (*(ASR_SPDPI_IN *)TBS_BUFFER) /************************************************************************ Exported Function Call Prototypes (N/A) *************************************************************************/ #ifdef _ASR_C_ _ASR_EXT void asr_voSpdPI(ASR_SPDPI_IN *in, ASR_SPDPI_COF *coef, ASR_SPDPI_OUT *out); _ASR_EXT void asr_voSpdPICoef(ASR_SPDPI_COFIN *in, ASR_SPDPI_COF *out); _ASR_EXT void asr_voSpdPIInit(void); #else _ASR_EXT void asr_voSpdPI(ASR_SPDPI_IN *in, ASR_SPDPI_COF *coef, ASR_SPDPI_OUT *out); _ASR_EXT void asr_voSpdPICoef(ASR_SPDPI_COFIN *in, ASR_SPDPI_COF *out); _ASR_EXT void asr_voSpdPIInit(void); #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! *************************************************************************/