how come m-file and simulink generate different results with same PID controller design?
조회 수: 15 (최근 30일)
이전 댓글 표시
the transfer function 1/(s^2+10s+20) closed-loop transfer function is therefore ( Kds^2+Kps+ki )/ [s^3+(10+Kd)s^2+(20+Kp)s+Ki]
running the following code in command window generates as what figure1 shows.
Kp=350; Ki=300; Kd=50;
num=[Kd Kp Ki]; den=[1 10+Kd 20+Kp Ki];
t=0:0.01:2; step(num,den,t)
tried to obtain the same plot of same characteristics by using Simulink http://imageshack.us/photo/my-images/861/83492059.jpg/
http://imageshack.us/photo/my-images/254/31185574.jpg/ how come there is delay? and the peak amplitube exceeds 1 that step response generated by m-file doesnt? would also like to know how to tell some characteristics like rise time, settling time from the plot generated by scope?
detailed explanations are appriciated,thank you
댓글 수: 0
채택된 답변
Arkadiy Turevskiy
2012년 4월 9일
how come there is a delay
It is not a delay. In your model you have the reference signal stepping at 1 second - default value of "Step time" field in Step block. To have the step happen at 0, double-click Step block, and change "Step time" to 0 in block dialog.
and the peak amplitube exceeds 1 that step response generated by m-file doesnt?
The response you see from plot command is correct. The reason why your Simulink model produces a response that look different (the overshoot, not the step time issue addressed above) is because you are using pure derivative block. This is not a good idea, and in real life you never want to differentiate a noisy measurement signal. The recommended approach is to replace a pure derivative s with a derivative plus a lowpass filter: s * N/(s+N). Make N a large number, 1,000, and you will see Simulink model provide essentially the same response as step command.
would also like to know how to tell some characteristics like rise time, settling time from the plot generated by scope?
You cannot do it directly in the scope. The best way would probably be to save the simulation results to worskspace, and then use stepinfo function. You can even include a callback to your model to do this automatically when simulation ends.
Finally, some suggestions on working with PID controllers.
In MATLAB, you can use pid objects. For example, to create the controller you have and plot closed-loop step response:
>>s=tf('s');
>>sys=1/(s^2+10*s+20);
>>C1=pid(350,300,50);
>> C2=pid(350,300,50,0.001); % use lowpass filter for derivative term with N=1,000
>>step(feedback(C1*sys,1)); % plot closed loop step response
>> hold on; step(feedback(C2*sys,1),'r'); %observe essentially unchanged response
In Simulink, use PID Controller block. Parameterize with C2.Kp, C2.Ki, C2.Kd, 1/C2.Tf, and you will see the same response as from step command.
HTH.
Arkadiy
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!