Problems with Matlab Projects? You may face many Problems, but do not worry we are ready to solve your Problems. All you need to do is just leave your Comments. We will assure you that you will find a solution to your project along with future tips. On Request we will Mail you Matlab Codes for Registered Members of this site only, at free service...Follow Me.

Vehicle Dynamics using matlab


Introduction

The Texas Instruments C28x family of processors has been designed to implement control applications, for example digital motor control and un-interruptible power supplies. We shall start here with a simple application. In this Laboratory, you will build a simulation model of a vehicle dynamics using Simulink, and then emulate it using the eZDSP-F2812 board.

Related Files

Objectives

  • Design a Simulink model of the motion of a vehicle.
  • Run the model using Simulink on a PC.
  • Modify the model for use with the Texas Instruments C28x Digital Signal Processor.
  • Run the modified model on the Texas Instruments F2812 ezDSP.

Level

Beginner; This is intended as the first complete project using Matlab and Simulink.
It is suitable for students who have only limited exposure to Texas Instruments DSPs before.

Requirements

In developing this Laboratory, the following hardware and software were used:
  • Matlab R2006b with Embedded Target for TI C2000.
  • Code Composer Studio (CCS) 3.1.
  • Spectrum Digital ezDSP F2812 Hardware
  • Some external electronic components costing about $2.

Simulation

Running the Vehicle Dynamics Simulation

Figure 1: Engine Management Subsystem
Figure 1 (fig1.JPG)
Run the Model.
The input to the model is a ramp generator, which simulates smooth acceleration.
You will see the graphs of Horsepower and Vehicle Speed.

Changing the Vehicle Mass

Double click on the “Vehicle Dynamics” block. This models the equation of motion using Simulink Blocks.
Figure 2: Vehicle Dynamics
Figure 2 (graphics2.jpg)
At present, the vehicle mass is 8000 kg.
We will now simulate a small compact car. Change the 1/m gain block to 1/1000 and change the b/m block to 2/1000.
Run the model again and notice the effect on maximum vehicle speed and how long it takes to reach maximum vehicle speed
You might also like to simulate a 35,000 kg lorry. Change the 1/m block to 1/35000 and b/m to 10/35000.

Changing the Engine Power Profile

Double click on the “Engine Management” block. This models the gas in – horsepower out function of the engine.
Figure 3: Engine Management Subsystem
Figure 3 (graphics3.jpg)
Double-click on the Power Transfer Function
Figure 4: Engine Power Transfer Function
Figure 4 (graphics4.jpg)
Change the shape of the Power Transfer Function. You may wish to change the gradient or make the plateau wider. Run the model.

Other Modifications to the Model

Go to the Website of an automobile manufacture, and obtain the actual engine power transfer function for a real car. Run this in the model.
Replace the ramp generator input with a step function. This simulates someone stamping on the gas!

Reference Simulation for F2812

Running the Vehicle Dynamics Simulation

Figure 5: Modified Model for F2812
Figure 5 (graphics5.jpg)
Run this model. This is the behavior that should be seen when the real-time model is run on the ezDSP for F2812.

Creating Your Own Models

Creating a new Matlab Model

Start Matlab 7.3.0 R2006b
In the top left hand corner of the Matlab screen, select: File -> New -> Model.
Figure 6: A New MatLab Model
Figure 6 (graphics6.png)
The following screen will appear.
Figure 7: An Empty MatLab Model
Figure 7 (graphics7.jpg)

Saving the New Model

Save the model as “vehicle_dynamics.mdl”.
Figure 8: Saving the new model
Figure 8 (graphics8.jpg)

Opening the Library Browser

Select View-> Library Browser
Figure 9: Selecting the Library Browser
Figure 9 (graphics9.jpg)

Selecting the Subsystems

A list of available blocks will appear. Select “Commonly used blocks”. Highlight “Subsystems”. Drag-and-drop two copies of this block into the model.
Figure 10: The Simulink Library Browser
Figure 10 (graphics10.jpg)

Subsystems Added

Rename the Subsystems to “Engine Management” and “Vehicle Dynamics”.
Figure 11: Subsystems Added
Figure 11 (graphics11.jpg)
Drag-and-drop a “saturation” block onto the model.

Adding a Ramp Generator

From the Simulink Library Browser, select “Sources”. Drag-and-drop the “Ramp” block onto the model.
Figure 12: Adding a Ramp Generator
Figure 12 (graphics12.jpg)

Adding Scope Blocks

From the Simulink Library Browser, select “Sinks”.
Drag-and-drop the “Scope” block onto the model twice.
Drag-and-drop the “Display” block onto the model twice.
Figure 13: Adding a Scope
Figure 13 (graphics13.jpg)

Joining and Renaming the Blocks

Join the blocks as shown in the figure below. Change the names and add a title.
Figure 14: First Blocks Added
Figure 14 (graphics14.jpg)

Setting the Solver

