基于TMS320F2812的永磁同步电动机SVPWM空间矢量控制算法实现的源代码资料.doc
《基于TMS320F2812的永磁同步电动机SVPWM空间矢量控制算法实现的源代码资料.doc》由会员分享,可在线阅读,更多相关《基于TMS320F2812的永磁同步电动机SVPWM空间矢量控制算法实现的源代码资料.doc(59页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Good is good, but better carries it.精益求精,善益求善。基于TMS320F2812的永磁同步电动机SVPWM空间矢量控制算法实现的源代码-/*=SystemName:PMSM34FileName:PMSM3_4.CDescription:PrimarysystemfilefortheRealImplementationofPositionControlBasedSensoredFieldOrientationControlforaThreePhasePermanent-MagnetSynchronousMotor(PMSM)usingQEPsensorOri
2、ginator:DigitalcontrolsystemsGroup-TexasInstrumentsNote:Inthissoftware,thedefaultinverterissupposedtobeDMC550board.=History:-04-15-2005Version3.20:SupportbothF280xandF281xtargets04-25-2005Version3.21:MoveEINTandERTMdowntoensurethatallinitializationiscompletedbeforeinterruptsareallowed.=*/Includehead
3、erfilesusedinthemainfunction#includetarget.h#includeDSP281x_Device.h#includeIQmathLib.h#includepmsm3_4.h#includeparameter.h#includebuild.h#include/Prototypestatementsforfunctionsfoundwithinthisfile.interruptvoidMainISR(void);interruptvoidQepISR(void);interruptvoidPDPINTAISR(void);/Globalvariablesuse
4、dinthissystemfloat32VdTesting=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
5、),seeparameter.hUint16IsrTicker=0;Uint16BackTicker=0;volatileUint16EnableFlag=FALSE;Uint16LockRotorFlag=FALSE;Uint16SpeedLoopPrescaler=10;/SpeedloopprescalerUint16SpeedLoopCount=1;/Speedloopcounter/InstanceafewtransformobjectsCLARKEclarke1=CLARKE_DEFAULTS;PARKpark1=PARK_DEFAULTS;IPARKipark1=IPARK_DE
6、FAULTS;/InstancePIDregulatorstoregulatethedandqsynchronousaxiscurrents,/speedandpositionPIDREG3pid1_id=PIDREG3_DEFAULTS;PIDREG3pid1_iq=PIDREG3_DEFAULTS;PIDREG3pid1_pos=PIDREG3_DEFAULTS;PIDREG3pid1_spd=PIDREG3_DEFAULTS;/InstanceaPWMdriverinstancePWMGENpwm1=PWMGEN_DEFAULTS;/InstanceaSpaceVectorPWMmodu
7、lator.Thismodulatorgeneratesa,bandc/phasesbasedonthedandqstationeryreferenceframeinputsSVGENDQsvgen_dq1=SVGENDQ_DEFAULTS;/InstanceaQEPinterfacedriverQEPqep1=QEP_DEFAULTS;/InstanceaspeedcalculatorbasedonQEPSPEED_MEAS_QEPspeed1=SPEED_MEAS_QEP_DEFAULTS;/Instancearampcontrollertosmoothlyrampthefrequency
8、RMPCNTLrc1=RMPCNTL_DEFAULTS;/InstancearampgeneratortosimulateanAngleleRAMPGENrg1=RAMPGEN_DEFAULTS;/Createaninstanceofthecurrent/dc-busvoltagemeasurementdriverILEG2DCBUSMEASilg2_vdc1=ILEG2DCBUSMEAS_DEFAULTS;voidmain(void)/*/InitializationcodeforDSP_TARGET=F2812/*/InitializeSystemControlregisters,PLL,
9、WatchDog,Clockstodefaultstate:/ThisfunctionisfoundintheDSP281x_SysCtrl.cfile.InitSysCtrl();/HISPCPprescaleregistersettings,normallyitwillbesettodefaultvaluesEALLOW;/ThisisneededtowritetoEALLOWprotectedregistersSysCtrlRegs.HISPCP.all=0x0000;/SYSCLKOUT/1EDIS;/ThisisneededtodisablewritetoEALLOWprotecte
10、dregisters/DisableandclearallCPUinterrupts:DINT;IER=0x0000;IFR=0x0000;/InitializePieControlRegistersToDefaultState:/ThisfunctionisfoundintheDSP281x_PieCtrl.cfile.InitPieCtrl();/InitializethePIEVectorTableToaKnownState:/ThisfunctionisfoundinDSP281x_PieVect.c./ThisfunctionpopulatesthePIEvectortablewit
11、hpointers/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_
12、GPIOD0=1;/功能PDPINTAGpioMuxRegs.GPDMUX.bit.T2CTRIP_SOCA_GPIOD1=0;/INPUTGpioMuxRegs.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;G
13、pioMuxRegs.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.GPGM
14、UX.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;/Waitingforenableflagsetwhile(EnableFlag=FALSE)BackTicker+;/EnableUnderf
15、lowinterruptbitsforGPtimer1EvaRegs.EVAIMRA.bit.T1UFINT=1;EvaRegs.EVAIFRA.bit.T1UFINT=1;/EnableCAP3interruptbitsforGPtimer2EvaRegs.EVAIMRC.bit.CAP3INT=1;EvaRegs.EVAIFRC.bit.CAP3INT=1;/ReassignISRs./ReassignthePIEvectorforT1UFINTandCAP3INTtopointtoadifferent/ISRthentheshellroutinefoundinDSP281x_Defaul
16、tIsr.c./ThisisdoneiftheuserdoesnotwanttousetheshellISRroutine/butinsteadwantstousetheirownISR.EALLOW;/ThisisneededtowritetoEALLOWprotectedregistersPieVectTable.T1UFINT=&MainISR;PieVectTable.CAPINT3=&QepISR;PieVectTable.PDPINTA=&PDPINTAISR;EDIS;/ThisisneededtodisablewritetoEALLOWprotectedregisters/En
17、ablePIEgroup2interrupt6forT1UFINTPieCtrlRegs.PIEIER2.all=M_INT6;/EnablePIEgroup3interrupt7forCAP3INTPieCtrlRegs.PIEIER3.all=M_INT7;/EnablePIEgroup1interrupt1forPDPINTAPieCtrlRegs.PIEIER1.all=M_INT1;/EnableCPUINT2forT1UFINTandINT3forCAP3INT:IER|=(M_INT2|M_INT3|M_INT1);/InitializePWMmodulepwm1.PeriodM
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 基于 TMS320F2812 永磁 同步电动机 SVPWM 空间 矢量 控制 算法 实现 源代码 资料
限制150内