本帖最后由 qwer0145 于 2016-7-13 17:56 编辑
pid_spd.Fdb = spd; //速度反馈
pid_spd.Ref = Spdref; //速度给定
PID_MACRO(pid_spd)
Duty = pid_spd.Out;
// temp1 = _IQmpy(4500,(Duty+_IQ(0.5)));
CMP = 4500*(int32)_IQtoIQ15(Duty+_IQ(0.5)); //IQ0*IQ15 = IQ15
CMPA = (int16)(CMP>>15);
DELAY_US(50);
EPwm1Regs.CMPA.half.CMPA = CMPA; //IQ15->IQ0
EPwm2Regs.CMPA.half.CMPA = CMPA;
// EPwm2Regs.CMPA.half.CMPA = (Uint16)_IQmpy(4500,(Duty+_IQ(0.5)));
// EPwm1Regs.CMPA.half.CMPA = InitCmpA;
// EPwm2Regs.CMPA.half.CMPA = InitCmpA;
程序中InitCmpA是常量,CMPA是通过计算出来的数,如果把EPwm1Regs.CMPA.half.CMPA = CMPA; //IQ15->IQ0
EPwm2Regs.CMPA.half.CMPA = CMPA;
这两句屏蔽,将InitCmpA对应的两句放开,程序运行正常,但现在这种情况上电后,直接复位
|