/************************************************************************ Project: Welling Motor Control Paltform Filename: syspar.h Partner Filename: Null Description: System parameters Complier: IAR Embedded Workbench for ARM 7.80, IAR Systems. CPU TYPE : Cortex-M4 ************************************************************************* Copyright (c) 2019 Welling Motor Technology(Shanghai) Co. Ltd. All rights reserved. ************************************************************************* ************************************************************************* Revising History (ECL of this file): ************************************************************************/ #ifndef SYSPAR_H #define SYSPAR_H /************************************************************************ Compiler Directives *************************************************************************/ /************************************************************************ Definitions & Macros *************************************************************************/ /*======================================================================* Update Time 2020-2-13 11:22:19 *=======================================================================*/ /*======================================================================* MCU Model Number *=======================================================================*/ #define HARDWARE_STM4_64PIN 0 #define HARDWARE_STM4_32PIN 1 #define HARDWARE_VERSION HARDWARE_STM4_32PIN /*======================================================================* MCU Frequency *=======================================================================*/ #define CLK_CORE_KHZ 72000 #define CLK_PWM_KHZ 72000 #define CLK_ADC_KHZ 36000 #define CLK_AHB_KHZ 72000 #define CLK_APB1_KHZ 36000 #define CLK_APB2_KHZ 72000 #define CLK_TIM0_KHZ 72000 #define CLK_TIM1_KHZ 72000 /*======================================================================* Control Frequency *=======================================================================*/ #define FPWM_HZ 16000 #define FTBC_HZ 8000 #define FTBS_HZ 4000 #define FSYSTICK_HZ 1000 #define PWM_PERIOD_CNT 4500 #define PWM_PERIOD_US 625 #define TBC_PERIOD_US 1250 #define TBS_PERIOD_US 2500 #define EVENT_1MS_HZ 1000 /*======================================================================* ADC *=======================================================================*/ #define ADC_RESOLUTION_BIT 12 #define ADC_CALIB_INDEX 12 #define ADC_SMPL_PERIOD 7POINT5 #define ADC_CONV_PERIOD 12POINT5 #define ADC_INSERTED_CH_NUM 1 #define ADC_REGULAR_CH_NUM 5 #define ADC_UABC_LPF_COMP 20430 /*======================================================================* ADC Maximum Value *=======================================================================*/ //#if ((MOTOR_ID_SEL == MOTOR_WELLING_CITY_36V) || (MOTOR_ID_SEL == MOTOR_WELLING_MTB_36V)) //#define ADC_IPHASE_CUR_MAX_AP 15600 //13400 //#elif ((MOTOR_ID_SEL == MOTOR_WELLING_CITY_48V) || (MOTOR_ID_SEL == MOTOR_WELLING_MTB_48V)) //#define ADC_IPHASE_CUR_MAX_AP 7500 //13400 //#endif #define ADC_IDC_CUR_MAX_AP 9524//10476//11640//9524 //10476 #define ADC_ISENSOR_CUR_MAX_AP 6005 #define ADC_VDC_MAX_VT 605 #define ADC_UABC_MAX_VT 495 #define ADC_DISPLAY_MAX_VT 363 #define ADC_LIGHT_MAX_VT 188 #define ADC_SPDSENSOR_MAX_VT 188 #define ADC_UABC_MAX_VT 495 #define ADC_UMotorTemp_MAX_VT 0 #define ADC_UPcbTemp_MAX_VT 33 /*======================================================================* Base value *=======================================================================*/ #define VBASE 480 // 0.1V 100mv #define IBASE 6000 // 0.01A #define FBASE 700 // Hz #define TORQUEBASE 900 // 0.1Nm wzy /*======================================================================* Control cycle *=======================================================================*/ #define TBC_TM (((ULONG)FBASE << 10) / FTBC_HZ) #define TBS_TM (((ULONG)FBASE << 10) / FTBS_HZ) /*======================================================================= TBC real value to count function define =======================================================================*/ #define TBC_US2CT(x) ((ULONG)(x)*FTBC_HZ / 1000000) #define TBC_MS2CT(x) ((ULONG)(x)*FTBC_HZ / 1000) #define TBC_S2CT(x) ((ULONG)(x)*FTBC_HZ) #define EVENT1MS_MS2CT(x) ((ULONG)(x)*EVENT_1MS_HZ / 1000) #define EVENT1MS_S2CT(x) ((ULONG)(x)*EVENT_1MS_HZ) /*======================================================================= TBS real value to count function define =======================================================================*/ #define TBS_US2CT(x) ((ULONG)(x)*FTBS_HZ / 1000000) #define TBS_MS2CT(x) ((ULONG)(x)*FTBS_HZ / 1000) #define TBS_S2CT(x) ((ULONG)(x)*FTBS_HZ) #define TBS_MIN2CT(x) ((ULONG)(x)*FTBS_HZ * 60) /*======================================================================= SysTick real value to count function define =======================================================================*/ #define TBT_MS2CT(x) ((ULONG)(x)*FSYSTICK_HZ / 1000) #define TBT_S2CT(x) ((ULONG)(x)*FSYSTICK_HZ) #define TBT_MIN2CT(x) ((ULONG)(x)*FSYSTICK_HZ * 60) /*======================================================================= Speed real value to pu value function define =======================================================================*/ #define MOTOR_PAIRS M_POLE_PAIRS //#define SPD_RPM2PU(x) (((SLONG)(x)<<15)/60*MOTOR_PAIRS/FBASE) //#define SPD_HZ2PU(x) (((ULONG)(x)<<15)/FBASE) //#define SPD_ACC_RPM2PU(x) ((((ULONG)SPD_RPM2PU(x)<<16)/FTBS_HZ)<<1) #define SPD_RPM2PU(x) (((SLONG)(x) << 15) / 60 * MOTOR_PAIRS / FBASE) /* rpm to Pu(Q15) */ #define SPD_HZ2PU(x) (((SLONG)(x) << 15) / FBASE) /* Hz(Electric) to Pu(Q15) */ #define SPD_ACC_RPM2PU(x) (((SLONG)SPD_RPM2PU(x) << 14) / FTBS_HZ) /* rpm/s to Pu(Q29) */ /*======================================================================= Voltage real value to pu value function define =======================================================================*/ #define VLT_VT2PU(x) (((ULONG)(x) << 14) / VBASE) /*======================================================================= Current real value to pu value function define =======================================================================*/ #define CUR_AP2PU(x) (((ULONG)(x) << 14) / IBASE) /*======================================================================= Angle real value to pu value function define =======================================================================*/ #define ANG_DEG2PU(x) (((SLONG)(x) << 15) / 360) /*======================================================================= Bandwidth real value to pu value function define =======================================================================*/ #define BW_HZ2PU(x) (((ULONG)(x) << 15) / FBASE) /************************************************************************ Constant Table *************************************************************************/ /************************************************************************ TypeDefs & Structure defines *************************************************************************/ /************************************************************************ Exported Variables: *************************************************************************/ /************************************************************************ RAM ALLOCATION: *************************************************************************/ /************************************************************************ Exported Function Call Prototypes (N/A) *************************************************************************/ /************************************************************************ Local Function Call Prototypes (N/A) *************************************************************************/ /************************************************************************ Head files (N/A) *************************************************************************/ /************************************************************************ Flag Define (N/A) *************************************************************************/ #endif /************************************************************************* Copyright (c) 2019 Welling Motor Technology(Shanghai) Co. Ltd. All rights reserved. ************************************************************************* End of this File (EOF)! Do not put anything after this part! *************************************************************************/