Sie sind auf Seite 1von 22

Faculty of Engineering

MEC 4100 Robotics

Assignment 1

Robot Programming

Group no: 2

Thomas Brandner P 3492652

Marvic Cordina 31794 (G)

Maria Cutajar -102294 (M)

14th December 2016


PROBLEM DEFINITION

The aim of this programming assignment was to write the code of a program to be run on the
Mitsubishi RV-6SL for serving cocktail drinks. The number of orders and the different drinks were
inputted into the system by the user and the robot made the cocktails using the equipment in
the lab and served on a tray.

The second part of the assignment involved changing the position of the tray and teaching the
robot the new position of the tray. The robot was to check that all locations on the tray were
within its reach prior to starting to serve the drinks.

SOLUTION APPROACH
It was first agreed that the problem was a pick-and-place one where the robot would pick up the
glass, fill it with the ordered drink, and place the glass back in its respective position on the tray.
For the scope of this assignment it was decided that three different drinks could be chosen and
that in one whole run, the robot can serve up to four people. Should it be required to serve more
people, the user can opt to run the program multiple times over, in multiples of four.
Since it was decided to serve the drinks four at a time, the use of a palletising function would not
be economic, since four positions would still have to be specified in order to define the pallet.
Additionally, once the position of the pallet would be arbitrarily changed, the defining positions
would need to be re-programmed prior to running the program. Instead, the four different
positions of the glasses were to be defined individually in the first run of the program. The user
would however be free to provide the translation co-ordinates in the x- and y-direction of the
first cup provided that the orientation of the tray is maintained.

ANALYSIS UNDERTAKEN
A critical step in writing the program was to inspect the geometry of the workspace in order to
make sure that the program works properly. In approaching the cups or the bottles, the robot
would ideally pause and advance towards these locations slowly especially when the cups are
filled with liquids. An offset of 100mm was specified away from each of the bottles and the cups.

2
The gripper was programmed to approach each of these positions from a vertical distance above
or below them. The distance between each one of the cups on the tray was also measured so
that their position could be defined in terms of the location of one of the cups.
In fact, when running the program in the lab during one of the preliminary sessions, it was found
that using the tray available in the lab, the glasses were too close and while picking one of the
glasses it would hit another glass next to it. Since this could not be avoided due to the grippers
width, it was decided to place the glasses on a piece of cardboard further away from each other.
The implementation of loops and subroutines foolproof the program from malfunctioning due to
wrong user input. Should the user input an invalid integer, the program will not run and an error
will show up in the output window on the computer allowing the user to input the correct value.

Figure 1: It was noticed that the location of the glasses on the tray would be too close and that in picking one cup, the robot would
knock the adjacent cup

3
ANNOTATED PROGRAM
Below is a copy of the annotated program including the relevant comments which explain the
thought-process behind the program.
10 '===================OPEN COMMUNICATION=================
20 OPEN "COM3:" AS #1 'Open standard RS-232C line file No.1
30 '==================DEFINING THE VARIABLES
=======================
40 DEF POS PBOTTLE1 'Declaring XYZ type position variables of
the bottles and the cups
50 DEF POS PBOTTLE2
60 DEF POS PBOTTLE3
70 DEF POS PCUP1
80 DEF POS PCUP2
90 DEF POS PCUP3
100 DEF POS PCUP4
110 DEF POS PWAIT 'This is the home position to which the
robot will return between one loop and the next.
120 PBOTTLE1=P2 'variable PBOTTLE1 is assigned to position
P2.
130 PBOTTLE2=P3 'The same procedure applies to the rest of
the variables.
140 PBOTTLE3=P4
150 PCUP1=P5
160 PCUP2=PCUP1
170 PCUP3=PCUP1
180 PCUP4=PCUP1
190 PCUP2.Y=PCUP2.Y-85
200 PCUP3.Y=PCUP3.Y-2*85
210 PCUP4.Y=PCUP4.Y-3*85
220 PWAIT=P1

