Presentation is loading. Please wait.

Presentation is loading. Please wait.

SECTION 4 GSE IMPORT METHOD.

Similar presentations


Presentation on theme: "SECTION 4 GSE IMPORT METHOD."— Presentation transcript:

1 SECTION 4 GSE IMPORT METHOD

2 OVERVIEW Use MATLAB’s RealTime Workshop (RTW) code to create a compiled representation of a control system that will be integrated into an Adams/View model. Include tunable parameters for the control system and investigate system behavior.

3 RTW PRE-REQUISITES The following items are needed:
MATLAB with a Real Time Workshop license available. Microsoft Visual C++ for compilation in RTW. Other C/C++ compilers (for example gcc) will not work properly. An available Adams/Controls license.

4 RTW BUILD PROCESS MATLAB’s Real Time Workshop (RTW) (renamed to be MATLAB Coder and Simulink Coder in recent versions) package can be used to create a compiled library (.dll) representation of the Simulink model. The RTW creation process follows the general steps: Prepare the Simulink model for RTW creation (remove interactive/unsupported Simulink blocks) Generate Adams-specific files for MATLAB in current directory via: Read plant export .m files into MATLAB (sets up proper environment for Adams/Controls) Issue command in MATLAB: (copies necessary files to working directory): >> setup_rtw_for_adams Build the Simulink model with RTW, creating a .dll file in the working directory.

5 PARAMETERIZE THE RTW COMPONENT
Variables from the MATLAB workspace can be carried over into the RTW component as Design Variables in Adams/View (or Adams/Car, Adams/Engine, etc.) for use in parametric studies. The general steps are as follows: Create variables in MATLAB workspace (ex: spring_stiffness = 8). Modify Simulink blocks to reference the workspace variables. In the Optimization section of the RTW options, select Configure and add the variables of interest to the table of defined Global (Tunable) Parameters. Build the RTW component as usual. The variables will appear as Adams/View Design Variables that are children of the general GSE element which is created for the RTW component.

6 GSE IMPORT PROCESS The Control System Import functionality of Adams/Controls is used to prepare the Adams model for use with the RTW .dll file. From the original Adams model: Ensure that the Adams/Controls plugin is loaded in Adams/View and that proper Plant Input/Output structures exist in the model. Import the .dll file via the Control System Import dialog box. This creates the following modeling elements: A STRING specifying the .dll file name A GSE that contains all the states in the Simulink model Several ARRAY elements needed by the GSE (number of states, references to variables, etc.). A SENSOR element that monitors error values in the GSE.

7 DEPENDENCE ON HMAX RTW code that has been imported into Adams is subject to the same Adams/Solver error control as all of the other states in the Adams model. This can be a problem if the imported code has significantly different error control requirements than the Adams model. Example: An Adams/Car vehicle model created in units of millimeters might have a relative error control value of 1e-2. A hydraulic power steering system for this vehicle that has been modeled in EASY5 (or MATLAB) might use the same displacement units, but may have relative error control in the order of 1e-5 or smaller. This is needed to capture the high-frequency behavior of the hydraulic system. Creating the hydraulic steering system as a GSE-import element is likely to yield problems for Adams/Solver; Adams/Solver will need to solve using the finest error control value, leading to long simulation times and potential simulation failures due to very small step sizes. This kind of system might best be modeled using co-simulation. In co-simulation, Adams and EASY5 (MATLAB) can have different error control settings, sharing only the sampling rate.

8 DISCRETE VS. CONTINUOUS RTW COMPONENTS
Simulink allows for the creation of either discrete or continuous models. How these are handled within Adams/Solver is dependant on the type: Continuous Simulink models: the states in the RTW component are combined with the Adams/Solver states and the larger problem is solved simultaneously. Adams/Solver therefore, solves the RTW states explicitly. Adams/Solver handles error control and maximum step-size for the RTW states. Discrete Simulink models: Simulink builds a fixed step-size integrator into the RTW .dll code. The RTW code then acts as a “function evaluator” for Adams/Solver during simulation. Error control and maximum step-size are handled by the RTW .dll itself; these values are specified when the RTW component is built.

9 PREPARE SIMULINK MODEL FOR RTW
Before RTW compilation, inspect the Simulink model carefully and consider the following: Some Simulink elements are not suitable for inclusion, for example: Blocks that interact with the GUI or the general MATLAB environment do not make sense. Examples: Scope, Display, To Workspace, To File, etc. Blocks that are unsupported by RTW. Example: the Derivative block (du/dt). Use a Transfer Function block like: s/(Ns+1) with a small value of N (ex: 0.001) to approximate a derivative. Disable Sample Time Inheritance: Sampling rates for blocks often default to the previous or parent blocks. Sampling rates should be set to zero (“0”) to accommodate the fixed step-size algorithm used by RTW. Do not parameterize source blocks as this can also cause problems related to the integration step-size. For further details see this article in the MSC Knowledge Base:

10


Download ppt "SECTION 4 GSE IMPORT METHOD."

Similar presentations


Ads by Google