Contents Previous Next Index
|
1 Getting Started
|
|
|
1.2 Using the dSPACE Application Generation Template
|
|
The MapleSim Connector for dSPACE provides a dSPACE Application Generation template in the form of a Maple worksheet for manipulating and exporting MapleSim subsystems. This template contains pre-built embedded components that allow you to generate dSPACE applications from a MapleSim subsystem and save the source code.
Using this template, you can define inputs and outputs for your system and how these inputs and outputs are connected with the dSPACE inputs and outputs. You can also generate the source code and create an executable.
|
Viewing Examples
|
|
Examples are available in the dSPACE Connector Examples palette in MapleSim. Each example includes a code generation template in its Attachments palette.
To view an example
1.
|
Under the Libraries tab on the left side of the MapleSim window, expand the dSPACE Connector Examples palette, and click the entry for the model that you want to view.
|
2.
|
In the Project tab, expand the Attachments palette and then expand Documents.
|
3.
|
From the list, right-click the dSPACE_DS1104_Controller and select View. The code generation template opens in Maple.
|
Some models include additional documents, such as templates that display model equations or define custom components. You can open any of these documents by right-clicking its entry in the list and clicking View.
|
|
|
1.3 Example: VCFP Model
|
|
This example is based on the VCFP (voice-coil-driven flexible positioner) system, a standard demo plant you can purchase from dSPACE. In this example, you will generate a dSPACE executable from the controller subsystem of the closed loop VCFP model that was created in MapleSim. The dSPACE executable that is generated can then be used in ControlDesk.
This example is a ready-to-run application with the following prerequisites:
•
|
You have setup the dSPACE software and a DS1104 board on your computer
|
•
|
The real dSPACE demo VCFP plant is physically connected to the DS1104 board
|
The following steps explain how to configure the existing dSPACE_DS1104 template to match your configuration.
To generate a dSPACE Application
1.
|
From the dSPACE Connector Examples palette, open the VCFP_GettingStarted example.
|
2.
|
Select the Project tab, expand the Attachments palette, expand the Documents section and double-click on dSPACE_DS1104_Controller. Your MapleSim model opens in Maple, in the template that you selected.
|
3.
|
Browse to the Controller1 subsystem by selecting the subsystem name from the drop-down menu in the toolbar above the model diagram. This menu displays all of the subsystems and components in your MapleSim model.
|
4.
|
In the Subsystem Selection section of the template, click Load Selected SubSystem. All of the template fields are populated with information specific to the subsystem displayed in the model diagram. You can now check if the mapping between the inputs and outputs of the subsystem and the dSPACE DS11014 inputs and outputs match the real connections on your system
|
5.
|
Navigate to the Input / Output Settings for the dSPACE DS1104 Board subsection. Select the Main.Controller1.Reference(t) signal in the list of model inputs. In this example, this signal is replaced in the application by a square signal generator running on the dSPACE board in the DS1104 inputs or Virtual signals list box.
|
6.
|
You can modify the configuration of this square signal generator by navigating to, and expanding, the Virtual Square Signals Generator section. In the Square 1 part of the table, you can modify the Amplitude, the Frequency and the Offset values. If you want to change the input mapping of this signal, select another virtual signal or a DS1104 channel. For example, if you want to connect it to an ADC channel, such as ADCH1 (this signal reads the value of the first ADC channel of the DS1104 board, physically connected on the reference of the real plant), select the ADC from the list. There is no configuration possibility for this channel; however, you can review its characteristics by expanding the Mux ADC Unit section below the table.
|
7.
|
In the Input / Output Settings for the dSPACE DS1104 Board section, select the Main.Controller1.Measurement(t) signal in the list of model inputs. In this example, this signal is connected to ADCH2 in the DS1104 inputs or Virtual signals list box. It will read the value of the second ADC channel of the DS1104, physically connected to the measurement of the real plant. There is no configuration possibility for this channel but you can review its characteristics by expanding the Mux ADC Unit section below the table. You can change the DS1104 channel in order to match the configuration of your system.
|
8.
|
In the Input / Output Settings for the dSPACE DS1104 Board section, select the Main.Controller1.Command(t) signal in the list of model outputs. In the DS1104 outputs list box on the right, select DACH1: this signal will send the value computed by the application to the first DAC channel of the DS1104, physically connected to the command of the real plant.
|
9.
|
To configure this output, expand the DAC Unit section. Define the DAC mode as transparent, initialize the DACH1 to 0 and specify a termination value of 0.
|
Note: You could also store the current value when the application terminates. There is no problem in this particular application. However, in general when termination values are different from 0, it is very often unsecure. You can also change the DS1104 channel in order to match the configuration of your system.
10.
|
In the Options, Solver Setting section, you can change the base sampling rate of the application.
|
11.
|
In the Optimization Options section, set the Level of Code Optimization option to Full by moving the slider to the 3 position This option specifies the degree of simplification applied to the model equations during the code generation process. This option eliminates redundant variables and equations in the system.
|
12.
|
In the TRC Variables and Parameters Option section, you can set options to allow you to add all the possible parameters and/or variables in the TRC file that are generated with the dSPACE application. The TRC file is used by ControlDesk so that you can display variables and modify parameters on the running real-time application.
|
13.
|
In the Generate the dSPACE Application section of the template, specify the dSPACE directory and the directory where the application should be generated.
|
14.
|
Click Generate to dSPACE Application to generate the C code, the .trc file, the .sdf file and the .ppc file of the application.
|
15.
|
Open ControlDesk ® and load the generated application as usual. You will have access to the inputs, outputs, states and states derivatives of the application in the Model group. The parameters are in the Model Parameters subgroup, the execution time and current time can be accessed from the Task Info → Execution subgroup.
|
|
|
Contents Previous Next Index
|