毕业论文基于TMS320F2812的永磁同步电动机SVPWM空间矢量控制算法实现的源代码终稿.docx

上传人:b****8 文档编号:30569443 上传时间:2023-08-16 格式:DOCX 页数:31 大小:19.90KB
下载 相关 举报
毕业论文基于TMS320F2812的永磁同步电动机SVPWM空间矢量控制算法实现的源代码终稿.docx_第1页
第1页 / 共31页
毕业论文基于TMS320F2812的永磁同步电动机SVPWM空间矢量控制算法实现的源代码终稿.docx_第2页
第2页 / 共31页
毕业论文基于TMS320F2812的永磁同步电动机SVPWM空间矢量控制算法实现的源代码终稿.docx_第3页
第3页 / 共31页
毕业论文基于TMS320F2812的永磁同步电动机SVPWM空间矢量控制算法实现的源代码终稿.docx_第4页
第4页 / 共31页
毕业论文基于TMS320F2812的永磁同步电动机SVPWM空间矢量控制算法实现的源代码终稿.docx_第5页
第5页 / 共31页
点击查看更多>>
下载资源
资源描述

毕业论文基于TMS320F2812的永磁同步电动机SVPWM空间矢量控制算法实现的源代码终稿.docx

《毕业论文基于TMS320F2812的永磁同步电动机SVPWM空间矢量控制算法实现的源代码终稿.docx》由会员分享,可在线阅读,更多相关《毕业论文基于TMS320F2812的永磁同步电动机SVPWM空间矢量控制算法实现的源代码终稿.docx(31页珍藏版)》请在冰豆网上搜索。

毕业论文基于TMS320F2812的永磁同步电动机SVPWM空间矢量控制算法实现的源代码终稿.docx

毕业论文基于TMS320F2812的永磁同步电动机SVPWM空间矢量控制算法实现的源代码终稿

/*==============================================================================

SystemName:

PMSM34

FileName:

PMSM3_4.C

Description:

PrimarysystemfilefortheRealImplementationofPositionControl

BasedSensoredFieldOrientationControlforaThreePhasePermanent-

MagnetSynchronousMotor(PMSM)usingQEPsensor

Originator:

DigitalcontrolsystemsGroup-TexasInstruments

Note:

Inthissoftware,thedefaultinverterissupposedtobeDMC550board.

=====================================================================================

History:

-------------------------------------------------------------------------------------

04-15-2005Version3.20:

SupportbothF280xandF281xtargets

04-25-2005Version3.21:

MoveEINTandERTMdowntoensurethatallinitialization

iscompletedbeforeinterruptsareallowed.

=================================================================================*/

//Includeheaderfilesusedinthemainfunction

#include"target.h"

#include"DSP281x_Device.h"

#include"IQmathLib.h"

#include"pmsm3_4.h"

#include"parameter.h"

#include"build.h"

#include

//Prototypestatementsforfunctionsfoundwithinthisfile.

interruptvoidMainISR(void);

interruptvoidQepISR(void);

interruptvoidPDPINTAISR(void);

//Globalvariablesusedinthissystem

float32VdTesting=0;//Vdtesting(pu)

float32VqTesting=0.25;//Vqtesting(pu)

float32IdRef=0;//Idreference(pu)

float32IqRef=0.2;//Iqreference(pu)

float32SpeedRef=0.1;//Speedreference(pu)

float32PositionRef=0.5;//Positionreference(MechanicalrotorAnglele(pu)

float32T=0.001/ISR_FREQUENCY;//Sampingperiod(sec),seeparameter.h

Uint16IsrTicker=0;

Uint16BackTicker=0;

volatileUint16EnableFlag=FALSE;

Uint16LockRotorFlag=FALSE;

Uint16SpeedLoopPrescaler=10;//Speedloopprescaler

Uint16SpeedLoopCount=1;//Speedloopcounter

//Instanceafewtransformobjects

CLARKEclarke1=CLARKE_DEFAULTS;

PARKpark1=PARK_DEFAULTS;

IPARKipark1=IPARK_DEFAULTS;

//InstancePIDregulatorstoregulatethedandqsynchronousaxiscurrents,

//speedandposition

PIDREG3pid1_id=PIDREG3_DEFAULTS;

PIDREG3pid1_iq=PIDREG3_DEFAULTS;

PIDREG3pid1_pos=PIDREG3_DEFAULTS;

PIDREG3pid1_spd=PIDREG3_DEFAULTS;

//InstanceaPWMdriverinstance

PWMGENpwm1=PWMGEN_DEFAULTS;

//InstanceaSpaceVectorPWMmodulator.Thismodulatorgeneratesa,bandc

//phasesbasedonthedandqstationeryreferenceframeinputs

SVGENDQsvgen_dq1=SVGENDQ_DEFAULTS;

//InstanceaQEPinterfacedriver

QEPqep1=QEP_DEFAULTS;

//InstanceaspeedcalculatorbasedonQEP

SPEED_MEAS_QEPspeed1=SPEED_MEAS_QEP_DEFAULTS;

