0% found this document useful (0 votes)
27 views11 pages

TN1 DesignRobotUsingSolidworksMATLAB 13.02.2020 English

The document discusses how to design and simulate a 2 degree of freedom robot model using SolidWorks, Simscape Multibody Link plugin, and Simscape Multibody in MATLAB. It provides instructions on installing the necessary software, designing a 2DOF robot model in SolidWorks, exporting and importing the model into Simscape Multibody, and building the simulation model to program and simulate the robot's motion.

Uploaded by

Duy Thoại Lê
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views11 pages

TN1 DesignRobotUsingSolidworksMATLAB 13.02.2020 English

The document discusses how to design and simulate a 2 degree of freedom robot model using SolidWorks, Simscape Multibody Link plugin, and Simscape Multibody in MATLAB. It provides instructions on installing the necessary software, designing a 2DOF robot model in SolidWorks, exporting and importing the model into Simscape Multibody, and building the simulation model to program and simulate the robot's motion.

Uploaded by

Duy Thoại Lê
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

FL061

Mechanical Engineering Faculty DESIGN AND SIMULATE ROBOT


Department of Mechatronics
MOTIONS USING SIMSCAPE
MULTIBODY

1. OVERVIEW
1.1 Introduction
Simscape Multibody™ (formerly SimMechanics™ in MATLAB 2015b and before) provides
a multibody simulation environment for 3D mechanical systems, such as robots, vehicle
suspensions, construction equipment, and aircraft landing gear. You can model multibody systems
using blocks representing bodies, joints, constraints, force elements, and sensors. Simscape
Multibody formulates and solves the equations of motion for the complete mechanical system.
You can import complete CAD assemblies, including all masses, inertias, joints, constraints, and
3D geometry, into your model. An automatically generated 3D animation lets you visualize the
system dynamics.
Simscape Multibody helps you develop control systems and test system-level performance.
You can parameterize your models using MATLAB® variables and expressions, and design
control systems for your multibody system in Simulink®. You can integrate hydraulic, electrical,
pneumatic, and other physical systems into your model using components from the Simscape™
family of products. To deploy your models to other simulation environments, including hardware-
in-the-loop (HIL) systems, Simscape Multibody supports C-code generation.
Simscape Multibody Link is a plug-in that you install on your CAD application to export
your CAD assembly models. The plug-in generates the files that you need to import the model into
the Simscape Multibody environment in MATLAB. From this file, users can program, simulate
the motion of the model (designed by CAD) by attaching sensors, actuators, signal system, etc.
into the model.
You can install the plug-in on 3 CAD applications: SolidWorks, Autodesk Inventor, and PTC
Creo. In this Laboratory lesson, we design a robot in SolidWorks and after that, we import this
model into MATLAB for programming.

1.2 Preparation
Students need to install following software before coming to class:
- SolidWorks
- MATLAB
- Download Simscape Multibody Link Plug-in on MATLAB website.
Select the file versions matching your MATLAB release number and system architecture—e.g.,
release R2017b and Win64 architecture. Do not extract the zip archive.

Faculty of Mechanical Engineering @HCMUT 1


FL061
1.3 Goals
 Have ability to design a mechanical model (robot) using SolidWorks.
 Have ability to export a designed file in CAD and import this file into MATLAB using
Simscape Multibody Link.
 Have ability to simulate robot motion using Simscape Multibody environment of
MATLAB.

2. BASIC KNOWLEDGE
2.1 Install Simscape Multibody Link Plug-in
Step 1: Get the Installation Files
- Go to the Simscape Multibody Link download page.
- Follow the prompts on the download page.
- Save the zip archive and MATLAB file in a convenient folder.
Select the file versions matching your MATLAB release number and system architecture—
e.g., release R2017b and Win64 architecture. Do not extract the zip archive.

Step 2: Run the Installation Function


