Hello everyone, I made a project using the SearchL command, a part finder project. I've made some progress, but I'm having trouble somewhere. When the robot goes to Box1 and picks up the part, everything works as I want it to. However, Box1 gives a Search Error when it cannot find a part. I'm trying to program this in rapid error handling. If it can't find it, I want it to search Box1 again. If it can't find it in a search again, I want it to go to Box2. And if it finds it there, go to "gomark_1" again. However, if it can't find it after two searches, it should go to the Home position and wait for me to press the start button again. However, I'm having trouble with the error handling part. I can't run the error handling twice in Box 1 and 2. Even if you run it only once, it goes to the "pendbox2" point, which is the last search part of Box 2, and gives a Search Error again. I couldn't understand where I made a mistake. Could you help?
I am sharing my code below, I have also shared it in .txt format. Thank you.
MODULE Search_L_Example
! Box-1 Start and End Point
CONST robtarget pStartbox1:= [[1076.48,4.89,1045.62],[0.00409052,-0.558244,0.829555,-0.0136419],[0,-1,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget pEndbox1:= [[1078.37,4.89,474.31],[0.00408344,-0.558227,0.829566,-0.0136351],[0,-1,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
! Box-2 Start and End Point
CONST robtarget pstartbox2:= [[580.82,-686.54,1227.32],[0.00427247,-0.558234,0.829558,-0.0137694],[-1,0,-2,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget pendbox2:= [[587.71,-686.54,604.37],[0.00427365,-0.558245,0.829551,-0.0137545],[-1,0,-2,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
! pfound / active the position is stored
VAR robtarget pFound;
VAR robtarget pFound2;
PROC search_part_routine()
R_Open_valve;
MoveAbsJ [[1.51802,-36.4441,33.6546,-1.06968,91.5557,-66.399],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]]\NoEOffs, v1000, z50, tool0;
MoveL pStart, v100,fine,tool0;
SearchL\PStop , DI_part_detect ,pFound,pEnd,v100,tool0;
R_Close_Valve;
go_mark1;
! Define Error.
ERROR
IF ERRNO=ERR_WHLSEARCH THEN
R_Open_valve;
MoveL pStartbox1,v1000,z50,tool0;
! if part not found on Box1, /// Search Box-2
MoveL pstartbox2,v300,z50,tool0;
SearchL\PStop, DI_part_detect, pFound2,pend2,v100,tool0;
!RETURN;
ELSEIF ERRNO=ERR_SIGSUPSEARCH THEN
TPWrite "part not found!";
TPReadFK reg1,"Robot go home?",
"YES","stEmpty","stEmpty","stEmpty","NO";
IF reg1 = 1 THEN
TPWrite "Robot going home!";
MoveAbsJ [[1.51802,-36.4441,33.6546,-1.06968,91.5557,-66.399],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]]\NoEOffs, v1000, z50, tool0;
Stop;
ELSE
Stop;
ENDIF
ENDIF
ENDPROC
Display More