You are on page 1of 84

MSC Confi denti al

MSC.Software Corporation
Europe Corporate Asia Pacific
MSC.Software GmbH MSC.Software Corporati on MSC.Software J apan Ltd.
Am Moosfeld 13 2 MacArthur Pl ace Shinjuku First West 8F
81829 Munic h, Germany Santa Ana, CA 92707 U SA 23-7 Nishi Shi njuku
Telephone: (49) (89) 43 19 87 0 Telephone: (800) 345-2078 1-Chome, Shi njuku-Ku
Fax: (49) (89) 43 61 71 6 Fax: (714) 784- 4056 Tokyo 160-0023, JAPAN
Telephone: (81) (3)-6911-1200
Fax: (81) (3)-6911-1201

MD R3 Adams/Controls
ADM711 Course Notes

Part Number: MDAM*R3*Z*Z*Z*SM-ADM711-NT1 Copyright 2008 MSC.Software C orporation


July 2008
MSC Confi denti al

LEGAL INFORMATION
MSC.Software Corporation reserves the right to make changes in specifications and other information contained in this
document without prior notice. The concepts, methods, and examples presented in this text are for illustrative and
educational purposes only, and are not intended to be exhaustive or to apply to any particular engineering problem or
design. MSC.Software Corporation assumes no liability or responsibility to any person or company for direct or indirect
damages resulting from the use of any information contained herein.
Copyright © 2008 MSC.Software Corporation. All Rights Reserved. This notice shall be marked on any reproduction of this
documentation, in whole or in part. An y reproduction or distribution of this document, in whole or in part, without the prior
written consent of MSC.Software Corporation is prohibited.
The MSC.Software corporate logo, Adams, Dytran, Easy5, Fatigue, Laminate Modeler, Marc, Mentat, MD Nastran,
MD Patran, MSC, MSC Nastran, Mvision, Patran, SimDesigner, SimEnterprise, SimManager, SimXpert and Sofy are
trademarks or registered trademarks of the MSC.Software Corporation in the United States and/or other
countries. NASTRAN is a registered trademark of NASA. All other trademarks belong to their respective owners.

Copyright 2008 MSC.Software C orporation


MSC Confi denti al

TABLE OF CONTENTS

Section Page

0.0 Welcome to Adams/Controls Training


A Brief History of Adams …………………….………………………………………………………………….. 0-5
About MSC.Softw are ...…………………………………………………………………………………………… 0-7
Getting Help …………...…………………………………………………………………………………………… 0-8
A Review of Basic Adams Ter minology.………………………………………………………………………… 0-12

1.0 Co-simulation Mode


State variables in Adams……….......…………………………………………………………………………….. 1-3
The Adams/Controls Plugin………...…………………………………………………………………………….. 1-5
Plant Inputs and Outputs……………………. …..……………………………………………………………….. 1-6
Control System Export……………………………… ....…...…………………………………………………….. 1-7
MATLAB Setup Process ….…...…...…………………………………………………………………………….. 1-10
Easy5 Setup Process……………………………………………………………………………………………....1-11
Co-Simulation ( Discrete Mode)……………………………………………………………….………………….. 1-12

2.0 Function Evaluation, Co-Simulation Performance


Function Evaluation Mode ……...………………………………….……………………………..…………….. 2-3
TCP/IP Communication………………………………………………….………………………..………………. 2-5
Co-Simulation Performance Settings…………………..…………..…………………………..……….……… 2-7

3.0 GSE Import Method


RTW Prerequisites… ………………………………………………………………….………………………….. 3-3
RTW Build Process… ..………………………………………………………………….……………………….. 3-4
Parameterize the RTW Component…………………………………………………….……………………….. 3-5
GSE Import Process…………...………………………………………………………….………………………..3-6
Discrete Vs. Continuous RTW Components……..…………………………………….……………………….. 3-9
Prepare Simulink Model for RTW…………... ………………………………………….……………………….. 3-10

Copyright 2008 MSC.Software C orporation


MSC Confi denti al

TABLE OF CONTENTS (Cont.)

Section Page
4.0 GSE Import Specifics
Discrete Controllers Need External Solver……………... ……………………………….…………………….. 4-3
Discrete Vs. Continuous Controllers..…………………………………………………….…………………….. 4-5
Library Name, Multiple Controllers...…………………………………………………………………………….. 4-6

5.0 Co-Simulation Modifiers


Adams_exec Parameter………. ……………………………………………………………………..…………. 5-3
Adams_init Parameter………………………… ...…………………………………………………..…………… 5-4
Adams Controls Wait Time…….. …..……………………………………………………………...……………. 5-5
Co-Simulation Interpolation Order....……………………………………………………………...……………. 5-7
Co-Simulation Limitations………………………………………………………………………………………... 5-9

