![Mitsubishi MELFA 4D-2CG5100-PKG-E Скачать руководство пользователя страница 80](http://html1.mh-extra.com/html/mitsubishi/melfa-4d-2cg5100-pkg-e/melfa-4d-2cg5100-pkg-e_instruction-manual_1808016080.webp)
7
Robot Controller Settings
7-69 Robot Program Writing
7.3.
Robot Program Writing
In order to start (execute) image processing with the vision sensor from the robot, it is necessary to
execute commands controlling the vision sensor in a robot program written in MELFA-Basic IV.
7.3.1.
Flow for starting of image processing by robot
Next is shown the method for starting image processing from a robot program.
①
Check the line connection with the vision sensor (State variable
:M_NVOPEN)
②
Line connection with vision sensor
(MELFA-BASIC IV :NVOPEN)
③
Vision
program
start
(MELFA-BASIC
IV
:NVPST)
④
Vision sensor detection quantity acquisition
(State variable
:M_NVNUM)
⑤
Vision detection position data acquisition
(State variable
:P_NVS1 - P_NVS8)
⑥
After this, the robot is moved with the position data detected with the vision sensor.
For details on the vision program dedicated MELFA-BASIC IV commands and status variables, see "9.1
Vision Sensor Dedicated Commands and Status Variables".
7.3.2.
Writing a Sample Robot Program
The robot program below is written and stored in the robot controller. For details on the storage
method, see the "RT ToolBox PC Support Software Instruction Manual".
Example acquiring data in the absolute coordinates using pattern matching
1 ' Before this program is run, the evacuation position P0, the work grasping position P1, and the work placement position P2 must have
already been taught.
2 ' Example: P0=(+250.000,+350.000,+300.000,-180.000,+0.000,+0.000)(7,0)
3 ' P1=(+500.000, +0.000, +100.000, -180.000, +0.000, +10.000)(7,0)
4 ' P2=(+300.000, +400.00, +100.000, -180.000, +0.000, +90.000)(7,0)
10 IF M_NVOPEN(1)<>1 THEN
' When logon has not been completed for vision sensor number 1
20 NVOPEN “COM2:” AS #1
' Connects with the vision sensor connected to COM2.
30 ENDIF
40 WAIT M_NVOPEN(1)=1
' Connects with vision sensor number 1 and waits for logon to be completed.
50 NVPST #1,“Job1”,“E76”,“J81”,“L85”,0,10
' Start vision program [Job1] and receives the number of recognitions by the
vision sensor from the [E67] cell.
60
' and receives the recognized coordinates from the [J81] -[L85] cells, and stores this in P_NVS1 (30).
70 MOV P0 ' Moves to the evacuation point.
80 IF M_NVNUM(1)=0 THEN *NG ' If the detection count is 0, jumps to an error.
90 FOR M1=1 TO M_NVNUM(1)
' Loops once for each detection by vision sensor number 1.
100 P10=P1 ' Creates the target position P10 using the vision sensor 1 results data.
110 P10.X=P_NVS1(M1).X
120 P10.Y=P_NVS1(M1).Y
130 P10.C=P_NVS1(M1).C
140 MOV P10,10 ' Moves to 10 mm above the work grasping position P10.
150 MVS P10 ' Moves to the work grasping position P10.
160 DLY 0.1 ' Wait time of 0.1 second
170 HCLOSE 1 ' Closes hand 1
180 DLY 0.2 ' Wait time of 0.2 second
190 MVS P10,10 ' Moves to 10 mm above the work grasping position P10
200 MOV P2,10 ' Moves to 10 mm above the work placement position P2
210 MVS P2 ' Moves the work placement position P2
220 DLY 0.1 ' Wait time of 0.1 second
230 HOPEN 1 ' Opens hand 1.
240 DLY 0.2 ' Wait time of 0.2 second
250 MVS P2,10 ' Moves to 10 mm above the work placement position P2
260 NEXT M1 ' Repeats.
270 HLT ' Program pause (Create the appropriate processing.)
280 END ' Exit
290 '
300 *NG ' Error processing
310 ERROR 9000 ' Error 9000 output.
320 HLT ' Program pause (Create the appropriate processing.)
330 END ' Exit