AN908
DS00908A-page 20
2004 Microchip Technology Inc.
UserParms.h
//#define TORQUE_MODE
#define DIAGNOSTICS
//**************** Oscillator ************************************
#define dFoscExt
7372800
// External Crystal or Clock Frequency (Hz)
#define dPLL
8
// PLL ratio
#define dLoopTimeInSec
0.00005
// PWM Period - 100 uSec, 10Khz PWM
#define dDeadTimeSec
0.000002
// Deadtime in seconds
// 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
#define dDispLoopTime
0.100
// Display and button polling loop
//**************** Motor Parameters ******************************
#define diPoles
1
// Number of pole pairs
#define diCntsPerRev
2000
// Encoder Lines per revolution
#define diNomRPM
3600
// Name Plate Motor RPM
#define dfRotorTmConst
0.078
// Rotor time constant in sec, from mfgr
//**************** Measurement *************************************
#define diIrpPerCalc
30
// PWM loops per velocity calculation
//************** PI Coefficients ************************************
#define dDqKp
0x2000
// 4.0
(NKo = 4)
#define dDqKi
0x0100;
// 0.125
#define dDqKc
0x0100;
// 0.125
#define dDqOutMax
0x5A82;
// 0.707
set to prevent saturation
#define dQqKp
0x2000;
// 4.0
(NKo = 4)
#define dQqKi
0x0100;
// 0.125
#define dQqKc
0x0100;
// 0.125
#define dQqOutMax
0x5A82;
// 0.707
set to prevent saturation
#define dQrefqKp
0x4000
// 8.0
(NKo = 4)
#define dQrefqKi
0x0800
// 1.0
#define dQrefqKc
0x0800
// 1.0
#define dQrefqOutMax
0x3FFF
// 0.4999
set to prevent saturation
//************** ADC Scaling ***************************************
// Scaling constants:
Determined by calibration or hardware design.
#define dqK
0x3FFF;
// equivalent to 0.4999
#define dqKa
0x3FFF;
// equivalent to 0.4999
#define dqKb
0x3FFF;
// equivalent to 0.4999
//************** Field Weakening **************************************
// Flux reference value in constant torque range.
// Determined empirically to give rated volts/hertz
#define dqK1
3750;
//