6.0 Adams/Car and Adams/Controls


Adams/Car GUI Sequence……..………………………………………………….…………………………….. 6-3
Special Files Required …………………………………………………………………………………..……….. 6-4
Adams_init, Adams_exec..………………………………………………………………………………..…….. 6-6
Sampling Rates… ….…………….……………………………………………………………..……………….. 6-7
Persisting Data in Assemblies...…………………………………………………………………..…………….. 6-8
Allow able Simulation Types……………………………………………………………………………………… 6-9

Copyright 2008 MSC.Software C orporation


MSC Confi denti al

Copyright 2008 MSC.Software C orporation


INTRODUCTION

WELCOME TO ADAMS/CONTROLS TRAINING

ADM711, Introduction, July 2008


Copyright2008 MSC.Software Corporation INTRO-1 Copyright 2008 MSC.Software C orporation
ADM711, Introduction, July 2008
Copyright2008 MSC.Software Corporation INTRO-2 Copyright 2008 MSC.Software C orporation
WELCOME TO ADAMS/CONTROLS TRAINING
● In this course, you learn how to use Adams/Controls to
connect your Adams model to block diagrams that you
have developed with control applications such as Easy5 or
MATLAB.

ADM711, Introduction, July 2008


Copyright2008 MSC.Software Corporation INTRO-3 Copyright 2008 MSC.Software C orporation
WELCOME TO ADAMS/CONTROLS TRAINING
● What’s in this section:

● A Brief History of Adams

● About MSC.Software

● Getting Help

● A Review of Basic Adams Terminology

ADM711, Introduction, July 2008


Copyright2008 MSC.Software Corporation INTRO-4 Copyright 2008 MSC.Software C orporation
A BRIEF HISTORY OF ADAMS
● Adams: Automatic dynamic analysis of mechanical
systems.

● Technology was implemented about 25 years ago.

● Mechanical Dynamics Incorporated (MDI) formed by


researchers who developed the base Adams code at the
University of Michigan, Ann Arbor, MI, USA. MDI has been
part of MSC.Software Corporation since 2002.

● Large displacement code.

ADM711, Introduction, July 2008


Copyright2008 MSC.Software Corporation INTRO-5 Copyright 2008 MSC.Software C orporation
A BRIEF HISTORY OF ADAMS (Cont.)
● Systems-based analysis.

● Original product was Adams/Solver, an application that


solves nonlinear numerical equations. You build models in
text format and then submit them to Adams/Solver.

● In the early 90’s, Adams/View was released, which


allowed users to build, simulate, and examine results in a
single environment.

● Today, industry-specific products are being produced,


such as Adams/Car and Adams/Driveline.

ADM711, Introduction, July 2008


Copyright2008 MSC.Software Corporation INTRO-6 Copyright 2008 MSC.Software C orporation
ABOUT MSC.SOFTWARE
● Find a list of MSC.Software products at:
● http://www.mscsoftware.com/products/products.cfm

● Find a list of Adams products at:


● http://www.mscsoftware.com/products/mdadams.cfm?Q=457&Z=455

● Find additional training at:


● http://www.engineering-e.com/training/
● Or your local support center

ADM711, Introduction, July 2008


Copyright2008 MSC.Software Corporation INTRO-7 Copyright 2008 MSC.Software C orporation
GETTING HELP
● Online help

● To access the online help, do one of the following:


● From the Help menu, select Adams/Controls Help
● Press F1 when a dialog box is active

● Once the online help is displayed, you can browse through the
table of contents or the index, or search for any terms.

ADM711, Introduction, July 2008


Copyright2008 MSC.Software Corporation INTRO-8 Copyright 2008 MSC.Software C orporation
GETTING HELP (Cont.)
Index/search for entire
Contents of Adams help
selected tab

Table of contents

ADM711, Introduction, July 2008


Copyright2008 MSC.Software Corporation INTRO-9 Copyright 2008 MSC.Software C orporation
GETTING HELP (Cont.)
● Technical support
● To find your local support center, go to:
http://www.mscsoftware.com/support/contacts/index.cfm
● To read the Service Level Agreement, go to:
http://www.mscsoftware.com/support/pdf/MSC_Tech_Support_Guide_2006.pdf

● knowledge base
● Go to http://support.adams.com/kb
● For a quick tour of the knowledge base, go to:
http://www.adams.com/news/newsletter/vol3/kbtour.htm

● Consulting services
● Go to http://support.adams.com/services/consulting.shtm

ADM711, Introduction, July 2008


Copyright2008 MSC.Software Corporation INTRO-10 Copyright 2008 MSC.Software C orporation
GETTING HELP (Cont.)
● MSC Virtual Product Development Community

● To join the community of MSC.Software users, go to:


