hexagon logo

Alignment in Subroutine Not Working

Hi All,

I've worked with subroutines a bit before, but so far mostly to put math stuff in one place out of the main program. Today I'm working on writing an external subroutine to measure a threaded hole using something like this: < https://www.pcdmisforum.com/forum/pc...ion-of-threads>. I think this might be my first subroutine that I've actually tried to measure features in.

My first step in the subroutine is to create an alignment directly over the hole, which vastly simplifies the feature programming. However, PC-DMIS is not using the alignment properly. Move points move the machine relative to the alignment as I would expect; however, it is trying to probe all of my measured features as if they were at the CAD origin rather than at the center of my alignment!

Here is my subroutine code so far:


SUBROUTINE/THREADSCANNER,
POSITION = : POSITION OF HOLE IN ACTIVE ALIGNMENT,
DIRECTION = : DIRECTION VECTOR (POINTING STRAIGHT OUT OF HOLE) IN ACTIVE ALIGNMENT,
ORIENTATION = : VECTOR NORMAL TO DIRECTION, POINTING TO SIDE TO VERTICALLY SCAN,
MINOR_DIA = : NOMINAL MINOR DIAMETER OF HOLE,
MAX_DEPTH = : DEPTH TO START VERTICAL SCAN AT (MUST BE AT LEAST 2*PITCH BELOW TOP),
PITCH = : PITCH OF THREAD,
SCAN_REVS = : NUMBER OF REVOLUTIONS TO SPIRAL SCAN (MUST FIT WITHIN HOLE),
MOVESPD = : SPEED DURING MOTION,
RADIAL_DISTANCE_TOL = 0.001 : POINTS WITHIN THIS DISTANCE FROM HIGH POINT WILL BE CONSIDERED ON THE CREST,
MIN_CREST_TOL = 0.125 : MINIMUM ACCEPTABLE CREST WIDTH AS A PERCENTAGE OF PITCH,
MAX_CREST_TOL = 0.375 : MAXIMUM ACCEPTABLE CREST WIDTH AS A PERCENTAGE OF PITCH,
=
$$ NO,
**WARNING: THIS WILL MOVE THE MACHINE!!!**
If you type in dumb numbers, it will do dumb things.
Also, make sure your tip angle is right.
ACCELERATION/MAXACCELX=250, MAXACCELY=250, MAXACCELZ=250
MOVESPEED/ MOVESPD
$$ NO,
Align to hole, move to top
POSITION_POINT=GENERIC/POINT,DEPENDENT,CARTESIAN,$
NOM/XYZ,<POSITION.X,POSITION.Y,POSITION.Z>,$
MEAS/XYZ,<POSITION.X,POSITION.Y,POSITION.Z>,$
NOM/IJK,<DIRECTION.X,DIRECTION.Y,DIRECTION.Z>,$
MEAS/IJK,<DIRECTION.X,DIRECTION.Y,DIRECTION.Z>
ORIENTATION_LINE=GENERIC/LINE,DEPENDENT,CARTESIAN,$
NOM/XYZ,<POSITION.X,POSITION.Y,POSITION.Z>,$
MEAS/XYZ,<POSITION.X,POSITION.Y,POSITION.Z>,$
NOM/IJK,<ORIENTATION.X,ORIENTATION.Y,ORIENTATION.Z>,$
MEAS/IJK,<ORIENTATION.X,ORIENTATION.Y,ORIENTATION.Z>,$
DISTANCE/1,1
[COLOR=#2980b9]HOLE_ALIGNMENT=ALIGNMENT/START,RECALL:STARTUP,LIST=YES
ALIGNMENT/LEVEL,ZPLUS,POSITION_POINT
ALIGNMENT/ROTATE,XPLUS,TO,ORIENTATION_LINE,ABOUT,ZPLUS
ALIGNMENT/TRANS,XAXIS,POSITION_POINT
ALIGNMENT/TRANS,YAXIS,POSITION_POINT
ALIGNMENT/TRANS,ZAXIS,POSITION_POINT
ALIGNMENT/END[/COLOR]
[COLOR=#27ae60]MOVE/POINT,NORMAL,<0,0,0>
MOVE/POINT,NORMAL,<0,0,0.1>
MOVE/POINT,NORMAL,<0.05,0,0>
MOVE/POINT,NORMAL,<0,0,0>
MOVE/INCREMENT,<0,0,0.1>
MOVE/INCREMENT,<0.1,0,0>[/COLOR]
[COLOR=#e74c3c]TEST_MEAS_POINT=FEAT/POINT,CARTESIAN
THEO/<0,0,0>,<0,0,1>
ACTL/<0,0,0>,<0,0,1>
MEAS/POINT,1,WORKPLANE
HIT/BASIC,NORMAL,<0,0,0>,<0,0,1>,<0,0,0>,USE THEO=YES
ENDMEAS/[/COLOR]
[COLOR=#e74c3c]TEST_POINT =FEAT/CONTACT/VECTOR POINT/DEFAULT,CARTESIAN
THEO/<0,0,0>,<0,0,1>
ACTL/<0,0,0>,<0,0,1>
TARG/<0,0,0>,<0,0,1>
SNAP=NO
SHOW FEATURE PARAMETERS=NO
SHOW CONTACT PARAMETERS=YES
AVOIDANCE MOVE=NO,DISTANCE=0.4
SHOW HITS=NO[/COLOR]
$$ NO,
Set scanning options to take ~1 second with 100 points, make vertical scan
ASSIGN/VERTICAL_SCAN_LENGTH=PITCH*2
ASSIGN/VERTICAL_SCAN_LENGTH_MM=VERTICAL_SCAN_LENGTH*25.4
SCANSPEED/VERTICAL_SCAN_LENGTH_MM
OPTIONPROBE/MAXFORCE=0.36,LOWFORCE=0.06,UPPERFORCE=0.18,TRIGGE RFORCE=0.06,
PROBEACCURACY=0.1,POSACCURACY=0.1,#RETURNDATA=7,
RETURNSPEED=1,SCANPNTDENSITY=100/VERTICAL_SCAN_LENGTH_MM,
SCANACCELERATION=10,SCANOFFSETFORCE=0.06,
PROBINGMODE=DFL,MANFINEPROBING=NO
PREHIT/MINOR_DIA/2
RETRACT/MINOR_DIA/2
TOUCHSPEED/ 1
[COLOR=#e74c3c]VERT_LINE_SCAN=BASICSCAN/LINE,NUMBER OF HITS=2,SHOW HITS=YES,SHOWALLPARAMS=YES
<MINOR_DIA/2,0,-MAX_DEPTH>,<MINOR_DIA/2,0,-MAX_DEPTH+VERTICAL_SCAN_LENGTH>,CutVec=0,1,0,DirVe c=0,0,1
InitVec=-1,0,0,EndVec=-1,0,0,THICKNESS=0,PROBECOMP=YES,AVOIDANCE MOVE=NO,DISTANCE=0
FILTER/NULLFILTER,
EXEC MODE=DEFINED
BOUNDARY/PLANE,<0,0,0>,PlaneVec=0,0,-1,Crossings=1
HITTYPE/VECTOR
NOMS MODE=NOM,0.05
HIT/VECTOR,<0,0,0>,<-1,0,0>,<0,0,0>,T=0
HIT/VECTOR,<0,0,0>,<-1,0,0>,<0,0,0>,T=0
ENDSCAN[/COLOR]
ENDSUB/



The move points in green work, both in simulation and on the machine; the features in red do not work in either simulation or reality (or at least, the first one doesn't in reality; I didn't let it bury itself in my part just to test the next two Slight smile ). Here's the code I'm calling it with, if that helps:


MOVE/CLEARPLANE
MILL_MILL_1=CALLSUB/THREADSCANNER,"THREAD_SCANNER":MPOINT(-0.15,0.375,0),MPOINT(0,0,1),MPOINT(0,1,0),0.07,0.0 5,1/56,1,20,,



This is preceded by manual, rough, and finish alignments which I can post as well if that would be helpful.

Does anyone know why my alignment might work for movements but not for measurements, or how I can fix it so it works for both?

Thank you,
Matthew
Parents
  • Good stuff love that you commented along the entire way.

    If I was going to use your SUB at your company my first question would be:
    SUBROUTINE/THREADSCANNER,
    POSITION = : POSITION OF HOLE IN ACTIVE ALIGNMENT, [COLOR=#e74c3c]<<-- what type do I pass in?[/COLOR]
    DIRECTION = : DIRECTION VECTOR (POINTING STRAIGHT OUT OF HOLE) IN ACTIVE ALIGNMENT, [COLOR=#e74c3c]<<<<<<<<<<<<<<[/COLOR]
    ORIENTATION = : VECTOR NORMAL TO DIRECTION, POINTING TO SIDE TO VERTICALLY SCAN, [COLOR=#e74c3c]<<<<<<<<<<<<<<[/COLOR]
    MINOR_DIA = : NOMINAL MINOR DIAMETER OF HOLE, [COLOR=#e74c3c]<<<<<<<<<<<<<<[/COLOR]
    MAX_DEPTH = : DEPTH TO START VERTICAL SCAN AT (MUST BE AT LEAST 2*PITCH BELOW TOP[COLOR=#e74c3c]),<<<<<<<<<<<<<<[/COLOR]
    PITCH = : PITCH OF THREAD, [COLOR=#e74c3c]<<<<<<<<<<<<<<[/COLOR]
    etc.......
    

    and the type of return I should expect. I would be able to figure it by going thru the code though having it available minimizes thinking.
Reply
  • Good stuff love that you commented along the entire way.

    If I was going to use your SUB at your company my first question would be:
    SUBROUTINE/THREADSCANNER,
    POSITION = : POSITION OF HOLE IN ACTIVE ALIGNMENT, [COLOR=#e74c3c]<<-- what type do I pass in?[/COLOR]
    DIRECTION = : DIRECTION VECTOR (POINTING STRAIGHT OUT OF HOLE) IN ACTIVE ALIGNMENT, [COLOR=#e74c3c]<<<<<<<<<<<<<<[/COLOR]
    ORIENTATION = : VECTOR NORMAL TO DIRECTION, POINTING TO SIDE TO VERTICALLY SCAN, [COLOR=#e74c3c]<<<<<<<<<<<<<<[/COLOR]
    MINOR_DIA = : NOMINAL MINOR DIAMETER OF HOLE, [COLOR=#e74c3c]<<<<<<<<<<<<<<[/COLOR]
    MAX_DEPTH = : DEPTH TO START VERTICAL SCAN AT (MUST BE AT LEAST 2*PITCH BELOW TOP[COLOR=#e74c3c]),<<<<<<<<<<<<<<[/COLOR]
    PITCH = : PITCH OF THREAD, [COLOR=#e74c3c]<<<<<<<<<<<<<<[/COLOR]
    etc.......
    

    and the type of return I should expect. I would be able to figure it by going thru the code though having it available minimizes thinking.
Children