The ode45 solver is not suitable for use with DSP. “Fixed Point Discrete” is required.
Figure 15: Configuring the Solver
Figure 15 (figure15.jpg)

The Engine Management Subsystem

Overview of the Engine Management Subsystem

The first stage of the Engine Management Subsystem is a “Gain” block, which converts the Gas Pedal input (0-100%) to 0-4000 rpm.
The second stage is a lookup table. This converts from rpm to hp.
Figure 16: The Engine Management Subsystem
Figure 16 (graphics16.jpg)

Adding a Lookup Table

From the Simulink Lookup Tables, drag-and-drop the “Lookup Table” block onto the model.
Figure 17: Adding a Lookup Table
Figure 17 (graphics17.png)
Double click on the “Lookup Table” block.
Figure 18: Lookup Table Block Parameters
Figure 18 (graphics18.jpg)
The values for the table can also be inserted as a table. Click on the “Edit” box.
Figure 19: Lookup Table Values
Figure 19 (graphics19.jpg)
Click on "Plot" as shown above, and you will see:
Figure 20: Adjusting the Lookup Table
Figure 20 (graphics20.jpg)

The Vehicle Dynamics Subsystem

Overview of Vehicle Dynamics Subsystem

The C28x operates in discrete-time; therefore the continuous integrator must be replaced by a “Discrete Time Integrator” for DSP model implementation.
Figure 21: Vehicle Dynamics Subsystem
Figure 21 (graphics21.jpg)
Select the “Main” tab. Change the “Constant value” to 0. Click on “OK”.

Running the Simulation

The ramp generator gently changes the Gas Pedal from 0% to 100%. This simulates smooth acceleration. The Horsepower and Vehicle Speed are shown on the graphs.
Figure 22: Running the Simulation
Figure 22 (graphics22.jpg)

Modifications for ezDSP F2812

In order to run the model on the ezDSP F2812, some additional blocks need to be added to the project:
  • An Analog-to-Digital Converter (ADC) to allow a potentiometer input.
  • A block to scale the ADC input to the range 0 to 100%.
  • A Digital-to-Analog Converter (DAC) to convert the Vehicle Speed to an analog output in the range 0 to 3.3V

Connecting the F2812 ezDSP

For Matlab and Simulink to run correctly, you need to run the F2812 ezDSP.
Connect the F2812 hardware to the parallel port of the computer and turn on the supply to the board.
When the board is powered, the two green LED lights on the board will come on during self-test.
Start Code Composer Studio for F2812 ezDSP and use Debug -> Connect
Figure 23: Startup Screen for Code Composer Studio (CCS)
Figure 23 (graphics23.jpg)

Opening the Library Browser

Select View-> Library Browser
Figure 24: Selecting the Library Browser
Figure 24 (graphics24.jpg)

The Simulink Library Browser

A list of available blocks will appear. We are particularly interested in the “Embedded Target for TI C2000 DSP”. Click on this selection.
In the following sections we will select the building blocks for the DSP model shown in Figure 30.
Figure 25: The Simulink Library Browser
Figure 25 (graphics25.jpg)

Selecting Target Preferences

From the C2000 Target Preferences, select “F2812 ezDSP”. Drag-and-drop the icon onto the new model.
Figure 26
Figure 26 (graphics26.png)
Figure 26 – Selecting Target Preferences
When the following screen appears, it is important to select “Yes”.
Figure 27: Initializing Simulation Parameters
Figure 27 (graphics27.jpg)

Scaling the ADC Readings

To scale the ADC reading to the Gas Pedal 0 to 100% we will multiply the ADC input by 800 then divide by 32768.
Figure 28
Figure 28 (graphics28.jpg)
Figure 28 – Scaling the ADC

Scaling the DAC Output

To scale the kph to the DAC output, we will multiply the kph input by 312.5. The “Saturation” block limits the output to 200 kph.
Figure 29: Scaling the DAC
Figure 29 (graphics29.jpg)

The Finished Model

To scale the kph to the DAC output, we will multiply the kph input by 312.5.
Figure 30: The Final Model
Figure 30 (graphics30.jpg)

Building the Model

Select Tools -> Real-Time Workshop -> Build Model.
Figure 31: Building the Model
Figure 31 (graphics31.jpg)
You may find the final model here.

Comparing Performance

The real-time model running on the ezDSP F2812 should now be behaving in the same way as the Simulation.

References

  1. Spectrum Digital Incorporated, "eZdspTM F2812 Technical Reference" Rev. F, September 2003. (http://c2000.spectrumdigital.com/ezf2812/docs/ezf2812_techref.pdf)

0 comments:

Post a Comment

Recent Comments

Popular Matlab Topics

Share your knowledge - help others

Crazy over Matlab Projects ? - Join Now - Follow Me

Sites U Missed to Visit ?

Related Posts Plugin for WordPress, Blogger...

Latest Articles

Special Search For Matlab Projects

MATLAB PROJECTS

counter

Bharadwaj. Powered by Blogger.