http://forums.mscsoftware.com.

● Select Adams to view the Adams discussions.

● Select MSC News to view product alerts and company news and
events.

ADM711, Introduction, July 2008


Copyright2008 MSC.Software Corporation INTRO-11 Copyright 2008 MSC.Software C orporation
A REVIEW OF BASIC ADAMS TERMINOLOGY
● Adams/Solver
● The solution engine.

● Adams/Solver dataset (*.adm)


● The ASCII file submitted to Adams/Solver, which contains
statements and functions that define the model.

● Adams/Solver command (*.acf)


● An ASCII file that contains commands to control how
Adams/Solver runs the model.

ADM711, Introduction, July 2008


Copyright2008 MSC.Software Corporation INTRO-12 Copyright 2008 MSC.Software C orporation
A REVIEW OF BASIC ADAMS TERMINOLOGY (Cont.)

● Adams/Solver output files

● Graphics (*.gra) - Information about how graphics work.


● Request (*.req) - Contains output for user-specified results.
● Results (*.res) - Contains state-like results for every entity.
Message (*.msg) - Information about the Adams/Solver
simulations. Useful for debugging with DEBUG/EPRINT.
● Output (*.out) - Output including initial conditions and request, and
content can depend on output specifications. It is usually tabular
and human readable (for example, tables for output from LINEAR
command).

ADM711, Introduction, July 2008


Copyright2008 MSC.Software Corporation INTRO-13 Copyright 2008 MSC.Software C orporation
ADM711, Introduction, July 2008
Copyright2008 MSC.Software Corporation INTRO-14 Copyright 2008 MSC.Software C orporation
SECTION 1

CO-SIMULATION MODE

ADM711, Section 1, July 2008


Copyright2008 MSC.Software Corporation S1-1
INTRODUCTION
● Use Adams/Controls to compare a system modeled in
MATLAB with a similar system built entirely within the
Adams environment.

ADM711, Section 1, July 2008


Copyright2008 MSC.Software Corporation S1-2
STATE VARIABLES IN ADAMS
● State Variables are essential to Adams/Controls as they
represent the system input/output quantities.
● Users can create State Variables to represent any quantity
of interest. For example, a State Variable, that continuously
monitors the velocity of a PART as a simulation progresses,
might look like this in an Adams/Solver .adm file:
VARIABLE/5, IC = 0, FUNCTION = VR(9,10)

ADM711, Section 1, July 2008


Copyright2008 MSC.Software Corporation S1-3
STATE VARIABLES IN ADAMS (Cont.)
● State Variables are created in Adams/View using the menu
picks.
● Build > System Elements > State Variable > New

ADM711, Section 1, July 2008


Copyright2008 MSC.Software Corporation S1-4
THE ADAMS/CONTROLS PLUGIN
● Adams/Controls is implemented as an Adams plugin. In
Adams/View (or Adams/Car, Adams/Engine, etc.) you can
access the available plugins using the menu picks:
● Tools > Plugin Manager
● Loading the Adams/Controls plugin results in a new menu
within Adams/View named ‘Controls’.

ADM711, Section 1, July 2008


Copyright2008 MSC.Software Corporation S1-5
PLANT INPUTS AND OUTPUTS
● Past versions of Adams/Controls (prior to v2005R2) used
the concept of Plant Inputs and Plant Outputs to organize
the input and output State Variables that Adams/Controls
uses.
● A Plant Input is simply a grouping of State Variables.
● Plant Inputs and Outputs are created using the menu
picks:
● Build > Controls Toolkit > Plant Input

ADM711, Section 1, July 2008


Copyright2008 MSC.Software Corporation S1-6
CONTROL SYSTEM EXPORT
● The Adams model must be
‘exported’ from Adams/View
to create a plant
representation that MATLAB
or EASY5 understands. The
following menu picks bring
up the plant export dialog
box:
● Controls > Plant Export

ADM711, Section 1, July 2008


Copyright2008 MSC.Software Corporation S1-7
CONTROL SYSTEM EXPORT (Cont.)
● Given here are a few specifications of general interest in the
Adams/Controls Plant Export dialog box:
File Prefix Prefix used for the resulting .cmd,
.adm and .m (or .inf) files
Input/Output Signals Listing of State Variables that are
the Adams inputs/outputs
Target Software Either MATLAB or EASY5

ADM711, Section 1, July 2008


Copyright2008 MSC.Software Corporation S1-8
CONTROL SYSTEM EXPORT (Cont.)
● Exporting the plant will create the following files in the
working directory:
● prefix.adm : an Adams/Solver representation of the model, used
when running Adams/Controls in batch mode.
● prefix.cmd : an Adams/View representation of the model, used when
running Adams/Controls in interactive mode.
● prefix.m (MATLAB only) : all the information that MATLAB needs to
start Adams, load the current model and interact with it via the
defined input/output Variables.
● prefix.inf (EASY5 only) : all the information that EASY5 needs to
start Adams, load the current model and interact with it using the
defined input/output Variables.

