A机器人编程程序解析.docx
《A机器人编程程序解析.docx》由会员分享,可在线阅读,更多相关《A机器人编程程序解析.docx(5页珍藏版)》请在冰豆网上搜索。
A机器人编程程序解析
1
程序解析:
1、此程序是典型的ABB机器人官方编程思路与方法,分为主程序,初始化例行程序和轨迹程序。
2、思路清晰,结构编排明确,方便使用者阅读。
%%%VERSION:
1LANGUAGE:
ENGLISH%%%MODULEMainModulePERStooldatatGripper:
=[TRUE,[[0,0,100],[1,0,0,0]],[25,[0,0,10],[1,0,0,0],0,0,0]];?
PERSwobjdataWobBox:
=[FALSE,TRUE,"",[[1,1,1],[0,0,0,0]],[[0,0,0],[1,0,0,0]]];CONSTrobtargetpPointA:
=[[1,1,1],[1,1,1,1],[-1,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];CONSTrobtargetpPointB:
=[[1,1,1],[1,1,1,1],[-1,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];CONSTrobtargetPHome:
=[[1,1,1],[1,1,1,1],[-1,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];?
PERSloaddataload_Empty:
=[1,[0,0,0],[1,0,0,0],0,0,0];PERSloaddataload_Box:
=[20,[0,0,0],[1,0,0,0],0,0,0];以上是固定的数据存放位置。
?
PROCmain()主程序,是一个程序的开始rInitial;Accset60,60;此部分其实可放入到rInitial中去,这样管理起来更方便velset100,100;此部分其实可放入到rInitial中去,这样管理起来更方便WHILETRUEDO?
rBox;在此指令后插入秒的等待指令,防止CPU过负荷的情况出现。
ENDWHILEENDPROC
PROCrInitial()?
SetDoDOGrip,0;WaitDIDIGripReleased,1;?
MoveJpHome,v300,z50,tGripper;?
ENDPROC
PROCrBox()MoveJoffs(pPointA,0,200,500),v1500,z100,tGripper;MoveJoffs(pPointA,0,200,0),v1500,z50,tGripper;A:
TPErase;IFDIAllowPick=1THENWaitTime0;ELSEIFDIAllowPick=0THENTPWrite"SignalofAllowPicknoready,PleaseCheck!
";GOTOA;ENDIF?
MoveLpPointA,v800,fine,tGripper;?
SetDoDOGrip,1;WaitDIDIGripPicked,1;Griploadload_Box;这一句很重要的,设定机器人的实际负荷情况,有利于机器人伺服控制的优化MoveJoffs(pPointA,0,0,500),v1000,z100,tGripper;?
MoveJoffs(pPointB,0,0,200),v1000,z50,tGripper\WObj:
=WobBox;?
MoveLpPointB,v1000,fine,tGripper\WObj:
=WobBox;SetDoDOGrip,0;WaitDIDIGripReleased,1;?
Griploadload_Empty;MoveLoffs(pPointB,0,200,0),v800,z50,tGripper\WObj:
=WobBox;MoveJoffs(pPointB,0,200,500),v1500,z100,tGripper\WObj:
=WobBox;
ENDPROC
ENDMODULE
ABB机器人编程02
程序解析:
1、此程序编写的思路是完全按照比赛题目中的要求的进行,就是按步就班式的
2、思路清晰,结构编排明确,方便使用者阅读。
3、有相应的写屏信息提示,方便操作员对机器人运行状态的了解。
4、有一点小问题,就是缺少初始化的部分。
MODULEMainModuleCONSTrobtargetPHOME:
=[[,,],[,,,],[0,0,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];CONSTrobtargetPA:
=[[,,],[,,,],[-1,0,-2,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];CONSTrobtargetP20:
=[[,,],[,,,],[-1,0,-3,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];CONSTrobtargetP30:
=[[,,],[,,,],[0,0,-2,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];CONSTrobtargetP40:
=[[,,],[,,,],[0,0,-3,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];CONSTrobtargetPB:
=[[,,],[,,,],[0,0,-2,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];PROCmain()在主程序里,过于臃肿,将具体功能尽量细分到例行程序TPErase;MoveJPHOME,v1000,z50,tool0;OpenGripper;WaitTime5;WHILEtrueDOIFPLC=1THENTPErase;TPWrite"Warning!
Begintomovethenewstaff...";WaitTime1;ClkResetclock1;ClkStartclock1;MovFromAtoB;ClkStopclock1;reg1:
=ClkRead(clock1);TPErase;TPWrite"Goodshandlinginplace,ittake(timeinsecond):
"\Num:
=reg1;运行时间的显示WaitTime5;ELSETPErase;TPWrite"Waitingfornewgoods...";运行状态的提醒WaitDIPLC,1;ENDIFENDWHILEENDPROCPROCOpenGripper()将对夹具的控制做在一个例行程序里,方便管理SetG0;ResetG1;ENDPROCPROCCloseGripper()将对夹具的控制做在一个例行程序里,方便管理
SetG1;ResetG0;ENDPROCPROCMovFromAtoB()MoveJP30,v1000,z50,tool0;MoveJP20,v1000,z50,tool0;MoveLPA,v50,fine,tool0;WaitTime1;CloseGripper;WaitTime1;MoveJP20,v50,z50,tool0;MoveJP30,v1000,z50,tool0;MoveJP40,v1000,z50,tool0;MoveLPB,v50,fine,tool0;WaitTime1;OpenGripper;WaitTime1;MoveLP40,v50,z50,tool0;MoveJP30,v1000,z50,tool0;MoveJPHOME,v1000,z50,tool0;ENDPROCENDMODULE
程序解析:
1、此程序是典型的ABB机器人官方编程思路与方法,分为主程序,初始化例行程序和轨迹程序。
2、思路清晰,结构编排明确,方便使用者阅读。
3、但有点要注意的初始化例行程序只在开始时,执行一次,正常运行时,不再执行。
但此程序是每个循环都会进行一次初始化,是有点问题的。
PROCmain()InitAll;此初始化程序应与循环执行的程序隔离开,使用WHILE指令Circle;WaitTime;ENDPROC?
PROCInitAll()ResetDo_fixOn;WaitDI\OnConfJ\On;ConfL\On;VelSet80,1000;AccSet70,70;MoveJPHome,v150,fine,Tool0\WObj:
=Wobj2;RETURN;ENDPROC?
?
PROCCircle()MoveJHome,v60,z0,Tool0\WObj:
=Wobj2;waitDI;work;resetwaitDI?
MoveJHome,v150,fine,Tool0\WObj:
=Wobj2;ENDPROC?
?
PROCfixopen()SetDo_fixopen;ENDPROC?
PROCfixclose()ResetDo_fixclose;ENDPROC?
?
PROCWork()MOVEJA0v150,z10,Tool0\WObj:
=Wobj2;fixopen;waittime2;MOVELA1v30,fine,Tool0\WObj:
=Wobj2;fixclose;waittime2;MOVEJB0v150,z10,Tool0\WObj:
=Wobj2;MOVEjB1v30,fine,Tool0\WObj:
=Wobj2;fixopen;waittime2;MoveJPHome,v150,fine,Tool0\WObj:
=Wobj2;ENDPROC
ABB机器人编程04
程序解析:
1、此程序是典型的ABB机器人官方编程思路与方法。
2、思路清晰,结构编排明确,方便使用者阅读。
3、此程序有一个亮点,就是有一个回等待点的例行程序rMoveHome,这个好处在于可以在手动状态下,就能方便的回到机器人的等待位置。
4、有足够的写屏信息,很好地提示运行状态。
PROCMain()?
rInitial;rMoveHome;WhileTrueDoVelset100,3000;AccSet70,70;rpickworkpiece;rplaceworkpiece;?
endwhile?
procrpickworkpiece;ifworkpiece=falseMoveJpickup,v2000,z5,too10;A:
TPErase;?
IFDI10_pickup=1THEN(pickup为PLC发来拾取信号)WaitTime0;?
ELSEIFDI10_pickup=0THENTPWrite"PLC-pickupsignalnoready.";GOTOA;ENDIFMoveJOffs(pickup,0,0,300),v500,z200,too10;SetDoDO10_pickup1,1;waittime1;workpiece=tureendifendproc?
?
procrplaceworkpiece;ifworkpiece=tureMoveJplacemiddle,v2000,z5,too10;?
MoveJplaceworkpiece,v2000,z5,too10;MoveJOffs(placeworkpiece,0,0,300),v500,z200,too10;SetDoDO10_pickup1,0;A:
TPErase;?
IFDI10_pickon=1THEN(pickon为PLC检测已放好信号)WaitTime0;?
ELSEIFDI10_pickup=0THENTPWrite"PLC-pickONsignalnoready.";GOTOA;workpiece=falseENDIF?
endproc?
?
?
PROCrInitial()TpReadFknInput,"Isthepack_machineready","","","","No","Yes";(机器是否准备好)IfnInput=4ThenbReady:
=False;stop;ElseIFnInput=5thenbReady:
=True;ENDIF?
bFirstPickBoard:
=True;TpReadFknInput,"Doyouwanttoplaceworkpiece","","","","No","Yes";(机器人抓头是否工件)
IfnInput=4Thenworkpiece:
=False;ElseIFnInput=5thenworkpiece:
=True;ENDPROC?
?
?
?
PROCrMoveHome()(定义原点)此例行程序可以方便地回到等待位置MoveJpHome,v500,z50,tGripper;ENDPROC
程序解析:
1、此程序是典型的ABB机器人官方编程思路与方法。
2、思路清晰,结构编排明确,方便使用者阅读。
3、此程序共分了3个程序模块,清楚地将不同用途的语句分开,方便阅读,这种编程在进行一些复杂系统的编程是非常有用的。
4、里面编程中运用了很多编程技巧,节省了机器人示教的时间,如使用OFFS功能。
5、在写屏信息提示方面也非常丰富。
6、此程序非常适合大家的参考与提高。
7、有一个小问题,缺少搬运重要的负荷重量设定数据。
MODULEData此模块专门用于存放程序数据的!
target?
CONSTjointtargethome_pos:
=[[0,0,0,0,90,0],[9E9,9E9,9E9,9E9,9E9,9E9]];CONSTjointtargetdelta_pos:
=[[2,2,2,2,2,2],[9E9,9E9,9E9,9E9,9E9,9E9]];CONSTjointtargetjhome:
=[[0,0,0,0,90,0],[9E9,9E9,9E9,9E9,9E9,9E9]];VARwzstationaryhome;VARshapedatajoint_space;VARnumnu_inhome;VARboolflag1:
=FALSE;ENDMODULE
%%%VERSION:
1LANGUAGE:
ENGLISH%%%
MODULECalibData此模块用于存放需要设定的程序数据TASKPERStooldataTooldata_1:
=[TRUE,[[0,0,1000],[1,0,0,0]],[1,[0,0,1],[1,0,0,0],0,0,0]];TASKPERSwobjdataWorkobject_1:
=[FALSE,TRUE,"",[[0,0,0],[1,0,0,0]],[[0,0,0],[1,0,0,0]]];?
ENDMODULE
MODULEMainModulePROCmain()CheckHome;CheckGriper;Production;ENDPROCPROCCheckHome()IFDOutput(do_inhome)=1THENnu_inhome:
=1;ELSE?
nu_inhome:
=0;ENDIFTESTnu_inhomeCASE0:
GoHome;CASE1:
RETURN;DEFAULT:
TPWrite"error";Stop;ENDTESTENDPROCPROCCheckGriper()IFdi_griperclosed=1THENControlGriper;ELSERETURN;ENDIFENDPROCPROCProduction()WHILETRUEDOWaitUntildi_plc=1;MoveLOffs(roFetch,0,0,500),v1000,z100,Tooldata_1\WObj:
=Workobject_1;利用OFFS此功能,减少示教MoveLroFetch,v1000,fine,Tooldata_1\WObj:
=Workobject_1;CloseGriper;MoveLOffs(roFetch,0,0,500),v1000,z100,Tooldata_1\WObj:
=Workobject_1;MoveLOffs(roDeFetch,0,0,500),v1000,z100,Tooldata_1\WObj:
=Workobject_1;MoveLroDeFetch,v1000,fine,Tooldata_1\WObj:
=Workobject_1;OpenGriper;MoveLOffs(roDeFetch,0,0,500),v1000,z100,Tooldata_1\WObj:
=Workobject_1;ENDWHILEENDPROCPROCCloseGriper()flag1:
=FALSE;Resetdo_opengriper;Setdo_closegriper;WaitDIdi_griperclosed,1\MaxTime:
=3\TimeFlag:
=flag1;WHILEflag1=TRUEDOTPWrite"CANN'TCLOSEGRIPER";Stop\NoRegain;ENDWHILEENDPROCPROCOpenGriper()flag1:
=FALSE;Setdo_opengriper;Resetdo_closegriper;WaitDIdi_griperopend,1\MaxTime:
=3\TimeFlag:
=flag1;WHILEflag1=TRUEDOTPWrite"CANN'TOPENGRIPER";Stop\NoRegain;ENDWHILEENDPROCPROCDEF_Zone()对机器人是否在等待位进行检测WZHomeJointDef\Inside,joint_space,home_pos,delta_pos;WZDOSet\Stat,home\Inside,joint_space,do_inhome,1;!
RETURN;ENDPROCPROCGoHome()?
VARbtnresanswer;VARstringmy_message{2}:
=["",""];CONSTstringmy_buttons{2}:
=["MOVETOHOME","STOPPRG"];丰富的写屏指令my_message{1}:
="RBTISINSAFETYPOSITION";my_message{2}:
="ORCANNOTMOVEAUTOMATICALLY";answer:
=UIMessageBox(\Header:
="RBTISINSAFETYAREATOMOVEONHOME"\MsgArray:
=my_message\BtnArray:
=my_buttons\Icon:
=iconWarning);IFanswer=2THENEXIT;!
Stop\NoRegain;ELSEMoveAbsJjhome\NoEOffs,v100,z5,Tooldata_1;ENDIFENDPROCPROCControlGriper()VARbtnresanswer;VARstringmy_message{2}:
=["",""];CONSTstringmy_buttons{2}:
=["OPENGRIPER","STOPPRG"];丰富的写屏指令my_message{1}:
="GRIPERISNOTEMPTY";my_message{2}:
="ORSENSORISWRONG";answer:
=UIMessageBox(\Header:
="OPENTHEGRIPER"\MsgArray:
=my_message\BtnArray:
=my_buttons\Icon:
=iconWarning);IFanswer=2THENEXIT;!
Stop\NoRegain;ELSEOpenGriper;ENDIFENDPROCENDMODULE