4
230 OVRD 5 'Specifies the speed of the robot movement
as a value in the range from 1 to 100%.
240 DEF INTE DRINKS 'Variable how many drinks were ordered? (1-
4)
250 DEF INTE DRINKP1 'Drink of Person1Variables are assigned
as integers which will correspond to the respective drink
chosen.
260 DEF INTE DRINKP2 'Drink of Person2
270 DEF INTE DRINKP3 'Drink of Person3
280 DEF INTE DRINKP4 'Drink of Person4
290 DEF INTE COUNT 'Variable to count the served drinks
300 DEF INTE HSPEED 'HSPEED variable of type integer is
defined
310 DEF INTE LSPEED 'LSPEED variable of type integer is
defined
320 DEF INTE OFFSET 'This will be the distance to which the
robot will retract away from the cups and bottles when
approaching them
330 DEF INTE MENU
340 DEF INTE PALETTX
350 DEF INTE PALETTY
360 COUNT%=1 'Starts serving drink 1
370 OFFSET%=100
380 DRINKS%=5 'How many people want a drink
390 DRINKP1%=5 'Person 1
400 DRINKP2%=5 'Person 2
410 DRINKP3%=5 'Person 3
420 DRINKP4%=5 'Person 4
430 MENU%=5 'Decision of serving the drink or
changing the palette position
440 PALETTX%=0
450 PALETTY%=0

5
460 WHILE (MENU>2) OR (MENU<1) 'While the variable menu is
greater than 2 or less than 1 implement the following loop. The
user will be allowed to change the position of the the palette
or to use the default position and start running the program
470 PRINT#1, "PRESS 1 FOR MIXING COCKTAILS OR PRESS 2 FOR
CHANGING THE PALETTE POSITION AND MIXING AFTERWARDS"
480 INPUT#1, MENU
490 WEND
500 IF MENU%=1 THEN
510 GOSUB *SUBMIX
520 ENDIF
530 IF MENU%=2 THEN
540 GOSUB *SUBPAL
550 GOSUB *SUBMIX
560 ENDIF
570 END
580 '============SUBROUTINE PALETT================
590 *SUBPAL 'This subroutine allows the user to
change the position of the pallette provided that measurements
have been taken and orientation is maintained
600 PRINT#1, "How many mm do you want to change the position of
CUP1 in X-Direction?"
610 INPUT#1, PALETTX
620 PCUP1.X=PCUP1.X+ PALETTX
630 PRINT#1, "How many mm do you want to change the position of
CUP1 in Y-Direction?"
640 INPUT#1, PALETTY
650 PCUP1.Y=PCUP1.Y+ PALETTY
660 PCUP2=PCUP1
670 PCUP3=PCUP1
680 PCUP4=PCUP1
690 PCUP2.Y=PCUP2.Y-85

6
700 PCUP3.Y=PCUP3.Y-2*85
710 PCUP4.Y=PCUP4.Y-3*85
720 GOSUB *RANGE
730 RETURN
740 *SUBMIX
750 WHILE (DRINKS>4) OR (DRINKS<1)
760 PRINT#1, "HOW MANY DRINKS DO YOU WANT TO ORDER?? (1-4)" 'The
users can now decide how many drinks they want to order
770 INPUT#1, DRINKS
780 WEND
790 '==========Moves to Waiting Position===========
800 GOSUB *SUBSERVO
810 MOV PWAIT
820 HOPEN 1
830 '======MAIN WHILE LOOP======
840 WHILE(COUNT%<=DRINKS%)
850 IF COUNT%=1 THEN
860 'Asking which drink P1 wants
870 WHILE (DRINKP1>3) OR (DRINKP1<1)
880 PRINT#1, "Which drink does person 1 want? (1:Water, 2:Coke,
3:Kinnie)"
890 INPUT#1, DRINKP1
900 WEND
910 'MOV To CUP1 and back to WAITING Position
920 PCUP1.Z= PCUP1.Z+OFFSET% 'OFFSET mm above the cup
930 MOV PCUP1
940 DLY 1
950 PCUP1.Z= PCUP1.Z-OFFSET% 'Original position
960 MVS PCUP1
970 DLY 1
980 HCLOSE 1
990 PCUP1.Z = PCUP1.Z+OFFSET 'OFFSET mm in Z direction

