Question
Please convert all matlab commands to Skilab commands. Don't do anything else just convert to skilab commands. a. We enter this state-space model into MATLAB
Please convert all matlab commands to Skilab commands. Don't do anything else just convert to skilab commands.
a. We enter this state-space model into MATLAB using the following commands:
m = 1000; b = 50;
A = -b/m; B = 1/m; C = 1; D = 0;
cruise_ss = ss(A,B,C,D);
We enter the transfer function model into MATLAB using the following commands:
s = tf('s'); P_cruise = 1/(m*s+b);
b.The open-loop response of the system, without any feedback control, to a step input force of 500 Newtons is simulated in MATLAB as follows:
m = 1000; b = 50; u = 500;
s = tf('s'); P_cruise = 1/(m*s+b);
step(u*P_cruise)
The cruise control system has a single pole at s = -b/m which we can see plotted on the s-plane using the following MATLAB commands:
pzmap(P_cruise) axis([-1 1 -1 1])
We are also interested in the open-loop frequency response of the system which we find using the following MATLAB command:
bode(P_cruise)
c. We can define a PID controller in MATLAB using the transfer function directly:
Kp = 1; Ki = 1; Kd = 1;
s = tf('s'); C = Kp + Ki/s + Kd*s
Alternatively, we may use MATLAB's pid controller object to generate an equivalent continuous time controller as follows:
C = pid(Kp,Ki,Kd)
For now, use K_p equal to 100 and a reference speed of 10 m/s. Create a new m-file and enter the following commands.
m = 1000; b = 50; r = 10;
s = tf('s'); P_cruise = 1/(m*s + b);
Kp = 100; C = pid(Kp);
T = feedback(C*P_cruise,1)
t = 0:0.1:20; step(r*T,t) axis([0 20 0 10])
You can increase the proportional gain, K_p, to reduce the rise time and the steady-state error. Change the existing m-file so that K_p equals 5000 and rerun it in the MATLAB command window. You should see the following plot.
Kp = 5000; C = pid(Kp); T = feedback(C*P_cruise,1);
step(r*T,t) axis([0 20 0 10])
An addition of an integral controller to the system eliminates the steady-state error. For now, let K_p equal 600 and K_i equal 1 and see what happens to the response. Change your m-file to the following.
Kp = 600; Ki = 1; C = pid(Kp,Ki);
T = feedback(C*P_cruise,1);
step(r*T,t) axis([0 20 0 10])
Now adjust both the proportional gain, K_p, and the integral gain, K_i, to obtain the desired response. When you adjust the integral gain, K_i, we suggest you to start with a small value since a large K_i can de-stabilize the response. When K_p equals 800 and K_i equals 40, the step response will look like the following:
Kp = 800; Ki = 40; C = pid(Kp,Ki);
T = feedback(C*P_cruise,1);
step(r*T,t) axis([0 20 0 10])
Let K_p equal 1, K_i equal 1, and K_d equal 1 and enter the following commands into a new m-file.
Kp = 1; Ki = 1; Kd = 1; C = pid(Kp,Ki,Kd);
T = feedback(C*P_cruise,1);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started