You are on page 1of 3

Experiment No.

REAL TIME CONTROL USING dSPACE


AIM
To familiarize the dSPACE Control-Desk for the real time control of systems.

REQUIREMENTS
1. Software (Matlab – Simulink and dSPACE)
2. DS 1103 R&D Controller Card, this card is installed on the motherboard of the computers
with dSPACE in the lab and connects to the dSPACE I/O box via a master I/O ribbon cable.

THEORY
Introduction
The dSPACE system is a so-called rapid prototyping tool. Rapid prototyping means that
the generation of a working prototype should be direct and obviously rapid, in order to apply the
model developed to the actual system with the smallest procedural delay. Another advantage is
that the applied system will be the same as the tested one, thus reducing possible translation
errors. Before the real-time system’s era, the development times were very long. The real world
and the model were not directly connected, i.e. the system used for the application was quite
different from the system used for the development. This difference obliged the engineers to
translate the results obtained in one system to the other. This was a time-consuming activity and
a source of extra errors. The need to reduce the development times has brought to the market
these systems, which have become very powerful with the evolution of real-time processors.
Among the real-time systems available, dSPACE is one of the most comfortable to use because
of its strong ties with Matlab-Simulink. In fact, the dSPACE system is very easy to integrate in
Simulink and the generation of the code for its processor can be started directly in Matlab. The
dSpace system has a wide range of different hardware. The hardware is composed from several
real-time processors mounted on a PC board and a large choice of input/output boards. For the
supported hardware dSPACE offers a toolbox for Simulink with the optimized drivers.

dSPACE is a complete real time control system based on a 603 PowerPC floating-point
processor running at 250MHz. For advanced I/O purposes, the board includes a slave-DSP
subsystem based on the TMS320F240DSP microcontroller. For purpose of rapid control
prototyping, DAC, encoder interface module of the connector panel. Provide easy access to all
input and output signals of the board. The control program is written in Simulink environment
combined with the real-time interface of the DS1103/ DS1104 board. The main ingredient of the
software used in the laboratory experiment is based on MATLAB/Simulink programs. The
control law is designed in Simulink and executed in real time using the dSPACE DS1103/
DS1104 DSP board. Once the controller has been built in Simulink block-set, machine codes are
achieved that runs on the DS1103/ DS1104’TMS320F240 DSP processor. While the

1
experimental is running, the dSPACE DS1103/ DS1104 provides a mechanism that allows the
user to change controller parameter online. Thus, it is possible for the user to view the real
process while the experiment is in progress. ControlDesk developer version 3.5, dSPACE’s
experiment software, provides all the functions to control, monitor and automate experiments
and makes the development of controllers more effective. The graphical user interfaces to control
manually the real time simulation. Many well-structured layouts enable the user to gain full
control over the system. ControlDesk allows users to generate convenient, graphical user
interfaces (layouts) with a great variety of control elements, from simple GUI elements (push-
buttons, displays, radio buttons, etc.) to complex plotters and photorealistic graphics. This virtual
environment allows the user not only to control or monitor any control algorithm parameter
during the real time simulation, but also to access any I/O signal connected to the hardware
components.

The procedure essentially consists of the following six points:


1. Develop a mathematical model of the system in Matlab-Simulink.
2. Analyze the system, assisted by the models obtained (Simulation, Linearization, etc.)
3. Extend the controller with Input-Output blocks from the dSPACE Library to connect the
Simulink environment to the real world (depending on the hardware).
4. Compile the Simulink model in the dSPACE Processor via dSPACE Compiler (only discrete
system).
5. Prepare an environment for the experiment with dSPACE ControlDesk.
6. Activate the real-time processor and optimize the parameters directly on the test bench.
Interfacing dSPACE Software to the Experiment
The digital to analog conversion (DAC) blocks are provided in Simulink when the dSPACE
software is available. To see the dSPACE blocks, type rti from the Matlab command window.
Here, when you place an ADC block in a Simulink model (by drag and drop) and then double
click it, all you need to select is the “Channel number.” Next, it is important to understand the
“scaling” that occurs in acquiring the signal. The physical input signal input range is –10V to
+10V. dSPACE always scales this by a factor of 0.1 (multiplies by this number) to place the
value on a range of –1V to +1V. Here, note that if you place a DAC block in your Simulink
model and double click it there are several settings that need to be made. On the “Unit” tab you
need to select the channel number. Due to the dSPACE scaling factor that we saw in the input,
now it should be reversed when it goes to the exterior (1/10)

EXPERIMENTAL WORK

1. Create a working directory for your project


2. Open ControlDesk
3. Open Matlab and choose RTI1103 (long connector board) or RTI1104 (short connector
board).Verify that “dSPACE configuration okay” or “RTI Platform Support Activated” is
displayed.

2
4. Switch to your working directory. It is important to stay in this directory during the whole
work session, especially when you compile.
5. Open Simulink and create a blank diagram. Save it under your working directory.
6. Go to Control-Desk and create a new experiment (not layout) from the File menu. Name the
experiment and choose your working directory in the Working root field.
7. Select and declare a sampling period according to application requirements. Return to
Simulink and start adding interfacing blocks according to needs.
8. The interface is able to accept single-ended or differential encoder electronics. Wiring for each
case must be done according to the Hardware Implementation Manual. Open the dSPACE
RTI110X / DS110X Master PPC libraries and drop an Encoder Setup block and a DS110X
Encoder Position Block C_1 to the Simulink diagram. Open the Encoder Pos_C1 block and
select the channel where your encoder is hooked up and set the initialization value (counts at
start time) to zero.
9. Go to Configuration Parameters/Solver and make sure you have a fixed-step solver with a step
size of Ts.
10. Save the Simulink file and press Ctrl B to compile. Make sure the active directory in Matlab
is your working directory before compiling.
11. Several messages will appear on the Matlab prompt as compilation takes place. After
compilation you should see the message:
##Successful completion of Real-Time Workshop build procedure for model: (your model name)
**Finished RTI build procedure for model (your model name)
12. Return to Control Desk. You will notice that a tab appears showing an sdf file in the working
directory. · From the File menu in Control Desk, create a new Layout (not experiment). Save it
right away in your working directory (at the root, not within the subdirectories created by
Control Desk). Add plotters from the data acquisition tab. Find the correct variables from Model
Root/Labels and drag them to the plotters. Your interface is now ready to run

RESULT

You might also like