- Run MATLAB as administrator.
- Add the saved installation files to the MATLAB path.
You can do this by entering addpath('foldername') at the MATLAB command prompt. Replace
“foldername” with the name of the folder in which you saved the installation files—e.g., C:\Temp.
- At the MATLAB command prompt, enter install_addon('zipname').
Replace zipname with the name of the zip archive—e.g., smlink.r2017b.win64.zip.

Step 3: Register MATLAB as an Automation Server


Each time you export a CAD assembly model, the Simscape Multibody Link plug-in attempts to
connect to MATLAB. For the connection to occur, you must register MATLAB as an automation
server. You can do this in two ways:
- In a MATLAB session running in administrator mode — At the command prompt, enter
“regmatlabserver”.
- In an MS-DOS window running in administrator mode — At the command prompt, enter
“matlab –regserver”.

Step 4: Enable the Simscape Multibody Link Plug-In


Before you can export an assembly, you must enable the Simscape Multibody Link plug-in on
your CAD application. To do this, see:
- At the MATLAB® command prompt, enter “smlink_linksw”.
- Start SolidWorks.
- In the Tools menu, select Add-Ins.

Faculty of Mechanical Engineering @HCMUT 2


FL061
- In the Add-Ins dialog box, select the Simscape Multibody Link check box. A Simscape
Multibody Link menu appears in the SolidWorks menu bar when you start or open a CAD
assembly.

2.2 Introduction of 2DOF robot


The robot model designed in this exercise is a two degree-of-freedom (2DOF) robot, shown in
Figure 1. This robot includes 4 parts: base link (Part 0), first link (Part 1), second link (Part 2), and
end-effector link (Part 3). The base link is connected to the first link by a revolute joint and the
first link is connected to the second link by another revolute joint. The end-effector link is
connected to the second link by a revolute joint but this joint make the end-effector part rotate
around its axis. Thus, we can consider the robot just has two degrees of freedom.

Figure 1: A 2DOF robot designed in SolidWorks


Detailed dimensions of each link of the 2DOF robot are shown in those figures from Figure 2
to Figure 5.

Figure 2: Dimension of the base link

Faculty of Mechanical Engineering @HCMUT 3


FL061

Figure 3: Dimension of the first link

Figure 4: Dimension of the second link

Figure 5: Dimension of the end-effector link

2.3 Export and Import files


2.3.1 Export files in SolidWorks
After designing and assembling robot, students should open assembly file of robot.
Next, you choose: Tool>Addin>Simscape Multibody Link (or Simmechanics Link).
After that, you choose: Tool>Simscape Multibody Link>Export>Simscape Multibody and
export to ‘robot2DOF.XML’ file.
You can choose “First generation” if using version MATLAB 2015b and before.
2.3.2 Import files to MATLAB
To import files to MATLAB, you use the following command line:
smimport(‘robot2DOF’)
In case of First Generation (in SolidWorks), we should use another command line as follows:
mech_import
Next, you choose the file XML (export from SolidWorks).

Faculty of Mechanical Engineering @HCMUT 4


FL061

2.4 Simscape Multibody Simulink


At its core, a multibody system is a set of bodies linked through joints and bound by kinematic
constraints such as gears. Forces and torques of various types enable you to actuate the various
bodies, while sensors enable you to sense the resulting motion. In Simscape™ Multibody™
software, you use blocks to directly represent these components.

2.4.1 Basic Model Components


In “Simulink Library Browser”, module Simscape>Multibody includes following groups:
Body Elements, Constraints, Curves and Surfaces, Forces and Torques, Frames and
Transforms, Gears and Couplings, Joints, and Utilities.
Consider the Simscape Multibody four-bar featured example. You can open this model at the
MATLAB® command prompt by entering “sm_four_bar”. The model consists of solid body
subsystems interconnected through joint blocks. The joint blocks define the degrees of freedom
available between bodies. The body subsystems define, through an underlying block diagram, the
solid properties of the body.

Figure 6: Four bar mechanism model

The body subsystems in turn consist of Extruded Solid blocks interconnected through Rigid
Transform blocks. The Extruded Solid blocks provide the solid properties, including geometry,
inertia, color, and frames—axis triads that encode all position and orientation information in a
model. The Rigid Transform blocks rotate and translate the solids to ensure proper body
assembly.

