1 Getting Started - MapleSim Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : MapleSim Toolboxes : MapleSim Connector for dSPACE Software : Getting Started Guide : MapleSimdSPACEConnectorGSG/Chapter01

Contents     Previous     Next     Index

1 Getting Started

1.1 Getting Help

In Maple, enter ?dSPACEConnector at a prompt in a worksheet.

1.2 Using the dSPACE DS1104 Real-Time Application Template

The MapleSim Connector for dSPACE provides a dSPACE DS1104 Real-Time Application 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 then click the entry for the model that you want to view.

 

2. 

Under the Project tab, expand the Attachments palette, and then expand Documents.

3. 

From the list, right-click dSPACE_DS1104_Controller.mw, and then 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_Controller template to match your configuration.

 

To generate a dSPACE Application

1. 

From the dSPACE Connector Examples palette, open the VCFP Getting Started example.

2. 

Under 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 list box in the toolbar above the model diagram. This menu displays all of the subsystems and components in your MapleSim model.

4. 

In the Step 1: 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 DS1104 inputs and outputs match the real connections on your system

5. 

Navigate to the Step 2: Input / Output Settings for the dSPACE DS1104 Board section. 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 with this particular application. However, in general when termination values are different from 0, it is very often insecure. You can also change the DS1104 channel in order to match the configuration of your system.

10. 

In the Step 3: Options section, enter the base sampling rate of the application in the Solver Setting area.

11. 

In the Optimization Options area, 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. The optimization options and what they do are as follows:

• 

None (0): performs no optimization; the default equations are used in the generated code.

• 

Partial (1, 2): removes redundant equations from the system.

• 

Full (3): performs index reduction to reduce the system to an ODE system or a differential algebraic equation (DAE) system of index 1, and removes redundant equations.

12. 

In the Constraint Handling Options area, specify whether constraints are satisfied in a DAE system by using constraint projection in the generated C code. Use this option to improve the accuracy of a DAE system that has constraints. If the constraint is not satisfied, the system result may deviate from the actual solution and could lead to an increase in error at an exponential rate. The options in this area are as follows:

• 

Maximum number of projection iterations: maximum number of times that a projection is permitted to iterate to obtain a more accurate solution

• 

Error tolerance: the desirable error tolerance to achieve after the projection

• 

Apply projection during even iterations: interpolate iterations to obtain a more accurate solution

13. 

In the Event Handling Options area, specify whether the events are satisfied in a DAE system by using event projection in the generated C code. Use this option to improve the accuracy of a DAE system with events. If the constraint is not satisfied, the system result may deviate from the actual solution and could lead to an increase in error at an exponential rate. The options in this area are as follows:

• 

Maximum number of event iterations: the maximum number of times that a projection is permitted to iterate to obtain a more accurate solution

• 

Width of event hysteresis band: the desirable error tolerance to achieve after the projection

14. 

In the TRC Variables and Parameters Options area, 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.

15. 

In the Step 4: Generate dSPACE Application section of the template, specify the dSPACE directory and the directory where the application should be generated.

16. 

Click Generate dSPACE Application to generate the C code, the .trc file, the .sdf file and the .ppc file of the application.

17. 

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


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam