Sunteți pe pagina 1din 10

Using MATLAB to Advance

the Robotics Laboratory


CARTER HAMILTON
Department of Mechanical and Manufacturing Engineering, Miami University, Oxford, Ohio

Received 30 January 2006; accepted 15 November 2006

ABSTRACT: The RV-M1 Movemaster from Mitsubishi Electric is an excellent educational


robot for students as they learn to program automated tasks and simulate manufacturing
processes. Because it was publicly introduced in 1991, the RV-M1 utilizes the DOS-based
QBASIC computer code as the primary interface language with the robotic drive unit. Todays
students, however, often face great frustration when they work with the unfamiliar QBASIC
language and the even more unfamiliar DOS operating system. To address these shortcomings,
the Mechanical and Manufacturing Engineering Department at Miami University introduced
MATLAB as an alternative Window-based interface language to better reflect the current
educational experience of students and to increase the functionality of the RV-M1 robotic
arms. MATLAB successfully overcomes the limitations of the QBASIC/DOS environment and
augments the capability of the RV-M1. Examples of the extended capability include the use of
graphical user interfaces to facilitate student interaction with the robotic arm and the ability to
move the robot along contoured paths. With MATLAB, instructors can develop projects that
enhance the student experience with the RV-M1 and give them greater insight into robotic
applications. 2007 Wiley Periodicals, Inc. Comput Appl Eng Educ 15: 205213, 2007; Published online in
Wiley InterScience (www.interscience.wiley.com); DOI 10.1002/cae.20143

Keywords:

robotics; serial communication; interface language; MATLAB; student survey

INTRODUCTION
The RV-M1 Movemaster from Mitsubishi Electric is
a 5-axis, vertically articulated robotic arm suitable
not only to light-duty industrial settings, but also to
educational and scientific laboratories. Schematically
shown in Figure 1, Mitsubishi Electric maintains that
the RV-M1 is the best-selling educational robot in the
world [1,2]. The RV-M1 offers both direct robotic
control by means of a Teach Pendant and programmable robotic control by a personal computer (PC)
Correspondence to C. Hamilton (hamiltbc@muohio.edu).
2007 Wiley Periodicals Inc.

interface with the drive unit. PC-interface with the


robotic arm is achieved through either Centronic
parallel communication (i.e., commands on the PCscreen are printed to the drive unit) or more
commonly through RS-232 serial communication.
The programming language of the RV-M1 itself is
similar in structure and syntax to BASIC, but it
utilizes a set of 63 unique commands to control the
motion of the robotic arm, receive input signals, direct
output signals and interpret the flow of the program.
The Mechanical and Manufacturing Engineering
(MME) Department at Miami University utilizes four
RV-M1 robotic arms for the laboratory component
of its fourth-year undergraduate class in Advanced
205

206

HAMILTON

Figure 1

Schematic of the RV-M1 Movemaster from Mitsubishi Electric.

Manufacturing. The robotic arms serve as excellent


educational tools for students as they program
automated tasks and simulate actual manufacturing
processes. In general, course evaluations demonstrate
that students enjoy the hands-on nature of the robotics
lab, but are frustrated with the interface environment
between the PC and the drive unit of the robot.
Since the RV-M1 was initially introduced in the
early 1990s, the typical (and recommended) PCinterface utilizes the DOS-based QBASIC computer
code as the interface language and primary method of
interacting with the drive unit. To the students of the
1980s and of the early 1990s, DOS and QBASIC were
not an unusual part of their education and computing experience; however, with the introduction and
adoption of Windows in the PC environment, DOS
and QBASIC now serve as significant stumbling
blocks to students of the 21st century.
For the most part, students will initially approach
the DOS interface of the RV-M1s objectively and are
willing to learn new methods associated with the
robotics lab. Frustrations, however, quickly appear
when students habitually attempt to use Windowsbased shortcuts, such as Ctrl-C or Ctrl-V, during
program editing and/or then attempt to save their
programs with file names that are longer than eight
characters or that contain spaces. Figure 2 summarizes
the results of a survey given to 36 fourth-year students
who were asked to rate their familiarity with DOS and

Windows prior to taking the Advanced Manufacturing