Faculty of Mechanical Engineering @HCMUT 5


FL061
2.4.2 Essential Steps to Build a Model
You use the same basic procedure for building a Simscape™ Multibody™ model regardless of its
complexity. The steps are similar to those for building a regular Simulink® model. More complex
models add steps without changing these basics.
1. Select Ground, Body, and Joint blocks. From the Bodies and Joints libraries, drag and drop
the Body and Joint blocks needed to represent your machine, including a Machine
Environment block and at least one Ground block, into a Simulink model window.
The Machine Environment block represents your machine's mechanical settings.
Ground blocks represent immobile ground points at rest in absolute (inertial) space.
Body blocks represent rigid bodies.
Joint blocks represent relative motions between the Body blocks to which they are connected.
2. Position and connect blocks. Place Joint and Body blocks in proper relative position in the
model window and connect them in the proper order. The essential result of this step is creation
of a valid tree block diagram made of
Machine Env — Ground — Joint — Body — Joint — Body — ... — Body
with an open or closed topology and where at least one of the bodies is a Ground block.
Connect exactly one environment block to a Ground.
A Body can have more than two Joints attached, marking a branching of the sequence. But
Joints must be attached to two and only two Bodies.
3. Configure Body blocks. Click the Body blocks to open their dialog boxes; specify their mass
properties (masses and moments of inertia), then position and orient the Bodies and Grounds
relative to the World coordinate system (CS) or to other CSs. You set up Body CSs here.
4. Configure Joint blocks. Click each of the Joint blocks to open its dialog box and set translation
and rotation axes and spherical pivot points.
5. Select, connect, and configure Constraint and Driver blocks. From the Constraints & Drivers
library, drag, drop, and connect Constraint and Driver blocks in between pairs of Body blocks.
Open and configure each Constraint/Driver's dialog box to restrict or drive the relative motion
between the two respective bodies of each constrained/driven pair.
6. Select, connect, and configure Actuator and Sensor blocks. From the Sensors & Actuators
library, drag and drop the Actuator and Sensor blocks that you need to impart and sense
motion. Reconfigure Body, Joint, and Constraint/Driver blocks to accept Sensor and Actuator
connections. Connect Sensor and Actuator blocks. Specify control signals (applied
forces/torques or motions) through Actuators and measure motions through Sensors.
Actuator and Sensor blocks connect Simscape Multibody blocks to normal Simulink blocks.
You cannot connect Simscape Multibody blocks to regular Simulink blocks otherwise.
Actuator blocks take import signals from normal Simulink blocks (for example, from the
Simulink Sources library) to actuate motion. Sensor block output ports generate Simulink
signals that you can feed to normal Simulink blocks (for example, from the Simulink Sinks
library).
In the most straightforward case, you apply forces/torques and initial conditions, then start the
simulation in the Forward Dynamics mode to obtain the resulting motions. In the Kinematics

Faculty of Mechanical Engineering @HCMUT 6


FL061
and Inverse Dynamics modes, you apply motions to all independent degrees of freedom. With
these modes, you can find the forces/torques needed to produce these imposed motions.
7. Encapsulate subsystems. Systems made from Simscape Multibody blocks can function as
subsystems of larger models, like subsystems in normal Simulink models. You can connect an
entire Simscape Multibody model as a subsystem to a larger model by using the Connection
Port block in the Utilities library.

2.4.3 Essential Steps to Configure and Run a Model


After you have built your model as a connected block diagram, you need to decide how you want
to run your model, configure Simscape Multibody and Simulink settings, and set up visualization.
- You can choose from among four Simscape Multibody analysis modes for simulating a
machine. The mode you will probably use most often is Forward Dynamics. But a more complete
analysis of a machine makes use of the Kinematics, Inverse Dynamics, and Trimming modes as
well. You can create multiple versions of the model, each with the same underlying machine, but
connected to Sensors and Actuators and configured differently for different modes.
- You can also use the powerful Simscape Multibody visualization and animation features.
You can visualize your model as you build it or after you are finished but before you start the
simulation, as a tool for debugging the model's geometry. You can also animate the model as you
simulate.
- Choose the analysis mode, as well as other important mechanical settings, in your
Machine Environment dialog. Start visualization and adjust Simulink settings in the Simulink
Configuration Parameters dialog. See Model and Simulate a Closed-Loop Machine for an
example.

