hexagon logo

using onerror commands in PCDIMS Vision

Hi
Not found the need to use ONERROR statements before; always found a work around until now. I am having edge detection issues, which I know, can be resolved by reversing the polarity of the edge, I can do this manually and it works. I have used the ONERROR statement. Which appears to have resolved the issue of the program stopping, but I do not fully understand what it is doing, even though it outputs a result. Any guidance would be welcome.

ONERROR/EDGE_NOT_DETECTED,SET EDGE
AC1_WNGTRM_UPPER_EDGE2=FEAT/VISION/LINE/DEFAULT,CARTESIAN,BOUNDED
THEO/<-0.2,-74.8611,0>,<0.2,-74.862,0>,<1,-0.0023,0>,<-0.00225,-0.9999973,0.0005844>,<0.0001739,0.000584,0.9999998>,0.4
ACTL/<-0.276,-74.8579,0.0003>,<0.1239,-74.8583,0.0003>,<1,-0.0009,-0.0002>,<-0.0009297,-0.9999994,0.000565>,<-0.0000916,-0.0001494,1>,0.3999
TARG/<-0.2,-74.8611,0>,<0.2,-74.862,0>,<1,-0.0023,0>,<-0.00225,-0.9999973,0.0005844>,<0.0001739,0.000584,0.9999998>
SHOW FEATURE PARAMETERS=NO
SHOW_VISION_PARAMETERS=YES
TYPE=AUTOMATIC HIT TARGET
COVERAGE=100%
COVERAGE ACTIVE TARGETS=4
MAGNIFICATION=13.5817
HIT TARGET COLOR=YELLOW,NOMINAL COLOR=GREEN
HIT TARGET=EA1,0,1,HIGH,0.04
FILTER=NO,YES,0,1.9
EDGE=MATCHING EDGE,5,[|]->[ ],-->,-1,-1,-1,NO,Toplight=<OFF,29,OFF>,Backlight=<OFF,36,OFF>,Ringlight=<OFF,100,ON>
FOCUS=NO
ONERROR/EDGE_NOT_DETECTED,OFF
  • Xaarman, I will get the ball rolling here, but have only rarely used OnError myself.

    As I recall, I used OnError as a sort of label/subroutine that the program will go to when a vision feature error is detected. If you are intending to error handle multiple points of the same feature type, then you may need to variablize the measured and theoretical xyz ijk to carry over data from the failed point.

    If it is just one point you are trying to error handle, then you can hard code the measured point, but change the edge detect parameters.

    Here is an example where I used OnError for missed z focus. Some parts were very far off in Z, but running 60 points with a 7mm focus would have taken a very long time on a lot of parts. Error handling allowed me to run most parts more quickly and only use the greater focus range for bad parts.

    The point location data were read in from a .csv file and the program looped through a single z focus point using the point data pulled from file. When an error was detected, the focus range and time were incremented.
    ONERROR/FOCUS_NOT_DETECTED,GOTO MISSFOCUS
    DO/
                ASSIGN/REMEASURED=0
                ASSIGN/FOCUSRANGE=4
                ASSIGN/FOCUSTIME=FOCUSRANGE*2
    V1         =FILE/READLINE,FPTR,{RowNum} + ";" + {ColNum} + ";" + {Meas_X} + ";" + {Meas_Y} + ";" + {Meas_Z} + ";" + {Measured} + ";" + {IVEC} + ";" + {JVEC} + ";" + {KVEC}
                IF/MEASURED=="Yes"
                ASSIGN/POINTID="C" + COLNUM + "-R" + ROWNUM
    REMEASURE  =LABEL/
    POINTID    =FEAT/VISION/SURFACE POINT/DEFAULT,CARTESIAN
                THEO/<MEAS_X,MEAS_Y,MEAS_Z>,<IVEC,JVEC,KVEC>
                ACTL/<47.1,142,11.835>,<0.0000875,0.0001729,1>
                TARG/<MEAS_X,MEAS_Y,MEAS_Z>,<IVEC,JVEC,KVEC>
                SNAP=NO
                SHOW FEATURE PARAMETERS=NO
                SHOW_VISION_PARAMETERS=YES
                  TYPE=AUTOMATIC HIT TARGET
                  MAGNIFICATION=6.567
                  HIT TARGET COLOR=YELLOW,NOMINAL COLOR=GREEN
                  HIT TARGET=SA1,YES,0.13,0.13
                  FOCUS=FULL,FOCUSRANGE,YES,FOCUSTIME,-1,-1,-1,NO,Toplight=<OFF,60,ON>,Backlight=<OFF,40,OFF>,Ringlight=<OFF,0,ON>
    MEASFAIL   =LABEL/
    UNTIL/V1=="EOF"
                FILE/CLOSE,FPTR,KEEP
                GOTO/ENDPROG
    MISSFOCUS  =LABEL/
                IF/REMEASURED<5
                ASSIGN/FOCUSRANGE=FOCUSRANGE+5
                ASSIGN/FOCUSTIME=FOCUSRANGE*2
                ASSIGN/REMEASURED=REMEASURED+1
                GOTO/REMEASURE
                END_IF/
                ELSE_IF/REMEASURED>=3
                ASSIGN/MEASURED="Failed"
                GOTO/MEASFAIL
                END_ELSEIF/
    ENDPROG    =LABEL/


    In your case, under the MISSFOCUS label, you could have another measured edge detect feature with the detection vector flipped. In my case, I used it to increment focus parameters, then retry the same measured point.