ADM711, Section 1, July 2008


Copyright2008 MSC.Software Corporation S1-9
MATLAB SETUP PROCESS
● After exporting the plant representation from Adams, the
environment must be setup in MATLAB. The general
process as follows:
● Start MATLAB, change working directory to that of exported files
from Adams (prefix.m).
● Read in prefix.m with the following command:
● prefix
● This will create several variables in the MATLAB environment needed to
interact with Adams.
● Execute the command on the MATLAB command line:
● adams_sys
● This will create a Simulink block that represents the Adams model in
MATLAB.
● Create a Simulink model that interacts with the Adams block.
ADM711, Section 1, July 2008
Copyright2008 MSC.Software Corporation S1-10
EASY5 SETUP PROCESS
● After exporting the plant representation from Adams, setup must be
performed in Easy5. The general process for this as follows:
● Start Easy5, save current model into the directory containing files from
Adams (prefix.inf).
● Ensure that the Adams extension library has been set up for the Easy5
installation (see appendix).
● From the Extensions library, locate the ‘Adams Mechanism’ component, add
this to the model.
● Double-click this new AD component to view the Component Data Table
(CDT).
● Use the ‘Select/Configure Adams Model’ button in the CDT to select the .inf
file.
● This process creates the proper Inputs and Variables for the AD block in
Easy5. Create an Easy5 model that interacts with these inputs and
outputs.
ADM711, Section 1, July 2008
Copyright2008 MSC.Software Corporation S1-11
CO-SIMULATION (DISCRETE MODE)
● One of the most common uses of Adams/Controls, co-
simulation, does the following process:
● MATLAB (or Easy5) starts the Adams ‘server’.
● Adams loads the appropriate .adm or .cmd model.
● MATLAB (Easy5) initializes its solution at time=0.
● Adams initializes its solution at time=0.
● MATLAB (Easy5) simulates for a duration of TSampling, holding the
Adams inputs constant.
● Adams simulates for the same duration (TSampling), holding the
MATLAB inputs fixed.
● MATLAB (Easy5) and Adams exchange updated input/output state
values.
● The process repeats for another TSampling duration.

ADM711, Section 1, July 2008


Copyright2008 MSC.Software Corporation S1-12
CO-SIMULATION (DISCRETE MODE) (Cont.)

ADM711, Section 1, July 2008


Copyright2008 MSC.Software Corporation S1-13
ESSENTIAL CO-SIMULATION SETTINGS
● Co-simulation parameters can be inspected/altered by
viewing the Adams block in MATLAB or EASY5.
To view settings:
● MATLAB: double-click the ‘adams_sub’ block, then the ‘Adams Plant’
block.
● EASY5: double-click the ‘AD’ block.

ADM711, Section 1, July 2008


Copyright2008 MSC.Software Corporation S1-14
ESSENTIAL CO-SIMULATION SETTINGS
(Cont.)
Co-simulation Sampling interval during which system inputs are
sampling rate held fixed.
-MATLAB: Communication Interval parameter
-EASY5: Communication_Interval parameter
Note: Sampling interval must be set to capture
system dynamics of interest. Large intervals will miss
high-frequency content; small intervals will
unnecessarily increase simulation time.
Animation Mode Specifies whether Adams/View (interactive mode) or
Adams/Solver (batch mode) is used.
-MATLAB: Animation mode parameter
-EASY5: Adams_Animation_Mode parameter
Note: Batch mode is generally much faster than
interactive mode.
Simulation Prefix for the Adams/Solver simulation results files.
output prefix -MATLAB: Output files prefix parameter
-EASY5: The text of the 4th line in the .inf file

ADM711, Section 1, July 2008


Copyright2008 MSC.Software Corporation S1-15
ADM711, Section 1, July 2008
Copyright2008 MSC.Software Corporation S1-16
SECTION 2

FUNCTION EVALUATION,
CO-SIMULATION PERFORMANCE

ADM711, Section 2, July 2008


Copyright2008 MSC.Software Corporation S2-1
OVERVIEW
● Investigate Function Evaluation mode, compare results
quality to co-simulation mode. Explore co-simulation
performance as simulation parameters are altered.

ADM711, Section 2, July 2008


Copyright2008 MSC.Software Corporation S2-2
FUNCTION EVALUATION MODE
● Function evaluation (or continuous) mode lets the MATLAB
(or EASY5) integrators solve the entire problem made up of
the Adams equations and the MATLAB (EASY5) equations.
In this mode, Adams simply acts as a ‘function evaluator’ for
the MATLAB (EASY5) integrator.