course on a scale of 15 with the following scale
definitions: (1) have had no experience, (2) have had
limited experience, but cannot work independently,
(3) have had moderate experience, and can work
somewhat independently, (4) have had ample experience, and can work independently, and (5) have had
extensive experience. Not surprisingly, students rated
their experience with Windows much higher than that
with DOS, giving an average score of 4.7 to Windows
and 2.6 to DOS. In fact, 13 out of the 36 respondents
(36%) rated their familiarity with DOS at a 2 or less.
No respondents rated their experience with Windows
less than 4.
Figure 3 displays the results of a survey of the
same student population when asked to rate their
familiarity with QBASIC. Fifty-three percent of the
respondents indicated that they had no experience
with the interface language, with an average rating of
1.7. Though it is not unusual for students to have
limited experience with a specific computer language
offered in concert with a class such as robotics,
students are met with the additional challenge of
using the programming language in an unfamiliar
operating system like DOS. From the point of view of
an instructor leading a robotics lab with the current
RV-M1 configuration, not only must he/she teach the
RV-M1 programming language and the QBASIC
interface language, but he/she must also devote time

USING MATLAB TO ADVANCE THE ROBOTICS LABORATORY

207

Figure 2 Survey results of fourth-years students regarding DOS and Windows.

to educating students in an essentially new operating


system, thus diverting time and attention from the
ultimate objective of the class.
Interestingly, it is not just the students that are
frustrated with the DOS/QBASIC interface environment. Though Windows is the primary operating
system for todays PCs, Windows does offer limited
support for DOS applications. A significant change,
however, occurred in the ability to support DOS
between the Windows98 and WindowsXP operating
systems. Information Technology Support Services at
Miami University discovered that while Windows98

reliably executes QBASIC, WindowsXP does not


stably run the program. The IT department, therefore,
is currently obliged to maintain Windows98 on the
robotics lab computers despite the fact that the platform
has been phased out in favor of the XP operating
system. IT has strongly suggested that the PC-interface
with the robotics arms be migrated from a DOS-based
system to a Windows-based system, thereby facilitating
their computer support for the lab.
One solution to the limitations of the current
interface configuration with the RV-M1 robotic arms
is to purchase new systems or upgrade the existing

Figure 3 Survey results of fourth-year students regarding QBASIC.

208

HAMILTON

systems with new drive units and software. Unfortunately, with the market price of a used RV-M1 system
approximately $25,000, the budgetary pressure when
considering the need for multiple units makes this
recourse somewhat improbable in short-term planning
[3]. However, to immediately address and overcome
the shortcomings of the DOS-based interface environment, MME Department set forth to identify a new
interface system for the robotics lab with the following objectives:
1. To introduce a new interface language/environment that is compatible with WindowsXP and
that reflects the current educational experience
of students at Miami University.
2. To introduce a new interface language/environment that is will increase the functionality of the
RV-M1 robotic arms and more accurately reflect
configurations in todays industry.
In Spring 2004, the MME Department at Miami
University introduced at new first-year level course in
Problem Solving and Design. A primary educational
objective of the course was to expose students
in the Engineering discipline to MATLAB as a tool
for problem solving, analysis, design and modeling.
The formation of the new course was part of a greater
objective of the department to utilize MATLAB
throughout the Engineering curriculum, including
the first-year follow on class in Engineering Design
and Computer Graphics. To assess the student familiarity with MATLAB, a survey was given to the same
fourth-year student population and asked to rate their

familiarity with the program based on the identical


5-point scale. Figure 4 displays the survey results and
shows that the average rating for MATLAB was only
marginally greater than that for QBASIC, 2.3 against
1.7; however, the percentage of students indicating that
they had no experience with the application fell from
53% with QBASIC to 19% with MATLAB. Since
MME only committed to MATLAB throughout its
curriculum in 2004, the limited experience of the
fourth-year students with the program is not a surprising or disappointing result. Even though MATLAB
may be unfamiliar to the veteran students, the fact that
it is a Windows-based program indicates that the
instructor does not need to devote time to educate the
students in the actual operating system, as required for
QBASIC.
Figure 5 summarizes the results of a survey given
to fifteen first and second-year students who were
asked to rate their familiarity with MATLAB and
QBASIC based on the same 5-point scale as the
fourth-year student survey. These students rated their
average experience with MATLAB much higher than
that with QBASIC, 3.1 against 1.2, and rated their
average MATLAB experience greater than that of the
fourth-year students. This result is in accordance
with the recent decision of MME to introduce the
application throughout its curriculum, particularly to
the younger students and demonstrates that MATLAB
better reflects the current educational experience
of students than QBASIC. As an Engineering tool,
the Windows-based MATLAB easily supports data
analysis, numerical modeling, design, simulation,
structured programming and GUI applications, as

