![Microchip Technology AN908 Using Manual Download Page 34](http://html1.mh-extra.com/html/microchip-technology/an908/an908_using-manual_1785807034.webp)
AN908
DS00908A-page 34
2004 Microchip Technology Inc.
InitCurModel.c
// Scaling for current model routine
#include "general.h"
#include "Parms.h"
#include "CurModel.h"
/**********************************************************
InitCurModelScaling
Initialize scaling constants for current model routine.
Physical constants:
fRotorTmConst Rotor time constant in sec
Physical form of equations:
Magnetizing current (amps):
Imag = Imag + (fLoopPeriod/fRotorTmConst)*(Id - Imag)
Slip speed in RPS:
VelSlipRPS = (1/fRotorTmConst) * Iq/Imag / (2*pi)
Rotor flux speed in RPS:
VelFluxRPS = iPoles * VelM VelSlipRPS
Rotor flux angle (radians):
AngFlux = A fLoopPeriod * 2 * pi * VelFluxRPS
Scaled Variables:
qImag Magnetizing current scaled by maximum current
qVelSlip Mechnical Slip velocity in RPS scaled by fScaleMechRPS
qAngFlux Flux angle scaled by pi
Scaled Equations:
qImag = qImag + qKcur * (qId - qImag)
qVelSlip = Kslip * qIq/qImag
qAngFlux = qA Kdelta * (qV qVelSlip)
Scaling factors:
qKcur = (2^15) * (fLoopPeriod/fRotorTmConst)
qKdelta = (2^15) * 2 * iPoles * fLoopPeriod * fScaleMechRPS
qKslip = (2^15)/(2 * pi * fRotorTmConst * iPoles * fScaleMechRPS)
**********************************************************/
bool InitCurModelScaling( void )
{
CurModelParm.qKcur = 32768.0 * MotorParm.fLoopPeriod / MotorParm.fRotorTmConst;
CurModelParm.qKdelta = 32768.0 * 2 * MotorParm.iPoles * MotorParm.fLoopPeriod *
MotorParm.fScaleMechRPS;
CurModelParm.qKslip = 32768.0/(6.2832 * MotorParm.iPoles *
MotorParm.fScaleMechRPS*MotorParm.fRotorTmConst);
// Maximum allowed slip speed
CurModelParm.qMaxSlipVel = 32768.0/8;
// Initialize private variables used by CurrModel
InitCurModel();
return False;
}