90
1 Introducing and Starting the Tutorials Getting Started Using Adams/Controls Introducing and Starting the Tutorials

Getting Started Using Adams Controls MDR3

Embed Size (px)

DESCRIPTION

This is the getting started Guide for the MDR3 version of Adams/Controls.

Citation preview

Page 1: Getting Started Using Adams Controls MDR3

1Introducing and Starting the Tutorials

Getting Started Using Adams/ControlsIntroducing and Starting the Tutorials

Page 2: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

2

OverviewThis 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.

This tutorial takes about two hours to complete.

Page 3: Getting Started Using Adams Controls MDR3

3Introducing and Starting the Tutorials

About the TutorialThe tutorials in this guide give you an overview of the four-step process of adding controls to an Adams model. See Welcome to Adams/Controls > About the Adams/Controls Four-Step Process, for a description of the four-step process. This chapter covers Steps One and Two of the process in depth. You'll learn how to:

• Import an Adams model and run a trial simulation with Adams/View. • Use the Adams/Controls interface to identify the inputs and outputs from your Adams model,

and create the files for the plant model in Easy5 and MATLAB/Simulink.

Steps Three and Four are covered in the chapters that follow for each controls application.

Page 4: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

4

How You’ll Learn Adams/ControlsBy following the tutorials in this guide, you’ll apply the four-step process of using Adams/Controls on a simple antenna-pointing problem. The objective of the problem is to add a control system to the antenna that will move the antenna along a defined path to track a satellite signal.

For this tutorial, you will supply the torque that pivots the antenna in the azimuthal (horizontal) direction. The torque level will be computed by a control system, based on the error between the actual antenna position and the desired antenna position. This is more realistic than attaching an Adams motion to the pivot and driving the motion directly. By applying a torque, you can look at issues related to motor size in an actual mechanical system.

Page 5: Getting Started Using Adams Controls MDR3

5Introducing and Starting the Tutorials

Starting Adams/ViewIn 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 R3, point to AView, and then select Adams - View. The Welcome dialog box appears, in the Adams/View main window.

Page 6: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

6

Step One - Build the Adams ModelNow you’ll import an Adams model and familiarize yourself with its construction by following the next four sections:

• Build the Adams Model

• Loading Adams/Controls

• Familiarizing Yourself with the Model

• Running a Trial Simulation

Build the Adams Model1. Select Import a File.2. In the Start In text box on the Adams/View welcome screen, enter the name of your new

directory (the one created in Step 1. in To start Adams/View: above).This sets your new directory as your working directory.

3. Select OK to close the Adams/View welcome screen.4. In the File Import dialog box, right-click the File to Read text box, and then select Browse.

The File Selection dialog box appears.5. Select the file antenna.cmd.6. Select OK.

The antenna model main_olt appears as shown in Figure 1.7. To change the display of the antenna from a wire frame into a shaded, three-dimensional image,

from the Main Toolbox, select Render.

Figure 1 Shaded Model of Antenna

Azimuth rotor

Antenna support

Elevation bearings

Plate

Reduction gear

Antenna

Page 7: Getting Started Using Adams Controls MDR3

7Introducing and Starting the Tutorials

Loading Adams/ControlsBecause 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.

Familiarizing Yourself with the ModelThis model is designed so that its base turns in the azimuthal (horizontal) direction and its antenna tilts in the vertical direction.

To familiarize yourself with the model, locate the following components: • Azimuth rotor (peach) connected to ground by revolute joint.• Azimuth reduction gear (sky blue) connected to ground by revolute joint.• Azimuth plate (magenta) connected to ground by revolute joint.• Antenna support (silver) connected to plate by fixed joint.• Elevation bearings (peach) connected to support by fixed joint.• Antenna (sky blue) connected to bearings by revolute joint.• rotor_gear, couples the revolute joint at the rotor to the revolute joint at the reduction gear.• gear_plate, couples the revolute joint at the reduction gear to the revolute joint at the plate.

Running a Trial Simulation

To run a trial simulation with Adams/View:1. From the Simulate menu, select Interactive Controls.2. Enter the following in the Simulation Controls dialog box:

• End Time: 0.5• Steps: 250

Note: To automatically load Adams/Controls each time Adams/View starts up, select Load at Startup in the Plugin Manager.

Page 8: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

8

3. Select Start at equilibrium.4. Select the Start tool .

The base of the mechanism turns counterclockwise as the antenna tilts up and down.

Deactivating the MotionNow that you know the model is working properly, you can begin the process of adding a control system to it. The first step is to deactivate the azimuthal motion on the model. After the motion has be deactivated, you will apply a torque to the joint .main_olt.azimuth_actuator based on values that the controls system package provides.

To deactivate the motion:1. From the Edit menu, select Deactivate.

The Database Navigator appears.2. Double-click the model main_olt.

A list of parts and motions appears. 3. Scroll down the list and select azimuth_motion_csd.4. Select OK.

Adams/View deactivates the motion.5. Select the Reset to Start tool to reset the simulation back to its first frame.6. Rerun the simulation.

Now that you’ve deactivated the azimuthal motion, the antenna moves up and down, but it does not sweep horizontally as it did during the last simulation.

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.

Page 9: Getting Started Using Adams Controls MDR3

9Introducing and Starting the Tutorials

Step Two - Creating the Adams Plant Inputs and OutputsNow you’ll create the inputs and outputs on the Adams model by:

• Identifying the Adams Plant Inputs and Outputs

• Verifying Input Variables

• Verifying Input Functions

• Verifying Output Functions

• Exporting the Adams Plant Files for the Controls Application

Identifying the Adams Plant Inputs and OutputsFigure 2 indicates the flow path of the input and output variables shared between the antenna model and its control system. This diagram shows that when you supply an input control torque to the antenna model, you send outputs azimuth_position and rotor_velocity to the controller.

The steps you follow to achieve this closed-loop circuit are:

• Define the input and output variables in Adams/View. • Read in the plant and the input/output variables using Easy5 or MATLAB, create an Adams

plant, and run a simulation.• Animate and plot the simulation results in Adams/View.• Modify the variables and repeat this process as necessary.

Figure 2 Terminology for Adams Inputs and Outputs

Verifying Input VariablesAdams/Controls and controls applications, such as Easy5 and MATLAB, communicate by passing state variables back and forth. Therefore, you must define your model’s input and output variables (and the functions that those inputs and outputs reference) with a set of Adams state variables.

This step has already been done for you in the antenna model that you imported. When you create a model of your own, you will have to define the state variables for your input and output variables.

Output = azimuth_position and rotor_velocity

Input = control _torque Adamsmodel

Controlsystem

Page 10: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

10

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.

To verify the input variables:1. From the Build menu, point to System Elements, point to State Variable, and then select

Modify.The Database Navigator appears.

2. Double-click the model main_olt.The list of Adams variables appears.

Figure 3 List of Adams Variables

3. Select control_torque.4. Select OK.

The Modify State Variable dialog box appears.

Figure 4 Modify State Variable Dialog Box

Page 11: Getting Started Using Adams Controls MDR3

11Introducing and Starting the Tutorials

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.

Verifying Input FunctionsNow you’ll verify the function that references the input variable.

To verify the function that is referenced to the input variable control_torque:1. From the Edit menu, select Modify.

The Database Navigator appears.2. Double-click main_olt, and then double-click azimuth_actuator (azimuth_actuator is the

name of the control torque).The Modify Torque dialog box appears.

Note: After you close the box, click in the background of the screen to clear the selection of the model.

Page 12: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

12

Figure 5 Modify Torque Dialog Box

3. Look in the Function text box and verify that the run-time function for the input variable reads: VARVAL(.main_olt.control_torque).

4. Select Cancel to close the Modify Torque dialog box.

Verifying Output FunctionsNow you’ll verify the output functions just as you verified the input functions in the previous section.

To verify the output functions:1. From the Build menu, point to System Elements, point to State Variable, and then select

Modify.The Variable Selection dialog box appears.

2. Double-click the model main_olt.The list of Adams variables appears.

3. Select azimuth_position.

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.

Page 13: Getting Started Using Adams Controls MDR3

13Introducing and Starting the Tutorials

4. Select OK.The Modify State Variable dialog box appears.

Figure 6 Modify State Variable Dialog Box

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.

Exporting the Adams Plant Files for the Controls ApplicationIn this section, you will export the Adams linear and nonlinear plant files.

To export the nonlinear plant files:1. From the Controls menu, select Plant Export.

The Adams/Controls Plant Export dialog box appears.2. In the New Controls Plant text box, enter ant_test.

Page 14: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

14

3. In the File Prefix text box, type ant_test for the filename.This defines the prefix for the .adm, .cmd, .m, and .inf files created by the Plant Export dialog box.

4. Right-click the Input Signal(s) text box, point to Adams_Variable, and then select Browse.The Database Navigator appears.

5. In the Database Navigator, select control_torque, and then select OK. 6. In the Adams/Controls Plant Export dialog box, right-click the Output Signal(s) text box, point

to Adams_Variable, and then select Guesses.A selection list appears.

7. From the selection list, select rotor_velocity. 8. Repeat Step 6, and then from the selection list, select azimuth_position.

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.

