DECL/COMMON,INTGR,Doloop,DONUM,LSTEP
DECL/COMMON,DOUBLE,DR_PRBRAD,TOL2,TOL1
DECL/COMMON, DOUBLE, VI, VJ, VK, VI2, VJ2, VK2
DECL/COMMON, DOUBLE, GAGEHEIGHT, GAGEWIDTH, ENDCLEAR
DECL/COMMON, DOUBLE, BLENGTH[30], ZP, XP, BL, LB
DECL/CHAR,20,PROB
$$ 步距规步长30,可以自行修改
LSTEP = ASSIGN/30
$$ 步距规步数20,可以自行修改
Doloop = ASSIGN/20
$$ 循环次数3,可以自行修改
DONUM = ASSIGN/10
$$ 机器精度1.5,可以自行修改
TOL2 = ASSIGN/1.5
BLENGTH[1] = ASSIGN/0.3
BLENGTH[2] = ASSIGN/0.1
BLENGTH[3] = ASSIGN/-0.1
BLENGTH[4] = ASSIGN/-0.1
BLENGTH[5] = ASSIGN/-0.2
BLENGTH[6] = ASSIGN/-0.4
BLENGTH[7] = ASSIGN/-0.4
BLENGTH[8] = ASSIGN/-0.3
BLENGTH[9] = ASSIGN/-0.3
BLENGTH[10] = ASSIGN/-0.4
BLENGTH[11] = ASSIGN/-0.3
BLENGTH[12] = ASSIGN/-0.8
BLENGTH[13] = ASSIGN/-0.7
BLENGTH[14] = ASSIGN/-0.4
BLENGTH[15] = ASSIGN/-0.6
BLENGTH[16] = ASSIGN/-1.0
BLENGTH[17] = ASSIGN/-1.0
BLENGTH[18] = ASSIGN/-0.8
BLENGTH[19] = ASSIGN/-0.8
BLENGTH[20] = ASSIGN/-0.8
LB = ASSIGN/0
GAGEHEIGHT = ASSIGN/10
GAGEWIDTH = ASSIGN/32
ENDCLEAR = ASSIGN/2.5
BL = ASSIGN/0
DECL/CHAR,1,ANS
ANS = PROMPT/'START CNC MEASUREMENT [ Y/N ] '
IF/(ANS .EQ. 'Y') .OR. (ANS .EQ. 'Y')
PRCOMP/OFF
JUMPTO/(CNCSTART)
ENDIF
RECALL/D(MCS)
UNITS/MM,ANGDEC
PRCOMP/OFF
MODE/MAN
F(PTL1)=FEAT/POINT,CART,1 ,0, 0, 0, 0, 1
F(PTL2)=FEAT/POINT,CART,2 ,0, 0, 0, 0, 1
F(PTL3)=FEAT/POINT,CART,3 ,0, 0, 0, 0, 1
F(PTL4)=FEAT/POINT,CART,4 ,0, 0, 0, 0, 1
F(PTL5)=FEAT/POINT,CART,5 ,0, 0, 0, 0, 1
F(PTL6)=FEAT/POINT,CART,6 ,0, 0, 0, 0, 1
MEAS/POINT,F(PTL1),1
ENDMES
MEAS/POINT,F(PTL2),1
ENDMES
MEAS/POINT,F(PTL3),1
ENDMES
MEAS/POINT,F(PTL4),1
ENDMES
MEAS/POINT,F(PTL5),1
ENDMES
MEAS/POINT,F(PTL6),1
ENDMES
(CNCSTART)
VI = OBTAIN/FA(PTL1)[1],5
VJ = OBTAIN/FA(PTL1)[1],6
VK = OBTAIN/FA(PTL1)[1],7
F(BFPL1) = FEAT/PLANE,CART, 0.0, 0.0, 0.0, VI, VJ, VK
VI = OBTAIN/FA(PTL5)[1],5
VJ = OBTAIN/FA(PTL5)[1],6
VK = OBTAIN/FA(PTL5)[1],7
VI2 = OBTAIN/FA(PTL4)[1],5
VJ2 = OBTAIN/FA(PTL4)[1],6
VK2 = OBTAIN/FA(PTL4)[1],7
F(BFLN1) = FEAT/LINE,BND,CART, 0, 0, 0, -VI2, -VJ2, -VK2, VI, VJ, VK
CONST/PLANE,F(BFPL1),BF,FA(PTL1),FA(PTL2),FA(PTL3)
CONST/LINE,F(BFLN1),BF,FA(PTL5),FA(PTL6)
D(GAGG1CRD) = DATSET/FA(BFPL1), ZDIR, ZORIG, FA(BFLN1), -XDIR, YORIG, FA(PTL4), XORIG
PROB = VALUE/SNSLCT
DR_PRBRAD = OBTAIN/SS(PROB), 8
DR_PRBRAD = ASSIGN/(DR_PRBRAD/2)
D(GAGG1CRD) = TRANS/ZORIG, -DR_PRBRAD, YORIG, -DR_PRBRAD, XORIG, -DR_PRBRAD
$$DID(GageBlock) = DEVICE/STOR,'GagaBlockResult.out'
$$OPEN/DID(GageBlock), DIRECT, OUTPUT, APPEND
DECL/COMMON,DOUBLE,STD
M(GAGECRDSETUP) = MACRO/'CRDLABEL', ADVX, ADVZ, GHEIGHT, GWIDTH, GLENGTH, GCLEAR, PRBR
$$ D(@CRDLABEL) = TRANS/ZORIG, ADVZ, XORIG, ADVX
$$ 抬高的安全距离为43,可以根据实际情况修改此数值,如果修改要替换程序中所有43
$$FEDRAT/MESVEL, MMPS, 5.000000
$$FEDRAT/POSVEL, MMPS, 300.000000
$$
$$ACLRAT/MESACL, MMPSS, 50.000000
$$ACLRAT/POSACL, MMPSS, 500.000000
GOTO/-15, 5, 18
F(ZPLANE) = FEAT/PLANE,CART, 0.0, 0.0, 0.0, 0, 0, 1
F(XLINE) = FEAT/LINE,BND,CART, 0, 0, 0, 1, 0, 0, 0, 1, 0
F(XORIG)=FEAT/POINT,CART,6 ,0, 0, 1, 0, 0
$$面
MEAS/PLANE,F(ZPLANE), 3
PTMEAS/CART, -GCLEAR-12, -6,0, 0, 0, 1
GOTO/-GCLEAR-12, -6, 18
GOTO/-GCLEAR-12,-26, 18
PTMEAS/CART, -GCLEAR-12, -29, 0, 0, 0, 1
GOTO/-GCLEAR-12, -26, 18
GOTO/-(GLENGTH-3),-26, 18
PTMEAS/CART, -(GLENGTH-ENDCLEAR), -29, 0, 0, 0, 1
ENDMES
GOTO/-(GLENGTH-3), -26, 18
GOTO/-GCLEAR-12,-26, 18
GOTO/-10,5, 18
$$线
MEAS/LINE,F(XLINE), 2
PTMEAS/CART, -GCLEAR-5, 0, -5, 0, 1, 0
GOTO/-GCLEAR,5, 18
GOTO/-GLENGTH,5, 18
PTMEAS/CART, -(GLENGTH-GCLEAR)-5, 0, -5, 0, 1, 0
ENDMES
GOTO/-GLENGTH,5, 18
$$点
GOTO/GCLEAR, -18, (GHEIGHT+8)
MEAS/POINT,F(XORIG), 1
PTMEAS/CART, 0, -18,(GHEIGHT/2), 1, 0, 0
ENDMES
GOTO/GCLEAR, -18, (GHEIGHT+8)
D(@CRDLABEL) = DATSET/FA(ZPLANE), ZDIR, ZORIG, FA(XLINE), -XDIR, YORIG, FA(XORIG), XORIG
$$ D(@CRDLABEL) = TRANS/ZORIG, -PRBR, YORIG, -PRBR, XORIG, -PRBR
ENDMAC
M(GAGECHECK) = MACRO/GHEIGHT, GWIDTH, GLENGTH, PRBR
DECL/LOCAL, REAL, XS, XE, ACTLENGTH,ERROR1,ERROR2,ERROR3,ERROR4,MAXERROR,MINERROR,MAXIMUM,MINIMUM,JJYYCHANGE,AVERAG,AVERAG1
DECL/LOCAL, CHAR, 20, SSEP,SSEP1,SSEP2,SSEP3,STESTDATE, STESTTIME,JJYY,NY
DECL/LOCAL, INTGR, LPCOUNT,LPCOUNT1
DECL/LOCAL,DOUBLE,JJYY[DONUM]
ERROR3 = ASSIGN/DONUM
$$ SSEP = ASSIGN/'--------------------------------------------------------------------------------'
$$ WRITE/DID(GageBlock), SSEP
$$ WRITE/DID(DEFAULTSCREEN),SSEP
F(PTS)=FEAT/POINT,CART,0 ,0, 0, 1, 0, 0
F(PTE)=FEAT/POINT,CART,-GLENGTH ,0, 0, -1, 0, 0
STD = ASSIGN/0
SELECT/BL
CASE/BLENGTH[1]
TOL1 = ASSIGN/(TOLERROR+BLENGTH[1]/300)/1000
ENDCAS
CASE/BLENGTH[2]
TOL1 = ASSIGN/(TOLERROR+BLENGTH[2]/300)/1000
ENDCAS
CASE/BLENGTH[3]
TOL1 = ASSIGN/(TOLERROR+BLENGTH[3]/300)/1000
ENDCAS
CASE/BLENGTH[4]
TOL1 = ASSIGN/(TOLERROR+BLENGTH[4]/300)/1000
ENDCAS
CASE/BLENGTH[5]
TOL1 = ASSIGN/(TOLERROR+BLENGTH[5]/300)/1000
ENDCAS
ENDSEL
DO/LPCOUNT, 1,DONUM
GOTO/2.5, -18, (GHEIGHT+8)
MEAS/POINT,F(PTS), 1
PTMEAS/CART, 0, -20,(GHEIGHT/2), 1, 0, 0
ENDMES
GOTO/2.5, -20, (GHEIGHT+8)
GOTO/-(GLENGTH+2.5),-20, (GHEIGHT+8)
MEAS/POINT,F(PTE), 1
PTMEAS/CART, -GLENGTH, -20, (GHEIGHT/2), 1, 0, 0
ENDMES
XS = OBTAIN/FA(PTS), 3
XE = OBTAIN/FA(PTE), 3
$$ WRITE/DID(DEFAULTSCREEN),''
$$ STESTDATE = ASSIGN/SDATE()
$$ STESTTIME = ASSIGN/STIME()
$$ WRITE/DID(GageBlock), 'DATE : ', STESTDATE, ' TIME : ', STESTTIME
$$ WRITE/DID(DEFAULTSCREEN),'DATE : ', STESTDATE, ' TIME : ', STESTTIME
ACTLENGTH = ASSIGN/(XS - XE)
ERROR1 = ASSIGN/(ACTLENGTH-GLENGTH)*1000
$$ WRITE/DID(GageBlock), 'RUN ', LPCOUNT, 'Actual Length = ', ACTLENGTH, ' Nominal Length : ', GLENGTH ,$
$$ ' ERROR:',ERROR1,' TOL: ',TOL1
ERROR4 = ASSIGN/ABS(ERROR1)
IF/(ERROR4.GT.TOL1)
NY = ASSIGN/'NG'
ELSE
NY = ASSIGN/'OK'
ENDIF
IF/(LPCOUNT.EQ.1)
MINERROR = ASSIGN/ERROR1
MAXERROR = ASSIGN/ERROR1
AVERAG = ASSIGN/ERROR1/1000
WRITE/DID(DEFAULTSCREEN),''
WRITE/DID(DEFAULTSCREEN),' ','序号 ',' ','理论值',' ','实测值 ',' ','示值误差(u)',' ','允许误差(u)',' ','测试结论'
ENDIF
SSEP1 = ASSIGN/' '
SSEP2 = ASSIGN/' '
SSEP3 = ASSIGN/' '
WRITE/DID(DEFAULTSCREEN),' ',LPCOUNT,' ',GLENGTH:9:5,SSEP1,ACTLENGTH:10:5,SSEP2,ERROR1:5:2,SSEP3,TOL1:5:2,SSEP3,NY
$$ WRITE/DID(DEFAULTSCREEN),'RUN ', LPCOUNT, 'Actual Length = ', ACTLENGTH, ' Nominal Length : ', GLENGTH , $
$$ ' ERROR:',ERROR1,' TOL: ','-/+',TOL1
IF/(ERROR1 .LT. MINERROR)
MINERROR = ASSIGN/ERROR1
ENDIF
IF/(ERROR1 .GT. MAXERROR)
MAXERROR = ASSIGN/ERROR1
ENDIF
JJYY[LPCOUNT] = ASSIGN/ERROR1
KNPTR1 = ASSIGN/MINERROR
KNPTR2 = ASSIGN/MAXERROR
IF/(LPCOUNT.GT.1)
AVERAG = ASSIGN/ERROR1/1000 + AVERAG
ENDIF
KNPTR3 = ASSIGN/KNPTR2-KNPTR1
$$ JJYY[LPCOUNT] = ASSIGN/ABS(JJYY[LPCOUNT])
$$ STD = ASSIGN/0
$$ ERROR1 = ASSIGN/ABS(ERROR1)
$$ IF/(ERROR1.GT.STD)
$$ STD = ASSIGN/ERROR1
$$ ENDIF
GOTO/-GLENGTH, -18, (GHEIGHT+8)
ENDDO
$$ WRITE/DID(DEFAULTSCREEN),'MAXMUM ERROR IS ',STD
IF/(MAXERROR+MINERROR.GT.0)
MAXIMUM = ASSIGN/MAXERROR
$$ MINIMUM = ASSIGN/MINERROR
ELSE
$$ MAXIMUM = ASSIGN/MINERROR
MINIMUM = ASSIGN/MAXERROR
ENDIF
AVERAG = ASSIGN/AVERAG/DONUM+GLENGTH
$$ WRITE/DID(DEFAULTSCREEN),'MAXMUM ERROR IS ',KNPTR2:5:5,' MINIMUM ERROR IS ',KNPTR1:5:5
$$ WRITE/DID(DEFAULTSCREEN),' REPEATABILITY ERROR ',KNPTR3:5:5
WRITE/DID(DEFAULTSCREEN),' ','实测平均值: ', AVERAG:5:5
WRITE/DID(DEFAULTSCREEN),' ','重复性误差: ', KNPTR3:2:2
ENDMAC
$$ENDFIL
DECL/COMMON, INTGR, VAR1
DO/VAR1,1,Doloop
MODE/PROG,MAN
LB = ASSIGN/LB + LSTEP
BL = ASSIGN/LB + BLENGTH[VAR1]/1000
TOL1 = ASSIGN/TOL2 + BL/300
IF/(VAR1.EQ.1)
BL = ASSIGN/LB*Doloop
CALL/M(GAGECRDSETUP), (GAGE1CRD), XP, ZP, GAGEHEIGHT, GAGEWIDTH, BL, ENDCLEAR, DR_PRBRAD
BL = ASSIGN/LB + BLENGTH[VAR1]/1000
ENDIF
CALL/M(GAGECHECK), GAGEHEIGHT, GAGEWIDTH, BL, DR_PRBRAD
ENDDO