欢迎来到天天文库
浏览记录
ID:25025411
大小:52.00 KB
页数:7页
时间:2018-11-17
《电机的PID有效控制.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include"DSP28_Device.h"#include"pmsm3_1.h"#include"parameter.h"#include"build.h"//函数声明interruptvoidEvaTimer1(void);interruptvoidEvaTimer2(void);//全局变量定义floatVd_testing=0;/*Vdtesting(pu)*/floatVq_testing=0.25;/*Vqtesting(pu)*/floatId_ref=0;/*Idreference(pu)*/floatIq_ref=0.4;/*Iqrefer
2、ence(pu)*/floatspeed_ref=0.2;/*Speedreference(pu)*/floatT=0.001/ISR_FREQUENCY;/*Sampingperiod(sec),seeparameter.h*/intisr_ticker=0;intpwmdac_ch1=0;intpwmdac_ch2=0;intpwmdac_ch3=0;volatileintenable_flg=0;intlockrtr_flg=1;intspeed_loop_ps=10;//速度环定标器intspeed_loop_count=1;//速度环计数器CLARKE
3、clarke1=CLARKE_DEFAULTS;PARKpark1=PARK_DEFAULTS;IPARKipark1=IPARK_DEFAULTS;PIDREG3pid1_id=PIDREG3_DEFAULTS;PIDREG3pid1_iq=PIDREG3_DEFAULTS;PIDREG3pid1_spd=PIDREG3_DEFAULTS;PWMGENpwm1=PWMGEN_DEFAULTS;PWMDACpwmdac1=PWMDAC_DEFAULTS;SVGENDQsvgen_dq1=SVGENDQ_DEFAULTS;QEPqep1=QEP_DEFAULTS;
4、SPEED_MEAS_QEPspeed1=SPEED_MEAS_QEP_DEFAULTS;6DRIVEdrv1=DRIVE_DEFAULTS;RMPCNTLrc1=RMPCNTL_DEFAULTS;RAMPGENrg1=RAMPGEN_DEFAULTS;ILEG2DCBUSMEASilg2_vdc1=ILEG2DCBUSMEAS_DEFAULTS;//主函数voidmain(void){//系统初始化InitSysCtrl();//HISPCP设置EALLOW;SysCtrlRegs.HISPCP.all=0x0000;/*SYSCLKOUT/1*/EDIS;/
5、/禁止并清除所有CPU中断:DINT;IER=0x0000;IFR=0x0000;//初始化Pie到默认状态InitPieCtrl();//初始化PIE相量表InitPieVectTable();//初始化EVA定时器1://设置定时器1寄存器(EVA)EvaRegs.GPTCONA.all=0;//等待使能标志位while(enable_flg==0){//使能定时器1的下溢中断EvaRegs.EVAIMRA.bit.T1UFINT=1;EvaRegs.EVAIFRA.bit.T1UFINT=1;//使能CAP3中断(定时器2)EvaRegs.EVAIMRC.
6、bit.CAP3INT=1;EvaRegs.EVAIMRC.bit.CAP3INT=1;};6//重新分配中断向量EALLOW;PieVectTable.T1UFINT=&EvaTimer1;PieVectTable.CAPINT3=&EvaTimer2;EDIS;//使能PIE组2的中断6(T1UFINT)PieCtrlRegs.PIEIER2.all=M_INT6;//使能PIE组3的中断7(CAPINT3)PieCtrlRegs.PIEIER3.all=M_INT7;//使能CPUINT2(T1UFINT)和INT3(CAPINT3):IER
7、=(M_IN
8、T2
9、M_INT3);//使能全局中断和最高优先级适时调试事件管理器功能:EINT;//使能全局中断INTMERTM;//使能适时调试中断DBGM/*模块初始化*/pwm1.n_period=SYSTEM_FREQUENCY*1000000*T/2;/*预定标器X1(T1),ISR周期=Tx1*/pwm1.init(&pwm1);pwmdac1.pwmdac_period=2500;/*PWM频率=30kHz*/pwmdac1.PWM_DAC_IPTR0=&pwmdac_ch1;pwmdac1.PWM_DAC_IPTR1=&pwmdac_ch2;pwmdac1.
10、PWM_DAC_IPTR
此文档下载收益归作者所有