在网上看见一种准PR+PI的控制算法!我用的是28035!程序是这样的:
Kp = _IQ(1.6);
Kr = _IQ(10);
Ki = _IQ(0.14);
A0 = _IQ(0.0002499);
A1 = _IQ(-2.9992535);
A2 = _IQ(2.9987536);
A3 = _IQ(0.9995002);
D1 = _IQ(-0.9992535);
D2 = _IQ(-0.9997533);
temp = _IQmpy(Kr,A0);
B0 = Kp + Ki + temp;
B1 = _IQmpy(Ki,D1);
B1 = B1 + _IQmpy(Kp,A1);
B1 = B1 - temp;
B2 = _IQmpy(Ki,D2);
B2 = B2 + _IQmpy(Kp,A2);
B2 = B2 - temp;
B3 = _IQmpy(Ki,A3);
B3 = B3 - _IQmpy(Kp,A3);
B3 = B3 + temp;
temp1 = _IQmpy(B0,error);
temp2 = _IQmpy(B1,error1);
temp3 = _IQmpy(B2,error2);
temp4 = _IQmpy(B3,error3);
temp5 = _IQmpy(A1,out_pre);
temp6 = _IQmpy(A2,out_pre1);
temp7 = _IQmpy(A3,out_pre2);
out = temp1 + temp2 + temp3 + temp4 - temp5 - temp6 + temp7;
error3 = error2;
error2 = error1;
error1 =error;
out_pre2 = out_pre1;
out_pre1 = out_pre;
out_pre = out;
为什么数据会溢出?求出的值很大?不知道三阶的离散不是这样运算的?求论坛的大神们帮们分析解答下,谢谢啊! |