ABB机器人码垛程序.docx
《ABB机器人码垛程序.docx》由会员分享,可在线阅读,更多相关《ABB机器人码垛程序.docx(65页珍藏版)》请在冰豆网上搜索。
ABB机器人码垛程序
MODULEMainModule
PROCMain()
TPErase;
TPReadNumnCount1,"QingShuRuYiMaBaoShu!
";
TPReadNumnJob,"QingShuRuMoShi:
50KG:
=1,25KG:
=2!
";
InitAll;
WHILETRUEDO
ReadType;
clock2re;
PickIF;
clock2re;
PlaceOF;
ENDWHILE
ENDPROC
PROCclock2re()
!
tempint:
=movstat;
IFDI10_1Product0K=0orDI10_2TuoPanOK=0Then
IFtempint<0、25then
ClkStartCLK2;
ELSE
ClkStopCLK2;
ENDIF
Else
ClkStopCLK2;
EndIF
Endproc
PROCInitAll()
MoveHome;
ResetDO10_1JiaZhua;
ResetDO10_2YaBan;
ResetDO10_3ZhuaOK;
ResetDO10_4MaDuoOK;
Waittime0、5;
bPickPart:
=FALSE;
ClkResetCLK1;
ClkStartCLK1;
ClkResetCLK2;
MoveLOffs(pPick,0,0,400),vFast,z10,tGripper\WObj:
=wobj0;
ENDPROC
PROCPickIF()
IFbPickPart=FALSEANDnJob<>0ANDDI10_1Product0K=1THEN
!
CalculatePick;
MoveJOffs(pPick,0,0,400),vFast,z200,tGripper\WObj:
=wobj0;
!
MoveLDOOffs(pPick,0,0,100),vFast,z20,tool0\WObj:
=wobj0,DO10_1JiaZhua,1;
MoveLpPick,vFast,fine,tGripper\WObj:
=wobj0;
Close1;
GripLoadLoadFull;
Accset50,50;
HandshakeIF;
bPickPart:
=TRUE;
ConfL\Off;
MoveJpAfterPick,vFast,z60,tGripper\WObj:
=wobj0;
ENDIF
ENDPROC
PROCPlaceOF()
IFDI10_2TuoPanOK=1ANDbPickPart=TRUETHEN
CalculatePlace;
ConfL\Off;
!
MoveLOffs(pOver,0,0,nOffsZ2),vFast,z200,tGripper;
IFbTag=truethen
Accset70,70;
MoveJpAbovePlace,vFast,z10,tGripper\WObj:
=wobj0;
else
Accset90,90;
MoveJpAbovePlace,vFast,z10,tGripper\WObj:
=wobj0;
Endif
Accset100,100;
!
placefirstbox
ConfL\Off;
!
MoveLOffs(pPlace1,nOffsX1,nOffsY1,nOffsZ1),vTurn,z10,tGripper\WObj:
=wobj0;
MoveLpPlace1,vMiddle,fine,tGripper\WObj:
=wobj0;
Open1;
ConfL\Off;
MoveLOffs(pPlace1,0,0,nOffsZ1),vMiddle,z5,tGripper\WObj:
=wobj0;
GripLoadLoadEmpty;
Accset100,100;
bPickPart:
=FALSE;
IncrnCount1;
HandshakeOF;
MoveJpAbovePick,vFast,z200,tGripper\WObj:
=wobj0;
MoveLOffs(pPick,0,0,400),vFast,z10,tGripper\WObj:
=wobj0;
!
MoveJpHome,vFast,z200,tGripper;
ENDIF
ENDPROC
PROCHandshakeIF()
IFnJob=1THEN
!
SetDO10_3ZhuaOK;
ENDIF
IFnJob=2THEN
!
SetDO10_3ZhuaOK;
ENDIF
ENDPROC
PROCHandshakeOF()
IF(nCount1=40andnJob=1)or(nCount1=80andnJob=2)THEN
SetDO10_4MaDuoOK;
WaitDIDI10_2TuoPanOK,0;
SetDO\SDelay:
=0、5,DO10_4MaDuoOK,0;
nCount1:
=0;
ClkStopCLK1;
ClkStopCLK2;
TPErase;
nCycleCount:
=ClkRead(CLK1);
Waitingtime:
=ClkRead(CLK2);
TPWrite"Cycletime:
"\Num:
=nCycleCount;
TPWrite"WaitingtimeinthisCycle:
"\Num:
=Waitingtime;
ClkResetCLK2;
ClkResetCLK1;
ClkStartCLK1;
ENDIF
ENDPROC
PROCMoveHome()
TempP1:
=CRobT(\Tool:
=tool0\WObj:
=wobj0);
TempP1、trans、z:
=500;MoveJTempP1,v1000,z20,tGripper;
MoveJpHome,v1000,z20,tGripper;
ENDPROC
PROCReadType()
IFnPriority=1ANDDI10_1Product0K=1THEN
!
nJob:
=1;
!
IncrnPriority;
ELSEIFnPriority=2ANDDI10_1Product0K=1THEN
!
nJob:
=2;
!
IncrnPriority;
ELSE
!
nJob:
=0;
!
IncrnPriority;
!
IFnPriority>2nPriority:
=1;
ENDIF
ENDPROC
PROCOpen1()
ResetDO10_2YaBan;
Waittime0、0;
ResetDO10_1JiaZhua;
waittime0、1;
!
WaittimenTimeGripper;
ENDPROC
PROCClose1()
SetDO10_1JiaZhua;
Waittime0、0;
WaitDIDI10_4Zhua1End,1;
SetDO10_2YaBan;
Waittime0、0;
!
WaittimenTimeGripper;
WaitDIDI10_4Zhua1End,1;
!
WaitDIDI10_6Zhua2End,1;
ENDPROC
PROCCalculatePick()
IFnJob=1THEN
pPick:
=pPick1;
ELSEIFnJob=2THEN
pPick:
=pPick1;
ENDIF
!
pAbovePick:
=pPick;
!
pAfterPick:
=pPick;
!
Pattern80;
!
pAbovePick、trans、z:
=pAfterPick、trans、z;
!
pAbovePick、trans、y:
=pAfterPick、trans、y-500;
!
pAfterPick、trans、y:
=pAfterPick、trans、y-500;
ENDPROC
PROCCalculatePlace()
IFnJob=1THEN
nBagL:
=nBag50L;
nBagW:
=nBag50W;
nBagH:
=nBag50H;
Pattern80;
ELSEIFnJob=2THEN
nBagL:
=nBag25L;
nBagW:
=nBag25W;
nBagH:
=nBag25H;
Pattern100;
ENDIF
!
pAbovePlace:
=pPlace1;
pAfterPlace:
=pAbovePlace;
ENDPROC
PROCPattern80()
bTag:
=FALSE;
TESTnCount1+1
CASE1:
pPlace1:
=pBase180;
pPlace1、trans、x:
=pPlace1、trans、x;
pPlace1、trans、y:
=pPlace1、trans、y;
pPlace1、trans、z:
=pPlace1、trans、z;
nOffsX1:
=0;
nOffsY1:
=0;
nOffsZ1:
=500;
nOffsZ2:
=-500;
nLevel:
=1;
bTwice:
=FALSE;
pAfterPick、trans、z:
=pPick、trans、z+400;
pAbovePlace:
=pPlace1;
pAbovePlace、trans、z:
=pPick、trans、z+400;
bTag:
=True;
CASE2:
pPlace1:
=pBase0;
pPlace1、trans、x:
=pPlace1、trans、x;
pPlace1、trans、y:
=pPlace1、trans、y;
pPlace1、trans、z:
=pPlace1、trans、z;
nOffsX1:
=0;
nOffsY1:
=0;
nOffsZ1:
=nBagH*1、2;
nOffsZ2:
=-500;
nLevel:
=1;
bTwice:
=FALSE;
pAfterPick、trans、z:
=pPick、trans、z+400;
pAbovePlace:
=pPlace1;
pAbovePlace、trans、z:
=pPick、trans、z+400;
CASE3:
pPlace1:
=pBase90;
pPlace1、trans、x:
=pPlace1、trans、x;
pPlace1、trans、y:
=pPlace1、trans、y+25;
pPlace1、trans、z:
=pPlace1、trans、z;
nOffsX1:
=0;
nOffsY1:
=0;
nOffsZ1:
=nBagH*1、2;
nOffsZ2:
=-500;
nLevel:
=1;
bTwice:
=FALSE;
pAfterPick、trans、z:
=pPick、trans、z+400;
pAbovePlace:
=pPlace1;
pAbovePlace、trans、z:
=pPick、trans、z+400;
CASE4:
pPlace1:
=pBase90;
pPlace1、trans、x:
=pPlace1、trans、x+2*nBagW;
pPlace1、trans、y:
=pPlace1、trans、y+25;
pPlace1、trans、z:
=pPlace1、trans、z;
nOffsX1:
=0;
nOffsY1:
=0;
nOffsZ1:
=nBagH*1、2;
nOffsZ2:
=-500;
nLevel:
=1;
bTwice:
=FALSE;
pAfterPick、trans、z:
=pPick、trans、z+400;
pAbovePlace:
=pPlace1;
pAbovePlace、trans、z:
=pPick、trans、z+400;
CASE5:
pPlace1:
=pBase90;
pPlace1、trans、x:
=pPlace1、trans、x+nBagW;
pPlace1、trans、y:
=pPlace1、trans、y+25;
pPlace1、trans、z:
=pPlace1、trans、z+20;
nOffsX1:
=0;
nOffsY1:
=0;
nOffsZ1:
=nBagH*1、2;
nOffsZ2:
=-500;
nLevel:
=1;
bTwice:
=FALSE;
pAfterPick、trans、z:
=pPick、trans、z+400;
pAbovePlace:
=pPlace1;
pAbovePlace、trans、z:
=pPick、trans、z+400;
!
Layer2
CASE6:
pPlace1:
=pBase180;
pPlace1、trans、x:
=pPlace1、trans、x;
pPlace1、trans、y:
=pPlace1、trans、y+nBagL-5;
pPlace1、trans、z:
=pPlace1、trans、z+nBagH;
nOffsX1:
=0;
nOffsY1:
=0;
nOffsZ1:
=nBagH*1、2;
nOffsZ2:
=-500;
nLevel:
=1;
bTwice:
=FALSE;
pAfterPick、trans、z:
=pPick、trans、z+400;
pAbovePlace:
=pPlace1;
pAbovePlace、trans、z:
=pPick、trans、z+400;
CASE7:
pPlace1:
=pBase0;
pPlace1、trans、x:
=pPlace1、trans、x;
pPlace1、trans、y:
=pPlace1、trans、y+nBagL-5;
pPlace1、trans、z:
=pPlace1、trans、z+nBagH;
nOffsX1:
=0;
nOffsY1:
=0;
nOffsZ1:
=nBagH*1、2;
nOffsZ2:
=-500;
nLevel:
=1;
bTwice:
=FALSE;
pAfterPick、trans、z:
=pPick、trans、z+400;
pAbovePlace:
=pPlace1;
pAbovePlace、trans、z:
=pPick、trans、z+400;
CASE8:
pPlace1:
=pBase270;
pPlace1、trans、x:
=pPlace1、trans、x;
pPlace1、trans、y:
=pPlace1、trans、y;
pPlace1、trans、z:
=pPlace1、trans、z;
nOffsX1:
=0;
nOffsY1:
=0;
nOffsZ1:
=nBagH*1、2;
nOffsZ2:
=-500;
nLevel:
=1;
bTwice:
=FALSE;
pAfterPick、trans、z:
=pPick、trans、z+400;
pAbovePlace:
=pPlace1;
pAbovePlace、trans、z:
=pPick、trans、z+400;
CASE9:
pPlace1:
=pBase270;
pPlace1、trans、x:
=pPlace1、trans、x+2*nBagW-25;
pPlace1、trans、y:
=pPlace1、trans、y;
pPlace1、trans、z:
=pPlace1、trans、z;
nOffsX1:
=0;
nOffsY1:
=0;
nOffsZ1:
=nBagH*1、2;
nOffsZ2:
=-500;
nLevel:
=2;
bTwice:
=FALSE;
pAfterPick、trans、z:
=pPick、trans、z+400;
pAbovePlace:
=pPlace1;
pAbovePlace、trans、z:
=pPick、trans、z+400;
CASE10:
pPlace1:
=pBase270;
pPlace1、trans、x:
=pPlace1、trans、x+nBagW;
pPlace1、trans、y:
=pPlace1、trans、y;
pPlace1、trans、z:
=pPlace1、trans、z;
nOffsX1:
=0;
nOffsY1:
=0;
nOffsZ1:
=nBagH*1、2;
nOffsZ2:
=-500;
nLevel:
=2;
bTwice:
=FALSE;
pAfterPick、trans、z:
=pPick、trans、z+400;
pAbovePlace:
=pPlace1;
pAbovePlace、trans、z:
=pPick、trans、z+400;
!
Layer3
CASE11:
pPlace1:
=pBase180;
pPlace1、trans、x:
=pPlace1、trans、x;
pPlace1、trans、y:
=pPlace1、trans、y;
pPlace1、trans、z:
=pPlace1、trans、z+2*nBagH;
nOffsX1:
=0;
nOffsY1:
=0;
nOffsZ1:
=nBagH*1、2;
nOffsZ2:
=-500;
nLevel:
=1;
bTwice:
=FALSE;
pAfterPick、trans、z:
=pPick、trans、z+400;
pAbovePlace:
=pPlace1;
pAbovePlace、trans、z:
=pPick、trans、z+400;
bTag:
=True;
CASE12:
pPlace1:
=pBase0;
pPlace1、trans、x:
=pPlace1、trans、x;
pPlace1、trans、y:
=pPlace1、trans、y;
pPlace1、trans、z:
=pPlace1、trans、z+2*nBagH;
nOffsX1:
=0;
nOffsY1:
=0;
nOffsZ1:
=nBagH*1、2;
nOffsZ2:
=-500;
nLevel:
=1;
bTwice:
=FALSE;
pAfterPick、trans、z:
=pPick、trans、z+400;
pAbovePlace:
=pPlace1;
pAbovePlace、trans、z:
=pPick、trans、z+400;
CASE13:
pPlace1:
=pBase90;
pPlace1、trans、x:
=pPlace1、trans、x;
pPlace1、trans、y:
=pPlace1、trans、y+25;
pPlace1、trans、z:
=pPlace1、trans、z+2*nBagH;
nOffsX1:
=0;
nOffsY1:
=0;
nOffsZ1:
=nBagH*1、2;
nOffsZ2:
=-500;
nLevel:
=1;
bTwice:
=FALSE;
pAfterPick、trans、z:
=pPick、trans、z+400;
pAbovePlace:
=pPlace1;
pAbovePlace、trans、z:
=pPick、trans、z+400;
CASE14:
pPlace1:
=pBase90;
pPlace1、trans、x:
=pPlace1、trans、x+2*nBagW;
pPlace1、trans、y:
=pPlace1、trans、y+25;
pPlace1、trans、z:
=pPlace1、trans、z+2*nBagH;
nOffsX1:
=0;
nOffsY1:
=0;
nOffsZ1:
=nBagH*1、2;
nOffsZ2:
=-500;
nLevel:
=1;
bTwice:
=FALSE;
pAfterPick、trans、z:
=pPick、trans、z+400;
pAbovePlace:
=pPlace1;
pAbovePlace、trans、z:
=pPick、trans、z+400;
CASE15:
pPlace1:
=pBase90;
pPlace1、trans、x:
=pPlace1、trans、x+nBagW;
pPlace1、trans、y:
=pPlace1、trans、y+25;
pPlace1、trans、z:
=pPlace1、trans、z+2*nBagH;
nOffsX1:
=0;
nOffsY1:
=0;
nOffsZ1:
=nBagH*1、2;
nOffsZ2:
=-500;
nLevel:
=1;
bTwice:
=FALSE;
pAfterPick、trans、z:
=pPick、trans、z+400;
pAbovePlace:
=pPlace1;
pAbovePlace、trans、z:
=pPick、trans、z+400;
!
layer4
CASE16:
pPlace1:
=pBase180;
pPlace1、trans、x:
=pPlace1、trans、x;
pPlace1、trans、y:
=pPlace1、trans、y+nBagL-5;
pPlace1、trans、z:
=pPlace1、trans、z+3*nBagH+80;
nOffsX1:
=0;
nOffsY1:
=0;
nOffsZ1:
=nBagH*1、2;
nOffsZ2:
=-300;
nLevel:
=1;
bTwice:
=FALSE;
pAfterPick、trans、z:
=pPick、trans、z+400;
pAbovePlace:
=pPlace1;
pAbovePlace、trans、z:
=pPick、trans、z+400;
CASE17:
pPlace1:
=pBase0;
pPlace1、trans、x:
=pPlace1、trans、x;
pPlace1、trans、y:
=pPlace1、trans、y+nBagL-5;
pPlace1、trans、z:
=pPlace1、trans、z+3*nBagH;
nOffsX1:
=0;
nOffsY1:
=0;
nOffsZ1:
=nBagH*1、2;
nOffsZ2:
=-300;
nLevel:
=1;
bTwice:
=FALSE;
pAfterPick、trans、z:
=pPick、trans、z+400;
pAbovePlace:
=pPlace1;
pAbovePlace、trans、z:
=pPick、trans、z+400;
CASE18:
pPlace1:
=pBase270;
pPlace1、trans、x:
=pPlace1、trans、x;
pPlace1、trans、y:
=pPlace1、trans、y;
pPlace1、trans、z:
=pPlace1、trans、z+2*nBagH;
nOffsX1:
=0;
nOffsY1:
=0;
nOffsZ1:
=nBagH*1、2;
nOffsZ2:
=-300;
nLevel:
=1;
bTwice:
=FALS