ADAMS/Controls Version 12 TRAINING
ADAMS/Controls Version 12 TRAINING
ADAMS/Controls Version 12 TRAINING
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
1<br />
<strong>ADAMS</strong>/<strong>Controls</strong><br />
<strong>Version</strong> <strong>12</strong><br />
<strong>TRAINING</strong>
Contents<br />
Chapter 1: Welcome to <strong>ADAMS</strong>/<strong>Controls</strong> Training 6<br />
2<br />
A Brief History of <strong>ADAMS</strong> 7<br />
About Mechanical Dynamics 8<br />
Getting Help in Class 9<br />
Getting Help at Your Job Site 10<br />
A Recap of Basic <strong>ADAMS</strong> Terminology 11<br />
Design Methodology with/without <strong>ADAMS</strong>/<strong>Controls</strong> <strong>12</strong><br />
Chapter 2: Modeling <strong>Controls</strong> in <strong>ADAMS</strong> 15<br />
Open Loop Control Systems 16<br />
Closed Loop <strong>Controls</strong> Systems 17<br />
<strong>ADAMS</strong>/<strong>Controls</strong> Process 19<br />
<strong>ADAMS</strong>/<strong>Controls</strong> Compatibility with CSS 20<br />
Contents
Contents<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong> 22<br />
3<br />
<strong>ADAMS</strong>/<strong>Controls</strong> Goal: create <strong>ADAMS</strong> Plant for simulation<br />
24<br />
Four Step Process 25<br />
Step 1: Exporting Plant Files from <strong>ADAMS</strong> for the CSS 26<br />
Step 2: Creating the Plant in CSS 30<br />
Step 3: Connecting the <strong>ADAMS</strong> Plant and adjusting the<br />
simulation parameters 34<br />
Step 4: Running simulations from the CSS 37<br />
Workshop 1: The <strong>Controls</strong> Process 43<br />
Chapter 4: Setting Up Your <strong>ADAMS</strong> model for Plant Export<br />
53<br />
Creating Plant Inputs and Plant Outputs 54<br />
<strong>ADAMS</strong> Variable Types 55<br />
Creating Input State Variables 56<br />
Creating Output State Variables 58<br />
Specifying Plant Input/Output for Plant Export 59<br />
State Variable Order in Plant Inputs/Outputs 60<br />
Workshop 2: Creating State Variables 61<br />
Contents
Contents<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous 69<br />
4<br />
Discrete Mode 70<br />
Continuous Mode 71<br />
Continuous vs. Discrete Mode 74<br />
Co-simulation Process 76<br />
State Repartitioning 78<br />
Output Step Size/Sampling Rate 79<br />
Workshop 3 : Discrete vs. Continuous Results 80<br />
Chapter 6: Preparing Simulations 89<br />
Licenses (or) Should View be running? 90<br />
Speeding Up Simulations 91<br />
Initialization Commands 92<br />
Workshop 4: Initialization Commands 93<br />
Chapter 7: Advanced Topics 97<br />
User Libraries/Subroutines 98<br />
Debugging Models: General Tips 100<br />
Error Messages: Plant Communication Error 101<br />
Contents
5 Contents
Chapter 1: Welcome to <strong>ADAMS</strong>/<strong>Controls</strong> Training<br />
Within this chapter, you will find the following topics:<br />
6<br />
A Brief History of <strong>ADAMS</strong> 7<br />
About Mechanical Dynamics 8<br />
Getting Help in Class 9<br />
Getting Help at Your Job Site 10<br />
A Recap of Basic <strong>ADAMS</strong> Terminology 11<br />
Design Methodology with/without <strong>ADAMS</strong>/<strong>Controls</strong> <strong>12</strong><br />
Chapter 1: Welcome to <strong>ADAMS</strong>/<strong>Controls</strong> Training
A Brief History of <strong>ADAMS</strong><br />
•<strong>ADAMS</strong>: Automatic Dynamic Analysis of Mechanical Systems.<br />
•Technology has been around for 25 years.<br />
•Mechanical Dynamics Incorporated formed by researchers<br />
that developed the base <strong>ADAMS</strong> code at University of<br />
Michigan, Ann Arbor, Michigan, USA.<br />
•Large displacement code.<br />
•Systems based analysis.<br />
•Original product was the <strong>ADAMS</strong>/Solver, an application that<br />
solves non-linear numerical equations. Models are built up in<br />
text format then submitted to Solver.<br />
•In the early 90’s, the <strong>ADAMS</strong>/View GUI was released which<br />
allowed the user to build, simulate and examine results in a<br />
single environment.<br />
•Today, industry focused products are being produced such as<br />
<strong>ADAMS</strong>/Car, <strong>ADAMS</strong>/Rail, <strong>ADAMS</strong>/Engine etc.<br />
7<br />
Chapter 1: Welcome to <strong>ADAMS</strong>/<strong>Controls</strong> Training
About Mechanical Dynamics<br />
Find a list of <strong>ADAMS</strong> products at:<br />
8<br />
http://www.adams.com/mdi/product/modules.htm<br />
Learn about the <strong>ADAMS</strong> – CAD/CAM/CAE integration at:<br />
http://www.adams.com/mdi/product/partner.htm<br />
Find additional training at:<br />
http://support.adams.com/training/training.html<br />
…or your local support center.<br />
Get custom information at my.adams.com:<br />
http://my.adams.com<br />
Chapter 1: Welcome to <strong>ADAMS</strong>/<strong>Controls</strong> Training
Getting Help in Class<br />
Performing searches on any online <strong>ADAMS</strong> guide.<br />
9<br />
Chapter 1: Welcome to <strong>ADAMS</strong>/<strong>Controls</strong> Training
Getting Help at Your Job Site<br />
Online guides<br />
Use the “Help” menu in the <strong>ADAMS</strong> toolbar<br />
Knowledge Base<br />
Go to http://support.adams.com/<br />
…and select “Technical Support” “Knowledge Base”<br />
ASK Email-Based Users Group<br />
Go to http://support.adams.com/<br />
…and select “Technical Support” “ASK Email Listservers”<br />
Consulting Services<br />
Go to http://support.adams.com/<br />
…and select “Expert Consultants”<br />
Technical Support<br />
To read the Service Level Agreement, go to<br />
http://support.adams.com/ and select “Technical Support” <br />
“Standard Service Level Agreement”<br />
To find you support center, go to http://support.adams.com/<br />
and select “Technical Support” “Support Centers”<br />
10<br />
Chapter 1: Welcome to <strong>ADAMS</strong>/<strong>Controls</strong> Training
A Recap of Basic <strong>ADAMS</strong> terminology.<br />
•<strong>ADAMS</strong>/Solver<br />
11<br />
•The solution engine.<br />
•<strong>ADAMS</strong>/Solver Deck (*.adm file)<br />
•The actual ASCII format file submitted to the<br />
<strong>ADAMS</strong>/Solver.<br />
•<strong>ADAMS</strong>/Solver Command (*.acf file)<br />
•An ASCII file which contains commands to control how<br />
the <strong>ADAMS</strong>/Solver runs the model.<br />
•<strong>ADAMS</strong>/Solver Output Files.<br />
•Graphics (*.gra file) – Information about how graphics<br />
work.<br />
•Request (*.req file) – Contains output for a user-defined<br />
set of results.<br />
•Results (*.res file) - Contains state results for every<br />
entity.<br />
•Message (*.msg file) – Information about the<br />
solver/simulation/problems.<br />
•Output (*.out file) – Output including initial conditions<br />
and request, and content can depend on output<br />
specifications.<br />
Chapter 1: Welcome to <strong>ADAMS</strong>/<strong>Controls</strong> Training
Why You Use <strong>ADAMS</strong>/<strong>Controls</strong>: Typical<br />
Design Methodology<br />
Mechanical<br />
Designer<br />
Concept<br />
<strong>12</strong><br />
<strong>Controls</strong><br />
Designer<br />
Design<br />
Design<br />
Design<br />
Verification<br />
& Testing<br />
Physical<br />
Prototype<br />
Chapter 1: Welcome to <strong>ADAMS</strong>/<strong>Controls</strong> Training
Design Methodology with <strong>ADAMS</strong>/<strong>Controls</strong><br />
Mechanical<br />
Designer<br />
Concept<br />
13<br />
<strong>Controls</strong><br />
Designer<br />
Design<br />
Share<br />
same<br />
model<br />
Design<br />
Virtual<br />
Prototype<br />
Design<br />
Verification<br />
& Testing<br />
Physical<br />
Prototype<br />
Chapter 1: Welcome to <strong>ADAMS</strong>/<strong>Controls</strong> Training
Notes<br />
14<br />
Chapter 1: Welcome to <strong>ADAMS</strong>/<strong>Controls</strong> Training
Chapter 2: Modeling <strong>Controls</strong> with <strong>ADAMS</strong><br />
Within this chapter, you will find the following topics:<br />
15<br />
Open Loop Control Systems 16<br />
Closed Loop <strong>Controls</strong> Systems 17<br />
<strong>ADAMS</strong>/<strong>Controls</strong> Process 19<br />
<strong>ADAMS</strong>/<strong>Controls</strong> Compatibility with CSS 20<br />
Chapter 2: Modeling <strong>Controls</strong> with <strong>ADAMS</strong>
Open Loop Control Systems<br />
Open loop performance is determined by the calibration<br />
Open loop not generally troubled with instability<br />
Open loop not generally high performance<br />
Open Loop Example: “automatic” toaster uses timer<br />
Reference<br />
Input<br />
16<br />
Control<br />
Elements<br />
Control<br />
variable<br />
Disturbance<br />
Plant<br />
Transfer Function = Controlled Output<br />
Reference Input<br />
Controlled<br />
Output<br />
Chapter 2: Modeling <strong>Controls</strong> with <strong>ADAMS</strong>
Closed Loop Control Systems<br />
A closed loop control system is one in which the control action<br />
17<br />
is dependent on the output (usually), using “feedback”.<br />
Feed back is…<br />
A property of a closed loop system which permits the output (or some<br />
other state of the system) to be compared with the input (or some<br />
other state of the system), so that the appropriate control action<br />
may be formed as some function of both the output and the input.<br />
Benefits of a closed-loop system over an open-loop system:<br />
• Provides increased accuracy to track an input signal<br />
• Reduced sensitivity to variations in the system<br />
• Reduced effect of non-linearities<br />
• Increased bandwidth<br />
Example: home thermostat<br />
Chapter 2: Modeling <strong>Controls</strong> with <strong>ADAMS</strong>
Closed Loop Control Systems<br />
Reference<br />
Input<br />
+<br />
18<br />
Actuating<br />
Signal<br />
-/+<br />
Feedback<br />
Signal<br />
Control<br />
Elements<br />
Controller<br />
Control<br />
variable<br />
Feedback<br />
Elements<br />
Disturbance<br />
Plant<br />
Transfer Function = Controlled Output<br />
Reference Input<br />
Controlled<br />
Output<br />
Chapter 2: Modeling <strong>Controls</strong> with <strong>ADAMS</strong>
<strong>ADAMS</strong>/<strong>Controls</strong> Process<br />
Produced by <strong>ADAMS</strong>/<strong>Controls</strong>:<br />
19<br />
Control<br />
variable<br />
<strong>ADAMS</strong><br />
Plant<br />
Inserted into your CSS model for simulation:<br />
+<br />
-/+<br />
Control<br />
Elements<br />
Feedback<br />
Elements<br />
Controlled<br />
Output<br />
<strong>ADAMS</strong><br />
Plant<br />
Chapter 2: Modeling <strong>Controls</strong> with <strong>ADAMS</strong>
<strong>ADAMS</strong>/<strong>Controls</strong> Compatibility with CSS<br />
<strong>ADAMS</strong>/<strong>Controls</strong> v<strong>12</strong>.0 is compatible with:<br />
•MATLAB<br />
•EASY5<br />
•MATRIXx<br />
(MATRIXx support will parallel Mathwork’s support)<br />
See the “Partner Integration” information at www.adams.com<br />
for specific release compatibility. For <strong>ADAMS</strong> v<strong>12</strong>.0, this can<br />
be found at:<br />
20<br />
Chapter 2: Modeling <strong>Controls</strong> with <strong>ADAMS</strong>
Notes<br />
21<br />
Chapter 2: Modeling <strong>Controls</strong> with <strong>ADAMS</strong>
Notes<br />
22<br />
Chapter 2: Modeling <strong>Controls</strong> with <strong>ADAMS</strong>
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong><br />
Within this chapter, you will find the following topics:<br />
23<br />
<strong>ADAMS</strong>/<strong>Controls</strong> Goal: create <strong>ADAMS</strong> Plant for simulation<br />
24<br />
Four Step Process 25<br />
Step 1: Exporting Plant Files from <strong>ADAMS</strong> for the CSS 26<br />
Step 2: Creating the Plant in CSS 30<br />
Step 3: Connecting the <strong>ADAMS</strong> Plant and adjusting the<br />
simulation parameters 34<br />
Step 4: Running simulations from the CSS 37<br />
Workshop 1: The <strong>Controls</strong> Process 43<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
<strong>ADAMS</strong>/<strong>Controls</strong> Goal: Create Plant for Simulation<br />
Steps for setting up your model in <strong>ADAMS</strong> for use with<br />
<strong>ADAMS</strong>/<strong>Controls</strong>.<br />
Goal: create <strong>ADAMS</strong> model to insert into controls model<br />
Example: Antenna Control Problem<br />
Azimuth and Elevation DOF<br />
Flexible support<br />
Disturbance to elevation loop<br />
Input torques applied<br />
24<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Four Step Process<br />
1<br />
Mechanical System<br />
Simulation<br />
25<br />
--Create Create <strong>ADAMS</strong> <strong>ADAMS</strong> model model<br />
-Define -Define control control inputs inputs and and<br />
-sensor -sensor outputs outputs<br />
Control System Design<br />
--Connect Connect inputs inputs and and outputs outputs<br />
-Perform -Perform simulation simulation of of<br />
-combined -combined systems systems<br />
--Export Export model model<br />
--Create Create .m .m or or .inf .inffile file<br />
Control System Design<br />
--Build Build system system block block diagram diagram<br />
--Include Include <strong>ADAMS</strong> <strong>ADAMS</strong> block block<br />
Mechanical System<br />
Simulation<br />
--Simulate Simulate and and analyze analyze<br />
--Visualize Visualize system system in in motion motion<br />
3 4<br />
2<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Four Step Process: Step 1<br />
Step 1: Exporting the Plant Files from <strong>ADAMS</strong> for the<br />
controls simulation software (CSS)<br />
Example: Create or obtain antenna model; define variables to<br />
be used as inputs and outputs to antenna model (forces,<br />
torques to control antenna motion; azimuth and elevation<br />
position measurements)<br />
26<br />
1<br />
Mechanical System Simulation<br />
--Create Create <strong>ADAMS</strong> <strong>ADAMS</strong> model model<br />
--Define Define control control inputs inputs and and sensor sensor<br />
outputs outputs<br />
--Export Export model model<br />
--Create Create .m .m or or .inf .inffile file<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Four Step Process: Step 1 (continued)<br />
Step 1 (continued): Exporting the Plant Files from <strong>ADAMS</strong> for<br />
the CSS<br />
“Plant export” feature will create files specifically to generate<br />
an <strong>ADAMS</strong> antenna plant in the CSS:<br />
•.adm and .cmd files that describe mechanical model<br />
•.acf file includes solver commands (not necessarily used)<br />
• .m file for MATLAB; .inf for MATRIXx and EASY5<br />
27<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Four Step Process: Step 1 (continued)<br />
Step 1 (continued): Exporting the Plant Files from <strong>ADAMS</strong> for<br />
the CSS<br />
Example: antenna model produces .m shown below<br />
addpath( 'F:\PROGRA~1\<strong>ADAMS</strong>1~2.0/controls' ) ;<br />
addpath( 'F:\PROGRA~1\<strong>ADAMS</strong>1~2.0\controls\matlab' ) ;<br />
% <strong>ADAMS</strong> / MATLAB Interface - Release <strong>12</strong>.0.0<br />
<strong>ADAMS</strong>_sysdir = 'F:\PROGRA~1\<strong>ADAMS</strong>1~2.0' ;<br />
<strong>ADAMS</strong>_exec = '' ;<br />
<strong>ADAMS</strong>_prefix = 'ant_test' ;<br />
if (exist([<strong>ADAMS</strong>_prefix,'.adm']))<br />
<strong>ADAMS</strong>_static = 'no' ;<br />
<strong>ADAMS</strong>_init = '' ;<br />
<strong>ADAMS</strong>_inputs = 'control_torque' ;<br />
<strong>ADAMS</strong>_outputs = 'rotor_velocity!azimuth_position' ;<br />
<strong>ADAMS</strong>_pinput = '.main_olt.tmp_MDI_PINPUT' ;<br />
<strong>ADAMS</strong>_poutput = '.main_olt.tmp_MDI_POUTPUT' ;<br />
<strong>ADAMS</strong>_uy_ids = [<br />
1<br />
2<br />
3<br />
] ;<br />
<strong>ADAMS</strong>_mode = 'non-linear' ;<br />
tmp_in = decode( <strong>ADAMS</strong>_inputs ) ;<br />
tmp_out = decode( <strong>ADAMS</strong>_outputs ) ;<br />
disp( ' ' ) ;<br />
disp( '%%% INFO : <strong>ADAMS</strong> plant actuators names :' ) ;<br />
28<br />
Model Files Prefix<br />
(produced by plant<br />
export)<br />
disp( [int2str([1:size(tmp_in,1)]'),blanks(size(tmp_in,1))',tmp_in] ) ;<br />
disp( '%%% INFO : <strong>ADAMS</strong> plant sensors names :' ) ;<br />
disp( [int2str([1:size(tmp_out,1)]'),blanks(size(tmp_out,1))',tmp_out] ) ;<br />
disp( ' ' ) ;<br />
clear tmp_in tmp_out ;<br />
else<br />
disp( ' ' ) ;<br />
disp( '%%% ERROR : missing <strong>ADAMS</strong> plant model file !!!' ) ;<br />
disp( ' ' ) ;<br />
end<br />
% <strong>ADAMS</strong> / MATLAB Interface - Release <strong>12</strong>.0.0<br />
Paths<br />
Variables<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Four Step Process: Step 1 (continued)<br />
Step 1 (continued): Exporting the Plant Files from <strong>ADAMS</strong> for<br />
the CSS<br />
Example: antenna model produces .inf shown below<br />
C:\Program Files\<strong>ADAMS</strong> <strong>12</strong>.0
Four Step Process: Step 2<br />
Step 2: Creating the Plant in CSS<br />
Create control model (except for plant)<br />
Read in the .m/.inf file to set up the paths, variables<br />
30<br />
Control System Design<br />
--Build Build system system block block diagram diagram<br />
--Include Include <strong>ADAMS</strong> <strong>ADAMS</strong> block block<br />
2<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Four Step Process: Step 2(continued)<br />
Step 2 (continued): Creating the Plant in CSS<br />
MATLAB<br />
After the .m is read into MATLAB, type “adams_sys” which<br />
will generate the <strong>ADAMS</strong> plant<br />
31<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Four Step Process: Step 2 (continued)<br />
Step 2 (continued): Creating the Plant in CSS<br />
MATLAB<br />
Double click the “adams_sub” block to see:<br />
•Input and output names are automatically created<br />
•Workspace hooks are also automatically created<br />
32<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Four Step Process: Step 2(continued)<br />
Step 2 (continued): Creating the Plant in CSS<br />
EASY5<br />
Create an <strong>ADAMS</strong> Extension which<br />
references the .inf file created in<br />
Step 1<br />
33<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Four Step Process: Step 3<br />
Step 3: Connecting the <strong>ADAMS</strong> Plant and adjusting the<br />
simulation parameters in the CSS<br />
34<br />
3<br />
Control System Design<br />
--Connect Connect inputs inputs and and outputs outputs<br />
--Perform Perform simulation simulation of of combined combined<br />
systems systems<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Four Step Process: Step 3 (continued)<br />
Step 3 (continued): Creating the Plant in CSS<br />
MATLAB Plant Mask<br />
•Double click the Mechanical Dynamics block to bring up the<br />
mask<br />
•Here you select modes from and gain access to the full<br />
capabilities of <strong>ADAMS</strong>/<strong>Controls</strong><br />
35<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Four Step Process: Step 3 (continued)<br />
Step 3 (continued): Creating the Plant in CSS<br />
EASY5<br />
•Double click the Mechanical Dynamics block to bring up the<br />
Component Data Table<br />
•Here you select modes from and gain access to the full<br />
capabilities of <strong>ADAMS</strong>/<strong>Controls</strong><br />
36<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Four Step Process: Step 4<br />
Step 4: Running simulations from the CSS<br />
Example: Antenna model will simulate according to controls<br />
inputs (forces, torques, etc.)<br />
37<br />
Mechanical System Simulation<br />
--Simulate Simulate and and analyze analyze<br />
--Visualize Visualize system system in in motion motion<br />
4<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Four Step Process: Step 4 (continued)<br />
Step 4(continued): Running simulations from the CSS<br />
Use Simulation Parameters in MATLAB to control the<br />
control system integrator step size, end time, and integrator<br />
settings.<br />
38<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Four Step Process: Step 4 (continued)<br />
Step 4(continued): Running simulations from the CSS<br />
Interactive vs. Batch Modes<br />
•Interactive mode launches <strong>ADAMS</strong>/View (vcontrols.exe will<br />
use the .cmd file and see the model update)<br />
•Batch mode launches <strong>ADAMS</strong>/Solver (scontrols.exe will use<br />
the .adm file and will not see the model update, but will run<br />
faster)<br />
39<br />
Set animation mode here<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Step 4 (continued)<br />
Step 4(continued): Running simulations from the CSS<br />
MATLAB Notes:<br />
•Input and output variables are automatically saved to the<br />
workspace (if “adams_sub” block is used)<br />
•Use/modify MATLAB variable names to push data onto the<br />
mask instead of editing the mask entries directly<br />
•Mask variables are accessible via command line if you wish to<br />
set them manually or in a MATLAB script<br />
40<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Four Step Process: Step 4 (continued)<br />
Step 4(continued): Running simulations from the CSS<br />
EASY5<br />
Use Analysis Simulation to control the control system<br />
integrator step size, end time, and integrator settings.<br />
41<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Four Step Process: Step 4 (continued)<br />
Step 4(continued): Running simulations from the CSS<br />
Interactive vs. Batch Modes<br />
•Interactive mode launches <strong>ADAMS</strong>/View (vcontrols.exe will<br />
use the .cmd file and see the model update)<br />
•Batch mode launches <strong>ADAMS</strong>/Solver (scontrols.exe will use<br />
the .adm file and will not see the model update, but will run<br />
faster)<br />
In EASY5, set the animation mode with the ANI_MOD<br />
variable in the <strong>ADAMS</strong> block:<br />
42<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Workshop 1: The <strong>Controls</strong> Process<br />
In this workshop, you will export a non-linear <strong>ADAMS</strong> model to<br />
43<br />
your CSS (MATLAB or EASY5) by creating state<br />
variables for inputs and outputs to you <strong>ADAMS</strong> plant. You<br />
will also setup a pre-built controls model to observe how<br />
the co-simulation process works.<br />
1. Open <strong>ADAMS</strong>/View.<br />
NT: Select Start Programs <strong>ADAMS</strong> <strong>12</strong>.0 <br />
AView <strong>ADAMS</strong> - View<br />
Unix: Open a shell and type the alias “adams<strong>12</strong>0”<br />
which points to the “mdi” script to launch the<br />
<strong>ADAMS</strong> toolbar. Next, select the <strong>ADAMS</strong>/View<br />
button (1 st button).<br />
2. Select 'Import File' and find the 'antenna.cmd' file in<br />
the /Workshop1-General/ folder to load the “antenna”<br />
model.<br />
3. Simulate the antenna model for 0.5 seconds and 100 steps<br />
to see what it does. Note the gear and applied torque at<br />
the base.<br />
4. Load the <strong>ADAMS</strong>/<strong>Controls</strong> plugin with Tools Plugins <br />
<strong>Controls</strong> Load<br />
5. Select <strong>Controls</strong> Plant Export<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Workshop 1: The <strong>Controls</strong> Process<br />
To work with MATLAB, follow steps 6 – 20.<br />
To work with EASY5, follow steps 21 – 38.<br />
MATLAB Steps<br />
6. Specify information about this mechanical model as<br />
MATLAB is going to see it. Enter the following:<br />
44<br />
File Prefix: ant_test - this tells <strong>ADAMS</strong> to write<br />
out a ant_test.m file containing state variable and<br />
file location information that MATLAB<br />
understands.<br />
Plant Input: tmp_MDI_PINPUT. This<br />
contains the variable, control_torque -our plant<br />
input signal.<br />
Plant Output: tmp_MDI_POUTPUT. This<br />
contains the variabless, rotor_velocity &<br />
azimuth_position - our plants outputs.<br />
Control package: MATLAB<br />
Type: non_linear - our plant is a nonlinear<br />
description of our mechanical system (as opposed<br />
to linearized about some operating point).<br />
7. Select 'OK' to write out a plant description.<br />
We've supposedly written out a valid description of our<br />
mechanical system that MATLAB can handle. Now to<br />
import it into MATLAB.<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Workshop 1: The <strong>Controls</strong> Process<br />
8. Start MATLAB by typing ‘matlab'. Ensure that you're in<br />
the working directory where your .m file is. You can use<br />
“cd” and “ls” in the MATLAB environment to navigate<br />
through directories.<br />
9. Load the ant_test.m file that you just made in <strong>ADAMS</strong><br />
into MATLAB by simply typing the name of the file<br />
(ant_test).<br />
10. Type 'who' to give you a listing of all the variables<br />
currently defined in the MATLAB environment. See that<br />
you now have several <strong>ADAMS</strong>_*** variables defined in<br />
MATLAB. These tell MATLAB how to interact with<br />
<strong>ADAMS</strong>.<br />
11. Type the highly intuitive command 'adams_sys' to build<br />
a Simulink block representing your mechanical system.<br />
<strong>12</strong>. The block named ‘adams_sub’ represents your non-linear<br />
mechanical system. Note it's two outputs (that you've<br />
previously defined) and the single input.<br />
13. Select File Open from the Simulink window<br />
containing your <strong>ADAMS</strong> plant block. Select<br />
'antenna.mdl' to read in a pre-made control system for<br />
the antenna. The ‘adams_sub’ block has already been<br />
added (with the ‘adams_sys’ MATLAB command).<br />
14. In the Simulink window containing all of the control<br />
system elements, select Simulation Simulation<br />
Parameters.. and set:<br />
45<br />
Stop time = 0.5<br />
Max. Step size = 0.001<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Workshop 1: The <strong>Controls</strong> Process<br />
15. Select ‘OK'.<br />
16. Select Simulation Start to run a simulation.<br />
17. Take a look at the output by double clicking the<br />
terminal icons labeled 'rotor_vel' and 'azimuth_pos'.<br />
18. Note that the azimuth position has been driven to a<br />
fixed value and the rotor velocity has increased then<br />
dropped back to zero.<br />
19. Change the control parameters (step function end<br />
value, gain value) and resimulate.<br />
20. Change the animation mode in the <strong>ADAMS</strong> plant mask<br />
(batch vs. interactive) - note solution speed<br />
difference.<br />
46<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Workshop 1: The <strong>Controls</strong> Process<br />
EASY5 Steps<br />
21. Specify information about this mechanical model as<br />
EASY5 is going to see it. Enter the following:<br />
47<br />
File Prefix: ant_test - this tells <strong>ADAMS</strong> to write<br />
out a ant_test.inf file containing state variable and<br />
file location information that EASY5 understands.<br />
Plant Input: tmp_MDI_PINPUT. This<br />
contains the variable, control_torque -our plant<br />
input signal.<br />
Plant Output: tmp_MDI_POUTPUT. This<br />
contains the variabless, rotor_velocity &<br />
azimuth_position - our plants outputs.<br />
Control package: MATRIXx_and_EASY5<br />
Type: non_linear - our plant is a nonlinear<br />
description of our mechanical system (as opposed<br />
to linearized about some operating point).<br />
22. Select 'OK' to write out a plant description.<br />
We've supposedly written out a valid description of our<br />
mechanical system that EASY5 can handle. Now to<br />
import it into EASY5.<br />
23. Start EASY5:<br />
UNIX: Type ‘easy5'.<br />
Windows: Start Programs EASY5 61<br />
Ensure that you're in the working directory where<br />
the “antenna.mf.0” model and “ant_test.inf” are.<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Workshop 1: The <strong>Controls</strong> Process<br />
24. Open the EASY5 model “antenna.mf.0”<br />
48<br />
The EASY5 model opens. Notice that it already<br />
contains an <strong>ADAMS</strong> non-linear model block, so you<br />
do not need to create one. Note it's two outputs<br />
(that you've previously defined) and the single<br />
input.<br />
Now, before you connect the AD block to the rest of the<br />
system, initialize the AD block<br />
25. Open up the Component Data Table for the AD block<br />
and select ‘Spawn <strong>ADAMS</strong> Interface’<br />
26. Enter the name of the .inf file (ant_test.inf).<br />
27. Enter “25” for the maximum number of states.<br />
28. Enter “3” to submit a co-simulation (discrete) analysis.<br />
Your AD block is now initialized.<br />
29. Select ‘OK’ in the AD Component Data Table.<br />
30. Select Build Create Executable to compile and link<br />
the model.<br />
31. In the EASY5 main menu, select Analysis Simulation<br />
and set:<br />
Title: my_antenna<br />
Stop time = 0.25<br />
Time Increment = 0.001<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Workshop 1: The <strong>Controls</strong> Process<br />
32. Toggle “Plot Results” to “yes”, and select “Show/Edit<br />
Plot Variables”.<br />
49<br />
The “Plot Specification Form” opens.<br />
33. Select “Show Name List” to query the available<br />
variables to plot. Select “Y1”, “Y2”, “S2 LA”, and “S2<br />
SF” as variables to plot.<br />
34. Select “OK” to set-up the plots.<br />
35. Select “Execute and Close” to submit the simulation.<br />
If the animation mode is set to interactive (ANI_MOD = 1)<br />
, the simulation will be submitted with graphic updates<br />
to the <strong>ADAMS</strong> model during the co-simulation; if set<br />
to 0, a batch simulation will be submitted, which<br />
provides no graphical feedback. Note that the batch<br />
simulation takes less time.<br />
36. Take a look at the output by looking at the plots that<br />
EASY5 has created.<br />
Y1 vs. Time (rotor velocity)<br />
Y2 vs. Time (azimuth position)<br />
S2 SF vs. Time (desired step function input)<br />
S2 SL vs. Time (actual torque input)<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Workshop 1: The <strong>Controls</strong> Process<br />
Note that the azimuth position has been driven to a fixed<br />
value and the rotor velocity has increased then<br />
dropped back to zero.<br />
37. Change the control parameters (step function end<br />
value, gain value) and resimulate.<br />
50<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Notes<br />
51<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Notes<br />
52<br />
Chapter 3: Overview of Using <strong>ADAMS</strong>/<strong>Controls</strong>
Chapter 4: Setting Up Your <strong>ADAMS</strong> Model for Plant Export<br />
Within this chapter, you will find the following topics:<br />
53<br />
Steps to setup your model for a Plant Export 54<br />
<strong>ADAMS</strong> Variable Types 55<br />
Creating Input State Variables 56<br />
Creating Output State Variables 58<br />
Creating Plant Inputs and Outputs 59<br />
State Variable Order in Plant Inputs/Outputs 60<br />
Specifying Plant Input/Output for Plant Export 61<br />
Workshop 2: Creating State Variables 62<br />
Chapter 4:Setting Up Your <strong>ADAMS</strong> Model for Plant Export
Steps to setup your model for a Plant Export<br />
In order to export your plant model, you must define the<br />
inputs and outputs to your plant.<br />
To do so:<br />
1. Create the state variables to which will be the inputs<br />
and outputs to your plant<br />
2. Create Plant Inputs and Outputs which hold the state<br />
variables from step 1<br />
3. Use a single Plant Input and Plant Output to export<br />
your plant files using the <strong>ADAMS</strong>/<strong>Controls</strong> Plant<br />
Export dialog box.<br />
54<br />
Plant<br />
Input<br />
<strong>ADAMS</strong><br />
Plant<br />
Plant<br />
Output<br />
Both contain a list of state variables<br />
Chapter 4:Setting Up Your <strong>ADAMS</strong> Model for Plant Export
<strong>ADAMS</strong> Variable Types<br />
55<br />
Chapter 4:Setting Up Your <strong>ADAMS</strong> Model for Plant Export
Creating Input State Variables<br />
Input Variables<br />
Create state variables to hold inputs.<br />
56<br />
Leave function = 0 (usually)<br />
Initial values will be used if an initial static simulation is<br />
performed<br />
Chapter 4:Setting Up Your <strong>ADAMS</strong> Model for Plant Export
Assign Input State Variables to Actuators<br />
Assign the state variables which define your plant inputs to<br />
the actuators (e.g., forces) in the model with the VARVAL<br />
function.<br />
57<br />
Chapter 4:Setting Up Your <strong>ADAMS</strong> Model for Plant Export
Creating Output State Variables<br />
Create any valid runtime expression to provide an output to<br />
the CSS.<br />
Example: azimuth angle, elevation angle<br />
58<br />
Chapter 4:Setting Up Your <strong>ADAMS</strong> Model for Plant Export
Creating Plant Inputs and Plant Outputs<br />
Create Plant Inputs and Plant Outputs in your <strong>ADAMS</strong> model<br />
to provide inputs and outputs to your <strong>ADAMS</strong> plant. You<br />
specify one Plant Input and one Plant Output for your<br />
<strong>ADAMS</strong> plant, but they may contain as many variables as you<br />
desire.<br />
59<br />
Plant<br />
Input<br />
<strong>ADAMS</strong><br />
Plant<br />
Plant<br />
Output<br />
Both contain a list of state variables<br />
Chapter 4:Setting Up Your <strong>ADAMS</strong> Model for Plant Export
State Variable Order in Plant Input/Output Elements<br />
The state variable order in the Plant Input and Plant Output<br />
elements is very important, because it determines the order<br />
which the variables must be defined in the CSS.<br />
60<br />
Chapter 4:Setting Up Your <strong>ADAMS</strong> Model for Plant Export
Specifying Plant Inputs/Outputs for Plant Export<br />
Once the Plant Inputs and Outputs are created, reference<br />
these in the Plant Export dialog box.<br />
Using plant inputs and outputs instead of state variables<br />
allows users to edit inputs and outputs to the plant more<br />
robustly (for example, for a large number of state variables,<br />
the Plant Input/Output can be edited, rather than<br />
specifying them one by one in the Plant Export dialog box)<br />
61<br />
Chapter 4:Setting Up Your <strong>ADAMS</strong> Model for Plant Export
Workshop 2: Creating State Variables & Plant Inputs/Outputs<br />
In this workshop, you create a model to control the position of a<br />
ball on a beam-balancing mechanism. To do so, you will create<br />
state variables and a plant input and output for you non-linear<br />
plant export of the ball-beam model (the following are general<br />
steps; see the Appendix for an exact solution).<br />
1. Open the 'ball_beam.cmd' file in the /Workshop2-General/<br />
folder from <strong>ADAMS</strong>/<strong>Controls</strong>.<br />
2. Simulate the ball and beam model for 10 seconds and 200<br />
time steps - the ball should fall off the beam due to an initial<br />
velocity assignment to the beam.<br />
62<br />
We're going to try to balance the ball on a point off of the<br />
beam's center point by controlling a torque applied to the<br />
beam.<br />
3. Create 3 state variables that will be used for plant (this<br />
mechanical system) communication. As you're going to make<br />
your <strong>ADAMS</strong> model compatible with an existing control<br />
system, use the following names for the 3 state variables:<br />
Beam_Angle<br />
Position<br />
Torque_In<br />
4. Two of these 3 variables are the outputs of our plant. Define<br />
functions for these variables as follows:<br />
Beam_Angle = angle of the beam w.r.t. horizontal<br />
from the front view: AZ(.ball_beam.beam.cm)<br />
Position = position of ball center of mass (CM) along the<br />
beam top surface where the initial position is at distance<br />
= 0 and the value increases to the right:<br />
DX(.ball_beam.ball.cm,.ball_beam.beam.ref,.ball_beam.beam.ref)<br />
Chapter 4:Setting Up Your <strong>ADAMS</strong> Model for Plant Export
Workshop 2: Creating State Variables & Plant Inputs/Outputs<br />
5. Simulate the system again for 10 seconds and 200 steps, then<br />
go to the PostProcessor and see if your Beam_Angle and<br />
Position variable values look to be correct.<br />
6. Specify a value for the Torque_In state variable (for<br />
example, torque = 5). The next step will hook this value to the<br />
Torque that is applied to the beam.<br />
7. Tell the Torque on the beam (Sforce SFO1) to get it's<br />
magnitude from the state variable Torque_In. Use a<br />
VARVAL() in the Sforce function definition to do this.<br />
8. Simulate the system - the beam should rotate due to the<br />
applied torque. Change the torque value in the state variable<br />
and resimulate to ensure that the value of the state variable<br />
is getting picked up by the torque SFO1.<br />
9. Set the Torque_In state variable value back to zero with<br />
Build System Elements State Variable Modify.<br />
10. Create a Plant Input with Build <strong>Controls</strong> Toolkit Plant<br />
Input<br />
Plant Input Name: MDI_PINPUT<br />
Variable Name: Torque_In<br />
11. Create a Plant Output with Build <strong>Controls</strong> Toolkit Plant<br />
Output<br />
Plant Output Name: MDI_POUTPUT<br />
Variable Name: Beam_Angle, Position<br />
IMPORTANT: Take care that you get the order correct for the<br />
outputs (they have to synch up with the existing controls<br />
model).<br />
63<br />
Chapter 4:Setting Up Your <strong>ADAMS</strong> Model for Plant Export
Workshop 2: Creating State Variables & Plant Inputs/Outputs<br />
To work with MATLAB, follow steps <strong>12</strong>-27.<br />
To work with EASY5, follow steps 28-51.<br />
MATLAB Steps<br />
<strong>12</strong>. Export the plant with <strong>Controls</strong> Plant Export<br />
64<br />
File Prefix = ball_test<br />
Plant Input = MDI_PINPUT<br />
Plant Output = MDI_POUTPUT<br />
Control Package = MATLAB<br />
13. Start MATLAB from a new x-window by typing ‘matlab’.<br />
14. Type 'ball_test' - the .m file that we just exported from<br />
<strong>ADAMS</strong> - this sets up the state variables needed in MATLAB.<br />
15. Type ‘adams_sys' – this creates a plant that you can use in<br />
MATLAB.<br />
16. Select File Open = ball_beam.mdl . This opens the<br />
previously made MATLAB control schematic. Copy the plant<br />
from ‘adams_sys’ to the ball beam control model.<br />
Now, before you use MATLAB to simulate the combined<br />
controls/mechanical system, set up your environment:<br />
17. Set simulation parameters (Simulation Simulation<br />
Parameters):<br />
End time = 4 seconds<br />
Solver = ode15s (stiff integrator)<br />
Chapter 4:Setting Up Your <strong>ADAMS</strong> Model for Plant Export
Workshop 2: Creating State Variables & Plant Inputs/Outputs<br />
Next, set the <strong>ADAMS</strong> plant properties<br />
18. Double click the 'Mechanical Dynamics' block<br />
19. Set the “Output files” prefix to 'ball_results‘<br />
65<br />
Note: be sure to include the quotes (‘ ‘)<br />
20. Set the simulation modes to discrete<br />
21. Set the animation mode to interactive.<br />
22. Select ‘OK’ to save.<br />
23. Simulate the control system containing the <strong>ADAMS</strong> block by<br />
doing a Simulation Start.<br />
24. View results in MATLAB:<br />
If stripcharts in MATLAB aren't visible, double click the<br />
scope icons labelled 'Position', 'Force input', etc. The<br />
MATLAB strip charts can be autoscaled if the signal<br />
disappears by hitting the binocular icon.<br />
Next, look at results in <strong>ADAMS</strong>/<strong>Controls</strong>.<br />
25. Open <strong>ADAMS</strong>/PPT and select File Import<br />
26. Select “Analysis Files”<br />
27. Choose 'ball_results.gra' or 'aplant_out.gra' file (if you<br />
used the default output name)<br />
You can now animate the mechanical system.<br />
Chapter 4:Setting Up Your <strong>ADAMS</strong> Model for Plant Export
Workshop 2: Creating State Variables & Plant Inputs/Outputs<br />
EASY5 Steps<br />
28. Export the plant with <strong>Controls</strong> Plant Export<br />
66<br />
File Prefix = ball_test<br />
Plant Input = MDI_PINPUT<br />
Plant Output = MDI_POUTPUT<br />
Control Package = MATRIXx_and_EASY5<br />
29. Start EASY5 from a new x-window by typing ‘easy5’.<br />
30. Open the existing EASY5 model “ball_beam_noad.mf.0”.<br />
Notice that the model does not contain the non-linear<br />
<strong>ADAMS</strong> plant block.<br />
31. Select the block “Add” or the keystroke CRTL-A to open the<br />
Add Components dialog box.<br />
32. Select “Extensions” in the Open Libraries field, and select AD<br />
<strong>ADAMS</strong> Nonlinear Block to create an <strong>ADAMS</strong> (AD) block.<br />
An icon will follow your cursor until you select<br />
the location to create it.<br />
33. Place the AD block in the right of the model, between the<br />
“LA” block and the two unit gain blocks.<br />
Now, before you connect the AD block to the rest of the system,<br />
initialize the AD block<br />
34. Open up the Component Data Table for the AD block and<br />
select ‘Spawn <strong>ADAMS</strong> Interface’<br />
Chapter 4:Setting Up Your <strong>ADAMS</strong> Model for Plant Export
Workshop 2: Creating State Variables & Plant Inputs/Outputs<br />
33. Enter the name of the .inf file (ball_test.inf).<br />
35. Enter “25” for the maximum number of states.<br />
36. Enter “3” to submit a co-simulation (discrete) analysis.<br />
67<br />
Your AD block is now initialized.<br />
37. Select ‘OK’ in the AD Component Data Table.<br />
Next, connect the AD block to the rest of the EASY5 model.<br />
38. Connect S2 LA (actuator input) to U1 of the AD block (S-U1)<br />
39. Delete the two dummy unit gain blocks.<br />
40. Connect Y1 of the AD block to S3 SJ.<br />
41. Connect Y2 of the AD block to S1 SJ2.<br />
The EASY5 model should now be connect properly to the AD block.<br />
Before you use EASY5 to simulate the combined<br />
controls/mechanical system, set the AD block properties.<br />
42. Double click the AD block<br />
43. Set the animation mode to interactive (ANI_MOD=1).<br />
44. Select ‘OK’ to save.<br />
45. Select Build Create Executable to compile and link the<br />
model.<br />
Chapter 4:Setting Up Your <strong>ADAMS</strong> Model for Plant Export
Workshop 2: Creating State Variables & Plant Inputs/Outputs<br />
Next, set the simulation parameters:<br />
46. Set simulation parameters (Analysis Simulation<br />
Parameters):<br />
Title = ball_beam<br />
End time = 4 seconds<br />
Time increment = 0.01 seconds<br />
Int. Method = BCS Gear (stiff integrator)<br />
47. Create plots (Y1, Y2, etc.) by toggling “Plot Results” to “yes”<br />
and making appropriate selections in “Show/Edit Plot<br />
Variables”.<br />
48. Simulate the control system containing the <strong>ADAMS</strong> block by<br />
selecting “Execute and Close”.<br />
When the simulation is finished, the plots you created will appear<br />
automatically.<br />
Next, look at results in <strong>ADAMS</strong>/<strong>Controls</strong>.<br />
49. Open <strong>ADAMS</strong>/PPT and select File Import<br />
50. Select “Analysis Files”<br />
51. Choose 'ball_test.gra‘.<br />
You can now animate the mechanical system..<br />
68<br />
Chapter 4:Setting Up Your <strong>ADAMS</strong> Model for Plant Export
Chapter 5: Simulation Modes: Discrete vs. Continuous<br />
Within this chapter, you will find the following topics:<br />
69<br />
Discrete Mode 70<br />
Continuous Mode 71<br />
Continuous vs. Discrete Mode 74<br />
Co-simulation Process 76<br />
State Repartitioning 78<br />
Output Step Size/Sampling Rate 79<br />
Workshop 3 : Discrete vs. Continuous Results 80<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous
Discrete Mode (Co-simulation)<br />
70<br />
There are two choices for the method of exchanging data<br />
between the control simulation software and ADMAS:<br />
1. Discrete mode<br />
2. Continuous mode<br />
Discrete mode (the most common) lets MATLAB integrate<br />
the Control system, <strong>ADAMS</strong> integrate the mechanical<br />
system. <strong>Controls</strong> takes a step in time, then <strong>ADAMS</strong><br />
does the same, hence the 'discrete' label. In this<br />
mode, the integrators on both sides (CSS and<br />
<strong>ADAMS</strong>) are running in parallel. They exchange data<br />
as specified by the output step size. In this mode, the<br />
controls package, using output from <strong>ADAMS</strong>,<br />
calculates the mechanical model inputs and sends it<br />
back to <strong>ADAMS</strong>. It is the responsibility of <strong>ADAMS</strong><br />
to integrate the mechanical system for a single time<br />
step with the specified inputs.<br />
Discrete mode is also known as “co-simulation”<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous
Continuous (Function Evaluation) Mode<br />
71<br />
Continuous mode lets the controls simulation software<br />
integrate everything. The CSS computes a big system<br />
Jacobian that includes our mechanical system. <strong>ADAMS</strong> acts<br />
as a function evaluator.<br />
By this, we mean that the Jacobian, which describes the<br />
mechanical system, is evaluated by <strong>ADAMS</strong>, and the values<br />
are sent to the controls package to populate the equations<br />
integrated *solely* by the controls package. Viewed from<br />
the control side, <strong>ADAMS</strong> is no different from a nonlinear<br />
block (something like General State Equation, GSE, in<br />
<strong>ADAMS</strong>). At each integration steps, <strong>ADAMS</strong> provides the<br />
necessary information, such as inputs and states to the<br />
controls packages.<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous
Continuous (Function Evaluation) Mode (continued)<br />
72<br />
Because function evaluation mode creates a large system<br />
Jacobian matrix that presents both the control scheme and<br />
the mechanical system at once, any integrator dealing with<br />
this sees an effectively 'continuous' system. This means<br />
that function evaluation mode will give results that are<br />
exact for simple systems. The downfall is that the control<br />
system integrators must be used and they are not finely<br />
tuned for solving mechanical systems, hence they have a<br />
tendency to fail for complex systems, particularly those<br />
with high frequency mechanical system effects.<br />
Initially a system Jacobian is formulated by <strong>ADAMS</strong> based<br />
on the initial model configuration. As the CSS requests<br />
values from <strong>ADAMS</strong> and the model position changes, there<br />
is a possibility that the system Jacobian may change (by<br />
choosing different variables which define the Jacobian).<br />
-<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous
Continuous (Function Evaluation) Mode (continued)<br />
73<br />
<strong>ADAMS</strong> automatically chooses new independent generalized<br />
coordinates to build a Jacobian with, based on which<br />
variables are changing most rapidly in a simulation. If the<br />
variables that <strong>ADAMS</strong> uses change, the system Jacobian<br />
changes. This is a problem, as there is currently not a way<br />
to tell MATLAB that the form of the Jacobian has<br />
changed.<br />
What this means is that continuous mode only works for<br />
models that are near-linear. This is a limitation of the<br />
mode, so most people use discrete mode for mechanical<br />
systems with rotating parts and movements with large<br />
displacements.<br />
-<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous
Continuous vs. Discrete Modes<br />
Function Evaluation Mode Co-Simulation Mode<br />
74<br />
<strong>Controls</strong><br />
Software<br />
<strong>ADAMS</strong><br />
<strong>ADAMS</strong> writes out<br />
function and controls<br />
application does the<br />
work<br />
Jacobian partials<br />
sent by <strong>ADAMS</strong><br />
<strong>Controls</strong><br />
Software<br />
<strong>ADAMS</strong><br />
<strong>ADAMS</strong> and controls<br />
application share the<br />
work<br />
<strong>ADAMS</strong> plant outputs<br />
(state variables)<br />
sent by <strong>ADAMS</strong><br />
Chapter 5: Simulation Modes: Discrete vs. Continuous
Continuous vs. Discrete Modes<br />
Function Evaluation Mode Cosimulation Mode<br />
75<br />
( 1 2 )<br />
( x , x , )<br />
ẋ = f x , x , u,<br />
t<br />
1 1<br />
Plant<br />
P<br />
u,t,x y,f(.)<br />
U,t,x Plant<br />
Controller<br />
C<br />
0 = f21 2 t<br />
y = h x u t<br />
( , , )<br />
ẋ = f ( x,<br />
Uk<br />
, t)<br />
y = h( x,<br />
U , t)<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous<br />
P<br />
Controller<br />
C<br />
k<br />
y,f(.)<br />
ZOH T<br />
Control App. does the work! <strong>ADAMS</strong> and Control App.<br />
share the work!<br />
P:
Co-simulation (discrete mode) Process<br />
76<br />
Here's what happens when you run an <strong>ADAMS</strong>/Control cosimulation<br />
in discrete mode. The following steps through an<br />
<strong>ADAMS</strong> message file (.msg) output from a batch mode cosimulation.<br />
1. <strong>Controls</strong> tells <strong>ADAMS</strong> to start and loads up your model. You<br />
should see the following lines in your message file:<br />
OUTFOP:IN_FILENM<br />
<strong>ADAMS</strong> model file ..<br />
VERINP:END_INPUT<br />
Input and Input Check Phase complete.<br />
GTMODE:NUMB_DOF1<br />
The system has one kinematic degree of freedom.<br />
2. After the initialization tasks, the controls package and<br />
<strong>ADAMS</strong> exchange data regarding system states. The line<br />
GLGETL:USER_CMND<br />
var/1, fun=0<br />
in the .msg file shows the value from your controls package<br />
coming into <strong>ADAMS</strong>. At the same time the plant outputs from<br />
<strong>ADAMS</strong> are being sent to the <strong>Controls</strong> package.<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous
Co-simulation (discrete mode) Process (continued)<br />
3.Now that <strong>ADAMS</strong> has the input values needed, the line<br />
77<br />
DBANNR:BDF<br />
Begin the dynamic analysis.<br />
appears indicating that the dynamic analysis has begun on the<br />
<strong>ADAMS</strong> side. At this point the inputs to the plant are held<br />
fixed from the current time until the next output time step.<br />
In the above example, variable 1 is held fixed at 0.<br />
4.When the dynamic analysis in <strong>ADAMS</strong> has proceeded for the<br />
output time step interval the message appears:<br />
Simulation Time Cumulative Cumulative Integrator<br />
Time Step Iterations Steps Taken Order<br />
___________ ___________ __________ ___________<br />
__________<br />
0.00000E+00 2.50000E-04 0 0 1<br />
2.50000E-04 2.50000E-04 3 1 1<br />
5.00000E-03 2.50000E-03 13 5 2<br />
GLGETL:USER_CMND<br />
var/1, fun=0.01<br />
….indicating that the dynamic simulation has halted. The line<br />
var/1, fun=0.01 indicates that another exchange between the<br />
controls package and <strong>ADAMS</strong> follows, setting variable 1 to a<br />
value of 0.01. In this manner the co-simulation proceeds. At<br />
every specified time interval the controls package and<br />
<strong>ADAMS</strong> stop, update one another with new state values. Each<br />
package then runs it's simulation independently, using the<br />
fixed values throughout the following interval.<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous
State Repartitioning<br />
You may be performing an <strong>ADAMS</strong>/<strong>Controls</strong> simulation and get<br />
part way through when the simulation stops, with the error<br />
message: '<strong>ADAMS</strong> State Repartitioning occurred ...‘ The 'State<br />
Repartitioning' message means that the <strong>ADAMS</strong> integrator is<br />
having some major problems resolving an event in your<br />
mechanical system, such as a rapidly changing input force or a<br />
locking up mechanism. This message can sometimes be<br />
overlooked when using regular old <strong>ADAMS</strong>, but it is not good<br />
when using <strong>ADAMS</strong>/<strong>Controls</strong>, as it may trigger a failure in the<br />
<strong>Controls</strong> package <strong>ADAMS</strong> communication process.<br />
To avoid this problem with your mechanical system check<br />
things such:<br />
78<br />
- gains in your <strong>Controls</strong> package. If they're large and they<br />
feed back rapidly changing forces you can have trouble - try<br />
decreasing these.<br />
- step times for forces in <strong>ADAMS</strong>. If you're using any STEP<br />
functions, try increasing the ramp-up time.<br />
- force magnitudes. Try decreasing your forcing function<br />
magnitudes.<br />
- the output step size for <strong>ADAMS</strong> (typically set in the<br />
<strong>ADAMS</strong> plant mask, or properties panel). The <strong>Controls</strong><br />
package and <strong>ADAMS</strong> trade data only at discrete output steps.<br />
Try decreasing the output step size to have the two packages<br />
update more frequently, decreasing the discrepancies when<br />
they exchange data in periodic update process.<br />
Essentially the best way to avoid this is to try and 'smooth'<br />
things out by checking rapidly changing forces and/or making<br />
the output step size small so that the results from the two<br />
packages don't diverge too much.<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous
Output Step Size/Sampling Rate<br />
The output step size is the duration at which information is<br />
exchanged between the controls package and <strong>ADAMS</strong>.<br />
This is commonly known as the sampling rate, and its<br />
greatest affects are seen in the discrete mode.<br />
In discrete mode, the controls package, using output from<br />
<strong>ADAMS</strong>, calculates the mechanical model inputs and sends<br />
it back to <strong>ADAMS</strong>. It is the responsibility of <strong>ADAMS</strong> to<br />
integrate the mechanical system for a single time step with<br />
the specified inputs.<br />
The sampling rate at which the <strong>ADAMS</strong> side receives input<br />
updates is critical - you must ensure that you're sampling<br />
the mechanical system (in MATLAB this is set as the<br />
'output step size' variable in the <strong>ADAMS</strong> plant mask;<br />
EASY5, the “Time Increment”) at more than twice the<br />
highest frequency you're interested in on the mechanical<br />
side. Otherwise, you may see aliasing in your mechanical<br />
model (aliasing is the generation of a false (alias)<br />
frequency).<br />
The effect of aliasing is that high frequency noise can be<br />
converted into a lower frequency, which could change the<br />
response of your system.<br />
79<br />
-<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous
Workshop 3: Discrete vs. Continuous Results<br />
In this workshop, you will simulate the ball-beam model in<br />
80<br />
both discrete (co-simulation) and continuous (function<br />
evaluation) modes, and compare the results.<br />
To work with MATLAB, follow steps 1-14.<br />
To work with EASY5, follow steps 15-47.<br />
MATLAB Steps<br />
1. Open up MATLAB and select File Open in the<br />
Simulink window and read in the .mdl for the from<br />
Workshop 2 for the ball_beam model.<br />
Now, look at the plant properties - we'll be modifying the<br />
solution method and noting the simulation results.<br />
To open the plant properties:<br />
2. Double click plant (adams_sub block in the control<br />
system diagram)<br />
3. Double click 'Mechanical Dynamics' block<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous
Workshop 3: Discrete vs. Continuous Results<br />
MATLAB Steps<br />
4. Set Output files prefix to 'ball_results_discrete‘<br />
5. Set Simulation mode to discrete.<br />
6. Set Animation mode - batch (interactive if you like the<br />
81<br />
animations).<br />
7. Select ‘OK’ to save.<br />
8. Simulate using these parameters. The results, stored<br />
in the ball_results_discrete. files, will be saved for<br />
comparison to the continuous mode.<br />
9. Take a look at the results in the MATLAB strip charts.<br />
Use the zoom tool to take a close look at a section of<br />
the curve in the 'Position' strip chart. It should show<br />
the discrete nature of the simulation, with small steps<br />
evident in the plot.<br />
10. Now, change the simulation mode to continuous, the<br />
output prefix to 'ball_results_continuous‘.<br />
11. In your Simulink model, select Simulate Simulation<br />
Parameters, and change the solver to “ode23s (stiff/<br />
Mod. Rosenbrock).<br />
<strong>12</strong>. Select OK, and re-run the simulation<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous
Workshop 3: Discrete vs. Continuous Results<br />
82<br />
MATLAB Steps<br />
13. As in step 5 use the zoom tool and examine the<br />
'Position' strip chart. It should appear continuous no<br />
matter how close you zoom in.<br />
14. Open up the plant properties again and change back to<br />
the discrete mode. Make the output step size large -<br />
say 0.05 and resimulate. You should see the very<br />
discrete nature of the simulation and the result of<br />
undersampling the system.<br />
EASY5 Steps<br />
15. Edit the file “ball_test.inf” from Workshop 2, so that<br />
the fourth line is changed from “ball_test” to<br />
“ball_test_discrete”. This will change the output file<br />
names.<br />
16. Open the EASY5 model “ball_beam.mf.#” (where # =<br />
the number of your last saved model from Workshop<br />
2)<br />
17. Open up the Component Data Table for the AD block<br />
and select ‘Spawn <strong>ADAMS</strong> Interface’<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous
Workshop 3: Discrete vs. Continuous Results<br />
83<br />
EASY5 Steps<br />
18. Enter the name of the .inf file (ball_test.inf).<br />
19. Enter “25” for the maximum number of states.<br />
20. Enter “3” to submit a co-simulation (discrete) analysis.<br />
Your AD block is now initialized.<br />
21. Select ‘OK’ in the AD Component Data Table.<br />
Before you use EASY5 to simulate the combined<br />
controls/mechanical system, set the AD block<br />
properties.<br />
22. Double click the AD block<br />
23. Set the animation mode (ANI_MOD)to interactive.<br />
24. Select ‘OK’ to save.<br />
25. Select Build Create Executable to compile and link<br />
the model.<br />
Next, set the simulation parameters:<br />
26. Set simulation parameters (Analysis Simulation<br />
Parameters):<br />
Title = ball_beam_discrete<br />
End time = 4 seconds<br />
Time increment = 0.01 seconds<br />
Int. Method = BCS Gear (stiff integrator)<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous
Workshop 3: Discrete vs. Continuous Results<br />
84<br />
EASY5 Steps<br />
27. Create plots (Y1, Y2, etc.) by toggling “Plot Results” to<br />
“yes” and making appropriate selections in “Show/Edit<br />
Plot Variables”.<br />
28. Simulate the control system containing the <strong>ADAMS</strong><br />
block by selecting “Execute and Close”.<br />
When the simulation is finished, the plots you created will<br />
appear automatically.<br />
You can zoom in on the plots and see the discrete nature of<br />
the curve.<br />
Next, look at results in <strong>ADAMS</strong>/<strong>Controls</strong>.<br />
29. Open <strong>ADAMS</strong>/PPT and select File Import<br />
30. Select “Analysis Files”<br />
31. Choose 'ball_beam_discrete.res‘. You can now make<br />
plots from results of the simulation of your mechanical<br />
system.<br />
Next, perform the same simulation in continuous mode.<br />
32. Edit the file “ball_test.inf” from Workshop 2, so that<br />
the fourth line is changed from “ball_test” to<br />
“ball_test_continuous”. This will change the output<br />
file names.<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous
Workshop 3: Discrete vs. Continuous Results<br />
85<br />
EASY5 Steps<br />
33. Open up the Component Data Table for the AD block<br />
and select ‘Spawn <strong>ADAMS</strong> Interface’<br />
34. Enter the name of the .inf file (ball_test.inf).<br />
35. Enter “25” for the maximum number of states.<br />
36. Enter “1” to submit a continuous analysis with no input<br />
feed-through.<br />
Your AD block is now initialized.<br />
37. Select ‘OK’ in the AD Component Data Table.<br />
Before you use EASY5 to simulate the combined<br />
controls/mechanical system, set the AD block<br />
properties.<br />
38. Double click the AD block<br />
39. Set the animation mode (ANI_MOD)to batch.<br />
40. Select ‘OK’ to save.<br />
41. Select Build Create Executable to compile and link<br />
the model.<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous
Workshop 3: Discrete vs. Continuous Results<br />
86<br />
EASY5 Steps<br />
Next, set the simulation parameters:<br />
42. Set simulation parameters (Analysis Simulation<br />
Parameters):<br />
Title = ball_beam_continuous<br />
End time = 4 seconds<br />
Time increment = 0.01 seconds<br />
Int. Method = BCS Gear (stiff integrator)<br />
43. Create plots (Y1, Y2, etc.) by toggling “Plot Results” to<br />
“yes” and making appropriate selections in “Show/Edit<br />
Plot Variables”.<br />
44. Simulate the control system containing the <strong>ADAMS</strong><br />
block by selecting “Execute and Close”.<br />
When the simulation is finished, the plots you created will<br />
appear automatically.<br />
You can zoom in on the plots and see that the plots are<br />
smooth, no matter how close you zoom in.<br />
Next, look at results in <strong>ADAMS</strong>/<strong>Controls</strong>.<br />
45. Open <strong>ADAMS</strong>/PPT and select File Import<br />
46. Select “Analysis Files”<br />
47. Choose 'ball_beam_continuous.res‘. You can now make<br />
plots from results of the simulation of your mechanical<br />
system.<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous
Notes<br />
87<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous
Notes<br />
88<br />
Chapter 5: Simulation Modes: Discrete vs. Continuous
Chapter 6: Preparing Simulations<br />
Within this chapter, you will find the following topics:<br />
89<br />
Licenses (or) Should View be running? 90<br />
Speeding Up Simulations 91<br />
Initialization Commands 92<br />
Workshop 4: Initialization Commands 93<br />
Chapter 6: Preparing Simulations
Licenses<br />
Question: I'm about to run the cosimulation from MATLAB.<br />
Should <strong>ADAMS</strong> be running at this time?<br />
Answer: You do not have to have <strong>ADAMS</strong>/View running when<br />
running a co-simulation. The <strong>ADAMS</strong>/<strong>Controls</strong> scripts will<br />
launch <strong>ADAMS</strong>/View on its own when the time comes to<br />
animate the model interactively during the co-simulation. Note<br />
that <strong>ADAMS</strong>/View will only be launched if you are running an<br />
"interactive“ simulation. If you run a "batch" simulation, then<br />
View is not launched – the job is run completely by Solver, and<br />
you will not see any graphical feedback.<br />
The upside to running in "batch" mode is that the simulation<br />
will take far less time.<br />
Beware that if you have <strong>ADAMS</strong>/View running while you try to<br />
run a co-simulation, you will then need two licenses. If you<br />
don't have two available, you will get an error (“Plant<br />
communication error 109).<br />
90<br />
Chapter 6: Preparing Simulations
Speeding Up Simulation Times<br />
There are two cosimulation modes when using <strong>ADAMS</strong>/<strong>Controls</strong>.<br />
Interactive = use View, batch = use Solver on the command line.<br />
For speed you want to do the batch cosimulation.<br />
Here's the results of a simple experiment using the Antenna<br />
model provided with your <strong>ADAMS</strong> distribution. To baseline things,<br />
I've first run in plain old View, then ran the <strong>Controls</strong> cosimulation<br />
for comparison of it's operating modes.<br />
1. The baseline: run antenna model in View using output steps of<br />
size 0.005 and a simulation time of 1.0 seconds. Doing this yields:<br />
Description Computation time<br />
Regular View simulation 11 seconds<br />
View simulation - execution display off 5 seconds<br />
2. Test the <strong>ADAMS</strong>/<strong>Controls</strong> cosimulation: run cosimulation with<br />
MATLAB, using settings in the MATLAB plant mask:<br />
Result:<br />
91<br />
end time = 1 second<br />
dt (plant output step size) = 0.005s<br />
using Stiff integrator (ODE15S) in Simulation settings<br />
Description Computation time<br />
View (interactive cosimulation) 1:26 (~20 second startup)<br />
Solver (batch cosimulation) 0:18 (~8 second startup)<br />
Summary:<br />
Use the interactive cosimulation to verify that you've set your<br />
model up correctly; once you're sure of that, run using 'batch'<br />
model to significantly speed things up.<br />
Chapter 6: Preparing Simulations
Initialization Commands<br />
You can submit commands to your <strong>ADAMS</strong> model before the cosimulation<br />
process starts by using “initialization commands”.<br />
Initialization commands allow you to specify a Solver or View<br />
command that will be issued to <strong>ADAMS</strong>/Solver when running<br />
<strong>ADAMS</strong>/<strong>Controls</strong>. Solver commands are used for batch mode, and<br />
view commands are used for interactive mode. These can be used<br />
to run your model until it reaches some initial state at which you<br />
want to turn on your system controller (among other things).<br />
To use this in MATALB, enter a single Solver command (for batch<br />
mode) such as:<br />
92<br />
['file/command=Starting_Commands.acf']<br />
in the MATLAB plant mask "Initialization Commands" field. This<br />
Solver command reads an .acf (<strong>ADAMS</strong> command file) that can<br />
exercise your model before your Control system is turned on.<br />
To use this in EASY5, enter a single Solver command such as:<br />
file/command=Starting_Commands.acf<br />
in the EASY5 .inf file under the line NUMBER OF COMMANDS 1.<br />
This Solver command reads an .acf (<strong>ADAMS</strong> command file) that<br />
can exercise your model before your Control system is turned on.<br />
Refer to the <strong>ADAMS</strong>/Solver reference guide for valid Solver<br />
command file syntax.<br />
Chapter 6: Preparing Simulations
Workshop 4: Initialization Commands<br />
In the following workshop, the antenna model has a motion<br />
activated on the antenna base that twists the antenna in the<br />
direction opposite to what the control system does. An .acf<br />
file runs the model for .5 seconds with this motion turned on,<br />
then uses a DEACTIVATE/MOTION, ID=1 command to turn<br />
off the motion prior to the Control system turning on and<br />
running for another .5 seconds.<br />
To work with MATLAB, follow steps 1-7.<br />
To work with EASY5, follow steps 8-18.<br />
MATLAB Steps<br />
1. Start MATLAB and change to the /Workshop4-<br />
InitCommands/ directory.<br />
2. Type ‘ant_test’ to setup the MATLAB environment variables,<br />
then type ‘adams_sys’ to bring up a Simulink window.<br />
3. From the Simulink window, select File Open and open<br />
antenna.mdl.<br />
4. Edit the adams_sub block to include the initialization<br />
command ['file/command=Starting_Commands.acf'] in the<br />
initialization field.<br />
5. Simulate from MATLAB.<br />
6. Open <strong>ADAMS</strong>/View and import antenna.cmd. Then import the<br />
<strong>ADAMS</strong>/Solver Analysis files and attach the files to the<br />
antenna model or to a new analysis that you created (rightclick<br />
on the field beside ‘model name’ or 'analysis name').<br />
93<br />
Chapter 6: Preparing Simulations
Workshop 4: Initialization Commands<br />
7. Inspect the results and convince yourself that the<br />
initialization commands were performed before the cosimulation.<br />
EASY5 Steps<br />
8. With a text editor, modify ant_test.inf to include the<br />
following commands:<br />
94<br />
F:\Program Files\<strong>ADAMS</strong> <strong>12</strong>.0<br />
ant_test<br />
ant_test<br />
interactive<br />
continuous<br />
0.010000<br />
automatic<br />
no<br />
NUMBER OF COMMANDS<br />
1<br />
File/command=Starting_Commands.acf<br />
NUMBER OF INPUTS/OUTPUTS<br />
1 2<br />
INPUT VARIABLES<br />
control_torque 1 1<br />
OUTPUT VARIABLES<br />
rotor_velocity 2 1<br />
azimuth_position 3 1<br />
Chapter 6: Preparing Simulations
Workshop 4: Initialization Commands<br />
9. Start EASY5 and open the antenna model the /Workshop4-<br />
InitCommands/ directory.<br />
10. Double click on the <strong>ADAMS</strong> AD block<br />
11. Set the animation mode to batch (ANI_MOD=0).<br />
<strong>12</strong>. Select Spawn <strong>ADAMS</strong> Interface.<br />
13. Enter “ball_test.inf”.<br />
14. Enter 25 for the number of states.<br />
15. Enter 3 for a co-simulation.<br />
16. Build the executable and simulate.<br />
17. Open <strong>ADAMS</strong>/View and import antenna.cmd. Then import the<br />
<strong>ADAMS</strong>/Solver Analysis files and attach the files to the<br />
antenna model or to a new analysis that you created (rightclick<br />
on the field beside ‘model name’ or 'analysis name').<br />
18. Inspect the results and convince yourself that the<br />
initialization commands were performed before the cosimulation.<br />
95<br />
Chapter 6: Preparing Simulations
Notes<br />
96<br />
Chapter 6: Preparing Simulations
Chapter 7: Advanced Topics<br />
Within this chapter, you will find the following topics:<br />
97<br />
User Libraries/Subroutines 98<br />
Debugging Models: General Tips 100<br />
Error Messages: Plant Communication Error 101<br />
Chapter 7: Advanced Topics
User Libraries<br />
Unlike previous versions of <strong>ADAMS</strong>, you no longer create an<br />
entire executable for <strong>ADAMS</strong> when you want to link in a user<br />
subroutine. Instead, a library is created once and simply<br />
selected when the subroutine(s) within the library are<br />
needed. For more information on this change, see KB 9317.<br />
98<br />
What does this mean? Well, instead of creating a controls<br />
executable (e.g., adams11 controls cr-uscontrols), you simply<br />
create a "standard" user executable (e.g., adams11 cr-user).<br />
So, here are the explicit steps:<br />
From the mdi script for UNIX, or the NT selections from the<br />
Start menu, do the following:<br />
1) UNIX: mdi -c cr-user<br />
NT: Start --> Programs --> <strong>ADAMS</strong> 11.0 --> ASolver --><br />
Create Custom Solver (or just type mdi cr-user in the DOS<br />
prompt)<br />
2) answer if you want to link in debug mode, and provide the<br />
list of your user subroutines.<br />
3) provide a name for the library, such as my_sub.dll<br />
Chapter 7: Advanced Topics
User Libraries (continued)<br />
4) within <strong>ADAMS</strong>/View, when you use the <strong>Controls</strong> Plant Export<br />
dialog box to save out your input and output data, include the<br />
name of the user library you just created in the appropriate<br />
field<br />
5) The user executable name is now automatically written out to<br />
the MATLAB .m file or the MATRIXx/EASY5 information file and<br />
automatically picked up by the controls program as the proper<br />
executable. Alternatively, you can enter this explicitly in the file.<br />
For example, in MATLAB enter <strong>ADAMS</strong>_exec =<br />
'$my_path/my_sub.dll'; (where $my_path is the path to your<br />
library).<br />
6) Note that there is no longer a difference between a custom<br />
solver library and a custom view library if the library is used<br />
by solver. In other words, you create a library for solver,<br />
which can be used by either the view interface or solver when<br />
simulating. A view library can *only* be in view as in designtime;<br />
it makes no sense to use this with solver, and obviously<br />
cannot be used in solver.<br />
99<br />
Chapter 7: Advanced Topics
Debugging Models: General Tips<br />
100<br />
It's often difficult to understand what's happening with your<br />
<strong>ADAMS</strong>/<strong>Controls</strong> cosimulation because the Solver messages<br />
will scroll across your screen (or won't even be visible,<br />
depending on setup), then be gone, so you can't see what's<br />
causing errors in your cosimulation.<br />
To see the output from Solver in the cosimulation, turn on<br />
message file output by setting the<br />
MDI_<strong>ADAMS</strong>_NOMSGFILE environment variable to FALSE.<br />
This will save all of the output messages to a .msg file that<br />
you can look through for errors.<br />
If you're having trouble solving your equations of motion<br />
(integrator failures, long simulation times, odd results, etc.),<br />
use initialization commands to create a Solver command file<br />
(.acf file) which can change the default integrator settings,<br />
or perhaps run your model for a time without the controls<br />
inputs.<br />
To summarize, some of the things to watch for:<br />
- your inputs/outputs are in the correct order<br />
- your control block diagram is proper<br />
- you have an <strong>ADAMS</strong> license available (did you shut down<br />
<strong>ADAMS</strong> before doing the cosim?)<br />
- your input forces/torques are reasonable (not too large or<br />
abrupt)- the <strong>ADAMS</strong> integrator shouldn't have problems with<br />
them.<br />
Chapter 7: Advanced Topics
Error Messages: Plant Communication Error<br />
If you receive an <strong>ADAMS</strong> plant communication error when trying<br />
to perform the co-simulation, this could mean many things.<br />
The <strong>ADAMS</strong> plant communication error is a generic message<br />
that could unfortunately mean anything from you don't have a<br />
license available to you've referenced a variable incorrectly in<br />
the controls simulation software. If you're trying to make<br />
your own model work and haven't tried one of the example<br />
problems found in your <strong>ADAMS</strong> installation at<br />
/<strong>ADAMS</strong>_install/controls/examples/, then run an example.<br />
It's important to ensure that you can run an example as your<br />
own model can potentially have incorrect feedback values,<br />
crossed lines, etc. You should establish that you can run an<br />
example model, which has been setup to work properly, before<br />
you start with your own model.<br />
If you generate an <strong>ADAMS</strong> plant communication error at some<br />
point in an <strong>ADAMS</strong>/<strong>Controls</strong> co-simulation (due to too rapid<br />
feedback, improper variable specification in MATLAB, etc.)<br />
and then fix the source of your error, but now get the plant<br />
communication error as soon as you hit 'Simulate', you may<br />
need to do some clean-up in your workspace.<br />
To clear things in the MATLAB <strong>ADAMS</strong>/<strong>Controls</strong> environment,<br />
use the<br />
101<br />
clear mex<br />
command on the command line in MATLAB. This gets rid of<br />
anything floating around from past failures and will allow you<br />
to perform subsequent co-simulations.<br />
Finally, make sure there are no “pipe” files remaining: delete any<br />
“APCInput” or “APCOutput” files.<br />
Chapter 7: Advanced Topics
Notes<br />
102<br />
Chapter 7: Advanced Topics