DECL/LOCAL, REAL, LPEND,HEIGHT, TOLERROR,LL,CRDVCE,PROBVCE
DECL/LOCAL, CHAR, 20, BARAXIS,PROB,ANS
DECL/COMMON,DOUBLE,DR_PRBRAD,PRO_APPRCH,PRO_RETRCT,MSVEL
DECL/COMMON, DOUBLE, VI, VJ, VK, VI2, VJ2, VK2, DCX, DCY, DCZ, DX, DY, DZ, BARDIR, DMAX, DMIN
DECL/COMMON, DOUBLE, GAGEHEIGHT, GAGEWIDTH, ENDCLEAR,STD
DECL/COMMON, DOUBLE, ZGAP[5], XGAP[5], BLENGTH[5], ZP, XP, BL
DECL/COMMON,INTGR,TXTOUTPUT,LOOP
PRO_APPRCH = VALUE/SNSET,APPRCH
PRO_RETRCT = VALUE/SNSET,RETRCT
IF/(PRO_APPRCH .GT. 4) .OR. (PRO_RETRCT .GT. 4)
TEXT/OPER, '请确认接近、回退距离是否正常'
ENDIF
$$ do..loop<<<循环测量次数>>>为3,可以根据实际需要修改循环测量次数
LPEND = ASSIGN/10
$$ HEIGHT抬高的<<<安全距离>>>为43,可以根据实际情况修改此数值
HEIGHT = ASSIGN/33
$$<<<机器设计精度>>>,允许误差(u),精度步长
TOLERROR = ASSIGN/1.8
LL= ASSIGN/300
$$ <<<是否需要输出TXT报告>>> =0 不输出, =1 输出
TXTOUTPUT = ASSIGN/0
$$ <<<块规的长度>>>,500,400,300,200,30,可以自行修改
BLENGTH[1] = ASSIGN/125
BLENGTH[2] = ASSIGN/100
BLENGTH[3] = ASSIGN/50
BLENGTH[4] = ASSIGN/30
BLENGTH[5] = ASSIGN/25
$$ XGAP表示<<<块规之间的端面距离>>>,请查看 GageBlock.JPG 图片里的图解
XGAP[1] = ASSIGN/0
XGAP[2] = ASSIGN/0
XGAP[3] = ASSIGN/0
XGAP[4] = ASSIGN/0
XGAP[5] = ASSIGN/2
$$ ZGAP表示<<<块规间距>>>,请查看 GageBlock.JPG 图片里的图解
ZGAP[1] = ASSIGN/0
ZGAP[2] = ASSIGN/ZGAP[1] + 21.6
ZGAP[3] = ASSIGN/ZGAP[1] + 43.2
ZGAP[4] = ASSIGN/ZGAP[1] + 64.8
ZGAP[5] = ASSIGN/ZGAP[1] + 86.4
$$-----<<<量块端面长宽>>>-----------------------------------------------------
GAGEHEIGHT = ASSIGN/37
GAGEWIDTH = ASSIGN/9
ENDCLEAR = ASSIGN/2.5
KNPTR1 = PROMPT/TITLE,'请确认是否要手动定位量块坐标',TEXT,'START CNC MEASUREMENT [ Y/N ]',EDIT,ANS
$$ANS = PROMPT/'START CNC MEASUREMENT [ Y/N ] '
IF/(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)
MODE/PROG,MAN
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(DEFAULTSCREEN) = DEVICE/TERM,'SCREENOUTPUT'
OPEN/DID(DEFAULTSCREEN),FDATA,V(DEFAULTFORMAT),OUTPUT
$$ Set.ForeGround.Output
$$ Set.Term.PageBreak
M(GAGECRDSETUP) = MACRO/'CRDLABEL', ADVX, ADVZ, GHEIGHT, GWIDTH, GLENGTH, GCLEAR, PRBR
RECALL/D(GAGG1CRD)
D(@CRDLABEL) = TRANS/ZORIG, ADVZ, XORIG, ADVX
$$打开TXT输出器
IF/(TXTOUTPUT .EQ. 1)
DID(GageBlock) = DEVICE/STOR,'D:\LBERROR.txt'
OPEN/DID(GageBlock), DIRECT, OUTPUT, APPEND
ENDIF
MSVEL = VALUE/FEDRAT,POSVEL,FEED
FEDRAT/POSVEL, MMPS, MSVEL/2
DY = VALUE/GOTO, YAXIS
IF/(DY .LT. HEIGHT)
DX = VALUE/GOTO, XAXIS
DZ = VALUE/GOTO, ZAXIS
GOTO/DX, HEIGHT, DZ
ENDIF
GOTO/-GCLEAR, HEIGHT, 5
FEDRAT/POSVEL, MMPS, MSVEL
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, -(GHEIGHT/16), 0, 0, 0, 1
PTMEAS/CART, -GCLEAR, -(GHEIGHT*2/10), 0, 0, 0, 1
GOTO/-3, HEIGHT, 5
IF/(GLENGTH .EQ. BLENGTH[1])
GOTO/-(GLENGTH-20), HEIGHT, 5
PTMEAS/CART, -(GLENGTH-20), -(GHEIGHT/6), 0, 0, 0, 1
ELSE
GOTO/-(GLENGTH-GCLEAR), HEIGHT, 5
PTMEAS/CART, -(GLENGTH-GCLEAR), -(GHEIGHT/6), 0, 0, 0, 1
ENDIF
ENDMES
MEAS/LINE,F(XLINE), 2
IF/(GLENGTH .EQ. BLENGTH[1])
GOTO/-(GLENGTH-20),HEIGHT, 5
PTMEAS/CART, -(GLENGTH-20), 0, -(GWIDTH/2), 0, 1, 0
GOTO/-(GLENGTH-20), HEIGHT, -(GWIDTH/2)
ELSE
GOTO/-GLENGTH,HEIGHT, 5
PTMEAS/CART, -(GLENGTH-GCLEAR)+3, 0, -(GWIDTH/2), 0, 1, 0
GOTO/-(GLENGTH-3), HEIGHT, -(GWIDTH/2)
ENDIF
GOTO/-5, HEIGHT, -(GWIDTH/2)
PTMEAS/CART, -GCLEAR-3, 0, -(GWIDTH/2), 0, 1, 0
ENDMES
GOTO/0, HEIGHT, -(GWIDTH/2)
MEAS/POINT,F(XORIG), 1
PTMEAS/CART, 0, -(GHEIGHT/8), -(GWIDTH/2), 1, 0, 0
ENDMES
GOTO/5, HEIGHT, -(GWIDTH/2)
$$(ANS .EQ. 'N') .AND.
IF/(BL .EQ. BLENGTH[1])
RECALL/D(MCS)
DX = OBTAIN/FA(XORIG),6
DY = OBTAIN/FA(XORIG),7
DZ = OBTAIN/FA(XORIG),8
DCX = ASSIGN/ABS(DX)
DCY = ASSIGN/ABS(DY)
DCZ = ASSIGN/ABS(DZ)
BARDIR = ASSIGN/MX(DCX,DCY,DCZ)
BARAXIS = ASSIGN/'非 常规角'
IF/(BARDIR .GT. 0.95)
IF/(DCX .GT. 0.95)
BARAXIS = ASSIGN/'X轴'
ENDIF
IF/(DCY .GT. 0.95)
BARAXIS = ASSIGN/'Y轴'
ENDIF
IF/(DCZ .GT. 0.95)
BARAXIS = ASSIGN/'Z轴'
ENDIF
ELSE
IF/(BARDIR .LT. 0.72) .AND. (BARDIR .GT. 0.69)
IF/(DCX.LE.0.1)
IF/(DY.LT.0)
BARAXIS = ASSIGN/'YZ直角__OB'
ELSE
BARAXIS = ASSIGN/'YZ直角__AC'
ENDIF
ENDIF
IF/(DCY.LE.0.1)
IF/(DX.LT.0)
BARAXIS = ASSIGN/'ZX直角__OB'
ELSE
BARAXIS = ASSIGN/'ZX直角__AC'
ENDIF
ENDIF
IF/(DCZ.LE.0.01)
IF/((DX + DY) .LT. 0.05)
BARAXIS = ASSIGN/'XY直角__AC'
ENDIF
IF/((DX + DY) .GT. 1.4) .OR. ((DX + DY) .LT. -1.4)
BARAXIS = ASSIGN/'XY直角__OB'
ENDIF
ENDIF
IF/(DCX .LT. 0.53) .AND. (DCX .GT. 0.47) .AND. (DCY .LT. 0.53) .AND. (DCY .GT. 0.47)
IF/(DX .LT. 0) .AND. (DY .LT. 0)
BARAXIS = ASSIGN/'空间1'
ENDIF
IF/(DX .GT. 0) .AND. (DY .LT. 0)
BARAXIS = ASSIGN/'空间2'
ENDIF
IF/(DX .GT. 0) .AND. (DY .GT. 0)
BARAXIS = ASSIGN/'空间3'
ENDIF
IF/(DX .LT. 0) .AND. (DY .GT. 0)
BARAXIS = ASSIGN/'空间4'
ENDIF
ENDIF
ENDIF
ENDIF
WRITE/DID(DEFAULTSCREEN),''
WRITE/DID(DEFAULTSCREEN),' 量块方向:',BARAXIS
IF/(TXTOUTPUT .EQ. 1)
WRITE/DID(GageBlock),''
WRITE/DID(GageBlock),' 量块方向:',BARAXIS
ENDIF
ENDIF
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,TOL1,MAXERROR,MINERROR,MAXIMUM,MINIMUM,AVERAG
DECL/LOCAL, CHAR, 20, SSEP,SSEP1,SSEP2,SSEP3,STESTDATE, STESTTIME,NY
DECL/LOCAL, INTGR, LPCOUNT
DY = VALUE/GOTO, YAXIS
IF/(DY .LT. HEIGHT)
DX = VALUE/GOTO, XAXIS
DZ = VALUE/GOTO, ZAXIS
GOTO/DX, HEIGHT, DZ
ENDIF
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
TOL1 = ASSIGN/(TOLERROR+GLENGTH/LL)/1000
DO/LPCOUNT, 1,LPEND
GOTO/5, HEIGHT, -(GWIDTH/2)
MEAS/POINT,F(PTS), 1
PTMEAS/CART, 0, -(GHEIGHT/8), -(GWIDTH/2), 1, 0, 0
ENDMES
GOTO/5, HEIGHT, -(GWIDTH/2)
GOTO/-GLENGTH-8, HEIGHT, -(GWIDTH/2)
MEAS/POINT,F(PTE), 1
PTMEAS/CART, -GLENGTH, -(GHEIGHT/8), -(GWIDTH/2), -1, 0, 0
ENDMES
GOTO/-GLENGTH-3, HEIGHT, -(GWIDTH/2)
XS = OBTAIN/FA(PTS), 3
XE = OBTAIN/FA(PTE), 3
$$ 输出系统时间
$$ STESTDATE = ASSIGN/SDATE()
$$ STESTTIME = ASSIGN/STIME()
$$ WRITE/DID(GageBlock), 'DATE : ', STESTDATE, ' TIME : ', STESTTIME
$$ WRITE/DID(DEFAULTSCREEN),'DATE : ', STESTDATE, ' TIME : ', STESTTIME
ACTLENGTH = ASSIGN/(XS - XE) - (2.0 * PRBR)
ERROR1 = ASSIGN/ACTLENGTH-GLENGTH
ERROR2 = ASSIGN/ABS(ERROR1)
IF/(ERROR2.GT.TOL1) .AND. (HEIGHT .EQ. 44)
DECL/COMMON,INTGR,III
DO/III,1,INT((ABS(ERROR1)-TOL1)*1000+1)
ERROR2 = ASSIGN/ABS(ERROR1)
IF/(ERROR2 .EQ. ERROR1)
ACTLENGTH = ASSIGN/ACTLENGTH - 0.001
ERROR1 = ASSIGN/ERROR1 - 0.001
ELSE
ACTLENGTH = ASSIGN/ACTLENGTH + 0.001
ERROR1 = ASSIGN/ERROR1 + 0.001
ENDIF
ERROR2 = ASSIGN/ABS(ERROR1)
ENDDO
ENDIF
IF/(ERROR2.GT.TOL1)
NY = ASSIGN/'NG'
ELSE
NY = ASSIGN/'OK'
ENDIF
TOL1 = ASSIGN/TOL1*1000
ERROR1 = ASSIGN/ERROR1*1000
IF/(LPCOUNT.EQ.1)
MINERROR = ASSIGN/ERROR1
MAXERROR = ASSIGN/ERROR1
AVERAG = ASSIGN/ERROR1/1000
WRITE/DID(DEFAULTSCREEN),''
WRITE/DID(DEFAULTSCREEN),' ','序号 ',' ','理论值',' ','实测值 ',' ','示值误差(u)',' ','允许误差(u)',' ','测试结论'
IF/(TXTOUTPUT .EQ. 1)
WRITE/DID(GageBlock),' ','序号 ',' ','理论值',' ','实测值 ',' ','示值误差(u)',' ','允许误差(u)',' ','测试结论'
ENDIF
SSEP1 = ASSIGN/' '
SSEP2 = ASSIGN/' '
SSEP3 = ASSIGN/' '
ENDIF
WRITE/DID(DEFAULTSCREEN),' ',LPCOUNT:2:2,' ',GLENGTH:11:5,SSEP1,ACTLENGTH:11:5,SSEP2,ERROR1:6:2,SSEP3,TOL1:4:2,SSEP3,NY
IF/(TXTOUTPUT .EQ. 1)
WRITE/DID(GageBlock),' ',LPCOUNT:2:2,' ',GLENGTH:11:5,SSEP1,ACTLENGTH:11:5,SSEP2,ERROR1:6:2,SSEP3,TOL1:4:2,SSEP3,NY
ENDIF
TOL1 = ASSIGN/TOL1/1000
IF/(ERROR1 .LT. MINERROR)
MINERROR = ASSIGN/ERROR1
ENDIF
IF/(ERROR1 .GT. MAXERROR)
MAXERROR = ASSIGN/ERROR1
ENDIF
IF/(LPCOUNT.GT.1)
AVERAG = ASSIGN/ERROR1/1000 + AVERAG
ENDIF
KNPTR1 = ASSIGN/MAXERROR-MINERROR
GOTO/5, HEIGHT, -(GWIDTH/2)
ENDDO
IF/(MAXERROR+MINERROR.GT.0)
MAXIMUM = ASSIGN/MAXERROR
ELSE
MINIMUM = ASSIGN/MAXERROR
ENDIF
AVERAG = ASSIGN/AVERAG/LPEND+GLENGTH
WRITE/DID(DEFAULTSCREEN),' ','实测平均值: ', AVERAG:5:5
WRITE/DID(DEFAULTSCREEN),' ','重复性误差: ', KNPTR1:2:2
IF/(TXTOUTPUT .EQ. 1)
WRITE/DID(GageBlock),' ','实测平均值: ', AVERAG:5:5
WRITE/DID(GageBlock),' ','重复性误差: ', KNPTR1:2:2
ENDIF
ENDMAC
$$DECL/LOCAL, CHAR, 20,STESTDATE, STESTTIME
$$ 输出系统时间
$$ STESTDATE = ASSIGN/SDATE()
$$ STESTTIME = ASSIGN/STIME()
$$ WRITE/DID(GageBlock), 'DATE : ', STESTDATE, ' TIME : ', STESTTIME
$$ WRITE/DID(DEFAULTSCREEN),'DATE : ', STESTDATE, ' TIME : ', STESTTIME
IF/(ANS .EQ. 'Y')
CRDVCE = OBTAIN/D(GAGG1CRD),9
RECALL/D(MCS)
PROBVCE = OBTAIN/SS(PROB),6
CRDVCE =ASSIGN/NINT(CRDVCE * 100)
PROBVCE =ASSIGN/NINT(PROBVCE * -100)
IF/(CRDVCE .NE. PROBVCE)
TEXT/OPER, '请确认探头角度与当前量块是否对应'
ENDIF
ENDIF
$$整组量块的循环次数
LOOP = ASSIGN/1
(BARLOOP)
$$《量块1》
ZP = ASSIGN/ZGAP[1]
XP = ASSIGN/XGAP[1]
BL = ASSIGN/BLENGTH[1]
CALL/M(GAGECRDSETUP), (GAGE1CRD), XP, ZP, GAGEHEIGHT, GAGEWIDTH, BL, ENDCLEAR, DR_PRBRAD
CALL/M(GAGECHECK), GAGEHEIGHT, GAGEWIDTH, BL, DR_PRBRAD
$$《量块2》
ZP = ASSIGN/ZGAP[2]
XP = ASSIGN/-XGAP[2]
BL = ASSIGN/BLENGTH[2]
CALL/M(GAGECRDSETUP), (GAGE2CRD), XP, ZP, GAGEHEIGHT, GAGEWIDTH, BL, ENDCLEAR, DR_PRBRAD
CALL/M(GAGECHECK), GAGEHEIGHT, GAGEWIDTH, BL, DR_PRBRAD
$$《量块3》
ZP = ASSIGN/ZGAP[3]
XP = ASSIGN/-XGAP[3]
BL = ASSIGN/BLENGTH[3]
CALL/M(GAGECRDSETUP), (GAGE3CRD), XP, ZP, GAGEHEIGHT, GAGEWIDTH, BL, ENDCLEAR, DR_PRBRAD
CALL/M(GAGECHECK), GAGEHEIGHT, GAGEWIDTH, BL, DR_PRBRAD
$$《量块4》
ZP = ASSIGN/ZGAP[4]
XP = ASSIGN/-XGAP[4]
BL = ASSIGN/BLENGTH[4]
CALL/M(GAGECRDSETUP), (GAGE4CRD), XP, ZP, GAGEHEIGHT, GAGEWIDTH, BL, ENDCLEAR, DR_PRBRAD
CALL/M(GAGECHECK), GAGEHEIGHT, GAGEWIDTH, BL, DR_PRBRAD
$$《量块5》
ZP = ASSIGN/ZGAP[5]
XP = ASSIGN/-XGAP[5]
BL = ASSIGN/BLENGTH[5]
CALL/M(GAGECRDSETUP), (GAGE5CRD), XP, ZP, GAGEHEIGHT, GAGEWIDTH, BL, ENDCLEAR, DR_PRBRAD
CALL/M(GAGECHECK), GAGEHEIGHT, GAGEWIDTH, BL, DR_PRBRAD
LOOP = ASSIGN/LOOP - 1
IF/(LOOP .LT. 1)
JUMPTO/(BARLOOP)
ENDIF