`--点位定义--
local POS = {Standby=p51,Put=p52,TakePhoto=p53}
p12["x"],p12["y"],p12["z"],p12["c"],p12["h"]=p11["x"]+175,p11["y"],p11["z"],p11["c"],p11["h"]
p13["x"],p13["y"],p13["z"],p13["c"],p13["h"]=p11["x"],p11["y"]+375,p11["z"],p11["c"],p11["h"]
local PLT = {No=1,org=p11,xx=p12,yy=p13,XN=2,YN=5} --码垛参数
local CCDPos = {x=0,y=0,z=0,c=0,h=0} --像素
--IO定义--
local IO = {SuctionAir=0,BrokenAir=1}
--其他定义--
local n,data,T1,OnePieceTime
local TIME = {SuctionAir=10,BrokenAir=10,TakePhoto=5,WaitFor=10}
--IO初始化
DO({IO["SuctionAir"],IO["BrokenAir"]},{OFF,ON});Delay(TIME["BrokenAir"]);
MotOn();Delay(TIME["WaitFor"]);
SetU(0);SetT(0);
MovJ(J3,0)
MArchP(POS["Standby"],-85,5,5)
SetPlt(PLT["No"],PLT["org"],PLT["xx"],PLT["yy"],PLT["XN"],PLT["YN"])
while true do
T1 = systime()
for index=1,PLT["XN"]*PLT["YN"] do
MArchP(GetPlt(PLT["No"],(index-1)%PLT["XN"]+1,(index-1)//PLT["XN"]+1),-85,5,5)
DO({IO["BrokenAir"],IO["SuctionAir"]},{OFF,ON});Delay(TIME["SuctionAir"]);
MArchP(POS["TakePhoto"],-85,5,5);Delay(TIME["WaitFor"]);
::start::
CCDclr("CAM0")
CCDsent("CAM0","0,0,0,0;")
Delay(TIME["TakePhoto"])
n,data=CCDrecv("CAM0")
if data then
if((data[n][1]~=0)and(data[n][2]~=0))and(n==1)then
print(n,data[n][1],data[n][2],data[n][3])
CCDPos["x"] = data[n][1]
CCDPos["y"] = data[n][2]
CCDPos["c"] = data[n][3]
V2Tool(CCDPos,2)
else
print("XY坐标为0!")
--Pause()
goto start
end
else
print("拍照失败!")
--Pause()
goto start
end
--
SetU(0);SetT(2);
--Pause()
MovP(POS["Put"]+Z(30),"CP=90") --Put Up
MovP(POS["Put"]);Delay(TIME["WaitFor"]); --Put Down
DO({IO["SuctionAir"],IO["BrokenAir"]},{OFF,ON});Delay(TIME["BrokenAir"]); --BrokenAir
MovP(POS["Put"]+Z(30),"CP=90") --Get Up
Delay(80)
MovP(POS["Put"]) --Get Down
DO({IO["BrokenAir"],IO["SuctionAir"]},{OFF,ON});Delay(TIME["SuctionAir"]); --SuctionAir
MovP(POS["Put"]+Z(30),"CP=90") --Get Up
SetU(0);SetT(0);
MArchP(GetPlt(PLT["No"],(index-1)%PLT["XN"]+1,(index-1)//PLT["XN"]+1),-85,5,5) --PLT
DO({IO["SuctionAir"],IO["BrokenAir"]},{OFF,ON});Delay(TIME["BrokenAir"]); --BrokenAir
end
OnePieceTime = ((systime()-T1)/1000)/(PLT["XN"]*PLT["YN"])
print("平均完成1片的时间是:"..OnePieceTime.."S")
if(OnePieceTime>(60*60)/2500)then
print("慢了"..OnePieceTime-(60*60)/2500 .."S")
else
print("快了"..(60*60)/2500-OnePieceTime.."S")
end
end
end`
共同学习,写下你的评论
评论加载中...
作者其他优质文章