Figure 4 Survey results of fourth-year students regarding MATLAB.

USING MATLAB TO ADVANCE THE ROBOTICS LABORATORY

209

Figure 5 Survey results of first/second-year students regarding QBASIC and MATLAB.

well as many other program tools. Clearly, utilizing


MATLAB as the interface language with the RV-M1
robotic arms would increase their functionality and
open new programming/simulation opportunities for
the students when working with them. MATLAB,
therefore, fulfills both objectives for the new interface
environment.

SERIAL COMMUNICATION
The MATLAB software did not actually offer serial
port communication until the debut of Release 12 in
2000 [4]. Now, MATLAB is fully functional in RS-232
communication, and for recent computer models that
only offer USB connections, USB/RS-232 adapters are
readily available. Serial communication in MATLAB
can be established in either the Command Window
or in the M-file Editor through the following lines of
code:
s serial(COM1);
fopen(s)
The first line assigns the communication port,
COM1, to the variable, s, while the second line of
code simply opens the port for writing data from the
PC to the instrument (in this case the drive unit of the
RV-M1). It should be noted that in MATLAB
the default condition for the flow of data between
the PC and the instrument is none. Under this
condition, the user can write data from the PC to the
instrument Buffer, but cannot read or access data from
the Buffer. Many commands in the RV-M1 language
require data to be read from the Buffer of the drive

unit, such as the Position Read, PR, command that


returns the world space coordinates of predefined
positions when executed. In order to establish the read
functionality, the flow control of the serial port must
be set to hardware in the following manner:
s.flowcontrol hardware. This aspect is discussed
in greater detail in the proceeding section.
Once serial communication is properly established, commands may be written to the drive unit of
the RV-M1 utilizing MATLABs fprintf command
in the following format: fprintf(s, String), where s
is the variable associated with the port definition, and
String is simply a string variable in the RV-M1
robotic language. Figure 6 demonstrates a very simple
MATLAB M-file called sample that will action
the robotic arm initially to the nest position, NT,
and then to the origin, OG. A 1-s pause is placed
between the robotic commands to ensure that the RVM1 drive unit has time to receive and process the
initial command before the second one is received.
In comparison, consider the equivalent QBASIC
program show in Figure 7. In QBASIC, serial port
communication is established with the OPEN
command through which the baud rate, parity and bits
are defined and the port is assigned to #1 for random
access. Commands are then written to the drive unit
utilizing the PRINT #1, String format. Though
these sample MATLAB and QBASIC programs are
very similar in structure, the unfamiliar DOS environment provides an additional challenge to the student
users. In addition, the method of serial port definition in
MATLAB is more straightforward to the user than that
of QBASIC since the appropriate baud rate, parity and
bits are automatically assigned and do not need to be
specified in MATLAB.

210

HAMILTON

Figure 6 MATLAB robotic program shown in the M-file editor.

READING DATA FROM THE DRIVE UNIT


As mentioned previously, numerous commands in
the RV-M1 language require the interface language
to read data from the Buffer of the drive unit. The
two primary commands for this action are Position
Read, PR, and Where, WH. Position Read simply
returns the world space coordinates of the robotic arm (x,
y, z, roll angle of wrist, pitch angle of wrist) for
predefined positions when executed, and Where returns
the world space coordinates of the current location of
the robotic arm. For both commands, the coordinates
are formatted as a single string variable rather than a
series of integer variables. The following lines of code
demonstrate the successful execution of the Position
Read command in QBASIC:

OPEN COM1:9600, N,8,1,DS60000,


CD0 FOR RANDOM AS #1
INPUT Enter the Desired Position
Number:, P
PRINT #1, PR STR$(P)
LINE INPUT #1, A$
PRINT A$
END
In this program, the user inputs the relevant
predefined position number which is then assigned
the variable P. The next line of code writes the
PR command to the drive unit after converting the
position number from an integer to a string through
the STR$(P) command. Since the drive unit can
only accept string variables, the user input must be

Figure 7 QBASIC robotic program shown in the QBASIC editor.

USING MATLAB TO ADVANCE THE ROBOTICS LABORATORY

reformatted prior to writing. For example, if the


