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
- Powerpoint Presentation - VehicleDynamics.ppt
- Simulink Model for PC Simulation - VehicleDynamics.mdl
- Simulink Model for Simulation with DSKF2812 - VehicleDynamicsF2812Simulation.mdl
- Simulink Model for Real-Time - VehicleDynamicsDSKF2812.mdl
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
Open VehicleDynamics.mdl.
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.
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.
Double-click on the Power Transfer Function
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
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.
The following screen will appear.
Saving the New Model
Save the model as “vehicle_dynamics.mdl”.
Opening the Library Browser
Select View-> Library Browser
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.
Subsystems Added
Rename the Subsystems to “Engine Management” and “Vehicle Dynamics”.
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.
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.
Joining and Renaming the Blocks
Join the blocks as shown in the figure below. Change the names and add a title.
Setting the Solver
The ode45 solver is not suitable for use with DSP. “Fixed Point Discrete” is required.
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.
Adding a Lookup Table
From the Simulink Lookup Tables, drag-and-drop the “Lookup Table” block onto the model.
Double click on the “Lookup Table” block.
The values for the table can also be inserted as a table. Click on the “Edit” box.
Click on "Plot" as shown above, and you will see:
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.
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.
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
Opening the Library Browser
Select View-> Library Browser
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.
Selecting Target Preferences
From the C2000 Target Preferences, select “F2812 ezDSP”. Drag-and-drop the icon onto the new model.
Figure 26 – Selecting Target Preferences
When the following screen appears, it is important to select “Yes”.
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 – 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.
The Finished Model
To scale the kph to the DAC output, we will multiply the kph input by 312.5.
Building the Model
Select Tools -> Real-Time Workshop -> Build Model.
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
- 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