3. Experimental Content
3.1 Time: 5 hours for each group of students.
3.2 Content
Students do following steps:
- Step 1: Design and assemble a 2DOF robot in SolidWorks (the robot is shown in Figure 1).
Next you should save this robot model as an assembly file.

- Step 2: Export a designed 2DOF robot to XML format file and import this file to MATLAB
using Simscape Multibody Link (2.3 Export and import files).

- Step 3: Change the color of each link of the robot: the base link is black, the first link is blue, the
second link is red, the end-effector link is green.

Guide: Double click the desired link, double click Solid block, choose: Properties/Graphic/Visual
Properties/Color

Faculty of Mechanical Engineering @HCMUT 7


FL061

Figure 7: How to change the color of links

For First generation, double click the desired link (need to change color) and choose
Visualization.

Figure 8: How to change the color of links (First Generation)

- Step 4: Attach a “Transform Sensor” (For First generation is “Body Sensor’’) to the end-effector
link (KhauBut) to measure the position of the end-effector and show this position on XY Graph.

Guide: In end-effector link, add a new coordinate system. After that, attach “Transform Sensor”
to this frame.

Faculty of Mechanical Engineering @HCMUT 8


FL061

a) New version b) First Generation


Figure 9: Attach Body Sensor to End-effector link

For First Generation, in the end-effector link, add a CS3 coordinate system. The origin of this
frame is in the top of the end-effector. Next, we need to attach a “Body Sensor” in this frame.

- Step 5: Attach sensors “Joint Sensor” (First Generation) to joint 1 and joint 2 to measure the
angles as these joints and show on Scope. In case of new version, we attach directly to the joint
and choose “Sensor”.

a) New version b) First generation


Figure 10: How to use a Joint Sensor

- Step 6: Attach actuators “Joint Actuator” (First Generation) to joint 1 and joint 2. Choose control
mode of Force or Motion. In case of new version, we attach directly to the joint and choose
“Actuator”.

a) New version b) First generation


Figure 11: How to use a Joint Actuator

Faculty of Mechanical Engineering @HCMUT 9


FL061

- Step 7: Program to control joint 1 and joint 2 to rotate desired angles according to time using
“ramp” block. (Example: Joint 1 rotates 60 degrees, Joint 2 rotate 90 degrees).

Figure 12: Total model in new version

Figure 13: Total model in First Generation

References
[1] Website MATLAB

Faculty of Mechanical Engineering @HCMUT 10


FL061
4. Experimental Results (Note: Students should submit this paper to the Teacher after class)
Step 1:

Not work □ Not work perfectly □ Work perfectly □


Another Idea:

Step 2:

Not work □ Not work perfectly □ Work perfectly □


Another Idea:

Step 3:

Not work □ Not work perfectly □ Work perfectly □


Another Idea:

Step 4:

Not work □ Not work perfectly □ Work perfectly □


Another Idea:

Step 5:

Not work □ Not work perfectly □ Work perfectly □


Another Idea:

Step 6:

Not work □ Not work perfectly □ Work perfectly □


Another Idea:

Step 7:

Not work □ Not work perfectly □ Work perfectly □


Another Idea:

Name of Student:……….………….……..………Student ID:……...….………….Group:………


Name of Student:……….………….……..………Student ID:……...….………….Group:………
Name of Student:……….………….……..………Student ID:……...….………….Group:………
Name of Student:……….………….……..………Student ID:……...….………….Group:………
Name of Student:……….………….……..………Student ID:……...….………….Group:………
Faculty of Mechanical Engineering @HCMUT 11

You might also like