hexagon logo

Very new too coding.

Hey all, I have been trying out some if/ statements and what not. The hardest part is knowing the syntax to use. Is there a place I can go to find working syntax? Also, I wanted to see if this code would work the way i wanted it too. so here is the code-->

MODE/DCC
LOADPROBE/PRB2
TIP/T1A0B0, SHANKIJK=0, 0, 1, ANGLE=0
C1 =COMMENT/INPUT,NO,FULL SCREEN=NO,
OPERATOR:
C2 =COMMENT/INPUT,NO,FULL SCREEN=NO,
REASON FOR RUN:
C3 =COMMENT/INPUT,NO,FULL SCREEN=NO,
SAMPLE #:
C4 =COMMENT/YESNO,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
HAS PART MOVED SINCE LAST RUN?
IF/C4.INPUT=="YES"
END_IF/
IF/C4.INPUT=="NO"
RDPNT =FEAT/POINT,CARTESIAN
THEO/<0,0,0>,<0,0,1>
ACTL/<0,0,0>,<0,0,1>
READPOINT/
IF/RDPNT.Z<100
MOVE/INCREMENT,<0,0,200>
END_IF/
MOVE/POINT,NORMAL,<0,0,100>
MOVE/POINT,NORMAL,<0,0,0>
GOTO/READPNT
END_IF/
COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
PLACE PROBE IN THE STARTING POSITION. SEE CAD FOR REFERENCE.
READPNT =FEAT/POINT,CARTESIAN
THEO/<0,0,0>,<0,0,1>
ACTL/<0,0,0>,<0,0,1>
READPOINT/
RDPNTALIGNX =ALIGNMENT/START,RECALL:STARTUP,LIST=YES
ALIGNMENT/TRANS,XAXIS,READPNT
ALIGNMENT/TRANS,YAXIS,READPNT
ALIGNMENT/TRANS,ZAXIS,READPNT
ALIGNMENT/END
CIR1 =FEAT/CONTACT/CIRCLE/DEFAULT,CARTESIAN,IN,LEAST_SQR
THEO/<0,0,0>,<0,0,1>,9
ACTL/<0,0,0>,<0,0,1>,9
TARG/<0,0,0>,<0,0,1>
START ANG=0,END ANG=360
ANGLE VEC=<1,0,0>
DIRECTION=CCW
SHOW FEATURE PARAMETERS=NO
SHOW CONTACT PARAMETERS=YES
NUMHITS=7,DEPTH=2,PITCH=0
SAMPLE METHOD=SAMPLE_HITS
SAMPLE HITS=0,SPACER=0
AVOIDANCE MOVE=NO,DISTANCE=10
FIND HOLE=DISABLED,ONERROR=NO,READ POS=NO
SHOW HITS=NO

I would like the program to be able to run on its own with no operator touching the jog box as long as the part has ran once already. Would this work the way I am wanting it too? Is there a better code sample for doing this that I haven't seen?

Thanks in advance.
Parents
  • On an if/then statement, if you're only checking for one answer, you don't have to do anything for the other answer. In your code you have

    IF/C4.INPUT=="YES"
    END_IF/


    In plain language, evaluating for both conditions when you only want one looks something like this

    If the door is open (YES), close it. If the door is not open (NO), don't close it.

    I could have stopped after the first sentence, the second sentence must be the case if the first isn't true, and I'm not doing anything in the second case, so I don't need it documented. It's a minor thing, but...

    Another thing -

    IF/RDPNT.Z<100
    MOVE/INCREMENT,<0,0,200>
    END_IF/
    MOVE/POINT,NORMAL,<0,0,100>


    Good plan, but what if the Z axis is only 190 away from the end of travel? You throw an error and the program stops execution. You want to make sure the probe is a certain height and, IF it isn't, move it straight up without an X or Y move. There are two ways to do this that are easier.

    Since you want to get to 100, try either example below

    {code]MOVE/POINT,NORMAL,<,,100>[/code]

    or

    PNT1 =FEAT/POINT,CARTESIAN
    THEO/<0.1339,-2.845,0.7591>,<-1,0,0>
    ACTL/<0.1339,-2.845,0.7591>,<-1,0,0>
    READPOINT/
    MOVE/POINT,NORMAL,<PNT1.X,PNT1.Y,100>
    ]code]
  • Makes sense. If/C4.input=="yes" has been taken out. Thanks for the info.
Reply Children
No Data