7
1000 MVS PCUP1
1010 DLY 1
1020 PCUP1.Z = PCUP1.Z-OFFSET 'PCup1 original position
1030 MOV PWAIT
1040 DLY 1
1050 IF DRINKP1%=1 THEN
1060 GOSUB *SUBBOT1
1070 ENDIF
1080 DLY 1
1090 IF DRINKP1%=2 THEN
1100 GOSUB *SUBBOT2
1110 ENDIF
1120 DLY 1
1130 IF DRINKP1%=3 THEN
1140 GOSUB *SUBBOT3
1150 ENDIF
1160 DLY 1
1170 'MOV TO PCup1 and back to WAITING Position
1180 PCUP1.Z=PCUP1.Z+OFFSET% 'OFFSET mm above
1190 MOV PCUP1
1200 DLY 1
1210 PCUP1.Z=PCUP1.Z-OFFSET% 'origin position
1220 MVS PCUP1
1230 DLY 1
1240 HOPEN 1
1250 DLY 1
1260 PCUP1.Z=PCUP1.Z+OFFSET% 'OFFSET mm above
1270 MVS PCUP1
1280 DLY 1
1290 PCUP1.Z=PCUP1.Z-OFFSET% 'origin position
1300 MOV PWAIT
1310 DLY 1

8
1320 ENDIF
1330 IF COUNT%=2 THEN
1340 'Asking which drink P2 wants
1350 WHILE (DRINKP2>3) OR (DRINKP2<1)
1360 PRINT#1, "Which drink does person 2 want? (1:Water,
2:Coke, 3:Kinnie)"
1370 INPUT#1, DRINKP2
1380 WEND
1390 'MOV To CUP2 and back to WAITING Position
1400 PCUP2.Z= PCUP2.Z+OFFSET% 'OFFESET mm above Cup2
1410 MOV PCUP2
1420 DLY 1
1430 PCUP2.Z= PCUP2.Z-OFFSET% 'Origin position
1440 MVS PCUP2
1450 DLY 1
1460 HCLOSE 1
1470 DLY 1
1480 PCUP2.Z = PCUP2.Z+OFFSET 'OFFESET mm in Z direction
1490 MVS PCUP2
1500 DLY 1
1510 PCUP2.Z = PCUP2.Z-OFFSET 'PCup2 origin position
1520 MOV PWAIT
1530 DLY 1
1540 IF DRINKP2%=1 THEN
1550 GOSUB *SUBBOT1
1560 DLY 1
1570 ENDIF
1580 IF DRINKP2%=2 THEN
1590 GOSUB *SUBBOT2
1600 DLY 1
1610 ENDIF
1620 IF DRINKP2%=3 THEN

9
1630 GOSUB *SUBBOT3
1640 DLY 1
1650 ENDIF
1660 'MOV TO PCup2 and back to WAITING Position
1670 PCUP2.Z=PCUP2.Z+OFFSET% 'OFFSET mm above
1680 MOV PCUP2
1690 DLY 1
1700 PCUP2.Z=PCUP2.Z-OFFSET% 'origin position
1710 MVS PCUP2
1720 DLY 1
1730 HOPEN 1
1740 DLY 1
1750 PCUP2.Z=PCUP2.Z+OFFSET% 'OFFSET mm above
1760 MVS PCUP2
1770 DLY 1
1780 PCUP2.Z=PCUP2.Z-OFFSET% 'origin position
1790 MOV PWAIT
1800 DLY 1
1810 ENDIF
1820 IF COUNT%=3 THEN
1830 'Asking which drink P3 wants
1840 WHILE (DRINKP3>3) OR (DRINKP3<1)
1850 PRINT#1, "Which drink does person 3 want? (1:Water,
2:Coke, 3:Kinnie)"
1860 INPUT#1, DRINKP3
1870 WEND
1880 'MOV To CUP3 and back to WAITING Position
1890 PCUP3.Z= PCUP3.Z+OFFSET% 'OFFESET mm above Cup3
1900 MOV PCUP3
1910 DLY 1
1920 PCUP3.Z= PCUP3.Z-OFFSET% 'Origin position
1930 MVS PCUP3