11. Verify that the Adams/Solver choice is set to Fortran and Adams Host Name is set to your machine name. Be sure that the name for Adams Host is a fully qualified hostname. (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.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.

Figure 7 Adams/Controls Plant Export 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.

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.

Page 15: Getting Started Using Adams Controls MDR3

15Introducing and Starting the Tutorials

14. Select OK. 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.

This order isimportant.

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.

Page 16: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

16

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:

• MATLAB, go to Learning Adams/Controls with MATLAB

• Control System Import with MATLAB, go to Learning Adams/Controls with Control System Import

• Easy5, go to Learning Adams/Controls with Easy5

• Control System Import with Easy5, go to Learning Adams/Controls with Control System Import from Easy5

Page 17: Getting Started Using Adams Controls MDR3

17Learning Adams/Controls with MATLAB

Learning Adams/Controls with MATLAB

Page 18: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

18

OverviewThis 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.

Page 19: Getting Started Using Adams Controls MDR3

19Learning Adams/Controls with MATLAB

About the TutorialThis chapter provides procedures for using Adams/Controls with MATLAB in co-simulation. It teaches you Steps 3 and 4 of the four-step process of adding controls to an Adams model. You will learn how to:

• Add an Adams plant to your block diagram in MATLAB simulation. • Simulate an Adams model with a complex control system.• Plot simulation results.

Page 20: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

20

Step Three - Adding Controls to the Adams Block DiagramYou will add controls to the Adams block diagrams by:

• Starting MATLAB

• Creating the Adams Block Diagram

• Constructing the Controls System Block Diagram

• Setting Simulation Parameters in the Plant Mask

Starting MATLABA 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.

To start using MATLAB:1. Start MATLAB on your system. 2. Change directories to the one in which your ant_test.m file resides (the working directory you

specified during your Adams/Controls session).You can do this by entering the following:• On Windows: cd c:\new_dir, where new_dir is the name of your working directory.• On UNIX, cd /new_dir, where new_dir is the name of your working directory.

3. At the prompt (>>), type ant_test. MATLAB echoes:%%%INFO:Adams plant actuators names:1 control_torque%%%INFO:Adams plant sensors names:1 rotor_velocity2 azimuth_position.

4. At the prompt, type who to get the list of variables defined in the files. MATLAB echoes the following relevant information:

ADAMS_cwd ADAMS_inputs ADAMS_poutput ADAMS_sysdir

ADAMS_exec ADAMS_mode ADAMS_prefix ADAMS_uy_ids

ADAMS_host ADAMS_outputs ADAMS_solver_type

ADAMS_init ADAMS_pinput ADAMS_static

Page 21: Getting Started Using Adams Controls MDR3

21Learning Adams/Controls with MATLAB

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

Creating the Adams Block Diagram

To create the Adams block diagram:1. At the MATLAB prompt, enter adams_sys.

This builds a new model in Simulink named adams_sys_.mdl. This model contains the MSC.Software S-Function block representing your mechanical system.A selection window containing the Adams blocks appears. These blocks represent your Adams model in different ways:

• The S-Function represents the nonlinear Adams model. • The adams_sub contains the S-Function, but also creates several useful MATLAB

variables. • The State-Space block represents a linearized Adams model.

The adams_sub block is created based on the information from the .m file (either from ant_test.m or ant_test_l.m). If the Adams_mode is nonlinear, the S-Function block is used in the adams_sub subsystem. Otherwise, the State_Space block is copied into adams_sub.

Figure 8 Simulink Selection Window

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.

Page 22: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

22

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. All of the elements in the subsystem appear.

Figure 9 adams_sub block

Page 23: Getting Started Using Adams Controls MDR3

23Learning Adams/Controls with MATLAB

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.

Page 24: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

24

Constructing the Controls System Block DiagramThe completed block diagram is in the file, antenna.mdl, in the examples directory. To save time, you can read in our diagram instead of building it. Remember to update the settings in the plant mask if you decide to use this file (see Setting Simulation Parameters in the Plant Mask).

To construct the controls system block diagram:1. At the MATLAB prompt, type simulink.

The Simulink library selection windows appear. Use the block icons from the windows to complete your controls block diagram. Each icon contains a submenu.

2. Double-click each icon to reveal its submenu.

3. Look at the controls block diagram. Figure 11 which describes the topology in tabular form. 4. Drag and drop the appropriate blocks from the Simulink library to complete your block diagram

as shown below.5. From the File menu, select Save As, and enter a file name for your controls block diagram.

Figure 10 Topology in Tabular Form

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.

Only one adams_sub block is permitted per Simulink model.

Note: Be sure to set the step block parameters as follows:

• Step time: 0.001• Initial value: 0• Final value: .3• Sample time: .001

Page 25: Getting Started Using Adams Controls MDR3

25Learning Adams/Controls with MATLAB

Quantity Library Block Type1 Sources Step2 Continuous Transfer Function2 Math Ops Sum3 Sinks Scope (not floating)Step Parameters

Step Time: 0.001

Initial Value: 0

Final value: 0.3

Sample time: 0.001

[X] Interpret vector parameters as 1-D

[X] Enable zero crossing detection

Continuous Transfer Function Parameters1 Numerator: [1040]

Denominator: [0.001 1]

Absolute tolerance: auto2 Numerator: [950

Denominator: [0.001 1]

Absolute tolerance: autoSum Parameters1 SumP

Icon shape: Rectangular

List of signs: +-[ ] Show additional parameters2 SumV

Icon shape: Rectangular

List of signs: +-[ ] Show additional parameters

Scope

torque

rotor_vel

azimuth_pos

Page 26: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

26

Figure 11 Controls Block Diagram

Setting Simulation Parameters in the Plant Mask

To set the simulation parameters:1. From the controls block diagram, double-click the adams_sub block.2. From the new Simulink selection window, double-click the MSC.Software block.

The Adams Plant Mask dialog box appears.

Figure 12 Adams Plant Mask

Page 27: Getting Started Using Adams Controls MDR3

27Learning Adams/Controls with MATLAB

Page 28: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

28

3. In the Output Files Prefix text box, enter ‘mytest’. Be sure to enclose the name with single quotation marks. Adams/Controls will save your simulation results under this name in the three file types listed in Table 1

4. Keep the default Interprocess Option of PIPE(DDE).This option defines the communication method between MATLAB and Adams. You can change this setting to TCP/IP, if you want to run MATLAB and Adams on separate machines and communicate using TCP/IP protocol. Using this protocol, Adams_host defines the machine on which Adams runs. For more information, see TCP/IP Communication Mode in the Adams/Controls help.

5. Keep the default Adams solver type of Fortran. To run the simulation using Adams/Solver (C++), you can change the setting to C++.

6. Keep the default Communication Interval of 0.005.The communication interval defines how often the communication between Adams and Simulink occurs. This will affect simulation speed and accuracy.

7. Keep the default Number of communications per output step of 1.0.This value controls the size of .res, .req,and gra files. It must be an integer larger than zero. For example, if the value is n, Adams/Controls writes to the output file once for every n communication steps. This size-control mechanism only works in discrete mode.

8. Select a simulation parameter for each text box.• Set Simulation mode to discrete.

This mode specifies that the simulation run in co-simulation -- Adams solves the mechanical system equations and that the controls application solves the control system equations. The variables exchanged between Adams and MATLAB are exchanged at "discrete" intervals. See the online help for more details about simulation modes.

• Set Animation mode to interactive.Animation mode controls whether you graphically monitor your simulation results in Adams/View (interactive), or you simulate with Adams/Solver (batch). See the online help for more details about animation modes.

9. Set the parameters for initializing the Adams model:

Table 1 File Types

File Name File type: What the file containsmytest.res Results Adams/Solver analysis data and Adams/View graphics datamytest.req Requests Adams/Solver analysis datamytest.gra Graphics Adams/View graphics data

Page 29: Getting Started Using Adams Controls MDR3

29Learning Adams/Controls with MATLAB

• Initial Static Simulation Flag: Set ADAMS_static to yes or no to control whether or not a static analysis should be performed. ADAMS_static is a parameter in the MATLAB workspace that is passed in through the ant_test.m file (which sets the default). If ADAMS_static is yes, Adams performs a static analysis.

• Initialization commands: MATLAB string that holds the Adams commands. Default is ADAMS_init.

10. To save the change, select Apply.11. Select Cancel to close the plant mask.

Note: In batch mode, the static (or initial condition) analysis is performed first, followed by the user-defined initialization commands in ADAMS_init. In interactive mode, the procedure is reversed.

Page 30: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

30

Step Four - Simulating the ModelYou will simulate your mechanical model and control system by:

• Setting the Simulation Parameters

• Executing the Simulation

• Pausing the Simulation

• Plotting from MATLAB

• Plotting from Adams/View

Setting the Simulation Parameters

To set the simulation parameters:1. From the menus on the Simulink window, select Simulation, and then select Configuration

Parameters. The Simulation Parameters dialog box appears.

2. Enter the following simulation parameters: • For Start Time, enter 0.0 seconds.• For End Time, enter 0.25 seconds.

3. Select the Type text box for the Solver options:• Set the first text box to variable step.• Set the second text box to ode15s.• Accept the default values in the remaining text boxes.

4. Select OK to close the Simulation Parameters dialog box.

Executing the Simulation

To start the simulation:• Select Simulation -- Start.

After a few moments, a new Adams/View window opens and graphically displays the simulation. If you’re using Windows, a DOS window appears with the current simulation data. If you’re using UNIX, the current simulation data scrolls across the MATLAB window.Adams accepts the control inputs from MATLAB and integrates the Adams model in response to them. At the same time, Adams provides the azimuthal position and rotor velocity information for MATLAB to integrate the Simulink model. This simulation process creates a closed loop in which the control inputs from MATLAB 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.

Page 31: Getting Started Using Adams Controls MDR3

31Learning Adams/Controls with MATLAB

Pausing the SimulationThe interactive capabilities of Adams/Controls let you pause the simulation in MATLAB and monitor the graphic results in Adams/View. Because MATLAB controls the simulation, you must pause the simulation from within MATLAB. You can plot simulation results during pause mode. This feature is only available when animation mode is set to interactive.

To pause the simulation:1. A time display in the upper left corner of the MSC.ADAMS screen tracks the seconds of the

simulation. To pause the simulation, move your cursor to the Simulink window, point to Simulation, and then select Pause.MATLAB suspends the simulation.

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.

Figure 13 View Orientation Tools

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.

Plotting from MATLABYou can plot any of the data generated in MATLAB. In this tutorial, you will plot the ADAMS_uout data that is saved in the adams_sub block. This block is shaded in Figure 14.

Figure 14 adams_sub Block

Page 32: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

32

To plot from MATLAB:• At the MATLAB prompt, type in the following command:

>>plot (ADAMS_tout, ADAMS_uout)The plot window opens and shows the time history of input from MATLAB to Adams. The following figure shows you how the plot should look. Notice that the control torque reaches a peak, and then settles down as the antenna accelerates. As the antenna gets close to its final position, the torque reverses direction to slow down the antenna. The antenna moves past its desired position, and then settles down to the point of zero error. At this point, the torque value is also at zero.

To add labels to your plot:• At the MATLAB prompt, enter:

Page 33: Getting Started Using Adams Controls MDR3

33Learning Adams/Controls with MATLAB

>>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.

Figure 15 Control Torque Input from MATLAB to Adams

Plotting from Adams/View

To plot from Adams/View:1. Start Adams/View from your working directory and read in the command file, ant_test.cmd.2. From the File menu, select Import.

The File Selection dialog box appears.3. In the File Selection dialog box, select the following:

• For the File Type, select Adams Results File.

Page 34: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

34

• For Files to Read, select Read mytest.res.• For Model, select main_olt. Be sure to include the model name when you read in results files.

Adams/View needs to associate the results data with a specific model.4. Select OK.

The results are loaded. Now, you can plot any data from the cosimulation and play the animation.5. From the Review menu, select Postprocessing.

Adams/View launches Adams/PostProcessor, a postprocessing tool that lets you view the results of the simulations you performed (see the Figure 16). Adams/PostProcessor has four modes: animation, plotting, reports, and 3D plotting (only available with Adams/Vibration data). Note that the page in the plot/animation viewing area can contain up to six viewports to let you compare plots and animations.

Figure 16 Adams/PostProcessor Window

6. From the dashboard, set Source to Results.7. From the Simulation list, select mytest.8. From the Result Set, select control_torque.9. From the Component list, select Q.

10. Select Add Curves. Adams/PostProcessor generates the curve.

Page 35: Getting Started Using Adams Controls MDR3

35Learning Adams/Controls with MATLAB

To add labels to your plot:1. In the treeview, navigate to the plot and select it.2. In the Property Editor that appears, perform the following:

• Uncheck Auto Title.• Set h3 to Antenna Azimuth Control Torque in Adams.• Uncheck Auto Subtitle.• Set Subtitle to Using Matlab Continuous Controller.

3. Select the vertical axis.4. In the Property Editor, in the Labels tab, set Label to Control Torque Input (N-mm).

Figure 17 illustrates the torque signal received from the MATLAB controller. The difference between this curve and the one plotted in Figure 15 is because the number of output steps (Adams has fewer outputs).

Figure 17 Adams Antenna Joint Peak Torque, Controlled

Page 36: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

36

Page 37: Getting Started Using Adams Controls MDR3

35Learning Adams/Controls with Control System Import

Learning Adams/Controls with Control System Import

Page 38: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

36

OverviewThis 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 One – Setup MATLAB

• Step Two – Create Adams Target for Real Time Workshop

• Step Three – Create Simulink Model

• Step Four – Code Generation of Control System

• Step Five – Create GSE from the Simulink Model

Page 39: Getting Started Using Adams Controls MDR3

37Learning Adams/Controls with Control System Import

About the TutorialThis chapter provides the procedures to import control systems designed in MATLAB/Simulink into Adams. It relies on MATLAB/Real-Time Workshop to convert the control model to C-code. This tutorial is based on the files output from Adams/View in the previous chapter.

The antenna model is still used in this chapter. The controller used in last chapter will be modified to represent three different types of controllers: continuous, discrete, and hybrid (continuous/discrete). Those three simulink files (continuous.mdl, discrete.mdl, and hybrid.mdl) are in the examples directory. Copy them to the local directory.

If MATLAB/Simulink and Adams cannot be run on the same machine, you will have to perform additional steps to realize the cross-platform control system import. For more information, refer to the online help.

Page 40: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

38

Step One – Setup MATLABFirst 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_velocity2 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

ADAMS_cwd ADAMS_inputs ADAMS_poutput ADAMS_sysdir

ADAMS_exec ADAMS_mode ADAMS_prefix ADAMS_uy_ids

ADAMS_host ADAMS_outputs ADAMS_solver_type

ADAMS_init ADAMS_pinput ADAMS_static

Page 41: Getting Started Using Adams Controls MDR3

39Learning Adams/Controls with Control System Import

Step Two – Create Adams Target for Real Time WorkshopHere you will customize the makefile template and source code template for Adams. Once this is done, you can use the customized template files for other Simulink models.

To create the Real-Time Workshop files for the Adams/Controls model:1. At the MATLAB prompt (>>), type setup_rtw_for_adams

This will automatically detect the version of Matlab you are using and create the makefile template and source code template for Adams. This function will also build template for specific versions of Matlab if desired by entering the desired version token as an argument: setup_rtw_for_adams('<version')) For help with this, enter setup_rtw_for_adams('h').You should see the following message for success in this step:%%% Successfully created files for Adams library export from MATLAB/RTW.

You should also confirm that in your working directory that .tlc and .tmf files were created by this step.

Alternatively, since the function setup_rtw_for_adams also uses process.py, you can still setup using the old method:

(Optional method if not using setup_rtw_for_adams function)

1. Set the MATLAB_ROOT environment variable to the MATLAB installation directory. For example:• On Windows (DOS shell): set MATLAB_ROOT= c:\matlab73\ • On UNIX (c shell): setenv MATLAB_ROOT /usr/matlab_73/ • On UNIX (korn shell): export MATLAB_ROOT = /usr/matlab_73/ • Change the directory paths to match your installation.

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:

adamsmdr3 -c python ($adams_dir)/controls/utils/process.py -v 73 exit• On Windows:

adamsmdr3 python ($adams_dir)\controls\utils\process.py -v 73 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:adamsmdr3 -c python process.py -v 73 exit

Page 42: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

40

• On Windows:adamsmdr3 python process.py -v 73 The argument -v 73 stands for MATLAB 7.3 (R14SP3). This command customizes several files from the MATLAB installation for the Adams target and your computer setup. You should notice several new files in your working directory with a .tlc extension and two new files with a .tmf extension. These are files required by MATLAB’s Real Time Workshop in the steps that follow. For help with process.py, use the -h flag (i.e., process.py -h).

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.

Page 43: Getting Started Using Adams Controls MDR3

41Learning Adams/Controls with Control System Import

Step Three – Create Simulink ModelTo create the Simulink template for the control system:

1. Enter setio at the MATLAB prompt.MATLAB creates a template model with the inport(s) and outport(s) defined, as shown in Figure 18.

Figure 18 Simulink Template

Based on this template, you can design continuous, discrete, or hybrid control systems. These are the files you already copied into the local directory.

2. To open hybrid.mdl, from the File menu, select Open. Or, double-click the file in the file browser.In the following context, the hybrid control system will be used as the example to illustrate the process. The Figures 19 shows the hybrid system. and topology. Figure 20 shows the topology.

Page 44: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

42

Figure 19 Hybrid Control System

Figure 20 Hybrid Control System Topology

Page 45: Getting Started Using Adams Controls MDR3

43Learning Adams/Controls with Control System Import

Hybrid Control System Topology (continued)

Quantity Library Block Type1 Sources Step2 Continuous Transfer Function2 Discrete Transfer Function5 Math Ops Sum1 Math Ops Gain2 Ports Inport1 Ports OutportStep Parameters

Step Time: 0.001

Initial Value: 0

Final value: 0.3

Sample time: 0.001

[X] Interpret vector parameters as 1-D

[X] Enable zero crossing detection (greyed out)

Continuous Transfer Function Parameters1 Numerator: [1040]

Denominator: [0.001 1]

Absolute tolerance: auto2 Numerator: [950

Denominator: [0.001 1]

Absolute tolerance: auto

Discrete Transfer Function Parameters1 Numerator: [657.4]

Denominator: [1 -.3679]

Sample time: 0.0012 Numerator: [600.5]

Denominator: [1 -.3679]

Sample time: 0.001

Page 46: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

44

Sum Parameters1 SumP

Icon shape: Rectangular

List of signs: +-[ ] Show additional parameters2 SumV

Icon shape: Rectangular

List of signs: +-[ ] Show additional parameters3 SumP1

Icon shape: Rectangular

List of signs: +-[ ] Show additional parameters4 SumV1

Icon shape: Rectangular

List of signs: +-[ ] Show additional parameters5 Icon shape: Round

List of signs: ++[ ] Show additional parameters

GainGain: 0.5Multiplication: Element-wise(K, *u)[ ] Show additional parameters

InportName: rotor_velocityPort Number: 1Name: azimuth_positionPort number: 2

OutportName: control_torquePort number 1

Page 47: Getting Started Using Adams Controls MDR3

45Learning Adams/Controls with Control System Import

Step Four – Code Generation of Control SystemFirst you will configure MATLAB/Real-Time Workshop and then you will create the external system library from the Simulink model.

Given a controller designed with the appropriately designated inports and outports, the following steps are required to export the model using RTW.

1. From the Tools menu, point to Real-Time Workshop, and then select Options. The Simulation Parameters dialog box appears.

2. Verify that Generate code only is not selected.3. Complete the Simulink Parameters dialog box for MATLAB, as shown Figure 21.

Figure 21 Simulation Parameters

4. From the treeview on the left side of the window, select Solver.The dialog box displays the Solver options as shown next

Figure 22 Simulation Parameters - Solver Options

Page 48: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

46

5. Set Solver options Type to Fixed-Step.A Variable-step solver requires a MATLAB license, so Fixed-step is needed to remove this license requirement. Note that Adams/Solver integrates the model once it is created into an Adams General State Equations (GSE) entity.

6. Set Mode to SingleTasking. 7. Select a continuous integrator (because the control system has continuous states).

For the control system discrete.mdl, you would select a Discrete integrator.8. 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. 9. 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.

• Reduces global RAM usage, because parameters are not declared in the global parameters structure.

Figure 23 Simulation Parameters - Advanced Options

Page 49: Getting Started Using Adams Controls MDR3

47Learning Adams/Controls with Control System Import

10. Select Apply11. Select the Real-Time Workshop tab.12. 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

### Successful completion of Real-Time Workshop build procedure for model: hybrid

The library you created will be in your working directory.

Page 50: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

48

Step Five – Create GSE from the Simulink ModelFirst you will start Adams/View and import the command file, and then simulate your Adams model containing the GSE for the control system.

To start Adams/View and load the command file:1. Launch Adams/View and import the file ant_test.cmd.2. Load the Adams/Controls plugin, if not already loaded.3. From the Controls menu, point to Control System, and then select Import.

The Adams/Controls System Import dialog box appears.4. Select Import I/O Signals from Existing Controls Plant.5. From the Database Navigator, select ant_test for the plant. The values for the Output Signals and

Input Signals text boxes appear.6. Complete the dialog box as shown in Figure 24, and then select OK.

Figure 24 Adams/Controls System Import Dialog Box

Adams/View displays information on the GSE created (See Figure 25). The Database Navigator shown in Figure 26 shows the GSE and its associated arrays.

Page 51: Getting Started Using Adams Controls MDR3

49Learning Adams/Controls with Control System Import

Figure 25 Information Window

Page 52: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

50

Figure 26 Database Navigator

To simulate your model:1. From the Settings menu, point to Solver, and then select Dynamics.

The Solver Setting dialog box displays.2. Change Formulation to SI2.3. Set Category to Executable.4. Set Hold License to No.

This setting is critical to using the RTW dll in repeated simulations in Adams/View.When you rewind/stop 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.

5. Select Close.6. Run a simulation with a step size of .001s and duration of .25s.

During the simulation, the antenna motion behaves the same as the one in the co-simulation. 7. Press F8 to open Adams/PostProcessor.8. Plot and animate, as desired.

Page 53: Getting Started Using Adams Controls MDR3

51Learning Adams/Controls with Control System Import

Adams/PostProcessor displays the plot of azimuth position versus time, as shown in Figure 27.

Figure 27 Plot of Azimuth Position vs. Time

A comparison of the results of the above simulation, discrete simulation, and continuous simulation is conducted. 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 28. As shown, the result from the simulation with imported GSE is almost the same as that from continuous simulation. The control torque from the discrete 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.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.

Page 54: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

52

Figure 28 Control Torque vs. Time

Page 55: Getting Started Using Adams Controls MDR3

53Learning Adams/Controls with Easy5

Learning Adams/Controls with Easy5

Page 56: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

54

OverviewThis 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).

Page 57: Getting Started Using Adams Controls MDR3

55Learning Adams/Controls with Easy5

About the TutorialThis chapter provides procedures for using Adams/Controls with Easy5 in co-simulation. It teaches you Steps Three and Four of the four-step process of adding controls to an Adams model. You’ll learn how to:

• Add an Adams plant to your block diagram in the Easy5 simulation. • Simulate an Adams model with a complex control system.• Plot simulation results.

Page 58: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

56

Step Three - Adding Controls to the Adams Block DiagramYou will add controls to the Adams block diagrams by:

• Starting Easy5

• Creating the Adams Interface Block

• Constructing the Controls System Block Diagram

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.

Creating the Adams Interface BlockYou create the Adams interface block by defining its component parts in the Add Components dialog box. After you define the component parts, you place the block in the work space area of the Easy5 main window.

To create the Adams interface block:1. From the Easy5 toolbar, select Add or type Ctrl+A.

The Add Components window appears.

Figure 29 Add Components Window

Page 59: Getting Started Using Adams Controls MDR3

57Learning Adams/Controls with Easy5

2. Select a category for each of the component fields in the window.• Under Library, select Extensions.• Under Extensions, select MSC.Software.• Under MSC.Software, select the Adams Mechanism block.

3. Move the cursor to the center of the Easy5 main window and click.The Adams interface block appears. You build the controls block diagram by adding elements to this block.

Figure 30 Adams Mechanism Block

Page 60: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

58

Initializing the Adams Interface Block

To initialize the Adams interface block:1. Double-click the Adams interface block.

The Component Data Table appears as shown in Figure 31.

Figure 31 Component Data Table

2. Select Select/Configure Adams model in the lower left corner of the Component Data Table. The Adams Interface dialog box appears as shown below.

Page 61: Getting Started Using Adams Controls MDR3

59Learning Adams/Controls with Easy5

Figure 32 Adams Interface Dialog Box

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 Figure shown below:

Page 62: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

60

Figure 33 Component Data Table for Cosimulation

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.• For ADAMS_Output_Interval (output rate interval), enter .001.

Tip: For a description of the component inputs, outputs, and states, select the respective tabs.

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. Subsequest 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.

Page 63: Getting Started Using Adams Controls MDR3

61Learning Adams/Controls with Easy5

• For Communication_Interval (communication rate interval between Adams and Easy5), enter 0.001. It should not be larger than the ADAMS_Output _Interval.

• 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 below.

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.

Page 64: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

62

Figure 34 Component Data Table - Function Evaluation Mode

• Note the following in Figures 33 and 34:• ADAMS_Solver has a default value of 1.0, which uses the Adams FORTRAN solver for

cosimulation or function evaluation. Setting this value to 2.0 allows you to use the Adams C++ solver.

• ADAMS_Communication_Mode has a default value of 1.0, which uses the pipes-based communication protocol for communication between Easy5 and Adams. Setting this value to 2.0 specifies that TCP/IP-based communication be used between the two products. For more information on TCP/IP-based communication, see TCP/IP Communication Mode in the Adams/Controls help.

Page 65: Getting Started Using Adams Controls MDR3

63Learning Adams/Controls with Easy5

Constructing the Controls System Block DiagramThe completed block diagram is in the file, antenna.0.ezmf, in the examples directory. To save time, you can read in this diagram instead of building it.

To construct the controls system block diagram:1. Review the controls block diagram in Figure 35. Begin recreating the diagram with the blocks

from the Add Components menu. 2. Place the Step Function Generator block in the diagram first. 3. Click on the Step Function Generator block using the middle mouse button.

The Component Data Table appears. 4. Set the step time (TO) to 0.01 and the step value (STP) to 0.3, and then select OK.

Figure 35 Controls 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.

Note: Only one Adams block is allowed per Easy5 model.

Page 66: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

64

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.

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.

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.

Page 67: Getting Started Using Adams Controls MDR3

65Learning Adams/Controls with Easy5

Step Four - Simulating the ModelYou’ll simulate your mechanical model and controls system by:

• Building the Executable

• Executing the Simulation

• Pausing and Stepping Through the Simulation

• Plotting from Easy5

• Plotting from Adams/View

Building the ExecutableYou must build an executable for your model before you execute a simulation in Easy5.

To build the executable:• In Easy5, from the Build menu, select Create Executable.

After a few moments, Easy5 displays the message, Executable has been created, at the bottom of the main window.You are now ready to execute the simulation.

Executing the Simulation

To execute the simulation from Easy5:1. From the toolbar at the top of the Easy5 main window, point to Analysis, and then select

Simulation.The Simulation Data Form window appears.

2. Select the Plotting tab.3. For plot variables, select Selected from the pull-down menu.

A Plot Specification Form appears where you define the variables that you want to plot after the simulation.

Figure 36 Plot Specification Form

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 36.

Page 68: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

66

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.b. Expand the AO component, and then double-click rotor_velocity to select it.

The rotor_velocity component now appears as Variable #1 to be plotted.

Page 69: Getting Started Using Adams Controls MDR3

67Learning Adams/Controls with Easy5

• Repeat this procedure for the second and third variable. For the second variable, select azimuth_position, and for the third, select S_Out_ LA11 (the input to the Adams block

as indicated in Figure 35).The finished Plot Specification Form should look like the one in Figure 37.

Figure 37 Plot Specification Form

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. 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.

Page 70: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

68

To run an interactive simulation:1. As the simulation begins, arrange the windows so that you have a good vantage point to view the

antenna model.

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.

Pausing and Stepping Through the SimulationThe interactive capabilities of Adams/Controls let you pause the simulation in Easy5 and monitor the graphic results in Adams/View. You can plot simulation results during pause mode.

To pause the simulation:1. Select Break to pause the simulation at the next sample step.

You can use the interactive plot window (Figure 38) to pause the simulation, or you can single-step through the simulation. If you select Step, the simulation steps through one sample step (.001 seconds) of the interactive Strip Chart.

Figure 38 Interactive Plot Window

Note: The Adams model is initialized to the current simulation time in Easy5.

Page 71: Getting Started Using Adams Controls MDR3

69Learning Adams/Controls with Easy5

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.

Figure 39 View Orientation Tools

3. Once you have finished reorienting the model, select Continue to continue the simulation.

Page 72: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

70

Adams/View closes automatically after the simulation finishes.

Plotting from Easy5Easy5 automatically displays the Plot window after running a simulation. By default, Easy5 displays the plot of the first variable you defined in the Plot Specification Form. You can plot any data generated in Easy5 by selecting a variable from the Plot Selection Menu. In this tutorial, you’ll plot the curve for control torque.

To plot from Easy5:• From the Plot Selection menu, point to Displays, and then select the variable, S2 LA11, which

is the control torque input to the Adams block from Easy5.The Easy5 Plotter window displays the plot for control torque.The Figure 40 shows how the plot should look. Notice that the control torque reaches a peak, and then settles down as the antenna accelerates. As the antenna gets close to its final position, the torque reverses direction to slow down the antenna. The antenna moves past its desired position, and then settles down to the point of zero error. At this point, the torque value is also zero.

To add labels to the plot:1. At the bottom of the Plot Selection Menu, select Edit Display.

The Display Specification Form appears.2. Enter the following labels:

• 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 Figure 40.

Figure 40 Plot of Control Torque Input

Page 73: Getting Started Using Adams Controls MDR3

71Learning Adams/Controls with Easy5

Plotting from Adams/View

To plot from Adams/View:1. Display Adams/View in a new system window and read in the command file, ant_test.cmd.2. From the File menu, select Import.

The File Selection dialog box appears.3. Select the following:

• For File Type, select Adams Results File.• For Files to Read, select ant_test.res.• For Model, select main_olt.

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.

4. From the Review menu, select Postprocessing.

Note: You can plot any data from the simulation and rerun the animation from Adams/View.

Page 74: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

72

Adams/View launches Adams/PostProcessor, a postprocessing tool that lets you view the results of the simulations you performed. Take a minute to familiarize yourself with Adams/PostProcessor.Figure 16 shows the Adams/PostProcessor window

5. From the dashboard, set Source to Objects.6. From the Model list, select .main_olt.7. From the Filter list, select constraint.8. From the Object list, select antenna_joint.9. From the Characteristic list, select Element Torque.

10. From the Component list, select Y.11. Select Add Curves.

Adams/PostProcessor generates the curve.

To add labels to the plot:1. In the treeview, navigate to the plot and select it.2. In the Property Editor, in the Title text box, enter the name: Antenna Joint Peak Torque,

Controlled. The plot title appears above the plot. 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.

Figure 41 Adams Antenna Joint Peak Torque, Controlled

Page 75: Getting Started Using Adams Controls MDR3

73Learning Adams/Controls with Easy5

Page 76: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

74

Page 77: Getting Started Using Adams Controls MDR3

71Learning Adams/Controls with Control System Import from Easy5

Learning Adams/Controls with Control System Import from Easy5

Page 78: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

72

OverviewThis 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

This chapter contains the following sections:

• Setting Up the Environment

• Step One - Export Your Easy5 Model

• Step Two - Import the Exported Easy5 Model into Adams

• Step Three - Run a Simulation

This tutorial takes about 1 hour to complete.

Page 79: Getting Started Using Adams Controls MDR3

73Learning Adams/Controls with Control System Import from Easy5

About the TutorialIn this chapter you will continue using the Easy5 model of the antenna controller that you used in the previous Adams/Controls tutorials.

We assume that you have Easy5 and Adams/Controls installed on the same machine. For instructions on using this feature when Adams and Easy5 are not installed on the same machine, see the Adams Knowledge Base Article 10581 at: http://support.adams.com/kb/faq.asp?ID=kb10581.dasp. We assume that the Adams/Controls extension has been installed in your version of Easy5 (for more information about the Adams product installation, see the Adams Installation and Operations Guide).

Page 80: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

74

Setting Up the EnvironmentNo setup is required for Easy5 on UNIX or Linux platforms. On Windows, you need to set the PATH environment variable.

To find the appropriate value for the variable:1. Start Easy5.2. Open an Easy5 command shell: from the Easy5 File menu, select Open Command Shell. 3. At the command shell prompt, enter: echo %EZHOME%.

The output is the directory in which Easy5 is installed. You will use the directory information in Step 5 below. The usual value of EZHOME is:C:\MSC.Software\MSC.EASY5\2005r1.4\

To apply the value of the environment variable:1. From the Start menu, point to Settings, and then select Control Panel.2. In the Control Panel dialog box, select the System icon.3. In the System Properties dialog box, select the Advanced tab.4. In the Advanced tab container, select Environment Variables.

Adams must know the path to the subdirectory of your Easy5 installation tree to be able to load ez5_lmgr.dll:• lib_nt_IF8 - For the Intel FORTRAN 9.1compiler.

5. Using the path from step 3, in the Environment Variables dialog box, append or create the path to the user variable as follows:Variable Name = PATHFor the Intel FORTRAN 9.1compiler, enter the following, where <CURRENT_VALUE> is the current value of PATH:Variable Value = <CURRENT_VALUE>; %EZHOME%\easy5x\lib_nt_IF8and where the value of EZHOME is taken into account.

Note: • If, unlike the antenna controller model, your Easy5 model contains components from a licensed library (for example, the Thermo-Hydraulic, Powertrain, or Gas Dynamics libraries), you will need to make sure Adams finds your Easy5 license. Failure to perform this step will result in the Easy5 license library not being found. You will not be able to proceed with the tutorial.

• Adams supports the Intel Visual Fortran 9.1compiler only. The Easy5 model import feature is not supported with the GNU or Intel FORTRAN compilers on Microsoft Windows.

Page 81: Getting Started Using Adams Controls MDR3

75Learning Adams/Controls with Control System Import from Easy5

Step One - Export Your Easy5 ModelThis section details the procedure to export an Easy5 model as an Adams External System Library.

An Adams External System Library is a binary file that can be loaded into Adams as a General System Equation (GSE) element. In this form, the equations in the Easy5 model become equations of the Adams model just as if you had entered them as run-time function expressions within Adams State Variable or Differential Equation elements.

To create an Adams External System Library:1. Launch Easy5, move to the directory where the Adams model files and Easy5 model files reside,

and open the Easy5 antenna controller model.2. If Easy5 is running on an IBM RS6000 workstation, you must modify the antenna control system

by removing the Interactive Simulation components, such as strip charts, because you will not run the Easy5 model in the Easy5 environment.

Figure 42 Antenna Control System

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 43.

Page 82: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

76

Figure 43 Component Data Table

b. Select Select/Configure Adams Model to open the Configure Adams block panel.

Figure 44 Configure Adams Block Panel

Page 83: Getting Started Using Adams Controls MDR3

77Learning Adams/Controls with Control System Import from Easy5

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. The Component Data Table for the Adams Mechanism Block is updated as shown next.

Figure 45 Component Data Table after Re-Configuration

Page 84: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

78

e. Select OK to close the CDT for the Adams Mechanism component.The updated Adams Mechanism Block now contains all the information necessary to interface with Adams.

4. Create the Adams External System Library files:a. From the Easy5 Build menu, point to Export Model as, and then select Adams External

System Library. The Export Adams External Systems form appears.

b. Accept the settings in this form, and then select Export to start creating the library.

Note: The following Adams block inputs in the CDT are not relevant: ADAMS_Animation_mode, ADAMS_Output_Interval, and Use_Adams_ICs.

Page 85: Getting Started Using Adams Controls MDR3

79Learning Adams/Controls with Control System Import from Easy5

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.

Page 86: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

80

Step Two - Import the Exported Easy5 Model into AdamsIn this section, you import the exported Easy5 antenna controller model into the Adams antenna model.

1. Launch Adams/View.2. Import the Adams antenna model, ant_test.cmd: from the Adams/View File menu, select

Import.3. If the Controls menu does not appear on the Adams/View menu bar, load the Adams/Controls

plugin: • From the Tools menu, select Plugin Manager.• In the list of plugin names, find Adams/Controls, and then select Load.

4. From the Controls menu, point to Control System, and then select Control System Import.The Adams/Control system Import Dialog box appears. a. In the General State Equation Name text box, enter antenna_gse. You may use any name

here that has not already been used as an element name in your Adams model and is not an Adams keyword.

b. Right-click the External System Library text box, and then select Browse. c. Select the demand-load library file created in the previous step (named antenna.dll,

antenna.sl, or antenna.so depending on your platform). d. Select Import I/O Signals from Existing Controls Plant to display the Database Navigator.e. In the Database Navigator, select ant_test.

The output and input signal text boxes update automatically, as shown in Figure 46.

Figure 46 Adams/Controls System Import Panel

Page 87: Getting Started Using Adams Controls MDR3

81Learning Adams/Controls with Control System Import from Easy5

f. Select OK or Apply to import the model. If there is a problem in the importing process, the Adams Message window will explain it. Correct the problem and try importing again. When the import is successful, the Information window appears as shown in Figure 47, containing details about the GSE element created in the Adams model.

Figure 47 Message indicating the Creation of GSE

Page 88: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

82

5. 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.

Page 89: Getting Started Using Adams Controls MDR3

83Learning Adams/Controls with Control System Import from Easy5

Step Three - Run a SimulationIn this section, you will run a simulation of the antenna model containing the Easy5 controller.

To run the simulation:1. From the Settings menu, point to Solver, and then select Dynamics.

The Solver Settings dialog box appears.2. Change the Formulation setting to SI2.

This change is necessary because the SI2 formulation is better able to deal with the rapid value change. In this model, the rapid change is associated with the STEP function in the Easy5 model.

3. Select Close.4. Run a simulation with step size of 0.001 seconds and duration of 0.25 seconds.

During the simulation, the antenna moves the same as it did during the co-simulation in the preceding chapter.

5. Switch to Adams/PostProcessor and examine the results.6. From the list of analysis results plot the azimuth_position versus time.

Adams/PostProcessor displays the plot of azimuth position versus time, as shown next.

Figure 48 Simulation Result: Azimuth Position versus Time

Page 90: Getting Started Using Adams Controls MDR3

Getting Started Using Adams/Controls

84