123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- /************************************************************************
- Project: Welling Motor Control Paltform
- Filename: glbcof.c
- Partner Filename: glbcof.h
- Description: The global coefficients
- 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 _GLBCOF_C_
- #define _GLBCOF_C_
- #endif
- /************************************************************************
- Included File
- *************************************************************************/
- #include "syspar.h"
- #include "user.h"
- /************************************************************************
- Constant Table (N/A)
- *************************************************************************/
- /*************************************************************************
- Exported Functions (N/A)
- *************************************************************************/
- /***************************************************************
- Function: cof_voSysInit;
- Description: global power on initialization
- Call by:
- Input Variables: N/A
- Output/Return Variables: N/A
- Subroutine Call: N/A;
- Reference: N/A
- ****************************************************************/
- void cof_voSysInit(void)
- {
- /*=======================================================================
- Base value
- =======================================================================*/
- cof_uwUbVt = VBASE; /* unit: 0.1V, Voltage base */
- cof_uwIbAp = IBASE; /* unit: 0.01A, Current base */
- cof_uwFbHz = FBASE; /* unit: Hz, Frequency base */
- cof_uwTorqNm = TORQUEBASE; /* unit:0.1Nm, torque base */
- cof_uwPairs = cp_stMotorPara.swMotrPolePairs; /* Pole pairs base */
- cof_uwWebRadps =(ULONG) 2 * 31416 * cof_uwFbHz / 1000; /* unit: 0.1rad/s, Electrical radian frequency base */
- cof_uwTbUs = 100000000 / cof_uwWebRadps; /* unit: 0.1us, Time base */
- cof_uwRbOm = (ULONG)cof_uwUbVt * 100000 / cof_uwIbAp; /* unit: 0.1mOhm, Resistance base */
- cof_uwLbHm = (ULONG)cof_uwRbOm * 100000 / cof_uwWebRadps; /* unit: 0.01uH, Inductance base */
- cof_uwFluxbWb = (ULONG)cof_uwUbVt * 1000000 / cof_uwWebRadps; /* unit: 0.001mWb, Flux linkage base */
- cof_uwPbWt = (ULONG)3 * cof_uwUbVt * cof_uwIbAp / 100 >> 1; /* unit: 0.1w, Power base */
- cof_uwWmb = (ULONG)cof_uwWebRadps / cof_uwPairs; /* unit: 0.1rad/s, Mechanical radian frequency base */
- cof_uwTbNm = (ULONG)cof_uwPbWt * 1000 / cof_uwWmb; /* unit: mNm, Torque base */
- cof_uwJb = (ULONG)cof_uwTbNm * cof_uwTbUs * 10 / cof_uwWmb; /* unit: 10^-10*kg*m2, Rotational inertia base */
- cof_uwVbRpm = (ULONG)cof_uwFbHz * 60 / cof_uwPairs; /* unit: rpm, Velocity base */
- /*=======================================================================
- Pu value
- =======================================================================*/
- cof_uwTCurCtrPu = 2 * 102944 * cof_uwFbHz / FTBC_HZ; /* Q15, Current control period Pu, pi(Q15)=102944 */
- cof_uwTSpdCtrPu = 2 * 12868 * cof_uwFbHz / FTBS_HZ; /* Q12, Speed control period Pu, pi(Q12)=12868 */
- cof_uwRsPu = ((ULONG)cp_stMotorPara.swRsOhm << 15) / cof_uwRbOm; /* Q15, Phase resistance */
- cof_uwLdPu = ((ULONG)cp_stMotorPara.uwLdmH << 10) / cof_uwLbHm; /* Q10, D axis inductance */
- cof_uwLqPu = ((ULONG)cp_stMotorPara.uwLqmH << 10) / cof_uwLbHm; /* Q10, Q axis inductance */
- cof_uwFluxPu = ((ULONG)cp_stMotorPara.swFluxWb << 12) / cof_uwFluxbWb; /* Q12, Flux linkage */
- cof_uwJmPu = ((ULONG)cp_stMotorPara.swJD * 1000) / cof_uwJb; /* Q0, Rotational inertia */
- cof_swIdMinPu = ((SLONG)cp_stMotorPara.swIdMinA << 14) / cof_uwIbAp; /* Q14, Min d axis current (Charactoristic current) */
- cof_swIdMaxPu = ((SLONG)cp_stMotorPara.swIdMaxA << 14) / cof_uwIbAp; /* Q14, Max d axis current */
- cof_uwCurMaxPu = ((ULONG)cp_stMotorPara.swIpeakMaxA << 14) / cof_uwIbAp; /* Q14, Max phase current (peak value) */
- cof_uwPwrMaxPu = ((ULONG)M_POWER_MAX_WT << 14) * 10 / cof_uwPbWt; /* Q14, Max power of motor input */
- cof_uwLdMinPu = ((ULONG)M_LD_MIN_MH << 10) / cof_uwLbHm; /* Q10, D axis inductance */
- cof_uwLqMinPu = ((ULONG)M_LQ_MIN_MH << 10) / cof_uwLbHm; /* Q10, Q axis inductance */
- /*=======================================================================
- Time value
- =======================================================================*/
- cof_ulTbc10MsCt = TBC_MS2CT(10); /* ms to count in TBC */
- cof_ulTbc20MsCt = TBC_MS2CT(20); /* ms to count in TBC */
- cof_ulTbc50MsCt = TBC_MS2CT(50); /* ms to count in TBC */
- cof_ulTbc60MsCt = TBC_MS2CT(60); /* ms to count in TBC */
- cof_ulTbc100MsCt = TBC_MS2CT(100); /* ms to count in TBC */
- cof_ulTbc200MsCt = TBC_MS2CT(200); /* ms to count in TBC */
- cof_ulTbc250MsCt = TBC_MS2CT(250); /* ms to count in TBC */
- cof_ulTbc300MsCt = TBC_MS2CT(300); /* ms to count in TBC */
- cof_ulTbc400MsCt = TBC_MS2CT(400); /* ms to count in TBC */
- cof_ulTbc450MsCt = TBC_MS2CT(450); /* ms to count in TBC */
- cof_ulTbc500MsCt = TBC_MS2CT(500); /* ms to count in TBC */
- cof_ulTbc1SCt = TBC_S2CT(1); /* s to count in TBC */
- cof_ulTbc2SCt = TBC_S2CT(2); /* s to count in TBC */
- /*=======================================================================
- Angle value
- =======================================================================*/
- cof_sl0DegreePu = ANG_DEG2PU(0);
- cof_sl30DegreePu = ANG_DEG2PU(30);
- cof_sl60DegreePu = ANG_DEG2PU(60);
- cof_sl90DegreePu = ANG_DEG2PU(90);
- cof_sl120DegreePu = ANG_DEG2PU(120);
- cof_sl150DegreePu = ANG_DEG2PU(150);
- cof_sl180DegreePu = ANG_DEG2PU(180);
- cof_sl210DegreePu = ANG_DEG2PU(210);
- cof_sl240DegreePu = ANG_DEG2PU(240);
- cof_sl270DegreePu = ANG_DEG2PU(270);
- cof_sl300DegreePu = ANG_DEG2PU(300);
- cof_sl330DegreePu = ANG_DEG2PU(330);
- cof_sl360DegreePu = ANG_DEG2PU(360);
- cof_sl720DegreePu = ANG_DEG2PU(720);
- /*=======================================================================
- Speed value
- =======================================================================*/
- cof_uw80RpmPu = SPD_RPM2PU(80);
- cof_uw100RpmPu = SPD_RPM2PU(100);
- cof_uw200RpmPu = SPD_RPM2PU(200);
- cof_uw250RpmPu = SPD_RPM2PU(250);
- cof_uw300RpmPu = SPD_RPM2PU(300);
- cof_uw330RpmPu = SPD_RPM2PU(330);
- cof_uw600RpmPu = SPD_RPM2PU(600);
- cof_uw1000RpmPu = SPD_RPM2PU(1000);
- cof_uw1500RpmPu = SPD_RPM2PU(1500);
- cof_uw2800RpmPu = SPD_RPM2PU(2800);
- cof_uw3000RpmPu = SPD_RPM2PU(3000);
- }
- /*************************************************************************
- Copyright (c) 2018 Welling Motor Technology(Shanghai) Co. Ltd.
- All rights reserved.
- *************************************************************************/
- #ifdef _GLBCOF_C_
- #undef _GLBCOF_C_
- #endif
- /*************************************************************************
- End of this File (EOF)!
- Do not put anything after this part!
- *************************************************************************/
|