10
1940 DLY 1
1950 HCLOSE 1
1960 DLY 1
1970 PCUP3.Z = PCUP3.Z+OFFSET 'OFFESET mm in Z direction
1980 MVS PCUP3
1990 DLY 1
2000 PCUP3.Z = PCUP3.Z-OFFSET 'PCup3 origin position
2010 MOV PWAIT
2020 DLY 1
2030 IF DRINKP3%=1 THEN
2040 GOSUB *SUBBOT1
2050 DLY 1
2060 ENDIF
2070 IF DRINKP3%=2 THEN
2080 GOSUB *SUBBOT2
2090 DLY 1
2100 ENDIF
2110 IF DRINKP3%=3 THEN
2120 GOSUB *SUBBOT3
2130 DLY 1
2140 ENDIF
2150 'MOV TO PCup3 and back to WAITING Position
2160 PCUP3.Z=PCUP3.Z+OFFSET% 'OFFSET mm above
2170 MOV PCUP3
2180 DLY 1
2190 PCUP3.Z=PCUP3.Z-OFFSET% 'origin position
2200 MVS PCUP3
2210 DLY 1
2220 HOPEN 1
2230 DLY 1
2240 PCUP3.Z=PCUP3.Z+OFFSET% 'OFFSET mm above
2250 MVS PCUP3

11
2260 DLY 1
2270 PCUP3.Z=PCUP3.Z-OFFSET% 'origin position
2280 MOV PWAIT
2290 DLY 1
2300 ENDIF
2310 IF COUNT%=4 THEN
2320 'Asking which drink P4 wants
2330 WHILE (DRINKP4>3) OR (DRINKP4<1)
2340 PRINT#1, "Which drink does person 4 want? (1:Water,
2:Coke, 3:Kinnie)"
2350 INPUT#1, DRINKP4
2360 WEND
2370 'MOV To CUP4 and back to WAITING Position
2380 PCUP4.Z= PCUP4.Z+OFFSET% 'OFFESET mm above PCup4
2390 MOV PCUP4
2400 DLY 1
2410 PCUP4.Z= PCUP4.Z-OFFSET% 'Origin position
2420 MVS PCUP4
2430 DLY 1
2440 HCLOSE 1
2450 DLY 1
2460 PCUP4.Z = PCUP4.Z+OFFSET 'OFFESET mm in Z direction
2470 MVS PCUP4
2480 DLY 1
2490 PCUP4.Z = PCUP4.Z-OFFSET 'PCup4 origin position
2500 MOV PWAIT
2510 DLY 1
2520 IF DRINKP4%=1 THEN
2530 GOSUB *SUBBOT1
2540 DLY 1
2550 ENDIF
2560 IF DRINKP4%=2 THEN

12
2570 GOSUB *SUBBOT2
2580 DLY 1
2590 ENDIF
2600 IF DRINKP4%=3 THEN
2610 GOSUB *SUBBOT3
2620 DLY 1
2630 ENDIF
2640 'MOV TO PCup4 and back to WAITING Position
2650 PCUP4.Z=PCUP4.Z+OFFSET% 'OFFSET mm above
2660 MOV PCUP4
2670 DLY 1
2680 PCUP4.Z=PCUP4.Z-OFFSET% 'origin position
2690 MVS PCUP4
2700 DLY 1
2710 HOPEN 1
2720 DLY 1
2730 PCUP4.Z=PCUP4.Z+OFFSET% 'OFFSET mm above
2740 MVS PCUP4
2750 DLY 1
2760 PCUP4.Z=PCUP4.Z-OFFSET% 'origin position
2770 MOV PWAIT
2780 DLY 1
2790 ENDIF
2800 COUNT%=COUNT%+1
2810 WEND
2820 SERVO OFF
2830 RETURN
2840 '============SERVO START SUBROUTINE===========
2850 *SUBSERVO
2860 SERVO ON 'The robot servos are started
2870 DLY 2 'A delay of 2 seconds is given for the servos to have
time to start