//Instancearampcontrollertosmoothlyrampthefrequency

RMPCNTLrc1=RMPCNTL_DEFAULTS;

//InstancearampgeneratortosimulateanAnglele

RAMPGENrg1=RAMPGEN_DEFAULTS;

//Createaninstanceofthecurrent/dc-busvoltagemeasurementdriver

ILEG2DCBUSMEASilg2_vdc1=ILEG2DCBUSMEAS_DEFAULTS;

voidmain(void)

{

//******************************************

//InitializationcodeforDSP_TARGET=F2812

//******************************************

//InitializeSystemControlregisters,PLL,WatchDog,Clockstodefaultstate:

//ThisfunctionisfoundintheDSP281x_SysCtrl.cfile.

InitSysCtrl();

//HISPCPprescaleregistersettings,normallyitwillbesettodefaultvalues

EALLOW;//ThisisneededtowritetoEALLOWprotectedregisters

SysCtrlRegs.HISPCP.all=0x0000;//SYSCLKOUT/1

EDIS;//ThisisneededtodisablewritetoEALLOWprotectedregisters

//DisableandclearallCPUinterrupts:

DINT;

IER=0x0000;

IFR=0x0000;

//InitializePieControlRegistersToDefaultState:

//ThisfunctionisfoundintheDSP281x_PieCtrl.cfile.

InitPieCtrl();

//InitializethePIEVectorTableToaKnownState:

//ThisfunctionisfoundinDSP281x_PieVect.c.

//ThisfunctionpopulatesthePIEvectortablewithpointers

//totheshellISRfunctionsfoundinDSP281x_DefaultIsr.c.

InitPieVectTable();

//InitializeGPIO;MUX为0,表示IO;MUX为1表示外围;

//DIR为0,表示输入;DIR为1表示输出

EALLOW;

GpioMuxRegs.GPAMUX.all=0X073F;

GpioMuxRegs.GPADIR.all=0XC0C0;

GpioMuxRegs.GPBMUX.all=0X0000;

GpioMuxRegs.GPBDIR.all=0X0000;

GpioMuxRegs.GPDMUX.bit.T1CTRIP_PDPA_GPIOD0=1;//功能PDPINTA

GpioMuxRegs.GPDMUX.bit.T2CTRIP_SOCA_GPIOD1=0;//INPUT

GpioMuxRegs.GPDDIR.bit.GPIOD1=0;

GpioMuxRegs.GPDMUX.bit.T3CTRIP_PDPB_GPIOD5=0;

GpioMuxRegs.GPDDIR.bit.GPIOD5=0;

GpioMuxRegs.GPDMUX.bit.T4CTRIP_SOCB_GPIOD6=0;

GpioMuxRegs.GPDDIR.bit.GPIOD6=0;

GpioMuxRegs.GPEMUX.bit.XINT1_XBIO_GPIOE0=0;

GpioMuxRegs.GPEMUX.bit.XINT2_ADCSOC_GPIOE1=0;

GpioMuxRegs.GPEMUX.bit.XNMI_XINT13_GPIOE2=0;

GpioMuxRegs.GPEDIR.bit.GPIOE0=0;

GpioMuxRegs.GPEDIR.bit.GPIOE1=0;

GpioMuxRegs.GPEDIR.bit.GPIOE2=0;

GpioMuxRegs.GPFMUX.all=0X4037;

GpioMuxRegs.GPFDIR.all=0X01C8;

GpioMuxRegs.GPGMUX.bit.SCITXDB_GPIOG4=0;

GpioMuxRegs.GPGMUX.bit.SCIRXDB_GPIOG5=0;

GpioMuxRegs.GPGDIR.bit.GPIOG4=1;

GpioMuxRegs.GPGDIR.bit.GPIOG5=1;

EDIS;

//Userspecificfunctions,Reassignvectors(optional),EnableInterrupts:

//InitializeEVATimer1:

//SetupTimer1Registers(EVA)

EvaRegs.GPTCONA.all=0;

//Waitingforenableflagset

while(EnableFlag==FALSE)

{

BackTicker++;

}

//EnableUnderflowinterruptbitsforGPtimer1

EvaRegs.EVAIMRA.bit.T1UFINT=1;

EvaRegs.EVAIFRA.bit.T1UFINT=1;

//EnableCAP3interruptbitsforGPtimer2

EvaRegs.EVAIMRC.bit.CAP3INT=1;

EvaRegs.EVAIFRC.bit.CAP3INT=1;

//ReassignISRs.

//ReassignthePIEvectorforT1UFINTandCAP3INTtopointtoadifferent

//ISRthentheshellroutinefoundinDSP281x_DefaultIsr.c.

//ThisisdoneiftheuserdoesnotwanttousetheshellISRroutine

//butinsteadwantstousetheirownISR.

EALLOW;//ThisisneededtowritetoEALLOWprotectedregisters

PieVectTable.T1UFINT=&MainISR;

PieVectTable.CAPINT3=&QepISR;

PieVectTable.PDPINTA=&PDPINTAISR;

EDIS;//ThisisneededtodisablewritetoEALLOWprotectedregisters

//EnablePIEgroup2interrupt6forT1UFINT

PieCtrlRegs.PIEIER2.all=M_INT6;

//EnablePIEgroup3interrupt7forCAP3INT

PieCtrlRegs.PIEIER3.all=M_INT7;

//EnablePIEgroup1interrupt1forPDPINTA

PieCtrlRegs.PIEIER1.all=M_INT1;

//EnableCPUINT2forT1UFINTandINT3forCAP3INT:

IER|=(M_INT2|M_INT3|M_INT1);

//InitializePWMmodule

pwm1.PeriodMax=SYSTEM_FREQUENCY*1000000*T/2;//PerscalerX1(T1),ISRperiod=Tx1

pwm1.init(&pwm1);

//InitializeQEPmodule

qep1.LineEncoder=2000;

qep1.MechScaler=_IQ30(0.25/qep1.LineEncoder);

qep1.PolePairs=P/2;

qep1.CalibratedAngle=-1250;

qep1.init(&qep1);

//InitializetheSpeedmoduleforQEPbasedspeedcalculation

speed1.K1=_IQ21(1/(BASE_FREQ*T));

speed1.K2=_IQ(1/(1+T*2*PI*30));//Low-passcut-offfrequency

speed1.K3=_IQ

(1)-speed1.K2;

speed1.BaseRpm=120*(BASE_FREQ/P);

//InitializeADCmodule

//NoteforDMC550:

//-At24dc-busvolt,theADCinputformeasuredVdc_busrangeis24*1/(24.9+1)=0.927volt

//-Then,Vdc_busgain=3.0/0.927=3.2375(or0x675CinQ13)

ilg2_vdc1.VdcMeasGain=0x675C;

ilg2_vdc1.ChSelect=0x0610;

ilg2_vdc1.init(&ilg2_vdc1);

//InitializetheRAMPGENmodule

rg1.StepAngleMax=_IQ(BASE_FREQ*T);

//InitializetheRAMPGENmodule

rc1.RampDelayMax=5;

//InitializethePID_REG3moduleforId

pid1_id.Kp=_IQ(0.1);

pid1_id.Ki=_IQ(T/0.02);

pid1_id.Kd=_IQ(0/T);

pid1_id.Kc=_IQ(0.5);

pid1_id.OutMax=_IQ(0.30);

pid1_id.OutMin=_IQ(-0.30);

//InitializethePID_REG3moduleforIq

pid1_iq.Kp=_IQ(0.1);

pid1_iq.Ki=_IQ(T/0.02);

pid1_iq.Kd=_IQ(0/T);

pid1_iq.Kc=_IQ(0.5);

pid1_iq.OutMax=_IQ(0.95);

pid1_iq.OutMin=_IQ(-0.95);

//InitializethePID_REG3moduleforspeedcontrol

pid1_spd.Kp=_IQ

(1);

pid1_spd.Ki=_IQ(T*SpeedLoopPrescaler/0.3);

pid1_spd.Kd=_IQ(0/(T*SpeedLoopPrescaler));

pid1_spd.Kc=_IQ(0.2);

pid1_spd.OutMax=_IQ

(1);

pid1_spd.OutMin=_IQ(-1);

//InitializethePID_REG3moduleforpositioncontrol

pid1_pos.Kp=_IQ(28.2);

pid1_pos.Ki=_IQ(0);//Integraltermisnotused

pid1_pos.Kd=_IQ(0);//Derivativetermisnotused

pid1_pos.Kc=_IQ(0);

pid1_pos.OutMax=_IQ

(1);

pid1_pos.OutMin=_IQ(-1);

//EnableglobalInterruptsandhigherpriorityreal-timedebugevents:

EINT;//EnableGlobalinterruptINTM

ERTM;//EnableGlobalrealtimeinterruptDBGM

//IDLEloop.Justsitandloopforever:

for(;;)BackTicker++;

}

interruptvoidMainISR(void)

{

//VerifyingtheISR

IsrTicker++;

//*****************LEVEL1*****************

#if(BUILDLEVEL==LEVEL1)

//------------------------------------------------------------------------------

//ConnectinputsoftheRMPmoduleandcalltheRampcontrol

//calculationfunction.

//------------------------------------------------------------------------------

rc1.TargetValue=_IQ(SpeedRef);

rc1.calc(&rc1);

//------------------------------------------------------------------------------

//ConnectinputsoftheRAMPGENmoduleandcalltheRampgenerator

//calculationfunction.

//------------------------------------------------------------------------------

rg1.Freq=rc1.SetpointValue;

rg1.calc(&rg1);

//------------------------------------------------------------------------------

//ConnectinputsoftheINV_PARKmoduleandcalltheinverseparktransformation

//calculationfunction.

//------------------------------------------------------------------------------

ipark1.Ds=_IQ(VdTesting);

ipark1.Qs=_IQ(VqTesting);

ipark1.Angle=rg1.Out;

ipark1.calc(&ipark1);

//------------------------------------------------------------------------------

//Connect

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 面试

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1