Mode Integrators used Comments


MATLAB solves Simulink model,
MATLAB and
Co-simulation Adams/Solver solves Adams model.
Adams
Data exchanged periodically.
MATLAB solves both, Simulink model and
Function Evaluation MATLAB Adams model. Adams/Solver just acts as
function evaluator for MATLAB integrator.

ADM711, Section 2, July 2008


Copyright2008 MSC.Software Corporation S2-3
FUNCTION EVALUATION MODE (Cont.)
● Limitations of the method:
● Adams/Solver is often better at solving complicated Adams models,
especially with entities like CONTACTS. Co-simulation is therefore,
often more robust.
● Function Evaluation mode does not work with most Adams/Car
(Adams/Engine, Adams/Driveline, etc.) models as the CONTROL/
statement is not supported in continuous mode.

ADM711, Section 2, July 2008


Copyright2008 MSC.Software Corporation S2-4
TCP/IP COMMUNICATION
● Traditional communication method for Adams/Controls:
● ‘Named pipe’ files - basically, input/output file buffers.
● New alternative communication method:
● TCP/IP communication - uses network infrastructure found in all
modern computer Operating Systems.
● Advantages of TCP/IP communication method:
● Less hard disk activity than previous method.
● Typically better performance.
● MATLAB (EASY5) and Adams do not need to be on the same
machine: can be run across a network.

ADM711, Section 2, July 2008


Copyright2008 MSC.Software Corporation S2-5
TCP/IP COMMUNICATION (Cont.)
● Additional setup required for using the TCP/IP
communication method:
● The ‘adams_daemon.py’ file must be copied from the
Adams/Controls installation directory to the working directory where
all the files (.m, .adm, .inf, etc.) exist.
● The adams_daemon must be started via the command line from the
working directory.
● The TCP/IP communications method must be chosen in the Adams
plant mask (MATLAB) or the component data table (EASY5).

ADM711, Section 2, July 2008


Copyright2008 MSC.Software Corporation S2-6
CO-SIMULATION PERFORMANCE SETTINGS
● Save less data in Adams:
● By default, each communication interval generates output data for
the Adams output files (*.req, *.res, *.gra) during a co-simulation.
Adams/Controls can save every nth sample using the ‘Number of
communications per output step’ parameter in the MATLAB plant
mask.
● Use ‘batch’ animation mode, avoid ‘interactive’ mode:
● Interactive mode uses Adams/View, while batch mode uses
Adams/Solver. The smaller resource overhead of Adams/Solver
generally leads to faster simulation times.
● Disable interactive charts or similar elements in Simulink (or
EASY5).
● Use a coarser sampling rate:
● This will speed up co-simulations, typically at the expense of
solution precision.
ADM711, Section 2, July 2008
Copyright2008 MSC.Software Corporation S2-7
ADM711, Section 2, July 2008
Copyright2008 MSC.Software Corporation S2-8
SECTION 3

GSE IMPORT METHOD

ADM711, Section 3, July 2008


Copyright2008 MSC.Software Corporation S3-1
OVERVIEW
Use MATLAB’s Real Time 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.

ADM711, Section 3, July 2008


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

ADM711, Section 3, July 2008


Copyright2008 MSC.Software Corporation S3-3
RTW BUILD PROCESS
MATLAB’s Real Time Workshop (RTW) 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:
1. Read plant export .m files into MATLAB (sets up proper environment for
Adams/Controls)
2. 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.

ADM711, Section 3, July 2008


Copyright2008 MSC.Software Corporation S3-4
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.

ADM711, Section 3, July 2008


Copyright2008 MSC.Software Corporation S3-5
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:
1. Ensure that the Adams/Controls plugin is loaded in Adams/View and
that proper Plant Input/Output structures exist in the model.
2. Import the .dll file via the Control System Import dialog box.
This creates the following modeling elements:
1. A STRING specifying the .dll file name
2. A GSE that contains all the states in the Simulink model
3. Several ARRAY elements needed by the GSE (number of states,
references to variables, etc.).
4. A SENSOR element that monitors error values in the GSE.

ADM711, Section 3, July 2008


Copyright2008 MSC.Software Corporation S3-6
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.

ADM711, Section 3, July 2008


Copyright2008 MSC.Software Corporation S3-7
DEPENDENCE ON HMAX (Cont.)
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.

ADM711, Section 3, July 2008


Copyright2008 MSC.Software Corporation S3-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:
1. 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.
2. 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.

ADM711, Section 3, July 2008


