📄 userparms.h
字号:
#ifndef UserParms_H
#define UserParms_H
// This is a macro used to convert a floating point value to a
// fixed point fractional value.
#define Q15(X) \
((X < 0.0) ? (int)(32768*(X) - 0.5) : (int)(32767*(X) + 0.5)) ;
//************** Oscillator **************
#define dFoscExt 7372800 // External Crystal or Clock Frequency (Hz)
#define dPLL 8 // PLL ratio
#define dLoopTimeInSec 0.00005 // PWM Period - 50 uSec, 20Khz PWM
#define dDeadTimeSec 0.000002 // Deadtime in seconds
#define dDispLoopTime 0.100 // Display and button polling loop period in sec
// Derived
#define dFosc (dFoscExt*dPLL) // Clock frequency (Hz)
#define dFcy (dFosc/4) // Instruction cycle frequency (Hz)
#define dTcy (1.0/dFcy) // Instruction cycle period (sec)
#define dDeadTime (int)(dDeadTimeSec*dFcy) // Dead time in dTcys
#define dLoopInTcy (dLoopTimeInSec/dTcy) // Basic loop period in units of Tcy
// Number of control loops that must execute before the button and display
// routine is executed.
#define dDispLoopCnt (dDispLoopTime/dLoopTimeInSec)
//************** Motor Parameters **************
#define diPoles 1 // Number of pole pairs
#define diCntsPerRev 2000 // Encoder counts per revolution
#define diNomRPM 3600 // Name Plate Motor RPM
#define dfRotorTmConst 0.078 // Rotor time constant in sec, from manufacturer
//************** Open Loop **************
#define dqOL_VelMech 2150 // 900 RPM for test
//************** Measurement **************
#define diIrpPerCalc 40 // PWM loops per velocity calculation
//************** PI Coefficients **************
// This definition can be used to bypass the velocity control loop.
// If TORQUE_MODE is defined, then the potentiometer demand value
// is passed directly to the Q (torque) control loop.
//#define TORQUE_MODE
//******** D Control Loop Coefficients *******
#define dDqKp Q15(0.3125); //
#define dDqKi Q15(0.0625); //
#define dDqKc Q15(0.0625); //
#define dDqOutMax Q15(0.7071); //
//******** Q Control Loop Coefficients *******
#define dQqKp Q15(0.3125); //
#define dQqKi Q15(0.0625); //
#define dQqKc Q15(0.0625); //
#define dQqOutMax Q15(0.7071); //
//*** Velocity Control Loop Coefficients *****
#define dQrefqKp Q15(0.375); //
#define dQrefqKi Q15(0.0625); //
#define dQrefqKc Q15(0.0625); //
#define dQrefqOutMax Q15(0.5); //
//************** ADC Scaling **************
// Scaling constants: Determined by calibration or hardware design.
#define dqK Q15(0.5); //
#define dqKa Q15(0.5); //
#define dqKb Q15(0.5); //
//************** Field Weakening **************
// Field Weakening constant for constant torque range
#define dqK1 Q15(0.114); // Flux reference value
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -