当前位置:文档之家› ABB机器人程序实例

ABB机器人程序实例

MODULE MainModuleCONST robtarget pHome:=[[1525.42,272.18,1873.69],[4.42963E-05,0.699969,-0.7141 73,-2.80277E-05],[0,-1,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9 E+09]];CONST robtargetpPrePickMould:=[[1653.99,272.19,1779.41],[5.83312E-05,0.69997, -0.714172,-3.47922E-05],[0,-1,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];CONST robtarget pPrePickClapboard:=[[2036.17,-741.24,1235.05],[0.678651,0.73435 ,-0.0119011,0.00467586],[-1,-2,2,0],[9E+09,9E+09,9E+09,9E+09,9 E+09,9E+09]];CONST robtargetpPickMould:=[[1943.13,173.08,630.89],[4.66987E-05,0.699977,-0.7 14166,-3.24109E-05],[0,-1,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+0 9,9E+09]];CONST robtargetpPickClapboard:=[[1943.19,173.08,620.72],[1.61422E-05,0.699977, -0.714165,-7.62858E-06],[0,-1,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];robtarget pPrePlace:=[[785.90,-CONST957.40,1722.38],[0.00231652,0.0492402,-0.99 8779,-0.00310842],[-1,-1,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];CONST robtarget pPrePlace10:=[[-277.40,-1202.57,1621.17],[0.00183571,-0.0139794, -0.999895,-0.00341408],[-2,-1,-2,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];CONST robtarget pPrePlace20:=[[-491.18,-1082.85,1505.90],[0.000663644,0.69408,0. 719887,0.00386364],[-2,0,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09 ,9E+09]];CONST robtarget pPlaceMould:=[[-92.13,-2580.19,1171.45],[0.000771646,0.713144,0 .701007,0.00383692],[-2,0,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+0 9,9E+09]];CONST robtargetpPlaceClapboard:=[[1585.08,1761.04,787.33],[0.00645323,-0.00552 996,-0.726358,-0.687263],[0,1,-1,0],[9E+09,9E+09,9E+09,9E+09,9 E+09,9E+09]];CONST robtargetpPrePlaceClapboard:=[[1017.30,955.85,1443.17],[1.0621E-05,-0.00 849593,-0.999964,4.01139E-05],[0,-1,0,0],[9E+09,9E+09,9E+09,9E +09,9E+09,9E+09]];CONST robtarget pPrePickClapboard10:=[[2257.17,-841.03,1579.56],[0.667517,0.744 57,-0.00360206,0.00487631],[-1,-1,2,0],[9E+09,9E+09,9E+09,9E+0 9,9E+09,9E+09]];CONST robtarget pPrePickMould10:=[[530.24,-1703.27,1762.63],[5.07659E-05,0.961 61,0.274421,2.37287E-05],[-1,0,0,0],[9E+09,9E+09,9E+09,9E+09,9 E+09,9E+09]];CONST num nOffs:=100;PERS num nCurOffs:=100;CONST num nLayer:=0;PERS num nCurLayer:=0;CONST num nThickness:=40;VAR bool bTimeOut:=FALSE;PERS bool bDryCycle:=FALSE;VAR intnum iDryCycle;VAR intnum iResDryCycle;VAR intnum iVacuum;tooldata tGripper:=[TRUE,[[0,0,100],[1,0,0,0]],[88.5,[-3.7,-PERS1.4,132.1],[1,0,0, 0],5.5,17.831,25.067]];PROC main()rInitAll;WHILE TRUE DOIF siDryCycle=1 or nCurLayer<1 thenrPickClapboard;ELSErPickMould;ENDIFWaittime 0.2;ENDWHILEENDPROCPROC rPickMould()DIWait diMouldready,1,3,"entrance Conveyer","ready for pick";DIWait diPlaceReady,1,3,"exit Conveyer","ready for remove";MoveJ pPrePickMould, v1500, z50, tGripper;IF BitCheck(nCurlayer,1) THENnCurOffs:=nOffs;ELSEnCurOffs:=-nOffs;ENDIFMoveLoffs(pPickMould,0,nCurOffs,100+nCurLayer*nThickness), v1000, z50, tGripper;MoveL offs(pPickMould,0,nCurOffs,(nCurLayer-1)*nThickness), v200, fine, tGripper;GripClose;Decr nCurLayer;MoveLoffs(pPickMould,0,nCurOffs,100+nCurLayer*nThickness), v200, z50, tGripper;MoveJ pPrePickMould, v1000, z50, tGripper;DIWait diPlaceReady,1,3,"exit Conveyer","ready for remove";MoveJ pPrePlace10, v1500, z10, tGripper;MoveL offs(pPlaceMould,0,0,100), v1500, z10, tGripper;MoveL pPlaceMould, v200, fine, tGripper;GripOpen;MoveL offs(pPlaceMould,0,0,100), v200, z10, tGripper;MoveL pPrePlace10, v1500, z10, tGripper;MoveJ pPrePickMould, v1500, z10, tGripper;PulseDO\PLength:=2, doMouldPlaceOK;ENDPROCPROC rPickClapboard()DIWait diMouldready,1,3,"entrance Conveyer","ready for pick";MoveL offs(pPickClapboard,0,0,100), v1000, z50, tGripper;MoveL pPickClapboard, v200, fine, tGripper;GripClose;MoveL offs(pPickClapboard,0,0,100) ,v200, z50, tGripper;MoveL offs(pPickClapboard,0,0,500) ,v1000, z50, tGripper;MoveL pPrePlaceClapboard, v1000, z10, tGripper;DIWait diClapboardReady, 1, 3, "exit Conveyer", "ready for remove";MoveL offs(pPlaceClapboard,-700,-200,250), v1000, z10, tGripper;MoveL offs(pPlaceClapboard,00,-10,100), v1000, z10, tGripper;MoveL pPlaceClapboard, v100, fine, tGripper;GripOpen;MoveL offs(pPlaceClapboard,0,-50,100), v1000, z10, tGripper;MoveL offs(pPlaceClapboard,-700,-200,250), v1000, z10, tGripper;MoveL pPrePlaceClapboard, v1000, z10, tGripper;PulseDO\PLength:=1.0, doClapboardPickOK;MoveJ pHome, v1500, fine, tGripper;PulseDO\PLength:=1.0, doUnStackOk;WaitTime 2;DIWait diMouldready,0,3,"exit Conveyer","ready for remove";nCurLayer:=nLayer;ENDPROCPROC rInitAll()IF diVacuum1=0 THENWaitTime 1;ELSEErrWrite "The Rob1 gripper error! " ,"The gripper is not opened!"\RL2:="Check the gripper signal postion ."\RL3:=" open the gripper manually and take away the part from gripper.";Stop;Exit;ENDIFrMoveHome;nCurLayer:=nLayer;IDelete iVacuum;CONNECT iVacuum WITH tLostPart;ISignalDI diVacuum1, 1, iVacuum;ISleep iVacuum;ENDPROCROC GripClose()SetDO doVacuum,1;SetDO doBlow,0;WaitUntil diVacuum1=1\MaxTime:=10\TimeFlag:=bTimeOut;IF bTimeOut THENErrWrite "Rob Gripper Signal error ! " ,"Fatal error in Gripper"\RL2:="Check the gripper signal postion ."\RL3:=" change a new sensor .";Stop;ENDIFWaittime 0.5;IWatch iVacuum;ENDPROCPROC GripOpen()ISleep iVacuum;SetDO doVacuum,0;PulseDO \PLength:=2.0, doBlow;WaitUntil diVacuum1=0 \MaxTime:=5\TimeFlag:=bTimeOut;IF bTimeOut THENErrWrite "Rob Gripper Signal error ! " ,"Fatal error in Gripper"\RL2:="Check the gripper signal postion ."\RL3:=" change a new sensor .";Stop;ENDIFWaittime 0.5;ENDPROCPROC rMoveHome()VAR string HomeOffset;CONST num MinX:=-500;CONST num MaxX:=500;CONST num MinY:=-500;CONST num MaxY:=500;CONST num MinZ:=500;CONST num MaxZ:=1200;VAR robtarget ActualPos;VelSet 100,500;AccSet 70, 70;IF bCurrentPos(pHome,tGripper,50)=TRUE THENMoveJ pHome,v500,fine,tGripper\WObj:=wobj0;ENDIFIF bCurrentPos(pPrePickMould,tGripper,50\wobj:=Wobj0)= TRUE THENMoveJ pHome,v500,fine,tGripper\WObj:=wobj0;ENDIFIFbCurrentPos(pPrePickClapboard,tGripper,100\wobj:=Wobj0)= TRUE THENMoveJ pHome,v500,fine,tGripper\WObj:=wobj0;ENDIFIF bCurrentPos(pPreplace,tGripper,100\wobj:=Wobj0)= TRUE THENMoveJ pHome,v500,fine,tGripper\WObj:=wobj0;ENDIFIF bCurrentPos(pHome,tGripper,100)=FALSE THEN! If no known position is found, check if the robot is in a specified! window and move him to the first position in the programActualPos:=CRobT(\Tool:=tGripper\WObj:=wobj0);IF ActualPos.trans.x<MinX OR ActualPos.trans.x>MaxX OR ActualPos.trans.y<MinY OR ActualPos.trans.y>MaxY OR ActualPos.trans.z<MinZ OR ActualPos.trans.z>MaxZ THEN HomeOffset:="";IF ActualPos.trans.x<MinX THENHomeOffset:=HomeOffset+"X :"+NumToStr(MinX-ActualPos.trans. x,0)+" ";ELSEIF ActualPos.trans.x>MaxX THENHomeOffset:=HomeOffset+"X :"+NumToStr(MaxX-ActualPos.trans .x,0)+" ";ELSEENDIFIF ActualPos.trans.y<MinY THENHomeOffset:=HomeOffset+"Y :"+NumToStr(MinY-ActualPos.trans. y,0)+" ";ELSEIF ActualPos.trans.y>MaxY THENHomeOffset:=HomeOffset+"Y :"+NumToStr(MaxY-ActualPos.trans .y,0)+" ";ELSEHomeOffset:=HomeOffset+"Y : OK ";ENDIFIF ActualPos.trans.z<MinZ THENHomeOffset:=HomeOffset+"Z :"+NumToStr(MinZ-ActualPos.trans. z,0)+" ";ELSEIF ActualPos.trans.z>MaxZ THENHomeOffset:=HomeOffset+"Z :"+NumToStr(MaxZ-ActualPos.trans. z,0)+" ";ELSEENDIFErrWrite HomeOffset,"Move robot manuallynear homeposition";WHILE OpMode()<>OP_MAN_PROG DO TPErase;TPWrite "Please switch robot to Manualmode"; !TPErase;Stop;ENDWHILEStop;MoveJ pHome,v500,fine,tGripper;!npallet:=4;ActualPos:=CRobT(\Tool:=tGripper\WObj:=wobj0);WHILE OpMode()<>OP_AUTO DOTPErase;TPWrite "Please switch robot to AUTOmode"; !TPErase;Stop;ENDWHILEENDIFENDIFVelSet 100,3000;ENDPROCTRAP tLostPartErrWrite "Part lost!" ,"Fatal error inGripper"\RL2:="Check the gripper ."\RL3:=" check the vacuum .";Stop;ENDTRAPENDMODULE。

相关主题