Copyright2008 MSC.Software Corporation S3-9
PREPARE SIMULINK MODEL FOR RTW
Before RTW compilation, inspect the Simulink model carefully
and consider the following:
1. 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: Fcn
● The Derivative block (du/dt) is unsupported. Use a Transfer Function
block like: s/(Ns+1) with a small value of N (ex: 0.001) to approximate a
derivative.

ADM711, Section 3, July 2008


Copyright2008 MSC.Software Corporation S3-10
PREPARE SIMULINK MODEL FOR RTW
(Cont.)
2. 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.
3. Do not parameterize source blocks as this can also cause problems
related to the integration step-size.
● For further details, see KB article 1-KB12498 in the MSC Knowledge
Base: http://support.mscsoftware.com/kb/

ADM711, Section 3, July 2008


Copyright2008 MSC.Software Corporation S3-11
ADM711, Section 3, July 2008
Copyright2008 MSC.Software Corporation S3-12
SECTION 4

GSE IMPORT SPECIFICS

ADM711, Section 4, July 2008


Copyright2008 MSC.Software Corporation S4-1
OVERVIEW
● Consider the differences between discrete and continuous
controllers as error settings in Adams are altered.

ADM711, Section 4, July 2008


Copyright2008 MSC.Software Corporation S4-2
DISCRETE CONTROLLERS NEED EXTERNAL
SOLVER
● RTW code libraries, built from a Simulink model containing
purely discrete states, will contain a built-in integrator
provided by Simulink to deal with the Simulink model.
● However, this .dll file will have internal ‘counter’ elements
that deal with the integration logic. For the RTW code to
function properly, the .dll file must be released/loaded
between simulations. There are two ways to force this
behavior in Adams/View (see figure on following page):
1. Set ‘Hold License’ to be ‘No’.
2. Or, specify ‘External’ for the Solver Library.

ADM711, Section 4, July 2008


Copyright2008 MSC.Software Corporation S4-3
DISCRETE CONTROLLERS NEED EXTERNAL
SOLVER (Cont.)

Both methods (external Solver or not holding license) force


Adams/View to release/load libraries when a simulation
reset is encountered.
ADM711, Section 4, July 2008
Copyright2008 MSC.Software Corporation S4-4
DISCRETE VS. CONTINUOUS CONTROLLERS
Simulink allows creation of either discrete or continuous
models. How these are handled by Adams/Solver is
dependant on the type:
1. 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, handling all error control.
2. 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.
In general, in Simulink:
● Continuous blocks are expressed in terms of “s”.
● Discrete blocks are expressed in terms of “z”.
ADM711, Section 4, July 2008
Copyright2008 MSC.Software Corporation S4-5
LIBRARY NAME, MULTIPLE CONTROLLERS
Each GSE-Import element in an Adams model has at least the
following traits:
● A .dll file containing the controller implementation
● A GSE element in the Adams model
● A STRING element in the Adams model, identifying the associated
.dll library file prefix
● The relationship between the STRING element and the
actual .dll file name is very important: a .dll file name cannot
be renamed without modifying the accompanying STRING
in the Adams/model.
● Multiple controllers can exist in a single model. Each
controller will be associated with a unique STRING element
which identifies the unique library name.
ADM711, Section 4, July 2008
Copyright2008 MSC.Software Corporation S4-6
LIBRARY NAME, MULTIPLE CONTROLLERS
(Cont.)
Example .adm file fragments:
!adams_view_name='discrete_controller_name'
STRING/1, STRING =discrete

!adams_view_name='other_controller_name'
STRING/22, STRING =other

ADM711, Section 4, July 2008


Copyright2008 MSC.Software Corporation S4-7
ADM711, Section 4, July 2008
Copyright2008 MSC.Software Corporation S4-8
SECTION 5

CO-SIMULATION MODIFIERS

ADM711, Section 5, July 2008


Copyright2008 MSC.Software Corporation S5-1
OVERVIEW
● Explore parameters that can alter the Solver library choice,
issue initialization commands and modify the interpolation
scheme used in co-simulation mode.

ADM711, Section 5, July 2008


Copyright2008 MSC.Software Corporation S5-2
ADAMS_EXEC PARAMETER
● Adams_exec parameter is required to occasionally use a
custom Adams/Solver library with Adams/Controls.
Adams_exec must specify either of the following:
● Keyword: used to specify the special Adams Solvers, for example:
● acar_solver: use the Adams/Car-specific Solver
● aengine_solver: use the Adams/Engine-specific Solver
● String: specify the name of a custom Solver library (.dll, .sl or .so
library) to be used. This library should exist in the working directory.
● Examples:
● adams_exec = ‘acar_solver’
● adams_exec = ‘my_custom_solver.dll’
● Can be set in the plant export GUI, in the Adams plant
mask, or simply as a command in MATLAB.

ADM711, Section 5, July 2008


