I attached the file below. Please do not do number 3, only the simulation code for this model! Thank you.
Simulation of Automobile Cruise Control ENGR 1221 Designed to test skills with: simulation, graphical user interface 11/17/2021 Overview In a previous application assignment, you studied feedback control using a PID controller. In this project, you will apply that same control algorithm to control the speed of an automobile as it experiences a change of grade. Physical Model Despite its complex machinery, the dynamics of an automobile as it travels in a straight line, with no slipping between the wheels and the road, can be modeled by two relatively simple equations.1 The acceleration of the vehicle is: ? = ?? − ??? cos ? − 1 2 ????? 2 − ?? sin ? ? where • Fw is the force applied to the wheels • m is the mass of the vehicle, including its occupants and contents • f is the rolling resistance coefficient • is the density of air • CD is the drag coefficient • A is the front cross-sectional area • v is the speed of the vehicle • g is the acceleration of gravity • is the inclination angle of the road This equation is an application of Newton’s second law in the longitudinal direction with 4 external forces: traction, rolling resistance, drag, and gravity. The second equation is a simplified model of the drive train that relates the variation of Fw to the accelerator position, assuming first-order engine dynamics: ??? ?? = − ?? ? + ? ? ? ?? ? where • is the engine time constant • k is the engine torque gain factor • i is the gear ratio • Rw is the wheel radius 1 Adapted from the online course, “Model-Based Automotive Systems Engineering” from Chalmers University of Technology https://www.edx.org/course/model-based-automotive-systems-engineering?index=product&queryID=1032d0dd0332e300a064f9b0167cabf9&position=1 https://www.edx.org/school/chalmersx Simulation of Automobile Cruise Control ENGR 1221 Designed to test skills with: simulation, graphical user interface 11/17/2021 • u is the input (accelerator pedal position, given as an angle in radians) In this simple model, all of the complex mechanics of the engine and transmission are encapsulated in the time constant, , which represents how the engine responds when the accelerator position is changed. The transmission of the engine torque to the wheel force is captured with the parameters k, i, and Rw. Conditions for Cruising at Constant Speed At the beginning of the simulation, the vehicle can be taken as cruising at constant speed prior to experiencing a change in inclination or set point. The necessary wheel force and accelerator input for constant speed can be calculated by setting the acceleration and dFw/dt to 0 in the above equations. First, the necessary wheel force is: ?? = ??? cos ? + 1 2 ????? 2 + ?? sin ? Then, the required input is ? = ???? ? ? The vehicle parameters should be user inputs to the model. A representative set of values that can be used for testing is given in the table below. Project Requirements Simulation of Automobile Cruise Control ENGR 1221 Designed to test skills with: simulation, graphical user interface 11/17/2021 1. Write a simulation that calculates the position, velocity, and acceleration of the vehicle vs. time, given the input parameters of the model. 2. Apply the PID controller model from an earlier application to control the speed of the vehicle at a set point, with u being the input control signal. You can decide whether to include changes of gear ratio in the simulation. In practice, an automatic transmission would downshift (increase the gear ratio) when the vehicle hits an increase in grade or accelerates suddenly. A note about the controller: Unlike the temperature control application, you do not want the input signal, u, to be the output of the controller. Rather, you want the output of the controller to be the change in u, or the difference between u and its reference value. That is, you do NOT want this: u = PID (…); %No! But rather, one of the following: u = u + PID(…) or u = u0 + PID (…) where u0 is the reference input, i.e. the value that produced constant speed before the disturbance The first (wrong) way would mean that when the cruising speed is reached, the accelerator is released, which would not make sense. The second way continually adds (or subtracts) from the current input based on the error, while the third way calculates the input signal as a difference from the reference value based on the error. Either the second or third way will work, although the control parameters may be very different. (I found that with the second way, I needed much smaller values of P and I compared to the third way.) 3. Make a graphical user interface with App Designer that allows the user to input the vehicle and controller parameters and displays graphs of the velocity and acceleration vs. time. The GUI should allow the user to simulate at least the following scenarios: a. A step change in set point speed on level road (e.g. the vehicle is cruising at, say, 55 mph, and the set point is increased to 65 mph) b. A step change in road inclination at fixed set point (e.g. the vehicle is cruising on a level road and encounters a sudden uphill grade. The GUI should also display at least one text/numerical output, which could be the settling time (time after the disturbance at which the speed reaches and stays within 1 % of the set point), the % overshoot, or other appropriate value.