user were to input the position number 10, QBASIC
will compile this command line as a single string
equivalent to PR 10. The world space coordinates
are assigned the string variable A$ and displayed to
the user.
In MATLAB, the default condition for the flow
of data between the PC and the drive unit does not
facilitate the reading of data from the instrument
Buffer; therefore, the Flow Control setting must be
changed to hardware control after the serial port
has been opened. The equivalent Position Read
program in MATLAB is shown in the following
lines of code:
s serial(COM1);
fopen(s) s.flowcontrol hardware;
P input(Enter the Desired Position
Number:);
fprintf(s,sprintf(%s %s\n,PR,
int 2str(P)))
A fscanf(s);
fprintf(A)
fclose(s);
Like the QBASIC program, the user inputs the
desired position number which is then assigned the
variable P. The next line of code utilizes the formatted
string command, sprintf, to write the PR command to
the drive unit. The structure of the sprintf command is
(string format, String 1, String 2) and ensures
that the PR command plus the position number will be
written as a single string variable to the drive unit. The
additional int2str(P) command is utilized to convert
the user input from an integer to a string. Again, if
the position number of interest were 10, MATLAB
will compile this command line as a single string
equivalent to PR 10. The world space coordinates
are read from the Buffer by means the fscanf(s)
command, assigned to the variable A and displayed to
the user.
Though the MATLAB program may be visually
more complex than QBASIC program due to the
need to define the appropriate flow control and to use
the sprintf command, this simple program begins to
underscore some of the major advantages of MATLAB
over QBASIC. In general, QBASIC does not provide
the user with a convenient method for handling
multiple inputs. That is, if a user wanted to know the
world space coordinates of multiple predefined positions, he/she would need to rerun the QBASIC program
for each position of interest. In MATLAB, however,
the program can be easily modified with a for-loop so
that the user may input all desired positions as single

211

row matrix, and the coordinates of each position of


interest are displayed. The following lines of code
demonstrate this modification with all other lines
remaining the same:
P input(Enter the Desired Position
Numbers [1 2 3 etc.]: );
B size(P);
for i 1:B(1,2)
pause(1)
fprintf(s,sprintf(%s %s\n,PR,
int2str(P(1,i))))
pr fscanf(s);
fprintf(Point %1.0f: %s,P(1,i),
pr)
end
As another example of the MATLAB advantage,
the programmer can create graphical user interfaces
(GUIs) based on the preceding program to simplify
the interaction with the robotic arm [5,6]. Figure 8
displays the GUI for the Position Read program
with the Where functionality included. The user
may enter multiple, pre-assigned positions under
the What Are My Saved Positions? box and
see the results displayed in the World Space
Coordinates box, or execute the Where command
to see the current coordinates of the robotic arm. With
a GUI such as this, the instructor now has the option of
exposing the students to rigorous programming in the
interface language or of presenting the GUI directly to
the students allowing more time to focus on actual
applications with the robots. With either approach,
MATLAB enhances the student experience with the
RV-M1 and augments the instructional tools available
to the teacher [7].
Additionally, MATLAB provides the programmer with powerful control over data and formatting.
For example, a peculiarity to the RV-M1 drive unit
is that the Position Read and Where commands
return coordinates with the indices accurate to the
one decimal place; however, if the user utilizes
actual coordinate positions to action the robot, the
drive unit will only accept the indices in the
coordinate string as whole numbers. The user may
find it necessary in some applications to query the
drive unit for certain position coordinates, manipulate the values and then write new coordinates back
to the robot for movement. QBASIC does not have
a convenient method to execute this task; however,
MATLAB offers robust data manipulation and
smooth conversion from string variables to integers
and vice versa. An example of this concept is
explored in the next section.

212

HAMILTON

Figure 8 MATLAB graphical user interface for finding world space coordinates.

SIMULATION OF CONTINUOUS
PATH CONTROL
The RV-M1 accomplishes tasks by moving between
predefined positions. Motion between consecutive
points of interest occurs under point-to-point control
with the RV-M1 drive unit interpolating the shortest
linear path between positions. The RV-M1, however,
does not offer direct continuous path control for which
circular interpolations are feasible for contoured
motion. If desired, the user could teach the robot
numerous points along a curvilinear path such that
continuous path control is simulated during program
execution. This approach, however, is not very practical
and would be quite inefficient. With MATLAB as the
interface language, it is possible to simulate continuous
path control through the programming structure
and leveraging MATLABs superior data manipulation. In the following example, the program executes
the Where command to determine the current coordinates of the robot position and then moves the robot
in a circular path in the xz plane centered about
the current position with a radius determined by the
user:
fprintf(s,WH)
wh(1,:) floor(str2num(fscanf (s)));
R input(Enter the Radius: );
for theta 0:10: 360