Copyright2008 MSC.Software Corporation S5-3
ADAMS_INIT PARAMETER
● Adams_init enables specification of a command before the co-simulation
is launched. This is commonly used to initialize a model prior to the co-
simulation.
● Examples:
● Adams_init = ‘simulate/static’
● Adams_init = ‘file/command=init_commands.acf’
● The ‘init_commands.acf’ file from above might look like:
● EQUILIBRIUM/STATIC, TLIMIT=10, ERROR=1
● SIMULATE/STATICS
● EQUILIBRIUM/STATIC, TLIMIT=1, ERROR=0.001
● SIMULATE/STATICS
● This script is a classic “statics funnel” approach for finding equilibrium in a
model.
● Can be set in the plant export GUI, in the Adams plant mask, or simply
as a command in MATLAB.
ADM711, Section 5, July 2008
Copyright2008 MSC.Software Corporation S5-4
ADAMS CONTROLS WAIT TIME
● By default, Adams/Controls waits for approximately four
seconds for Adams/Solver to launch and start interacting with
Adams/Controls. Issues with acquiring licenses over a busy
network, or similar, can delay the startup of Adams/Solver,
yielding a “Plant Communication Error” from Adams/Controls.
● Setting the ADAMS_CONTROLS_WTIME environment
variable to a larger number (8 seconds) can lead to slightly
slower startup times, but more robust co-simulation
performance.

ADM711, Section 5, July 2008


Copyright2008 MSC.Software Corporation S5-5
ADAMS CONTROLS WAIT TIME (Cont.)
● This must be set as an environment variable in one of two
ways:
● Globally: create a user-space environment variable that is always
active, setting this variable to a value greater than four seconds.
● On a per-shell basis: set this environment variable only for a particular
shell instance. Then launch MATLAB (or Easy5) from this shell.
● Example of setting this variable from a DOS shell on Windows, then
launching MATLAB from this same shell:
● set ADAMS_CONTROLS_WTIME=8
● c:\MATLAB701\bin\matlab.bat

ADM711, Section 5, July 2008


Copyright2008 MSC.Software Corporation S5-6
CO-SIMULATION INTERPOLATION ORDER
● The default co-simulation method is to sample-and-hold
data on the MATLAB (or Easy5) and Adams sides of the co-
simulation. Once Adams and MATLAB exchange
input/output state information, these states are held fixed in
the respective models until the next communication interval.
This is also referred to as “zero-order hold”.
● The sudden changes in the variables at the co-simulation
data exchanges can cause problems for the respective
integrators.

ADM711, Section 5, July 2008


Copyright2008 MSC.Software Corporation S5-7
CO-SIMULATION INTERPOLATION ORDER
(Cont.)
● When the interpolation order parameter is set to “1”,
Adams/Controls does the following:
● MATLAB (Easy5) side: enough information is available to linearly
interpolate input data throughout the co-simulation sampling interval.
● Adams side: the current data values are used with the previous time
step to linearly extrapolate over the sampling duration.
● Interpolation (or extrapolation, depending on the package)
can lead to faster simulation times as the respective
integrators have less-severe state changes to work with.

ADM711, Section 5, July 2008


Copyright2008 MSC.Software Corporation S5-8
CO-SIMULATION LIMITATIONS
● Sampling Rate
● The data exchange sampling rate must be sufficient to capture the
system interaction dynamics. In some cases, the sampling rate must
be so small that simulations take a very long time to progress.
● SIMULATE/DYNAMICS only
● SIMULATE/KINEMATICS and SIMULATE/TRANSIENT will not work
since Adams/Controls only issues SIM/DYN commands. Note that
many suspension analysis events in Adams/Car are quasi-static
analyses, so they are not compatible with Adams/Controls.
● Unsupported Adams/Solver Commands
● SAVE and RELOAD: should not be used.

ADM711, Section 5, July 2008


Copyright2008 MSC.Software Corporation S5-9
CO-SIMULATION LIMITATIONS (Cont.)
● ACTIVATE and DEACTIVATE: should not be used with function
evaluation mode as they change the topology of the model. Works
with co-simulation mode.
● CONTROL/FUNCTION: should not be used with function evaluation
mode as model topology can be changed. Works with co-simulation
mode, but beware of accidentally advancing time.

ADM711, Section 5, July 2008


Copyright2008 MSC.Software Corporation S5-10
ADM711, Section 5, July 2008
Copyright2008 MSC.Software Corporation S5-11
SECTION 6

ADAMS/CAR AND ADAMS/CONTROLS

ADM711, Section 6, July 2008


Copyright2008 MSC.Software Corporation S6-1
OVERVIEW
● Investigate the effect of an anti-lock braking (ABS) system
on an Adams/Car model during a dynamic event.

ADM711, Section 6, July 2008


