Control Example using Matlab Control Example using Matlab Cruise Control Modeling a Cruise Control System • The inertia of the wheels is neglected • Aerodynamic Drag is neglected – is proportional to[.]
Control Example using Matlab Cruise Control Modeling a Cruise Control System Physical setup and system equations • The inertia of the wheels is neglected • Aerodynamic Drag is neglected – is proportional to the square of the car’s speed • It is assumed that friction is opposing the motion of the car –is proportional to the car's speed • The problem is reduced to the simple mass and damper system Modeling a Cruise Control System • Using Newton's law, the dynamic equation for this system is: m x b x u where u is the force from the engine • There are several different ways to describe a system of linear differential equations • To calculate the Transfer Function, we shall use the Stare Space representation then transform it to TF using ss2tf State-space equations • The state-space representation is given by the equations: dx A x Bu dt y C x Du where x is an n by vector representing the state (commonly position and velocity variables in mechanical systems), u is a scalar representing the input (commonly a force or torque in mechanical systems), and y is a scalar representing the output State Equation for our CC model The state vector x is [ x, x ] and y is x The equation m x b x u is b u x x m m or x x b u x m x m x y 0 1 0 u x Design requirements • For this example, let's assume that m = 1000kg b = 50Nsec/m u = 500N • Design requirements – When the engine gives a 500 Newton force, the car will reach a maximum velocity of 10 m/s (22 mph) – An automobile should be able to accelerate up to that speed in less than seconds Since this is only a cruise control system, a 10% overshoot on the velocity will not much damage A 2% steadystate error is also acceptable for the same reason – Rise time < sec Overshoot < 10% Steady state error < 2% Matlab representation and open-loop response m = 1000; b = 50; u = 500; A = [0 1; -b/m] B = [0; 1/m] C = [0 1] D=0 step(A,u*B,C,D) this step response does not meet the design criteria placed on the problem The system is overdamped, so the overshoot response is fine, but the rise time is too slow P controller • The first thing to in this problem is to transform the state-space equations into transfer function form m = 1000; b = 50; u = 500; A = [0 1; -b/m] B = [0; 1/m] C = [0 1] D = [num,den]=ss2tf(A,B,C,D) • Next, close the loop and add some proportional control to see if the response can be improved k = 100; [numc,denc] = cloop(k*num,den,-1); function %Closed-loop transfer t = 0:0.1:20; step(10*numc,denc,t) %for 10m/sec the signal used by step axis([0 20 10]) Get the Transfer Function • For m = 1000; b = 50; u = 500; A = [0 1; -b/m] B = [0; 1/m] C = [0 1] D =0 [num,den]=ss2tf(A,B,C,D) • Matlab should return the following to the command window: num = 0.0010 den = 1.0000 0.0500 • This is the way Matlab presents the TF 0.001s + -s^2 + 0.05s + Step function • The step function is one of most useful functions in Matlab for control design • Given a system that can be described by either a transfer function or a set of state-space equations, the response to a step input can immediately be plotted • A step input can be described as a change in the input from zero to a finite value at time t = • By default, the step command performs a unit step (i.e the input goes from zero to one at time t = 0) • The basic command to use the step function is one of the following – (depending if you have a set of state-space equations or a transfer function form): step(A,B,C,D) step(num,den)