13
2880 RETURN
2890 '============GOTO BOTTLE 1 SUBROUTINE===========
2900 *SUBBOT1
2910 'MOV To BOTTLE1 and back to WAITING Position
2920 PBOTTLE1.Z=PBOTTLE1.Z-OFFSET% 'OFFSETmm under PBottle1
2930 MOV PBOTTLE1
2940 DLY 1
2950 PBOTTLE1.Z=PBOTTLE1.Z+OFFSET% 'origin Position
2960 MVS PBOTTLE1
2970 DLY 5
2980 PBOTTLE1.Z=PBOTTLE1.Z-OFFSET% 'OFFSETmm under PBottle1
2990 MVS PBOTTLE1
3000 DLY 1
3010 PBOTTLE1.Z=PBOTTLE1.Z+OFFSET% 'origin Position
3020 MOV PWAIT
3030 RETURN
3040 '============GOTO BOTTLE 2 SUBROUTINE===========
3050 *SUBBOT2
3060 'MOV To BOTTLE2 and back to WAITING Position
3070 PBOTTLE2.Z=PBOTTLE2.Z-OFFSET% 'OFFSETmm under PBottle1
3080 MOV PBOTTLE2
3090 DLY 1
3100 PBOTTLE2.Z=PBOTTLE2.Z+OFFSET% 'origin Position
3110 MVS PBOTTLE2
3120 DLY 5
3130 PBOTTLE2.Z=PBOTTLE2.Z-OFFSET% 'OFFSETmm under PBottle1
3140 MVS PBOTTLE2
3150 DLY 1
3160 PBOTTLE2.Z=PBOTTLE2.Z+OFFSET% 'origin Position
3170 MOV PWAIT
3180 RETURN
3190 '============GOTO BOTTLE 3 SUBROUTINE===========

14
3200 *SUBBOT3
3210 'MOV To BOTTLE3 and back to WAITING Position
3220 PBOTTLE3.Z=PBOTTLE3.Z-OFFSET% 'OFFSETmm under PBottle1
3230 MOV PBOTTLE3
3240 DLY 1
3250 PBOTTLE3.Z=PBOTTLE3.Z+OFFSET% 'origin Position
3260 MVS PBOTTLE3
3270 DLY 5
3280 PBOTTLE3.Z=PBOTTLE3.Z-OFFSET% 'OFFSETmm under PBottle1
3290 MVS PBOTTLE3
3300 DLY 1
3310 PBOTTLE3.Z=PBOTTLE3.Z+OFFSET% 'origin Position
3320 MOV PWAIT
3330 RETURN
3340 '===================RANGE LIMIT=================
3350 *RANGE 'this subroutine checks whether all
positions are within the workspace of the robot prior to
starting the program.
3360 DEF INTE RANGE1 'RANGE1 through RANGE8 are
variables used to check whether the various defined locations
are within the workspace of the robot or not.
3370 RANGE1 = POSCQ(PWAIT) 'POSCQ(<Position Variables>) is a
command which checks whether the given position is within the
movement range of the robot. It is equal to 1 if the position is
within range and 0 is the position is out of range
3380 IF RANGE1 = 0 THEN
3390 PRINT#1, "WAITING POSITION IS OUT OF RANGE. PLEASE RESET
AND TRY AGAIN"
3400 GOSUB *SUBPAL
3410 ENDIF
3420 DEF INTE RANGE2
3430 RANGE2 = POSCQ(PBOTTLE1)

15
3440 IF RANGE2 = 0 THEN
3450 PRINT#1, "WATER BOTTLE IS OUT OF RANGE. PLEASE RESET AND
TRY AGAIN"
3460 GOSUB *SUBPAL
3470 ENDIF
3480 DEF INTE RANGE3
3490 RANGE3 = POSCQ(PBOTTLE2)
3500 IF RANGE3 = 0 THEN
3510 PRINT#1, "COKE BOTTLE IS OUT OF RANGE. PLEASE RESET AND TRY
AGAIN"
3520 GOSUB *SUBPAL
3530 ENDIF
3540 DEF INTE RANGE4
3550 RANGE4 = POSCQ(PBOTTLE3)
3560 IF RANGE4 = 0 THEN
3570 PRINT#1, "KINNIE BOTTLE IS OUT OF RANGE. PLEASE RESET AND
TRY AGAIN"
3580 GOSUB *SUBPAL
3590 ENDIF
3600 DEF INTE RANGE5
3610 RANGE5 = POSCQ(PCUP1)
3620 IF RANGE5 = 0 THEN
3630 PRINT#1, "CUP 1 IS OUT OF RANGE. PLEASE RESET AND TRY
AGAIN"
3640 GOSUB *SUBPAL
3650 ENDIF
3660 DEF INTE RANGE6
3670 RANGE6 = POSCQ(PCUP2)
3680 IF RANGE6 = 0 THEN
3690 PRINT#1, "CUP 2 IS OUT OF RANGE. PLEASE RESET AND TRY
AGAIN"
3700 GOSUB *SUBPAL

