hexagon logo

Looping question: Unique Input for Each Part plus Skipping Stations

I'd like to write a program capable of inspecting 4 identical parts mounted to fixtures, pitched 100mm apart from one another.
The user will be asked where each part came from (location on on the CNC machine)
Each report pdf will be named to identify where each part came from.
It will be possible to skip one or several of the parts.

The program I have allows me to do all of this except for the looping.

Manual alignment
Ask user part location
DCC alignment
Features
Dimensions
Report with pdf name identifying part location


Using the help file, I can create a simple looping program to measure the four parts, but I'm not sure how to include part identification and part skipping. I'd rather not have to have the program pause between parts while waiting for user input.
  • Step 0: don't use the PC-DMIS Loop & End Loop commands.
    They work great for simple jobs without variation, not for complex work.

    My #1 choice is a Do Until Loop.

    The Do Until Loop is a pair of commands, Do and Until, bracketing your inspection code with the "stop looping" condition being in the Until statement that's at the end of the loop.

    Step 1:
    There is no automatic loop # iteration tracking, you have to code that into the beginning of the loop.
    That's easy - before the loop declare a variable and set it's value to zero
    ASSIGN/COUNTER=0

    Then the very first line after the Do command begins the loop is
    ASSIGN/COUNTER=COUNTER+1


    Here's a sample of that structure:
    ASSIGN/COUNTER=0
                DO/
                ASSIGN/COUNTER=COUNTER+1
    $$ NO,
                "measure the part
                UNTIL/COUNTER==4

    So you see the code inside the Do -Until pair is going to get run 4 times.

    Step 2:
    There is no automatic alignment offsetting, you have to code that into the beginning of the loop.
    To handle this, I find a very effective method is to have a simple Generic Point with:
    a) fixed permanent zeros (0+0 formulas) in the Nom fields,
    b) variables on the Meas fields.
    Then a simple Origin Only alignment that sets the Generic Point as origin.
    But the real trick is that the Meas or actual values of the generic point come from some simple IF statements based on the COUNTER # of the loop corresponding to which fixture station.


    ASSIGN/COUNTER=0
                DO/
                ASSIGN/COUNTER=COUNTER+1
                IF/COUNTER==1
                  ASSIGN/FIXTURE_X=0
                END_IF/
                IF/COUNTER==1
                  ASSIGN/FIXTURE_X=100
                END_IF/
                IF/COUNTER==1
                  ASSIGN/FIXTURE_X=200
                END_IF/
                IF/COUNTER==1
                  ASSIGN/FIXTURE_X=300
                END_IF/
    LOOP_ORIGIN=GENERIC/POINT,DEPENDENT,CARTESIAN,$
                NOM/XYZ,<0+0,0+0,0+0>,$
                MEAS/XYZ,<FIXTURE_X,0+0,0+0>,$
                NOM/IJK,<0+0,0+0,1+0>,$
                MEAS/IJK,<0+0,0+0,1+0>
    
    A1         =ALIGNMENT/START,RECALL:STARTUP,LIST=YES
                  ALIGNMENT/TRANS,XAXIS,LOOP_ORIGIN
                ALIGNMENT/END
    $$ NO,
                "measure the part
                UNTIL/COUNTER==4


    With this method, the nominals of the code inside the loop can NEVER be modified accidentally by PC-DMIS.

    Chew on that for a minute while I check on my students.


  • This almost makes sense, and will probably become more concrete as I write a simple test program. Thanks!

    I may be a while before asking more, because I'm running a CNC while working on this little side project.

    Thanks!
  • Now the next two tricks are how to get Operator Input for information for report and report name - the Production Machine ID per part, and how to skip empty stations.

    The most AWESOME way to accomplish this is by creating a PC-DMIS form that pops up with four neat boxes that visually correspond to the four fixture stations, and inside each box are test boxes where they type in the required information. Then Visual Basic code written into the background of the form takes those entries and passes them to PC-DMIS as the current values of variables, and if a station is left empty the current value of the variable is null (or "") and this information can easily be used to skip an empty station.
    However, there's literally no way for me to train you on Form creation via this forum. It would take me 2 days of solid work, creating screenshots and typing. Instead I'm just going to tell you to sign up for PC-DMIS for CMMs 301 class where we teach it.

    The next way would be do a similar custom operator input system using a Visual Basic .BAS script. This provides fewer formatting options, and being text-based doesn't have the editing flexibility of the Form, and is also beyond "forum training". Check the
    http://www.pcdmisforum.com/forum/pc-dmis-enterprise-metrology-software/pc-dmis-code-samples
    section for examples of BAS files.

    The other way is to simply have a series of Operator Input Comments at the very beginning of the program before the looping, asking for the info for each station.
    The biggest drawback to this method is that the Comments retain their last-entered values and lazy operators simply hit the enter key without bothering to edit the input!


    Once you've got the input method down, then it's time to use it to direct PDF printing.
    For this, a Print Command combined with variable concatenation might work:
                ASSIGN/DATE=SYSTEMDATE("ddMMMyyyy")
                ASSIGN/TIME=SYSTEMTIME("HHmm")
                ASSIGN/PARTNAME=STR(GETTEXT(191,1,{FILEHEDR}))
                ASSIGN/PDFNAME="C:\Users\Public\Documents\\"+PARTNAME+"_"+MACHINE_ID+"_"+TIME+"_"+DATE+".PDF"
    
                PRINT/REPORT,EXEC MODE=END,$
                  TO_FILE=ON,OVERWRITE=PDFNAME,AUTO OPEN REPORT=OFF,$
                  TO_PRINTER=OFF,COPIES=1,$
                  TO_DMIS_REPORT=OFF,FILE_OPTION=OVERWRITE,FILENAME=,$
                  REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
                  TO_EXCEL_OUTPUT=OFF,
                  PREVIOUS_RUNS=KEEP_INSTANCES
    
  • When I call LOOP_ORIGIN in the alignment, I get red text. Why is that? (I double checked to ensure the names of both were identical. I even tried temporarily renaming them Z just to be sure they were identical. When I renamed LOOOP_ORIGIN, the alignment call of LOOP_ORIGIN did not automatically update to the new name)


    Now I REALLY want to take level 3. Gonna have work on convincing the boss Slight smile
  • should be able to use on error commands to skip over empty stations, take a point as the first feature in each station, if the part is not there then the on error would trigger and the program could jump to the next station.
  • When I call LOOP_ORIGIN in the alignment, I get red text. Why is that? (I double checked to ensure the names of both were identical. I even tried temporarily renaming them Z just to be sure they were identical. When I renamed LOOOP_ORIGIN, the alignment call of LOOP_ORIGIN did not automatically update to the new name)


    Now I REALLY want to take level 3. Gonna have work on convincing the boss Slight smile


    If you have RED script in a variable it does not like the variable (script name or variable of assign line of code; spacing, special characters or reserved words are common cause for this error)
    Often time when using a variable in and alignment or command group it will ask you if that is the variable you are trying to use and you have to answer yes when that question comes up; My understanding is that creates the connection of the variable used and assignment lines of code.

    Post code
  • Edit:
    Never mind. I just got back to messing with this program, and when I re opened it, the red text was no longer red.



    Here's the problem I'm having with Jeff's sample code:

    
    LOOP_ORIGIN=GENERIC/POINT,DEPENDENT,CARTESIAN,$
    NOM/XYZ,<0+0,0+0,0+0>,$
    MEAS/XYZ,<FIXTURE_X,0+0,0+0>,$
    NOM/IJK,<0+0,0+0,1+0>,$
    MEAS/IJK,<0+0,0+0,1+0>
    
    A1 =ALIGNMENT/START,RECALL:STARTUP,LIST=YES
    ALIGNMENT/TRANS,XAXIS,[COLOR=red]LOOP_ORIGIN[/COLOR]
    ALIGNMENT/END
    

  • Just in case it's useful to someone else, here's what I have so far, which I tested and it works.
    Typically I set up file name variables in a way that reduces the chances of incorrect entry. This test program is pretty wide open.
    Unfortunately I won't have spare time to play tomorrow, so I'll have to figure out how to allow it to skip stations, if necessary, later.

    PART NAME  : Loop Test
    REV NUMBER : 1
    SER NUMBER :
    STATS COUNT : 1
    
    STARTUP    =ALIGNMENT/START,RECALL:USE_PART_SETUP,LIST=YES
                ALIGNMENT/END
                MODE/MANUAL
                PREHIT/2
                RETRACT/2
                MOVESPEED/ 100
                TOUCHSPEED/ 1
                FLY/ON
                FORMAT/TEXT,OPTIONS, ,HEADINGS,SYMBOLS, ;NOM,TOL,MEAS,DEV,OUTTOL, ,
    $$ NO,
                *************************
                Report Filename Variables
                *************************
    
                ASSIGN/PARTNAME=STR(GETTEXT(191,1,{FILEHEDR}))
                ASSIGN/REVNUMBER=STR(GETTEXT(192,1,{FILEHEDR}))
    $$ NO,
    
                ======================
                Identify part location
                ======================
    
    C1         =COMMENT/INPUT,NO,FULL SCREEN=NO,
                Station 1 part identification:
                ASSIGN/LOCATION_1=C1.INPUT
    C2         =COMMENT/INPUT,NO,FULL SCREEN=NO,
                Station 2 part identification:
                ASSIGN/LOCATION_2=C2.INPUT
    C3         =COMMENT/INPUT,NO,FULL SCREEN=NO,
                Station 3 part identification:
                ASSIGN/LOCATION_2=C3.INPUT
    C4         =COMMENT/INPUT,NO,FULL SCREEN=NO,
                Station 4 part identification:
                ASSIGN/LOCATION_2=C4.INPUT
    $$ NO,
    
                ====================
                Load probe and Align
                ====================
    
                LOADPROBE/1MM BY 20MM
                TIP/T1A0B0, SHANKIJK=0, 0, 1, ANGLE=0
    
    Feature for alignment
    Feature for alignment
    Feature for alignment
    
    A1         =ALIGNMENT/START,RECALL:STARTUP,LIST=YES
                  ALIGNMENT/LEVEL,ZPLUS,PLN1
                  ALIGNMENT/ROTATE,XPLUS,TO,LIN1,ABOUT,ZPLUS
                  ALIGNMENT/TRANS,XAXIS,PNT1
                  ALIGNMENT/TRANS,YAXIS,LIN1
                  ALIGNMENT/TRANS,ZAXIS,PLN1
                ALIGNMENT/END
                MODE/DCC
                CLEARP/ZPLUS,150,ZPLUS,0,OFF
                MOVE/CLEARPLANE
    $$ NO,
    
                ****
                Loop
                ****
    
                ASSIGN/COUNTER=0
                DO/
                ASSIGN/COUNTER=COUNTER+1
                IF/COUNTER==1
                  ASSIGN/FIXTURE_X=0
                  ASSIGN/LOCATION=C1.INPUT
                END_IF/
                IF/COUNTER==2
                  ASSIGN/FIXTURE_X=100
                  ASSIGN/LOCATION=C2.INPUT
                END_IF/
                IF/COUNTER==3
                  ASSIGN/FIXTURE_X=200
                  ASSIGN/LOCATION=C3.INPUT
                END_IF/
                IF/COUNTER==4
                  ASSIGN/FIXTURE_X=300
                  ASSIGN/LOCATION=C4.INPUT
                END_IF/
    $$ NO,
    
                ==============================
                Complete report name variables
                ==============================
    
                ASSIGN/VAR_REPORTNAME="R:\\PCDMIS Data\\Sample Programs\\Loop with DO_UNTIL\\Reports\\" + PARTNAME + "-" + REVNUMBER + LOCATION + " " + ".PDF"
                COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
    
    
    LOOP_ORIGIN=GENERIC/POINT,DEPENDENT,CARTESIAN,$
                NOM/XYZ,<0+0,0+0,0+0>,$
                MEAS/XYZ,<FIXTURE_X,0+0,0+0>,$
                NOM/IJK,<0+0,0+0,0+1>,$
                MEAS/IJK,<0+0,0+0,0+1>
    A2         =ALIGNMENT/START,RECALL:A1,LIST=YES
                  ALIGNMENT/TRANS_OFFSET,XAXIS,LOOP_ORIGIN
                ALIGNMENT/END
    $$ NO,
    
                ************
                Part Program
                ************
    
    Features
    Features
    Dimensions
    Dimensions
    
    $$ NO,
                ************
                Print report
                ************
                PRINT/REPORT,EXEC MODE=END,$
                  TO_FILE=ON,AUTO=VAR_REPORTNAME,AUTO OPEN REPORT=OFF,$
                  TO_PRINTER=OFF,COPIES=1,$
                  TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
                  REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=YES,$
                  TO_EXCEL_OUTPUT=OFF,
                  PREVIOUS_RUNS=DELETE_INSTANCES
                UNTIL/COUNTER==4