Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

CONNECT TO FANUC ROBOT for beginners

#1
Hi there, 
I posted a version to show how I worked the Robot with RoboDK, this version is the final version.  And would be helpful for those who try to use RoboDK to connect with Robot using online programming, especially to the beginners.


ROBODK – FANUC ROBOT(R-30iB controller) connection:
 
PC and Robot Setting -
1.    Plug-in the Ethernet cable to R-30ib controller (located at the bottom-right side of the door)
2.    Set a IP to PC and Robot (at the same segment)
2.1 select MENU->SETUP->HOST COMM to set IP address to ROBOT (there’s no space allowed before IP address)¸ select NEXT->INIT->YES->ROBOT to finish setting
2.2 select MENU->SETUP->HOST COMM->PING to check the IP Address is correctly set
2.3 set a IP address to PC’s network setting of Ether Net network card
 
Software setting -
A.    ROBOT –
1.    Must USER SOCKET MESSAGING (R648) is installed
MENU->STATUS->VERSIONID->CONFIG to check
2.    Must $Karel_ENB set to 1
MENU->SYSTEM_Varibles to check, if 0 set to 1 and reboot
3.    Upload ROBODK DRIVERS for FANUC to robot
3.1 down driver: https://robodk.com/doc/en/Robots-Fanuc-R...Fanuc.html
3.2 use the correct version of driver (or the robot will not follow your code)
3.3 upload RDK_S3.PC, GO_MJ, GO_ML, GO_MC, GO_PROG to robot
-       insert usb to FANUC’s Teach Pendant
-       MENU->FILE->FILE->UTIL->SET DEVICE->USB on TP->ENTER
-       Select ‘*’ to show all files
-       Select all drivers and LOAD->YES to Robot
4.    Initial Robot Driver (according to RoboDK website: https://robodk.com/doc/en/Robots-Fanuc-R...Fanuc.html)
4.1 Follw the steps below:
a.    Select Menu-(Next)-System-[TYPE]-Variables.
b.    Select $HOSTS_CFG (holding shift while selecting key down will help you scroll down faster)
c.     Select Number 3
d.    Set $SERVER_PORT to 2000
e.    ($HOSTS_CFG[3].$SERVER_PORT = 2000)
f.      Select Menu-Setup
g.    Select [TYPE]-Host comm
h.    Select [SHOW]-Servers
i.      Select “S3”-Enter.
j.      Set Protocol Name to SM
k.     In Port Name, if multiple ports are available: Set Port to P3 (or the corresponding port).
l.      Set Inactivity Timeout to 9999
m.   Set Startup state to [CHOICE] START
n.    Set Current state to STARTED:       
To do so, select [ACTION]-DEFINE, then [ACTION]-START

o.    Start the program DRIVERRDK_S3:
Select the SELECT button from the teach pendant.
Scroll down towards the DRIVERRDK_S3 program
Select Enter (button from the teach pendant)
Select Shift-Reset and Shift-Forward to start the program,
The DEADMAN button should always be Pressed
p.    Finishing setting, the ‘busy’ and ‘run’ signal should turn yellow to breen
B.    PC –
1.    Open RoboDK->file->open online library to select a model of robot.
2.    File->open->downloaded robot file
3.    Connect to robot:
3.1 Right click the mouse on the robot name of the tree, and select connect to robot
3.2 Input IP address just set (e.g. 192.168.1.10)
3.3 Default port 2000
3.4 If set correct, will get a green signal ‘ready’
4.    Add python program:
4.1 program->add python program
4.2 right-click the ‘Prog1’->edit python script to start python programming, there are three methods to run python code:
-       F5 in editor: execute python code and a message window shows(only under this mode).  When the window is opened, run on robot dn’t work
-       Right click ‘Prog1’->run python script : simulate the python code and draw trajectories on RoboDK screen
-       Right click ‘Prog1’->run on robot: execute the python code to robot
 
Teach Pendant:
1.    Manual and auto:
1.1  Under auto mode, don’t need to press DEADMAN to run program:
-       Turn R-30ib to AUTO
-       Turn the top-left switch of Teach Pendant to OFF
-       Press  SHIFT+RESET of TP to disappear the FAULT signal
-       Select program in TP (SELECT->program name (RDK_S3.PC)->ENTER)
-       Press CYCLE START of R-30ib, the green signal ON, ‘busy’ and ‘run’ signal of TP turn yellow to green
-       If not work try FCTN->ABORT ALL->back to select program step

1.2  Manually run program:
-       Turn R-30ib to T1
-       Turn the top-left switch of TP to ON
-       Select program (SELECT->program name (RDKS_3.PC)->ENTER)
-       Press DEADMAN (all the time under T1/T2 mode)
-       Press SHIFT+RESET make FAULT disappear
-       SHIFT+FWD to run selected program
-       If not work try FCTN->ABORT ALL->back to select program step
1.3  Manually move ROBOT
-       Press DEADMAN (all the time pressed)
-       SHIFT+RESET
-       Press EADMAN+SHIFT and (X,Y,Z,rX,rY,rZ) to move the robot
2.    Change robot speed:
2.1  Press ”+%”, “-%” bottom-right of TP to change speed, speed will show on the top-right of the screen of TP
3.    Back to Zero posion:
-       FCTN->ABORT ALL
-       SELECT->HOME->ENTER
-       Run program (as mentioned)
-       SELECT->RDRIVERS_3->ENTER
-       Run program(as mentioned)
I/O –
1.    MENU->I/O
2.    TYPE(F1)to choose I/O type : Digit IO, Robot IO
3.    DI is not changeable under simulate = U (unmulate), if simulate need, change U to S
4.    Before use I/O of FANUC robot, need to set parameters:
-       Config(F2)
-       CRMA15/16 output: [109-120] Rack = 48, SLOT=1, START = 1(normally)
-       PLC[1-100](depend on need), Rack = 92, SLOT=1 START = 1(normally)
-       Need reboot to make STAT. = ACTIV
5.    Digit I/O:
5.1 CRMA15/16:
-       The connector located at the bottom side of R-30ib door, the wire can be bought from internet or agent
-       Wiring:
DO:(see attachments)
DI::(see attachments)

5.2 PLC –
Need to have the knowledge of PLC protocal setting between PLC and Robot
6.    ROBOT I/O (EE interface):
(Thanks to torayeff https://robodk.com/forum/Thread-Robot-I-O-control)
6.1 To use this, have to program two programs in robot:
-       Build two programs using TP:  RO[1 ] = ON and RO[1]=OFF in advance:
Select->CREATE->->ENTER->next->INST->I/O->RO[ ]=…->input RO=1 and select ON/OFF
 
PYTHON -
 
1.    Get robot position: Joint_org = robot.Joints()
2.    Move robot (X=forward/back, Y=left/right, Z=up/down) all in length(mm)-
def moverobot1(x_offset,y_offset,z_offset):
target_ref = robot.Pose()
pos_ref=target_ref.Pos()
robot_x = pos_ref[0]+x_offset
robot_y = pos_ref[0]+y_offset
robot_z = pos_ref[0]+z_offset
target_i = Mat(target_ref)
target_i.setPose([robot_x,robot_y,robot_z])
robot.MoveL(target_i)
3.    Tool coordinate control: rX= 4th axis(left/right), rY=forward/backward, rZ I will use RELTOOL and not used here, the value will always be 0)
def moverobotj(a_value, b_value, 0):
    target = robot.Pose()
    xyzabc = Pose_2_Fanuc(target)
    x,y,z,a,b,c = xyzabc
    xyzabc2 = [x,y,z,a+a_value,b+b_value,c+c_value]
    target2 = Fanuc_2_Pose(xyzabc2)
    robot.MoveJ(target2)
4.    RELTOOL is a function to turn the 6th axis separately and not affect the 4th axis and 5th axis (https://robodk.com/forum/Thread-control-...seperately)
cvalue_ang = 30 (e.g.)
target2 = robot.Pose()
target2= RelTool(target2,0,0,0,rz=cvalue_ang)
robot.MoveJ(target2)
5.    Deep learning:
5.1  I use YOLO4 + OPENCV to detect object
5.2  How to position –
-       To calculate the distance between center of object and the center of pop-up window,
-       Set big movement rate and scope to make robot move faster to object
-       Set smaller movement rate and scope to make robot move precisely to object
-       Must have two classes to calculate the direction of object , and the robot will turn to correct direction.
5.3  Angle calculate of object:
-       if object have an angle toward -25 degree, right side -15 degree,
-       if object turn clockwise 40 degree
-       the toward will change angle:
calculate if turn 90 degree = -15-(-25) = 10 degree
every degree causes the degree change of object = 10/90 = 0.11
turn 40 degree = 40*0.11 = 4.4
the new toward angle = -25-4.4 = -29.4
consider the right side angle change will also affect the toward degree:
-15+25-(-15)/90*40= -32.78
The latest rY = -29.4-(-17.78) = -19.33
 
-       my object have a 15 degree offset when object is put straight,
-               if angD<=15:
-                   offsetvalue = 0
-                   xoffset = 60
-                   yoffset = 15
-                   aang_diff = bvalue_ang-avalue_ang
-                   bang_diff = -avalue_ang-bvalue_ang
-                   angD+=offsetvalue
-                   cvalue_ang = angD-15
-                   avalue_ang1 = (avalue_ang-(aang_diff/-90)*angD)
-                   bvalue_ang1 = (bvalue_ang-(bang_diff/-90)*angD)
-                   avalue_ang2 = avalue_ang1-(bvalue_ang1-bvalue_ang)
-                   bvalue_ang2 = bvalue_ang1+(avalue_ang1-avalue_ang)
-               else:
-                   xoffset = 60
-                   yoffset=30
-                   offsetvalue = 0
-                   aang_diff = -bvalue_ang-avalue_ang
-                   bang_diff = avalue_ang-bvalue_ang
-                   angD-=offsetvalue
-                   if angD>=15:
-                       cvalue_ang = angD-15
-                   else:
-                       cvalue_ang = angD-0
-                   avalue_ang1 = (avalue_ang-(aang_diff/90)*angD)
-                   bvalue_ang1 = (bvalue_ang-(bang_diff/90)*angD)
-                   avalue_ang2 = avalue_ang1+(bvalue_ang1-bvalue_ang)
-                   bvalue_ang2 = bvalue_ang1-(avalue_ang1-avalue_ang)
-               moverobotj(avalue_ang2,bvalue_ang2,0)
-        
-               target2 = robot.Pose()
-               target2= RelTool(target2,0,0,0,rz=cvalue_ang)
-               robot.MoveJ(target2)
-               avalue_rad = (avalue_ang2)*(math.pi/180)
-               bvalue_rad = (bvalue_ang2)*(math.pi/180)
-               arm_length = 220
-               math_x_offset = (math.sin(bvalue_rad)*arm_length)
-               math_y_offset = -(math.sin(avalue_rad)*arm_length)
-               moverobot1(math_x_offset+xoffset,math_y_offset-yoffset,0)
6.    I/O
6.1  RIRO: use RobkDK command robot.RI[x, 0/1]RO[x, 0/1] to control Digital I/O of Robot (x = number of I/O, 0/1: 0 =OFF, 1 = ON)
6.2  ROBOT I/O: use RoboDK command robot.RunInstruction('RO_OFF', robolink.INSTRUCTION_CALL_PROGRAM), ’RO_OFF’ is the program name in Robot

7.    RUN ON ROBOT and Encryption:
7.1  Use command  RDK.setRunMode(RUNMODE_RUN_ROBOT) to run on robot by python code.
7.2  To make sure user won’t change python code, use the Plug-Ins function of RoboDK (https://robodk.com/forum/Thread-encrypti...ython-prog)
-       Save Python code as a .py file
-       Add a subfolder under C:\ROBODK\Apps
-       Put .py file to the subfolder
-       select tools->Plug-Ins->Load Plug-In->App Loader
-       the program will appears at the toolbar of RoboDK
-       to combine the command ‘runmode_run_robot’ for more convenient for user
#2
Nice work! Thank you Timothy.
  




Users browsing this thread:
1 Guest(s)