16
3710 ENDIF
3720 DEF INTE RANGE7
3730 RANGE7 = POSCQ(PCUP3)
3740 IF RANGE7 = 0 THEN
3750 PRINT#1, "CUP 3 xIS OUT OF RANGE. PLEASE RESET AND TRY
AGAIN"
3760 GOSUB *SUBPAL
3770 ENDIF
3780 DEF INTE RANGE8
3790 RANGE8 = POSCQ(PCUP4)
3800 IF RANGE8 = 0 THEN
3810 PRINT#1, "CUP 4 IS OUT OF RANGE. PLEASE RESET AND TRY
AGAIN"
3820 GOSUB *SUBPAL
3830 ENDIF
3840 RETURN

17
EXECUTION REPORT

To solve the predefined problem, a lab session was booked in order to start executing the
program. The first thing that was necessary to start the program was to set an arbitrary point to
eliminate unnecessary movement of the robot, named PWAIT. The coordinates of the predefined
variable PWAIT were saved. The next step undertaken was to save the coordinates of the bottles,
named PBOTTLE1, PBOTTLE2 and PBOTTLE3, respectively followed by the coordinates of PCUP1,
thus adding up to a total of 5 saved coordinate values. The coordinates of PCUP2, PCUP3 and
PCUP4 were worked out from PCUP1 by defining the distances between them.

The program was structured into various subroutines, followed by debugging of each subroutine
to avoid the congestion and accumulation of errors. Once each subroutine was debugged, the
program was compiled and checked once more. Once any syntax errors were fixed, the program
was put online and transferred to the controller. Other logical and runtime errors that were not
previously detected by the computer resurfaced. Subsequently, the errors were then corrected
and the program was functioning.

Figure 2: The robot being used was selected along with the corresponding settings

18
Figure 3: Adding the program code

Figure 4: Prior to transferring the program online it was checked for any syntax errors. Any occurrence of such errors was fixed.

19
Figure 5: This window shows the data link which displays the communication with the user and the robot. Here the user will be
prompted for input as well as advised should the input be invalid. Unfortunately, on the day the screenshot was taken, the robot
was malfunctioning so communication with the robot could not be opened.

Further Program Execution

At the start of the program, the user is prompted to enter an integer of 1 or 2 depending on
whether the coordinates of the cup positions need to be reprogrammed or not. If the integer 1
is selected, subroutine SUBMIX is executed prompting the user to enter how many drinks they
want. After this procedure, a main loop is executed prompting the user which type of drink they
want.

If the integer 2 is selected, the subroutine SUBPAL is executed allowing the user to alter the
coordinates the first cup in both Y and X directions with respect to the original default position
and orientation. A range limit was also taken into consideration so that if the cups are outside
robots reach, an error is displayed on the computer and the robot does not attempt to reach
said position. Following this subroutines execution the program continues prompting the user
to declare the number of drinks they want to order followed by what type of drink they want.

20
CONCLUSION
Pick-and-place robots have found their use in several industrial companies. The ability to speed
up the automation process of picking and placing drastically increases the production rates. As in
the case of this assignment, the end gripper of the robot can be specifically customized to fit
specific production requirements. Product handling in a factory line of small-to-large and light-
to-heavy materials is simplified thanks to the use of industrial robots.
The program coded with MELFAIV was successfully implemented as first intended and thus, the
aim of the assignment was achieved. If the program had to be designed to cater for more than 4
drinks at one go, the palletising function would have been more appropriate. However, in the
scope of this assignment since there was only one row of four cups the pallet function was
deemed unnecessary.

21
TEAM MEMBER CONTRIBUTION

Student ID Number Contribution Signature

Thomas Brandner P3492652 33.3% __________________________

Marvic Cordina 31794G 33.3% __________________________

Maria Cutajar 102294M 33.3% __________________________

22

Das könnte Ihnen auch gefallen