Copyright2008 MSC.Software Corporation S6-2
ADAMS/CAR GUI SEQUENCE
● The Adams/Car Graphical User Interface (GUI) must be
used to set up the Adams/Car model and generate
special files needed for the co-simulation.
● Adams/Car will write out special files (.m, .inf, etc.) related
to Adams/Controls if the following conditions are met in
the Adams/Car GUI and model:
● The Adams/Controls plugin must be loaded in Adams/Car.
● The current vehicle model must contain both, Plant Input and
Plant Output structures somewhere within the various
subsystems.
● A “Files Only” simulation must be submitted for the simulation
event.

ADM711, Section 6, July 2008


Copyright2008 MSC.Software Corporation S6-3
SPECIAL FILES REQUIRED
● If the conditions are met, Adams/Car will write out the files
needed to set up an Adams/Controls simulation.
● If the Adams/Controls plugin has been loaded, if model
contains both, Plant Input and Plant Output structures, and
if a ‘Files Only’ simulation has been submitted, the following
file types will be written to the working directory:
● .adm = the standard model file
● .acf = the standard event simulation script
● _controls.acf = special simulation script needed for
Adams/Controls model initialization
● .xml = the standard event definition file
● .m = information file for MATLAB
● .inf = information file for Easy5
ADM711, Section 6, July 2008
Copyright2008 MSC.Software Corporation S6-4
SPECIAL FILES REQUIRED (Cont.)
● A .acf file for a standard event may look like this:
! first line blank
file/model=baseline_brake
output/nosep
control/routine=abgVDM::EventInit, function=user(3,1,12,0,2,7,7,11,4,10, 19)
control/routine=abgVDM::EventRunAll, function=user(0)
stop
● The equivalent for an Adams/Controls simulation may look like this:
output/nosep
show status=simulation
control/routine=abgVDM::EventInit, function=user(3,1,12,0,2,7,7,11,4,10, 19)
show status=simulation
sim/init
● Note that the Adams/Controls-specific .acf file simply runs the “EventInit”
simulation and issues a “sim/init” command.
● Adams/Controls takes care of advancing time once the vehicle model
has been initialized.
ADM711, Section 6, July 2008
Copyright2008 MSC.Software Corporation S6-5
ADAMS_INIT, ADAMS_EXEC
● The method for setting up the vehicle model and the custom
Solver library needed to run the simulation must be specified
via the Adams_init and Adams_exec variables.
● Initializing: the Adams_init variable must be used to
initialize the model by reading the special ‘_controls.acf’ file,
for example:
Adams_init=’file/command=baseline_brake_controls.acf’
● Custom Library: the Adams_exec variable must name the
specific Adams/Solver library to be used for the vehicle
model, for example:
Adams_exec=’acar_solver’

ADM711, Section 6, July 2008


Copyright2008 MSC.Software Corporation S6-6
SAMPLING RATES
● For co-simulation (discrete) mode, the sampling rate must
always be the same as the one is specified in the standard
event .xml file.
● The ‘stepSize’ parameter in the .xml file must be identical to
the sampling rate for co-simulation.
<DcfMini name="BRAKING" active="true" userDefined="false"
smoothingTime="0.1" activeFlag="true" abortTime="4"
stepSize="0.0005" hMax="0">
● If the two sampling rates differ, the MATLAB model will have
a different time-basis than the Adams model and problems
will be apparent.

ADM711, Section 6, July 2008


Copyright2008 MSC.Software Corporation S6-7
PERSISTING DATA IN ASSEMBLIES
● By default, Adams/Car does not save any assembly
changes to file, unless the assembly is saved in the binary
format. Model elements such as Plant Input and Plant
Output structures should therefore be created and get
saved at the template level of the model.
● Therefore, the two methods for incorporating
Adams/Controls-specific model changes are:
● Make changes to the assembly, then save the assembly in the
binary format.
● Incorporate changes at the template level, then re-create
subsystems and assemblies as needed.

ADM711, Section 6, July 2008


Copyright2008 MSC.Software Corporation S6-8
ALLOWABLE SIMULATION TYPES
● Adams/Controls, during a co-simulation analysis, will only
issue the “SIMULATE/DYNAMICS, ….” command. Other
simulation types, such as quasi-statics, are not possible.
● Many full-vehicle simulations in Adams/Car are dynamic
simulations; some are quasi-static events and will therefore
not work with Adams/Controls.
● Most half-vehicle (suspension) analyses in Adams/Car are
quasi-static simulations, so these will not work with an
Adams/Controls co-simulation.

ADM711, Section 6, July 2008


Copyright2008 MSC.Software Corporation S6-9
ADM711, Section 6, July 2008
Copyright2008 MSC.Software Corporation S6-10

You might also like