123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- /************************************************************************
- Project: Welling Motor Control Paltform
- Filename: obs.h
- Partner Filename: obs.c
- Description: The header file of obs.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):
- ************************************************************************/
- /************************************************************************
- Beginning of File, do not put anything above here except notes
- Compiler Directives:
- *************************************************************************/
- #ifndef OBS_H
- #define OBS_H
- /************************************************************************
- Compiler Directives (N/A)
- *************************************************************************/
- #ifdef _OBS_C_
- #define _OBS_EXT
- #else
- #define _OBS_EXT extern
- #endif
- /************************************************************************
- Definitions & Macros
- *************************************************************************/
- #define OBS_COF_DEFAULT \
- { \
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \
- } // Default value of OBS_COF
- #define OBS_OUT_DEFAULT \
- { \
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \
- } // Default value of OBS_OUT
- #define OBS_FLUXPI_COF_DEFAULT \
- { \
- 0, 0 \
- } // Default value of OBS_FLUXPI_COF
- #define OBS_FLUXPI_OUT_DEFAULT \
- { \
- 0, 0, 0 \
- } // Default value of OBS_FLUXPI_OUT
- /************************************************************************
- Typedefs & Structure Defines
- *************************************************************************/
- typedef struct
- {
- UWORD uwFbHz; // Real Value, Unit:Hz frequency base
- UWORD uwRbOm; // Real Value, unit: 0.01Ohm, Resistance base
- UWORD uwLbHm; // Real Value, unit: 0.01mH, Inductance base
- UWORD uwFluxbWb; // Real Value, unit: 0.01mWb, Flux linkage base
- UWORD uwFreqTbcHz; // Real Value, Unit:Hz, Current loop control cycle
- UWORD uwRsOm; // Real Value, unit: 0.01Ohm, Phase resistance
- UWORD uwLdHm; // Real Value, unit: 0.01mH, D axis inductance
- UWORD uwLqHm; // Real Value, unit: 0.01mH, Q axis inductance
- UWORD uwFluxWb; // Real Value, unit: 0.01mWb, Flux linkage
- UWORD uwFluxDampingRatio; // Q12, Flux PI regulator damping ratio
- UWORD uwFluxCrossFreqHz; // Q8, Flux PI regulator cross frequency
- UWORD uwSpdPllMcoef; // Q0, PLL damping factor
- UWORD uwSpdPllWvcHz; // Q10, PLL bandwidth
- } OBS_COF_IN;
- typedef struct
- {
- UWORD uwRsPu; // Q15, Phase resistance
- UWORD uwLdPu; // Q10, D axis inductance
- UWORD uwLqPu; // Q10, Q axis inductance
- UWORD uwFluxPPu; // Q12, Flux linkage
- UWORD uwCurTsPu; // Q15, Current loop control cycle
- UWORD uwCurTs; // Q10, TBC time
- UWORD uwSpdPllKpPu; // Q14, PLL Kp
- UWORD uwSpdPllKiPu; // Q14, PLL Kit
- UWORD uwFluxKpPu; // Q18, Flux PI regulator Kp
- UWORD uwFluxKitPu; // Q28, Flux PI regulator Kit
- } OBS_COF;
- typedef struct
- {
- SWORD swUalphaPu; // Q14, Stationary alpha-axis stator voltage
- SWORD swUbetaPu; // Q14, Stationary beta-axis stator voltage
- SWORD swIalphaPu; // Q14, Stationary alpha-axis stator current
- SWORD swIbetaPu; // Q14, Stationary beta-axis stator current
- UWORD uwVdcPu; // Q14, unit:Pu, DC bus voltage
- } OBS_IN;
- typedef struct
- {
- SLONG slFluxAlphaPu; // Q27, Output stationary alfa-axis stator flux
- SWORD swFluxAlphaPu; // Q10, Output stationary alfa-axis stator flux
- SLONG slFluxBetaPu; // Q27, Output stationary beta-axis stator flux
- SWORD swFluxBetaPu; // Q10, Output stationary beta-axis stator flux
- SLONG slElecThetaPu; // Q29, Output motor electrical position
- UWORD uwElecThetaPu; // Q15, Output motor electrical position
- SLONG slElecFreqPu; // Q29, Output electrical speed reference
- SWORD swElecFreqPu; // Q15, Output motor electrical speed reference
- SWORD swActiveFluxPu; // Q10, Output active flux
- } OBS_OUT;
- typedef struct
- {
- SWORD swRefPu; // Q10, Flux PI regulator I reference
- SWORD swFdbPu; // Q10, Flux PI regulator I feedback
- SWORD swUmaxPu; // Q14, Flux PI regulator voltage output maximum limit
- SWORD swUminPu; // Q14, Flux PI regulator voltage output minimum limit
- } OBS_FLUXPI_IN;
- typedef struct
- {
- UWORD uwFluxKpPu; // Q18, Flux PI regulator Kp
- UWORD uwFluxKitPu; // Q28, Flux PI regulator Kit
- } OBS_FLUXPI_COF;
- typedef struct
- {
- SWORD swURefPu; // Q14, Flux PI regulator output voltage
- SLONG slURefPu; // Q28, Flux PI regulator output voltage
- SWORD swErrZ1Pu; // Q10, Flux PI regulator error recorder
- } OBS_FLUXPI_OUT;
- /************************************************************************
- Constant Table
- *************************************************************************/
- /************************************************************************
- Exported Variables
- *************************************************************************/
- #ifdef _OBS_C_
- _OBS_EXT OBS_COF obs_stObsCoefPu = OBS_COF_DEFAULT;
- _OBS_EXT OBS_OUT obs_stObsOutPu;
- _OBS_EXT OBS_FLUXPI_OUT obs_stFluxAlphaPIOut = OBS_FLUXPI_OUT_DEFAULT;
- _OBS_EXT OBS_FLUXPI_OUT obs_stFluxBetaPIOut = OBS_FLUXPI_OUT_DEFAULT;
- _OBS_EXT OBS_FLUXPI_COF obs_stFluxAlphaPICoef = OBS_FLUXPI_COF_DEFAULT;
- _OBS_EXT OBS_FLUXPI_COF obs_stFluxBetaPICoef = OBS_FLUXPI_COF_DEFAULT;
- _OBS_EXT CRD_PARK_OUT obs_stFluxParkPu = OBS_FLUXPI_COF_DEFAULT;
- _OBS_EXT CRD_IPARK_OUT obs_stFluxIParkPu = OBS_FLUXPI_COF_DEFAULT;
- _OBS_EXT CRD_PARK_IN obs_stParkInPu;
- _OBS_EXT CRD_IPARK_IN obs_stIParkInPu;
- _OBS_EXT OBS_FLUXPI_IN obs_stFluxAlphaPIIn;
- _OBS_EXT OBS_FLUXPI_IN obs_stFluxBetaPIIn;
- #else
- _OBS_EXT OBS_COF obs_stObsCoefPu;
- _OBS_EXT OBS_OUT obs_stObsOutPu;
- _OBS_EXT OBS_FLUXPI_OUT obs_stFluxAlphaPIOut;
- _OBS_EXT OBS_FLUXPI_OUT obs_stFluxBetaPIOut;
- _OBS_EXT OBS_FLUXPI_COF obs_stFluxAlphaPICoef;
- _OBS_EXT OBS_FLUXPI_COF obs_stFluxBetaPICoef;
- _OBS_EXT CRD_PARK_OUT obs_stFluxParkPu;
- _OBS_EXT CRD_IPARK_OUT obs_stFluxIParkPu;
- _OBS_EXT CRD_PARK_IN obs_stParkInPu;
- _OBS_EXT CRD_IPARK_IN obs_stIParkInPu;
- _OBS_EXT OBS_FLUXPI_IN obs_stFluxAlphaPIIn;
- _OBS_EXT OBS_FLUXPI_IN obs_stFluxBetaPIIn;
- #endif
- /************************************************************************
- RAM ALLOCATION (N/A)
- *************************************************************************/
- #define obs_stObsCalcIn (*(OBS_IN *)TBC_BUFFER)
- #define obs_stObsCoefIn (*(OBS_COF_IN *)MN_BUFFER)
- #define obs_stFluxAlphaPICoefIn (*(OBS_FLUXPI_COFIN *)MN_BUFFER)
- #define obs_stFluxBetaPICoefIn (*(OBS_FLUXPI_COFIN *)MN_BUFFER)
- /************************************************************************
- Exported Function Call Prototypes
- *************************************************************************/
- #ifdef _OBS_C_
- _OBS_EXT void obs_voObsInit(void);
- _OBS_EXT void obs_voObsCoef(OBS_COF_IN *in, OBS_COF *out);
- _OBS_EXT void obs_voFluxPI(OBS_FLUXPI_IN *in, OBS_FLUXPI_COF *coef, OBS_FLUXPI_OUT *out);
- _OBS_EXT void obs_voObsCalc(OBS_IN *IN, OBS_COF *COF, OBS_OUT *OUT);
- #else
- _OBS_EXT void obs_voObsInit(void);
- _OBS_EXT void obs_voObsCoef(OBS_COF_IN *in, OBS_COF *out);
- _OBS_EXT void obs_voObsCalc(OBS_IN *IN, OBS_COF *COF, OBS_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!
- *************************************************************************/
|