Getting Started Using Adams/Controls - MD Adams 2010
Getting Started Using Adams/Controls - MD Adams 2010
Overview
This chapter starts you off on the process of adding controls to your Adams model. Following this chapter
are tutorials for some of the controls applications you can use with Adams/Controls: co-simulation and
Control System Import with Easy5 or MATLAB. After you finish this chapter, continue with the tutorial
that is specific to the controls application you are using.
This chapter contains the following sections:
• About the Tutorial
• How You’ll Learn Adams/Controls
• Starting Adams/View
• Step One - Build the Adams Model
• Step Two - Creating the Adams Plant Inputs and Outputs
Before doing these tutorials, you should be familiar with the basic features of the Adams/View interface.
Refer to the online help for Adams/View for information about the Adams/View interface.
Starting Adams/View
In this section, you learn how to create a new directory and start Adams/Controls from within
Adams/View in the UNIX and Windows environments.
In the UNIX environment, you start Adams/View from the Adams Toolbar, and then, from within
Adams/View, you load the Adams/Controls plugin. For information on the Adams Toolbar, see the online
help for Running and Configuring Adams.
In the Windows environment, you start Adams/View from the Start menu, and then load the
Adams/Controls plugin. For more information, see the online help for Running and Configuring Adams.
To start Adams/View:
1. Copy all of the files in install_dir/controls/examples/antenna to a new directory.
2. Do either of the following depending on the platform on which you are running Adams/View:
• In UNIX, type the command to start the Adams Toolbar at the command prompt, and then
press Enter. Select the Adams/View tool .
• In Windows, from the Start menu, point to Programs, point to MSC.Software, point to MD
Adams 2010, point to AView, and then select Adams - View.
The Welcome dialog box appears, in the Adams/View main window.
Introducing and Starting the Tutorials 7
Step One - Build the Adams Model
Antenna
Elevation bearings
Plate
Antenna support
Reduction gear
Azimuth rotor
8 Getting Started Using Adams/Controls
Step One - Build the Adams Model
Loading Adams/Controls
Because Adams/Controls is a plugin for Adams/View, you need to load Adams/Controls when you use
it with Adams/View.
To load Adams/Controls:
1. From the Tools menu, point to Plugin Manager.
2. Select the Load checkbox next to Adams/Controls.
3. Select OK.
Adams/View loads the Adams/Controls plugin. Notice that there is now a Controls menu on the
main menu.
Note: To automatically load Adams/Controls each time Adams/View starts up, select Load at
Startup in the Plugin Manager.
• Steps: 250
3. Select Start at equilibrium.
4. Select the Start tool .
The base of the mechanism turns counterclockwise as the antenna tilts up and down.
Note: You might detect some small movement in the azimuthal direction because the model has
no constraints or restoring forces to control its natural movement. You should also notice
that the bending of the antenna support beam decreases when the azimuthal motion is
deactivated. The flexing illustrates that a certain amount of coupling takes place between
the elevation and azimuthal movements.
10 Getting Started Using Adams/Controls
Step Two - Creating the Adams Plant Inputs and Outputs
Control
system
For this tutorial, you will only verify that the state variables in the antenna model and control system
correspond to the correct input and output variables. For a description of state variables, see the online
help.
3. Select control_torque.
4. Select OK.
12 Getting Started Using Adams/Controls
Step Two - Creating the Adams Plant Inputs and Outputs
5. Look in the F(time, ...) = text box and verify that the run-time function for the input variable,
control_torque, is 0.0.
Because the control torque will get its value from the control application, the 0.0 will be
overwritten during each step of the simulation.
6. Select Cancel to close the Modify State Variable dialog box.
Note: After you close the box, click in the background of the screen to clear the selection
of the model.
3. Look in the Function text box and verify that the run-time function for the input variable reads:
VARVAL(.main_olt.control_torque).
Note: VARVAL (variable value) is the Adams function that returns the value of the given
variable. Notice that the function is defined as the value of the control_torque
variable. In other words, the input control torque (azimuth_actuator) gets its
value from the input variable.
5. Look in the F(time, ...) = text box to verify that the run-time function for the output variable is
AZ(MAR70, MAR26).
This function returns the angle about the z-axis, the vertical axis about which the antenna rotates.
Therefore, the function assigns the rotational position of the antenna to the output state variable.
6. Right-click the Name text box, point to ADAMS_Variable, point to Guesses, and then select
rotor_velocity.
The Modify State Variable dialog box updates.
7. Look at the F(time, ...) = text box and verify the run-time function for the output variable is
WZ(MAR21, MAR22, MAR22).
This function measures the rotational velocity of the rotor relative to ground.
8. Select Cancel to close the dialog box.
Note: It is important to maintain the above selection order for selecting output signals so
that the model works properly with the example MATLAB or Easy5 model.
9. From the Target Software pull-down menu, select the controls application you are using during
this session: MATLAB or Easy5.
10. Confirm that Analysis Type is set to non_linear and Initial Static Analysis is set to No.
Note: If Analysis Type is set to linear and Initial Static Analysis is set to Yes,
Adams/Controls conducts a static analysis before the linear analysis. Otherwise,
Adams/Controls performs an initial conditions analysis.
11. Verify that the Adams/Solver choice set as desired and Adams Host Name is set to your machine
name.
Be sure that the name for Adams Host is a fully qualified hostname or localhost if using TCP/IP
communication with co-simulation or function evaluation mode. This is not required for PIPE-
based communication. (To be fully qualified, the hostname must contain the workstation and
domain name.) If the Adams Host is not fully qualified, edit the value in the text box so that it is
fully qualified.
12. If Target Software is set to Easy5, verify that Dynamic States Output is selected.
16 Getting Started Using Adams/Controls
Step Two - Creating the Adams Plant Inputs and Outputs
Dynamic States Output performs an initial conditions analysis or a static analysis (if Initial Static
Analysis is set to Yes), and computes the number of states (i.e., displacements, velocities) in the
model. This is used by Easy5 for Function Evaluation mode. If your model has difficulty
computing this properly, you can disable this feature, but you will not be able to use Function
Evaluation mode unless the number for NUMBER OF STATES is modified in the .inf file from
Plant Export. This may be relevant for Adams/Chassis models imported into Adams/View.
13. Verify that the Plant Export dialog box is completed as shown in the figure below.
This order is
important.
Adams/Controls saves the input and output information in an .m (for MATLAB) or .inf file (for
Easy5). It also generates a command file (.cmd) and a dataset file (.adm) that are used during the
simulation process. Empty file called aviewAS.cmd is also created which will prevent the
startup screen from displaying when simulating interactively with Adams/View.
Note: The ant_test Controls Plant you just created is saved in the modeling database. By
importing settings from an existing plant, you can generate new plants based on plants you
already created.
To export the linear plant files (optional: not required for co-simulation or function
evaluation):
1. From the Controls menu, select Plant Export.
2. In the Adams/Controls Plant Export dialog box, create a new controls plant by importing settings
from a previous plant.
3. Change the file prefix from ant_test to ant_test_l.
4. Set Analysis Type to Linear.
5. Set Initial Static Analysis to Yes.
6. Select OK.
Adams/Controls generates the linear model of the Adams model in four matrices: ant_test_la,
ant_test_lb, ant_test_lc, and ant_test_ld.
Adams/Controls setup is complete after the plant files have been exported. Now you will go to the
specific controls application (Easy5 or MATLAB) and complete the link between the controls and
mechanical systems.
Note: You have now finished the introduction to the Adams/Controls tutorials. To continue
learning the Adams/Controls interface, go to the tutorials that follow this section. If you are
using:
Overview
This chapter teaches you how to use Adams/Controls with MATLAB in co-simulation. It contains the
following sections:
• About the Tutorial
• Step Three - Adding Controls to the Adams Block Diagram
• Step Four - Simulating the Model
Note: Before beginning this tutorial, you should have finished Introducing and Starting the
Tutorials.
Learning Adams/Controls with MATLAB Co-Simulation/Function Evaluation 19
About the Tutorial
Starting MATLAB
A note about your Adams license(s): Running an Adams/Controls cosimulation will check out an
Adams/Solver license and possibly an Adams/View license (for interactive simulations only). To ensure
that you are able to run these products, you may need to close any Adams applications that use these
licenses.
You can check any of the above variables by entering them in at the MATLAB prompt. For
example, if you enter ADAMS_outputs, MATLAB displays all of the outputs defined for your
mechanism:
ADAMS_outputs=
rotor_velocity!azimuth_position
Note: If you want to import the linearized Adams model, use ant_test_l.m instead of
ant_test.m. The main difference is in the ADAMS_mode variable:
• In ant_test.m, ADAMS_mode=non_linear.
• In ant_test_l.m, ADAMS_mode=linear.
2. From the File menu, point to New, and then select Model.
A new selection window for building your block diagram appears.
3. Drag and drop the adams_sub block from the adams_sys_ selection window onto the new
selection window.
4. Double-click the adams_sub block.
Learning Adams/Controls with MATLAB Co-Simulation/Function Evaluation 23
Step Three - Adding Controls to the Adams Block Diagram
Note: The inputs and outputs you defined for the model appear in the sub-block. The input and
output names automatically match up with the information read in from the ant_test.m
file.
Note: If the Simulink model containing the adams_sub block was created in an earlier version
of Adams/Controls, you should run adams_sys again to create a new adams_sub block
to replace the existing one for better performance.
5. From the File menu, select Save As, and enter a file name for your controls block diagram.
Note: For more features in the Adams/Controls block, select More parameters, which reveals
the following dialog box. Note that the dialog box will add and remove parameters
depending on the settings.
28 Getting Started Using Adams/Controls
Step Three - Adding Controls to the Adams Block Diagram
Learning Adams/Controls with MATLAB Co-Simulation/Function Evaluation 29
Step Three - Adding Controls to the Adams Block Diagram
3. Once you have finished reorienting the model, resume the simulation by selecting Simulation,
and then Continue, from the toolbar on the Simulink window.
Adams/View closes automatically after the simulation finishes.
>>xlabel(‘Time in seconds’)
>>ylabel(‘Control Torque Input, N-mm’)
>>title(‘Adams/Controls Torque Input from MATLAB to Adams’)
The labels appear on the plot.
Overview
This chapter teaches you how to generate external system libraries (ESL) from control systems designed
in MATLAB/Simulink and import them into Adams. It contains the following sections:
• Step Three – Setup MATLAB
• Step Four – Create Adams Target for Real Time Workshop
• Step Five – Create Simulink Model
• Step Six – Code Generation of Control System
• Step Seven – Create GSE from the Simulink Model
Learning Adams/Controls with Control System Import from MATLAB 39
About the Tutorial
To start MATLAB:
1. Start MATLAB in the same directory as the one the model and Simulink files reside.
2. Set up the MEX utility, if not already set up.
Enter mex -setup from the MATLAB command window, and then select the appropriate
compiler. (see http://support.adams.com under Hardware & Software Requirements for a list of
supported compilers)
3. At the prompt (>>), type ant_test.
MATLAB displays:
%%%INFO:Adams plant actuators names:
1 control_torque
%%%INFO:Adams plant sensors names:
1 rotor_velocity
2 azimuth_position.
4. At the prompt, type who to view the list of variables defined in the files.
MATLAB displays the following relevant information:
You can check any of the above variables by entering them at the MATLAB prompt. For example,
if you enter Adams_outputs, MATLAB displays all of the outputs defined for your mechanism.
For example:
ADAMS_outputs = rotor_velocity!azimuth_position
Learning Adams/Controls with Control System Import from MATLAB 41
Step Four – Create Adams Target for Real Time Workshop
2. In the directory where your Adams model resides, issue the following command, where
$adams_dir is the directory in which Adams is installed:
• On UNIX:
mdadams2010 -c python ($adams_dir)/controls/utils/process.py -v 78 exit
• On Windows:
mdadams2010 python ($adams_dir)\controls\utils\process.py -v 78
Alternatively, you can copy the process.py file from the
<adams_dir>/controls/utils/ directory on UNIX or
<adams_dir>\controls\utils\ on Windows to the current directory and issue the
following command:
• On UNIX:
42 Getting Started Using Adams/Controls
Step Four – Create Adams Target for Real Time Workshop
Note: The value for MATLAB_ROOT should have no quote, no spaces (on Windows, get short
names with command dir /x), and a final slash on the path.
Learning Adams/Controls with Control System Import from MATLAB 43
Step Five – Create Simulink Model
Based on this template, you can design continuous, discrete, or hybrid control systems. For this
tutorial, this step is information only. Since you already have these files copied into the local
directory, you can delete this "io" model and use one of the examples.
2. To open hybrid.mdl, from the File menu, select Open. Or, double-click the file in the file
browser. Optionally, you may also open discrete.mdl and/or continuous.mdl and run the rest of
the tutorial with those for comparison.
In the following context, the hybrid control system will be used as the example to illustrate the
process. The Figure 18 shows the hybrid system and Table 1 shows the topology.
44 Getting Started Using Adams/Controls
Step Five – Create Simulink Model
4. From the treeview on the left side of the window, select Solver.
The dialog box displays the Solver options as shown in Figure 20
Learning Adams/Controls with Control System Import from MATLAB 47
Step Six – Code Generation of Control System
5. Set Solver options Type to Variable-Step. (If selecting Fixed-step solver, Set Mode to
SingleTasking.).
6. Under zero-crossing options, set Zero-crossing control to Disable All.
7. From the treeview on the left side of the window, select Optimization.
The dialog box displays the Advanced options as shown in the Figure 21.
8. Verify that Inline parameters is selected. Enabling Inline parameters has the following effects:
• Real-Time Workshop uses the numerical values of model parameters, instead of their
symbolic names, in generated code.
48 Getting Started Using Adams/Controls
Step Six – Code Generation of Control System
• Reduces global RAM usage, because parameters are not declared in the global parameters
structure.
9. Select Apply.
10. Select the Real-Time Workshop tab.
11. To begin code generation and build the RTW library, select Build.
Messages will appear in the MATLAB command window indicating successful code generation
and RTW library creation. You should see messages that end with the following:
Creating library ..\hybrid.lib and object ..\hybrid.exp
*** Created ADAMS dll
C:\adams_controls_getting_started\antenna\hybrid_rsim_rtw>exit /B 0
Learning Adams/Controls with Control System Import from MATLAB 49
Step Six – Code Generation of Control System
Adams/View displays information on the GSE created (See Figure 23). The Database Navigator
shown in Figure 24 shows the GSE and its associated arrays.
A comparison of the results of the above simulation, Co-simulation, and Function Evaluation
simulation is conducted (the latter two not performed in this tutorial). In all cases, the output step
(sampling time in discrete simulation) is set to .001 second. The control torque versus time from
three simulations is plotted in Figure 26. As shown, the result from the simulation with imported
GSE is almost the same as that from Function Evaluation simulation. The control torque from the
Co-simulation is slightly larger in magnitude because the one-step delay introduced by the
discrete control system results in a control-mechanical system with less damping.
54 Getting Started Using Adams/Controls
Step Seven – Create GSE from the Simulink Model
Your RTW dll can contain discrete states and counters. When performing repeated simulations
(for example, design of experiments or design optimization), these entities need to be reset to their
original values at the beginning of each simulation. When you rewind a simulation in
Adams/View, the RTW dll is released and reacquired, thereby resetting the discrete states and
counters to their original state. Changing this behavior by issuing commands in Adams/View
causes unexpected simulations after the first one.
Optionally, if you repeat the tutorial to create ESL's for discrete and continuous models, and re-
run, you should see a plot like Figure 27. Note that the step excitation is slightly different for each
model, and delays are caused by discrete states, so you should see differences in the responses
accordingly.
Learning Adams/Controls with Control System Import from MATLAB 55
Step Seven – Create GSE from the Simulink Model
Overview
This chapter teaches you how to use Adams/Controls with Control System Import from MATLAB with
S-Functions. It contains the following sections:
• Step Three - Generate S-Function Using Real-Time Workshop
• Step Four - Use S-Function to Create Adams External System Library
• Step Five - Use S-Function without source code to Create ESL
• Step Six - Expose S-Function Parameters to Adams
• Step Seven - Use the S-Function ESL in Adams Control System Import
Learning Adams/Controls with Control System Import from MATLAB with S-Functions 57
Step Three - Generate S-Function Using Real-Time Workshop
Setup MATLAB
First you will start MATLAB, and then you will create a Simulink model for control system design. You
will use the antenna model files from the last section, plus several additional files.
To start MATLAB:
1. Start MATLAB in the same directory as the one the model and Simulink files reside.
2. Set up the MEX utility, if not already set up.
Enter mex -setup from the MATLAB command window, and then select the appropriate
compiler. (see http://support.adams.com under Hardware & Software Requirements for a list of
supported compilers)
3. At the prompt (>>), type ant_test.
MATLAB displays:
%%%INFO:Adams plant actuators names:
1 control_torque
%%%INFO:Adams plant sensors names:
1 rotor_velocity
2 azimuth_position.
4. At the prompt, type who to view the list of variables defined in the files.
MATLAB displays the following relevant information:
You can check any of the above variables by entering them at the MATLAB prompt. For example,
if you enter Adams_outputs, MATLAB displays all of the outputs defined for your mechanism.
For example:
ADAMS_outputs = rotor_velocity!azimuth_position
Limitations section. In addition, Adams/Controls has its own limitations for S-Functions support for ESL
creation/use, also listed.
For this example, you can simply open the Simulink model discrete.mdl, shown in Figure 27:
3. Here, under Solver options, Type, select Variable-Step. Any variable-step solver will be fine at
this point (for example, ode45), as long as you don't choose a discrete solver for a model with
continuous states.
Note: You can choose either Variable-step or Fixed-step solvers in MATLAB/Simulink. The
choice will affect the model code that is generated from RTW, in particular to how sample
times are handled. This is important to Adams since Adams will be integrating the model,
not MATLAB/RTW. In this regard, the Variable-step integrator is recommended since
Adams/Solver uses mainly variable-step integrators, and this will ensure the outputs and
states are computed properly. If you would still like to use a Fixed-step integrator setting,
the model should have at least one continuous state to produce the code for Adams that will
handle the sample times properly. For example, if you have a discrete-only model, add a
dummy continuous block (for example, Integrator) to the model.
Learning Adams/Controls with Control System Import from MATLAB with S-Functions 61
Step Three - Generate S-Function Using Real-Time Workshop
Tip: To look for differences in sample times between Fixed-Step and Variable-step integrators
settings, look for the function ssIsSampleHit(), which handles evaluation of code at
sample times.
Figure 30 Discrete/Configuration
5. Select Apply to apply your changes, and then select Build to build the S-Function.
62 Getting Started Using Adams/Controls
Step Three - Generate S-Function Using Real-Time Workshop
You should see messaging in the main MATLAB window about the build process, which should
conclude with this message upon a successful build (here, for 32-bit Windows; the extension will
depend on the platform):
### Created MEX-file discrete_sf.mexw32
In your working directory, you should find that RTW has created a directory called
discrete_sfcn_rtw containing the source files for generating your S-Function,
discreate_sf.mexw32.
Figure 31 S-Function
6. Furthermore, you should see that RTW created an S-Function block which now supplants your
Simulink model (here discrete.mdl):
Learning Adams/Controls with Control System Import from MATLAB with S-Functions 63
Step Three - Generate S-Function Using Real-Time Workshop
This is the block to be included in the Simulink model for the Adams External System Library.
64 Getting Started Using Adams/Controls
Step Four - Use S-Function to Create Adams External System Library
Setup MATLAB
If you haven't already done so, open ant_test.m in MATLAB as described in the section Step Three -
Generate S-Function Using Real-Time Workshop. This will create variables required and modify the
MATLAB path to pickup setup scripts and functions.
1. Run setio.
2. Copy S-Function block to setio model, and connect the inputs appropriately.
3. Save as discrete_sf_mdl.mdl:
4. From the treeview on the left side of the window, select Solver.
The dialog box displays the Solver options as shown in Figure 34.
Learning Adams/Controls with Control System Import from MATLAB with S-Functions 67
Step Four - Use S-Function to Create Adams External System Library
5. Set Solver options Type to Variable-Step (it must be the same Type as specified when generating
the S-Function). (If selecting Fixed-step solver, Set Mode to SingleTasking.)
6. Under zero-crossing options, set Zero-crossing control to Disable All.
7. From the treeview on the left side of the window, select Optimization.
The dialog box displays the Advanced options as shown in the figure below.
8. Verify that Inline parameters is selected. Enabling Inline parameters has the following effects:
• Real-Time Workshop uses the numerical values of model parameters, instead of their
symbolic names, in generated code.
68 Getting Started Using Adams/Controls
Step Four - Use S-Function to Create Adams External System Library
• Reduces global RAM usage, because parameters are not declared in the global parameters
structure.
9. Select Apply
10. Select the Real-Time Workshop tab.
11. To begin code generation and build the RTW library, select Build.
Messages will appear in the MATLAB command window indicating successful code generation
and RTW library creation. You should see messages that end with the following:
Creating library ..\discrete_sf_mdl.lib and object...\
discrete_sf_mdl.exp
### Created Adams External System Library discrete_sf_mdl.dll
C:\adams_temp\sfunction\discrete_sf_mdl_rsim_rtw>exit /B 0
### Successful completion of Real-Time Workshop build procedure
for model: discrete_sf_mdl
The library you created will be in your working directory.
Learning Adams/Controls with Control System Import from MATLAB with S-Functions 69
Step Five - Use S-Function without source code to Create ESL
3. Provide the following when distributing the model to the person who will make the
Adams/Controls ESL from RTW:
discrete_sf.mexw32
discrete_sf.h
discrete_sfcn_rtw/discrete_sf.h
discrete_sfcn_rtw/discrete_mid.h
discrete_sfcn_rtw/discrete_sid.h
discrete_sfcn_rtw/discrete_sf_private.h
discrete_sfcn_rtw/discrete_sf_types.h
discrete_sfcn_rtw/discrete.mk
discrete_sfcn_rtw/discrete_sf_data.c (if applicable)
discrete_sf_mdl_rsim_rtw/discrete_sf.obj
discrete_sf_mdl.mdl
4. To mimic what you would see at the receiver's end, first create a new directory called new_model.
Then, using the files from Step 3, retain the directory structure and copy all of these files to
new_model.
5. Also, move the files ant_test.m, ant_test.adm, and ant_test.cmd to the directory new_model.
6. Run ant_test.m in Matlab.
7. Open discrete_sf_mdl.mdl, and run setio to create the inputs and outputs for this model. Copy the
inports and outports to discrete_sf_mdl.mdl so it looks like in Figure 36:
Learning Adams/Controls with Control System Import from MATLAB with S-Functions 71
Step Five - Use S-Function without source code to Create ESL
12. Select Apply and then click Generate code. You should see a directory called
discrete_sf_no_source_rsim_rtw in the working directory, as below:
Learning Adams/Controls with Control System Import from MATLAB with S-Functions 73
Step Five - Use S-Function without source code to Create ESL
15. Select Build to build the ESL using the Adams/Controls-modified RSIM target.
You should see the following messaging in the MATLAB window:
### Created Adams External System Library
discrete_sf_no_source.dll
C:\adams_temp\sfunction\no_source_code\new_model\discrete_sf_no_
source_rsim_rtw>exit /B 0
Note: If you see a RTW message that it is compiling discrete_sf.c, then you have not performed
the steps properly, as it should not have a discrete_sf.c provided.
16. To use this ESL in Adams, See the section Step Seven - Use the S-Function ESL in Adams
Control System Import.
Learning Adams/Controls with Control System Import from MATLAB with S-Functions 75
Step Five - Use S-Function without source code to Create ESL
Note: The main RTW details can be found also written for another example here:
Select Parameters
To parameterize an S-Function for Adams, when building the S-Function block using an S-Function
target, first create parameters for the Simulink model.
1. Here we will create parameters "Kp1" and "Kp2" to parameterize the gain of the two transfer
functions:
Learning Adams/Controls with Control System Import from MATLAB with S-Functions 77
Step Six - Expose S-Function Parameters to Adams
2. Note that you must remove the square brackets [ ] to parameterize this field. The model should
now look like the following:
78 Getting Started Using Adams/Controls
Step Six - Expose S-Function Parameters to Adams
3. Here, we will set the values of the parameters to what they were originally:
>> Kp1=657.4
Kp1 =
657.4000
>> Kp2 = 600.5
Kp2 =
600.5000
3. Select Configure. This will allow you to select Kp1 and Kp2 add them to the list of Global
(tunable) parameters. Do this as below:
80 Getting Started Using Adams/Controls
Step Six - Expose S-Function Parameters to Adams
5. Under Configuration Parameters, select the Real-Time Workshop tab, and select the S-Function
Target for the System Target File.
6. Select Apply and then Build. This should create the file discrete_sf_data.c which will contain the
parameters selected:
/* Block parameters (auto storage) */
Parameters_discrete discrete_DefaultParameters = {
6.574E+002,
/* Kp1 : '<Root>/Discrete Transfer Fcn' */
600.5
/* Kp2 : '<Root>/Discrete Transfer Fcn1' */};
7. As in the section, "Step Four - Use S-Function to Create Adams External System Library", create
a new model based on your S-Function block, which now has the parameter exposed within it.
In the following steps, you will build the ESL using the Adams/Controls-modified RSIM target
and again choose the same parameters to be Global (tunable) Parameters.
8. In model with S-Function, select Kp1 and Kp2 as Global (tunable) parameters again:
82 Getting Started Using Adams/Controls
Step Six - Expose S-Function Parameters to Adams
9. Under Configuration Parameters, select the Real-Time Workshop tab, and select the
Adams/Controls-modified RSIM target for the System Target File.
Learning Adams/Controls with Control System Import from MATLAB with S-Functions 83
Step Six - Expose S-Function Parameters to Adams
10. Select Apply and then Build. This should create the file discrete_sf_mdl_data.c which will
contain the parameters selected (as well as their size (here: 1x1):
/* Block parameters (auto storage) */
Parameters rtP = {
/* RTWSFunction_P1_Size : '<Root>/RTW S-Function' */
{ 1.0, 1.0 }, 6.574E+002,
/* Kp1 : '<Root>/RTW S-Function'*/
/* RTWSFunction_P2_Size : '<Root>/RTW S-Function'*/
{ 1.0, 1.0 }, 600.5
/* Kp2 : '<Root>/RTW S-Function'*/
};
Following the steps in the section, Step Seven - Use the S-Function ESL in Adams Control System Import,
you can use Control System Import to load the ESL:
84 Getting Started Using Adams/Controls
Step Six - Expose S-Function Parameters to Adams
1. After loading the ESL, Adams/Controls will show these variables in the Adams Information
window:
Object Name : .main_olt.discrete_sf_gse.RTWSFunction_P1_Size_1_1
Object Type : Variable
Parent Type : General_State_Equation
Real Value(s) : 1.0 NO UNITS
Units : no_units
Note: The "size" parameters denote the size of the MATLAB array that stores the parameters.
You may ignore these values.
2. Run a simulation for 0.25 seconds, 250 steps with the default parameter settings.
3. Save this simulation as "baseline".
86 Getting Started Using Adams/Controls
Step Six - Expose S-Function Parameters to Adams
4. Select Tools Table Editor to modify the parameters from your ESL.
Learning Adams/Controls with Control System Import from MATLAB with S-Functions 87
Step Six - Expose S-Function Parameters to Adams
6. Run another simulation for 0.25 seconds, 250 steps with the new parameter settings.
7. Save this simulation as "new".
8. Switch to PostProcessor and plot the azimuth position for the baseline vs. new results. You should
see something similar to the plot below:
88 Getting Started Using Adams/Controls
Step Six - Expose S-Function Parameters to Adams
Learning Adams/Controls with Control System Import from MATLAB with S-Functions 89
Step Seven - Use the S-Function ESL in Adams Control System Import
Overview
This chapter teaches you how to use Adams/Controls with Easy5 in co-simulation. This chapter does not
include information on the basics of Easy5. For that information, refer to the appropriate Easy5
documentation.
It contains the following sections:
• About the Tutorial
• Step Three - Adding Controls to the Adams Block Diagram
• Step Four - Simulating the Model
Note: Before beginning this tutorial, you should have finished Introducing and Starting the
Tutorials, and have the Adams Extension for Easy5 installed (refer to the online help for
more information).
Learning Adams/Controls with Easy5 Co-Simulation/Function Evaluation 99
About the Tutorial
Starting Easy5
To start Easy5:
• Start Easy5 on your system from the directory that contains the file with the antenna example.
This is the working directory that you created in Step One - Build the Adams Model.
The Easy5 main window appears.
Note: The next two sections describe how to create a new Adams Interface block, and how to
configure it to run different analyses. You should review these sections before proceeding
to Constructing the Controls System Block Diagram where you will actually create a model
(or load the existing example).
2. Select Select/Configure Adams model in the lower left corner of the Component Data Table.
The Adams Interface dialog box appears as shown in Figure 41.
Learning Adams/Controls with Easy5 Co-Simulation/Function Evaluation 103
Step Three - Adding Controls to the Adams Block Diagram
3. Select ant_test.
4. Select Co-Simulation (Discrete).
Notes on the simulation options:
Options for Function Evaluation (1 and 2) are continuous simulation methods, integrating
completely within Easy5. Option for co-simulation (3) is a discrete simulation method where
Easy5 integrates the Easy5 model, and Adams integrates the Adams model, exchanging data at a
specified communication interval.
Regarding Feedthrough: Feedthrough refers to whether the inputs directly affect the outputs
(e.g., forces directly affect accelerations), or not (e.g., forces do not directly affect positions,
velocities). In other words, if you've linearized a nonlinear Adams model and represented it as A,
B, C, and D matrices and the matrix D is zero at all times, then there is no feed-through from the
input variables to the output variables. If the matrix D is not zero at all times, then there is feed-
through from the input variables to the output variables.
Options for Linear State Matrices (4 and 5) are linear methods that are solved completely within
Easy5.
For information on choosing a simulation method, see the online help.
5. Select Done.
The Adams Interface dialog box closes, and the Component Data Table now looks like in Figure
43:
104 Getting Started Using Adams/Controls
Step Three - Adding Controls to the Adams Block Diagram
Tip: For a description of the component inputs, outputs, and states, select the Info button
Note: You configure the Adams block the first time by reading in an .inf file. This
defines the extension inputs, such as ADAMS_Animation_Mode, ADAMS_Solver,
and so on. Subsequent reconfigurations of the block by reading in a new .inf file
do not overwrite the existing setting. You can change the settings of the extension
inputs at any time by manually resetting them before closing the Adams block CDT
using the OK button.
6. In the Component Data Table, in the Inputs tab, enter a value for the following input modes:
• For ADAMS_Animation_Mode, enter 1 to define interactive mode as the animation mode.
For more details about animation modes, see the Adams/Controls online help.
Learning Adams/Controls with Easy5 Co-Simulation/Function Evaluation 105
Step Three - Adding Controls to the Adams Block Diagram
Note: The ADAMS_Output _Interval in the Component Data Table determines the rate
at which Adams/Controls writes its result to file (and updates the animation, if in
interactive mode). It is the interval at which the result is written to file once. It has
the lower limit of Time Increment (see step 5), and works best if
ADAMS_Output _Interval is a multiple of Time Increment for integration. The
same rule applies to the Strip Chart output rate.
• Alternatively, if you select Option 1 in step 4, the Component Data Table appears as follows:
• In function evaluation mode, the communication interval option is not needed because the
integrators determine the communication interval.
• Leave Use_ADAMS_ICs at its default (1).
If the Use_ADAMS_ICs flag is set to 1, the model uses the Adams initial conditions.
If the flag is set to 0, the model relies on Easy5 to provide the initial conditions (for
example, starting a simulation from the end of the last run simulation, which is stored
in Easy5).
• Set the parameters as shown in Figure 44.
106 Getting Started Using Adams/Controls
Step Three - Adding Controls to the Adams Block Diagram
5. Connect the input blocks by clicking once on the First Order Lag block and then on the Adams
Mechanism Block.
Easy5 labels this connection as S_Out_LA11.
108 Getting Started Using Adams/Controls
Step Three - Adding Controls to the Adams Block Diagram
6. Connect the output blocks in the diagram by clicking on the Adams Mechanism Block and then
on the Summing Junction block. Be sure to connect the azimuth+position output to the first
Summing Junction block (SJ) and the rotor_velocity output to the second Summing Junction
block (SJ11).
7. Connect the Strip Chart to the Adams Mechanism Block.
Be sure to connect only the rotor_velocity output to the Strip Chart.
The rotor_velocity output corresponds to the rotor-velocity signal from the Adams Mechanism
Block.
8. Click the Strip Chart using the middle mouse button to display the Component Data Table. Set
the sample period TAU to .001, and then select OK.
Note: You must edit the connection from the Adams Mechanism Block to the Strip
Chart because Easy5 automatically connects the state vector from the Adams block
to the display variable on the Strip Chart.
9. From the File menu, select Save As, and then enter a file name for your controls block diagram.
You have now created the controls block diagram.
Learning Adams/Controls with Easy5 Co-Simulation/Function Evaluation 109
Step Four - Simulating the Model
Note: If you are using the completed block diagram from the file, antenna.0.ezmf,
which was provided for you in the examples directory, you may find that the Plot
Specification Form opens with information that is unnecessary for this tutorial.
After removing this information, the Plot Specification Form should look like the
shown in Figure 45.
110 Getting Started Using Adams/Controls
Step Four - Simulating the Model
4. Select the variables that you want to plot for the simulation.
For this tutorial, you will select three variables: rotor_velocity, azimuth_position, and S_Out_
LA11.
a. Under Dependent Variables, select the Variable #1 field.
Select the icon next to the field. The Select Plot Variables select list appears.
Learning Adams/Controls with Easy5 Co-Simulation/Function Evaluation 111
Step Four - Simulating the Model
5. Return to the General tab in the Simulation Data Form window, and then specify the following
simulation parameters:
• For Start Time, enter 0.0.
• For Stop Time, enter .25.
• For Time Increment, enter .001.
• For Integration Method, enter BCS Gear.
6. Select the Play tool to begin the simulation.
112 Getting Started Using Adams/Controls
Step Four - Simulating the Model
For more information about the simulation settings, see the Easy5 manual.
A new Adams/View window appears and the analysis begins on the model specified in the Adams
block. Adams/View displays the analysis for you.
Note: The Adams model is initialized to the current simulation time in Easy5.
2. Start and pause the simulation by selecting Continue and Break on the interactive plot window.
Adams/View accepts the control inputs from Easy5 and integrates the Adams model in response
to them. At the same time, Adams provides the azimuthal position and rotor velocity information
for Easy5 to integrate the Simulink model. The simulation process creates a closed loop in which
the control inputs from Easy5 affect the Adams simulation, and the Adams outputs affect the
control input levels. See Figure 2 for an illustration of the closed-loop simulation process.
2. Now go back to Adams/View. While the simulation is paused, you can change the orientation of
the model with the View Orientation tools in the Main toolbox. These tools help you to look at
the model from different vantage points.
114 Getting Started Using Adams/Controls
Step Four - Simulating the Model
3. Once you have finished reorienting the model, select Continue to continue the simulation.
Adams/View closes automatically after the simulation finishes.
• In the Plot Title text box, enter Adams/Controls Torque Input from Easy5 to Adams.
• In the x-axis text box, enter time in seconds.
• In the y-axis text box, enter Control Torque, Newton-mm.
The labels you entered appear on the plot as shown in below.
When you read in results files, be sure to include the model name because Adams/View needs
to associate the results data with a specific model.
Note: You can plot any data from the simulation and rerun the animation from Adams/View.
Figure 41 illustrates how the curve should look. The curve shows the torque in the antenna joint
from the azimuth control loop. You can use the information on the plot to help you determine how
to modify the control system of the antenna model. For example, you can reduce the load in the
antenna joint by decreasing the velocity gain of the azimuth controller at the expense of slowing
the overall response of the controller. This is the type of trade-off between the mechanism design
and the control design that you can analyze using Adams/Controls.
Overview
This chapter teaches you how to import external system models designed in Easy5 into an Adams model.
Importing an Easy5 model into Adams enables you to build, test, and refine your combined model using
the 3D visualization and design features available in Adams/View.
This feature is available only with Easy5 version 7.1 and later.
We assume that you:
• Read the previous chapter in this guide
• Know how to export Adams plant files
• Know how to use Adams Mechanism Blocks in Easy5
In the previous chapter, you configured the Adams component of the antenna controller model to
run in co-simulation mode. Because you want the controller to execute as a set of equations inside
Adams, you must reconfigure the Adams Mechanism component to be in function-evaluation
mode. Failure to reconfigure the Adams component may result in a model that does not behave
correctly in Adams. If you have already configured your Adams component to be in function-
evaluation mode, you may skip 3.
3. To reconfigure the Adams component:
a. Double-click the Adams Mechanism Block to open the Component Data Table (CDT) shown
in Figure 52.
124 Getting Started Using Adams/Controls
Step Three - Export Your Easy5 Model
b. Select Select/Configure Adams Model to open the Configure Adams block panel.
c. Select ant_test as the exported Adams model and choose the first option for execution mode:
Function Evaluation (no feedthrough).
d. Close the panel by selecting Done.
126 Getting Started Using Adams/Controls
Step Three - Export Your Easy5 Model
The Component Data Table for the Adams Mechanism Block is updated as shown next.
Note: The following Adams block inputs in the CDT are not relevant:
ADAMS_Animation_Mode, ADAMS_Output_Interval, and
Use_Adams_ICs.
b. Accept the settings in this form, and then select Export to start creating the library.
Messages in the message line at the bottom of the Easy5 window show the progress of the
library build. After a successful build, you will have two new files in your working directory.
The first file is a binary demand-loaded library file (named antenna.dll on Windows,
antenna.sl on HP-UX11 workstations, or antenna.so on other UNIX platforms). The
second file (named antenna.xfe.ezanl) contains the parameter values and other
information the Easy5 model needs. If you need to move these files to another directory (for
example, to make the Easy5 model available to other Adams users), you must move the two
files together or the exported Easy5 model will not work.
c. Exit Easy5.
128 Getting Started Using Adams/Controls
Step Four - Import the Exported Easy5 Model into Adams
7. When you have finished examining the Information window, select Close.
The Easy5 controls system has now been incorporated into your Adams model. Next you'll run a
simulation to see how it performs.
Learning Adams/Controls with Control System Import from Easy5 131
Step Five - Run a Simulation