AP2-ASD2007-part1.pdf

Embed Size (px)

Citation preview

  • 7/29/2019 AP2-ASD2007-part1.pdf

    1/6

    Hoda Yarmohamadi, Thomas Nygrds, Viktor BerbyukDepartment of Applied Mechanics

    Chalmers University of Technology

    1

    Assigned Problem 2, 2007, Applied Systems DynamicsMatlab/Simulink Cab and chassis suspensionPart 1

    Background

    Cab and chassis suspension have a significant effect on the vibration, ride and handling properties ofthe vehicle as well as drivers comfort.

    In this assignment you will first learn how to create a simple suspension system in Matlab/Simulinkand then you will build a half truck model in Simulink. You will implement simple models for chassis,

    cab and engine and their suspension systems. You will learn more about how to build simple models

    of mechanical systems.

    Simulink is an extension to Matlab. It is a tool for describing differential equations and other complexequations graphically with building blocks. It also provides a user friendly interface for processes

    surveillance and feature extraction; something which can demand much work using Matlabs plotcommand. Another main advantage is that there is not much need for rearrangement of the equations

    before starting the solving process.

    This introduction is intentionally held short although much can be said about this tool. In thisassignment we will try to give some easy to follow examples and a brief introduction to the user

    interface. The goal of this lab is to introduce the students to a commonly used tool when building

    simulation models and also interaction between Matlab and Simulink.

    Section 1: Introduction and setup

    Start Simulink and get to know the environment

    1. Start MATLAB2. Set your working directory to where you want to

    place your files, e.g. H:\Courses\ASD07\AP2\3. Start Simulink by writing simulink in the

    command window

    orBy clicking on the Simulink start button on topof the Matlab window

    orby clicking at Matlabs own start button at thelower left of the window and select

    Simulink -> Library Browser

    4. The window shown on the right will appear.5. Select File-> New->model6. An empty window opensFrom the components in this library you will buildyour own mathematical model of your system.

    The sub libraries we are going to use are:

    Continuous: i.e. integral and derivative operators

    but also more complex transfer functionsMath operators: Sums, products, sine waves and

    other standard Matlab functions.

  • 7/29/2019 AP2-ASD2007-part1.pdf

    2/6

    Hoda Yarmohamadi, Thomas Nygrds, Viktor BerbyukDepartment of Applied Mechanics

    Chalmers University of Technology

    2

    Sinks: Output blocks such as scopes, displays and export blocks.Sources: Constants, import blocks, a lot of pre defined inputs such as steps, sine and triangle waves.

    Section 2: Model creation

    A very simplified suspension of a car can be sketched as Fig. 1.

    Fig. 1: Simple suspension model

    The following equation describes the system above

    ( ) ( ( ) ( )) ( ( ) ( ))my t c x t y t k x t y t = + && & & (1)

    x(t) is the excitation movement coming from the road profile and y(t) is the displacement from the

    steady state position.

    We rewrite eq. (1) as follows:

    m

    tkytkxtyctxcty

    )()()()()(

    +=

    &&&& (2)

    The system can be implemented in Simulink using a rather straight forward method. The method is aTop-Down method and the key is to assume that variables unknown at the moment will become

    known later.

    The second term in the nominator is ( )cy t& . This is of course the same as0

    ( )

    t

    c y d && with 0)0( =y&

    This expression can be implemented in Simulink as inFig. 2

    (were )(ty&

    is denoted y_dot(t) and( )y t&& is denoted y_ddot(t))

    By building the second and forth terms, we end up with Fig. 2.

    0

    ( ) ( )

    t

    c y d cy t = && &

    0 0

    ( )

    t

    k y d d ky

    = &&

    Fig. 2: Modeling using simulink blocks

  • 7/29/2019 AP2-ASD2007-part1.pdf

    3/6

    Hoda Yarmohamadi, Thomas Nygrds, Viktor BerbyukDepartment of Applied Mechanics

    Chalmers University of Technology

    3

    Building the rest, summing these up and dividing with m give ( )y t&& according to (1) connecting the

    wires and rearranging the blocks will result in the following model.

    Fig. 3: block diagram of the model

    Task 1: Build a Simulink model of a simplified suspension

    Implement the model above. The add block is changed by double clicking it and assigning the

    appropriate signs to its list of signs write ++-- if you want the look of the big block above. Its sizecan be changed with the mouse.

    The constant blocks shall be given their respective constant name (defined in equation 1) as value. If

    you double click the text under a block you can change its name. Note that two blocks cannot have theexact same name.

    Task 2: Build initialization file and set up simulink

    Create an M-file in the working directory you defined before called suspension_init.m using theFile/New command in the Matlab window.

    In this file, assign the following values to constants:

    m=1600/4;

    c=720;k= 16812;

    speed_kmh=50;

    road1=struct('bump_length',0.4,'bump_amplitude',0.05);

    Afterwards press F5 to run the initialization file.

    Go to menu Simulation/Configuration parameters set Type to fixed-step and Fundamental

    sample time to 0.001.

    Make a test run of the Simulink model (by pressing the button in the model window) and see if themodel runs, then double click the scope to see the displacementy as a function of time.

    Add more scopes at appropriate points to see the velocity and acceleration as functions of time as well.

    If your scope does not show the curves from time=0: then open the scope, click in the scope

    window and go to Data history, uncheck the box where it says Limit data points to last: 5000

    Sinks/Scope

    Continuous/Integrator

    Math/Product

    Sources/Constant

  • 7/29/2019 AP2-ASD2007-part1.pdf

    4/6

    Hoda Yarmohamadi, Thomas Nygrds, Viktor BerbyukDepartment of Applied Mechanics

    Chalmers University of Technology

    4

    Task 3: Build a road model

    This part is about implementing a simple road bump model

    )2

    t_lengthroad1.bump3.6

    speed_kmh2sin((t)x1

    += (3)

    Remove the step atx(t) (by clicking on it and pressing delete button) and connect a Sine Wave block

    which can be found under Sources in the Library Browser.

    Double click it and write 2*pi*speed_kmh/(3.6*road1.bump_length) in the frequency box and pi/2

    in the phase box.

    Attach a scope to the wire from the sine wave block and simulate the model again. What is the output

    of the block?

    This road bump is way to steep so it needs to be smoothened. But first you will get a bit objectoriented. Drag and select the sine wave and a bit of the wire connected to it. Right click and select

    Create subsystem. The sine wave is replaced by a block. Rename this block to Road model_1.

    Double click the Road model_1 it to open what is inside. Inside you will find the sine waveconnected to a port named Out1. Click the text Out1 and rename it x(t). Now you got a separate

    block which describes the road input to the model! Making such subsystem is a neat way of keepingyour model clean. They will also help you to get a good overview of you model.

    To keep on extending the road model, we use the following expression:

    (t))x-(1_amplituderoad1.bump(t)x 12 = (4)

    Use suitable blocks in the Math section of the Library Browser to accomplish this.

    The number of bumps needs to be reduced to just one to see the behavior clearly. For this we will

    extend the model even further.

    (t)x(t))-(1(t)x 23 = (5)

    Where ( )t

    is a step at time . Implement this using blocks from Math and Source. The time

    you will have to specify in the Step parameters when right clicking the step. This time shall be

    calculated to make the step output = 1 exactly when half a sine period have been done. Set to

    road1.bump_length/(speed_kmh/3.6) to achieve this. Attach a scope to the wire near the x(t) and

    check if the output looks like a single smooth road bump.

    Fig. 4 shows one possible implementation of the road model according to eq. (5).

    Fig. 4: block diagram of the road model

    Math/Gain

  • 7/29/2019 AP2-ASD2007-part1.pdf

    5/6

    Hoda Yarmohamadi, Thomas Nygrds, Viktor BerbyukDepartment of Applied Mechanics

    Chalmers University of Technology

    5

    Save the whole model as suspension.mdl.

    Close the window with the bump model and look at the displacement scope. Does it look like a

    possible movement of a car when passing a road bump? Are the values reasonable?

    Set the value of c in the init file to 360 and run the init file. Simulate the model again. Has the

    displacement changed? Is there more movement or less? How about the acceleration?

    Change the value back to 720 and run the init file.

    Section 3: Result analysis

    Now you will export the results from Simulink to Matlab to plot the displacement, velocity and

    acceleration and analyze the comfort.

    Task 4: Exporting values to Matlab

    As it can be difficult to remember how the curves looked, you will learn to export the values to

    Matlab. This is done by connecting a Sinks/To workspace block to the desired signal.

    Connect it to where displacement y is. Double click the block and change the variable name to y.

    Change the Save format to Array and close.

    Export the other interesting signals: ( )y t& , ( )y t&& andx(t) to workspace in the same manner. Export also

    the simulation time to workspace, simulation time is available from block Sources/Clock.

    Simulate the model and use Matlabs plot command to view the exported signals as functions of the

    exported time. Save the model and the plots.

    Task 5: Building a simulation script

    To investigate how different constants of the spring and damper affect the movement and acceleration

    of the quarter car in the y direction you can create a simulation script. Create a new M-file calledsim_script in the same directory as your model. Implement in this file a for loop in varying the

    parameter c between 360 and 1080 and kbetween 10000 and 20000. Use only three values for eachvariable as otherwise the plots will be too messy. In the for loop put the line

    sim suspension %This line runs your Simulink model from your M-file

    Plot the exported result data fory(t), ( )y t& , and ( )y t&& . If you use the following commands in the for

    loop for plotting, you will get the plots with different colors.

    figure(1); %figure for displacement (y)

    plot(t,y); %plot displacement dataxlabel(time(s)); ylabel(y(m));

    figure(2); %figure for velocity (y&

    )plot(t,y_dot); %plot velocity dataxlabel(time(s)); ylabel(y-dot(m/s));

    figure(3); %figure for acceleration (y&& )

    plot(t,y_ddot); %plot acceleration dataxlabel(time(s)); ylabel(y-ddot(m/s

    2));

    Run your simulation script to see the curves as functions of time

  • 7/29/2019 AP2-ASD2007-part1.pdf

    6/6

    Hoda Yarmohamadi, Thomas Nygrds, Viktor BerbyukDepartment of Applied Mechanics

    Chalmers University of Technology

    6

    Task 6: Cost function

    As you can see in the plots generated by your script it is not easy to determine which setting of theparameters gives the best performance. To solve this you will design a suitable cost function for they

    acceleration to maximize comfort of your quarter car.Write your cost function below:

    ___________________________________________________________________________

    Export the necessary data from Simulink and implement your cost function in the simulation script

    file.

    Plot your cost function as a function of spring and damper coefficients. This can be done by usingMatlabs plot3-command. The command is used to plot a point or a line in the [x,y,z] coordinatesystem.

    If you want you can use plot3(k, d, cost function,*) to change the very small dot to a star. Writehelp plot3 in the command window for details of the command.

    Run the script to calculate the values of your cost function for all the spring and damper coefficients

    (you have 9 different cases). Write down the minimum value of the cost function.

    Min (cost function) = _________________

    Save the plot for the cost function from your simulation. Write down which values maximize the

    comfort according to your cost function when passing the road bump.

    k=_________________________________ c=_______________________________________

    Do you think that the minimum is a global minimum? Why/Why not?

    __________________________________________________________________________________

    __________________________________________________________________________________

    Can you think of any more interesting cost functions regarding suspension systems in general?

    __________________________________________________________________________________

    __________________________________________________________________________________

    After you answered all questions, respond briefly and orally to the assistants and also show yourmodel and your plots.