x floor(R*cos(theta*pi()/180))
wh(1,1);
z floor(R*sin(theta*pi()/180))
wh(1,3);
fprintf(s,sprintf (MP%1.0f,
%1.0f,%1.0f,%
1.0f,%1.0f,x,wh(1,2),z,
wh(1,4), wh(1,5)));
end
In this program, the coordinates from the Where
command are captured into a single row matrix and
rounded down to the nearest whole number by means
of the floor function. After the user enters the desired
radius of circular motion, the new x and z coordinates
are iteratively calculated, rounded down and written
back to the drive unit with the original values of the
other indices. The program employs the Move Position,
MP, command from the RV-M1 language to move
the arm to the location of the assigned coordinate
values. This program is just a single demonstration of
the added functionality MATLAB can bring to the
RV-M1 and other robotic systems [810].

CONCLUSION
The RV-M1 Movemaster is an excellent educational
robot for students as they learn to program automated

USING MATLAB TO ADVANCE THE ROBOTICS LABORATORY

tasks and simulate various manufacturing processes. Students, however, often face great frustration when they work with the QBASIC interface
language in the unfamiliar DOS operating system
common to the RV-M1 platform. The Windowsbased MATLAB program is an alternative interface language that successfully overcomes the
limitations of the QBASIC/DOS environment and
increases the functionality of the RV-M1. This
article presented the necessary steps to introduce
MATLAB as the interface language and the required
procedure to establish serial port communication
between the PC and the drive unit of the RV-M1.
Also presented are detailed examples of the
enhanced capabilities MATLAB brings to the
robotic arm, including the utilization of GUIs and
the simulation of continuous path control. With
greater functionality and flexibility, the RV-M1 more
accurately represents actual manufacturing processes and accomplishes more demanding tasks.
Ultimately, MATLAB equips the instructor with
the ability to create and assign projects that
enhance the student experience with the RV-M1
and gives them greater insight into robotic applications. Miami University will officially introduce
MATLAB as the interface language during the
spring semester of 2006 and will survey students
to assess the efficacy of the change and their
impressions.

BIOGRAPHY
Carter Hamilton is an assistant professor in
the Department of Mechanical and Manufacturing Engineering at Miami University,
Oxford, Ohio. Even though he earned his
PhD from the Georgia Institute of Technology in Metallurgical Engineering, Dr. Hamilton thoroughly enjoys teaching classes in
advanced manufacturing, statistical quality
control, statics, and introduction to engineering and design. He views MATLAB as a
critical tool to young engineers and integrates the program into all
course curricula. His other research interests include friction stir
welding and the development of aluminum alloys.

213

REFERENCES
[1] Mitsubishi Electric Corporation, Industrial MicroRobot System Model RV- M1: Instruction Manual,
Nagoya, Japan, 1991.
[2] Mitsubishi Electric Industrial Automation, Official
Website www.mitsubishi-automation.com, Vernon
Hills, IL, 2005.
[3] Rixan Associates, Inc., Official Website www.
roboticsonline.com, Dayton, OH, 2005.
[4] J. A. Piepmeier, K. A. Knowles, and B. E. Bishop,
The use of MATLAB for robotic control in an
undergraduate robotics laboratory, Comput Educ J 13
(2003), 6875.
[5] S. S. Joshi, Development and implementation of a
MATLAB simulation project for a multidisciplinary
graduate course in autonomous robotics, Comput Appl
Eng Educ 12 (2004), 5464.
[6] K. Erenturk, MATLAB-based GUIs for fuzzy logic
controller design and applications to PMDC motor and
AVR control, Comput Appl Eng Educ 13 (2005),
1025.
[7] L. Zhongming and C. J. Quinn, MATLAB in teaching a
robotics course, Comput Educ J 4 (1994), 5257.
[8] J. N. Pires, Interfacing industrial R&A equipment using
MATLAB, IEEE Robot Autom Mag 7 (2000), 3241.
[9] P. I. Corke, A robotics toolbox for MATLAB, IEEE
Robot Autom Mag 3 (1996), 2432.
[10] A. Breijs, B. Klaasens, and R. Babuska, Automated
design environment for serial industrial manipulators,
Ind Robot 32 (2005), 3234.

S-ar putea să vă placă și