DMIS简易教程
几何元素
F(CIRC3)=FEAT/CIRCLE,INNER,CART,-32.5000,38.3494,-25.0000,0.0000,0.0000,1.0000,10.0000
MEAS/CIRCLE,F(CIRC3),3
PTMEAS/CART,-32.5000,33.3494,-25.0000,0.0000,1.0000,0.0000
PTMEAS/CART,-36.8301,40.8494,-25.0000,0.8660,-0.5000,0.0000
PTMEAS/CART,-28.1699,40.8494,-25.0000,-0.8660,-0.5000,0.0000
ENDMES
F(CIRC3)=FEAT/CIRCLE,INNER,CART,-32.5000,38.3494,-25.0000,0.0000,0.0000,1.0000,10.0000
“MEAS”指令表示一个测量过程的开始。如果系统处在“MODE/AUTO”状态下,那么系统将自动测量下面的空间点。如果系统的状态是“MODE/PROG”,则PTMEAS将无须干预地将指定的点测量完毕。
MEAS/CIRCLE,F(CIRC3),3
“PTMEAS”指令只是指明需要测量的点的坐标和触测的方向。
PTMEAS/CART,-28.1699,40.8494,-25.0000,-0.8660,-0.5000,0.0000
“ENDMES”指令将结束点的测量,然后计算结果。
DECL变量定义
DECL/CHAR,80,TCDIRS
DECL/INTGR,TCNSLT
DECL/DOUBLE,TCDIFX,TCDIFY,TCDIFZ
DECL/CHAR,80,RESULTS[10]
DECL/CHAR,80,RESULTS[10,5]
通过“DECL”指令,可以定义各种变量
DECL/INTGR,IND
DECL/CHAR,80,RESULTS[10]
DO/IND,1,10,1
RESULTS[IND]=ASSIGN/''
ENDDO
可以定义以下类型的变量:
BOOL
CHAR
INTGR
REAL
VECTOR
LONG
这些变量的有效范围可以是:
COMMON
GLOBAL
LOCAL
ASSIGN变量赋值
在DMIS中进行变量赋值并不像只用“=”号那样简单
TCDIRS=ASSIGN/'C:\Programmi\Coord3\ARCO\Data\'
TCNSLT=ASSIGN/6
TEXT提示信息
TEXT/OPER,'MAKE SURE THE PART IS ON THE FIXTURE' text OPER must be closed pressing oK
TEXT/MAN,'MEAS UPPER HOLE' text MAN disappear automatically when you measure the 1st point
数据输入
TEXT/QUERY,(NMVAR),20,A,L,'Write your name'
提取数据
把一个变量赋值为任何一个参数的定义。不要忘了“F”和“FA”、“S”、“SA”的区别:
语句中的序号代表元素定义中数据位置:
F(POI_1)=FEAT/POINT,CART, 1.111,2.222,3.333, 0,0,0
F(POI_2)=FEAT/POINT,CART, 4.444,5.555,6.666, 0,0,0
F(POI_3)=FEAT/POINT,CART, 7.777,8.888,9.999, 0,0,0
FA(POI_1)=FEAT/POINT,CART, 1.111,2.222,3.333, 0,0,0
FA(POI_2)=FEAT/POINT,CART, 4.444,5.555,6.666, 0,0,0
FA(POI_3)=FEAT/POINT,CART, 7.777,8.888,9.999, 0,0,0
DECL/INTGR,i
DECL/CHAR,20,elnm
DECL/DOUBLE,xx,yy,zz
DO/i,1,3
elnm=ASSIGN/CONCAT('poi_',STR(i))
xx=OBTAIN/FA(@elnm),3
yy=OBTAIN/FA(@elnm),4
zz=OBTAIN/FA(@elnm),5
elnm=ASSIGN/CONCAT('newpoi_',STR(i))
F(@elnm)=FEAT/POINT,CART, xx,yy,zz, 0,0,0
FA(@elnm)=FEAT/POINT,CART, xx,yy,zz, 0,0,0
ENDDO
使用“EVAL”而不是使用“OUTPUT”时,可以在不输出该数据的情况下,得到需要的数据。
DECL/DOUBLE,tol_value
T(TP)=TOL/POS,2D,1.0000
EVAL/FA(COORD3),TA(TP)
tol_value=OBTAIN/TA(TP),3
CHAR
定义一个字符函数,返回一个长度为1、包含一个值为1-255的基于‘X’的字符。
CHR(x)
$$ *** to print ALL the ASCII characters ***
DECL/CHAR,50,st
DECL/INTGR,ii
DISPLY/OFF
DISPLY/TERM,V(TEXT)
DO/ii,1,255
st=ASSIGN/CHR(ii)
st=ASSIGN/CONCAT(STR(ii),' ',st)
TEXT/OUTFIL,st
ENDDO
CONCAT
Is used to concatenate more than 1 string
FILENAME=ASSIGN/CONCAT(PART1,NAME,'.TXT')
SCSNS
用来获取实际激活的测头的名字
DECL/DOUBLE,PRDIAM
DECL/CHAR,50,SENSOR_NAME
SENSOR_NAME=ASSIGN/SCSNS()
PRDIAM=OBTAIN/SA(@SENSOR_NAME),10
FILE 文件
$$————————————————————————————————————————
$$ write points coordinates to file
$$————————————————————————————————————————DECL/CHAR,50,filnm,elnm
DECL/INTGR,i
DECL/DOUBLE,xx
DECL/DOUBLE,yy
DECL/DOUBLE,zz
TEXT/QUERY,(filnm),50,A,L,'insert file name'
filnm=ASSIGN/CONCAT('C:\',filnm,'.TXT')
DID(F1)=DEVICE/STOR,filnm
OPEN/DID(F1),DIRECT,OUTPUT,OVERWR
F(POI_1)=FEAT/POINT,CART, 1.111,2.222,3.333, 0,0,0
F(POI_2)=FEAT/POINT,CART, 4.444,5.555,6.666, 0,0,0
F(POI_3)=FEAT/POINT,CART, 7.777,8.888,9.999, 0,0,0
FA(POI_1)=FEAT/POINT,CART, 1.111,2.222,3.333, 0,0,0
FA(POI_2)=FEAT/POINT,CART, 4.444,5.555,6.666, 0,0,0
FA(POI_3)=FEAT/POINT,CART, 7.777,8.888,9.999, 0,0,0
DO/i,1,3
elnm=ASSIGN/CONCAT('poi_',STR(i))
xx=OBTAIN/FA(@elnm),3
yy=OBTAIN/FA(@elnm),4
zz=OBTAIN/FA(@elnm),5
WRITE/DID(F1),xx
WRITE/DID(F1),yy
WRITE/DID(F1),zz
ENDDO
CLOSE/DID(F1)
$$————————————————————————————————————————
$$ read from file
$$————————————————————————————————————————
DECL/CHAR,50,filnm
DECL/CHAR,50,xyz
DECL/DOUBLE,xx
DECL/DOUBLE,yy
DECL/DOUBLE,zz
TEXT/QUERY,(filnm),50,A,L,'insert file name'
filnm=ASSIGN/CONCAT('C:\',filnm,'.TXT')
DID(F1)=DEVICE/STOR,filnm
OPEN/DID(F1),DIRECT,INPUT
READ/DID(F1),xx
READ/DID(F1),yy
READ/DID(F1),zz
F(POI_10)=FEAT/POINT,CART, xx,yy,zz, 0,0,0
FA(POI_10)=FEAT/POINT,CART, xx,yy,zz, 0,0,0
READ/DID(F1),xx
READ/DID(F1),yy
READ/DID(F1),zz
F(POI_20)=FEAT/POINT,CART, xx,yy,zz, 0,0,0
FA(POI_20)=FEAT/POINT,CART, xx,yy,zz, 0,0,0
READ/DID(F1),xx
READ/DID(F1),yy
READ/DID(F1),zz
F(POI_30)=FEAT/POINT,CART, xx,yy,zz, 0,0,0
FA(POI_30)=FEAT/POINT,CART, xx,yy,zz, 0,0,0
result=ASSIGN/CONCAT(STR(xx),' , ',STR(yy),' , ',STR(zz))
TEXT/OPER,result
CLOSE/DID(F1)
逻辑操作符
.AND.
.OR.
.NOT.
关系操作符
.EQ. equal to
.NE. NOT equal to
.LT. less than
.LE. less than or equal
.GT. greater than
.GE. greater than or equal to
条件判断
IF/(NCYCLE .EQ. 10)
$$instructions
ELSE
$$instructions
ENDIF
DO循环
DECL/INTGR,i
DECL/CHAR,20,elnm
DECL/DOUBLE,xx,yy,zz
DO/i,1,3,1
elnm=ASSIGN/CONCAT('poi_',STR(i))
xx=OBTAIN/FA(@elnm),3
yy=OBTAIN/FA(@elnm),4
zz=OBTAIN/FA(@elnm),5
elnm=ASSIGN/CONCAT('newpoi_',STR(i))
F(@elnm)=FEAT/POINT,CART, xx,yy,zz, 0,0,0
FA(@elnm)=FEAT/POINT,CART, xx,yy,zz, 0,0,0
ENDDO
分枝选择
DECL/INTGR,i
DECL/CHAR,50,tx
i=ASSIGN/10
SELECT/i
CASE/10
tx=ASSIGN/CONCAT('THE ACTUAL VALUE OF X IS: ',STR(i))
TEXT/OPER,tx
ENDCAS
CASE/20
tx=ASSIGN/CONCAT('THE ACTUAL VALUE OF X IS: ',STR(i))
TEXT/OPER,tx
ENDCAS
DFTCAS
TEXT/OPER,'X is not equal to the 2 cases'
ENDCAS
ENDSEL
程序跳转
JUMPTO/(CONTINUEFROMHERE)
$$ instructions
$$ instructions
(CONTINUEFROMHERE)
$$ instructions
$$ instructions
数学函数
ABS(X) absolute value
ACOS(X) arccosine
ASIN(X) arcsine
ATAN(X) arctangent
ATAN2(Y,X) arctangent of y/x, the sign of y and x determinate the quadrant
DTOR(X) convert degrees to radians
RTOD(X) convert radians to degrees
EXP(X) exponential
INT(X) return an integer
MN(val1, val2, …) obtain the smallest value of a list of values
MX(val1, val2, …) obtain the biggest value of a list of values
NINT(X) return an integer rounding the nearest value
LEN(str1) length of a string
INDX(str1,str2) location of a substring in a string
SDATE() return the date ‘yyyy/mm/dd’
STIME() return the date ‘hh:mm:ss’
COS(X) Real or Double (argument in radians)
SIN(X) Real or Double (argument in radians)
TAN(X) Real or Double (argument in radians)
SQRT(X) square root
STR(X) convert a number in a string
VAL(X) convert a string in number
宏
宏可以在主程序中,也可以在外部文件中。
如果在主程序中,宏必须位于程序开始的位置。
M(foro)=MACRO/off_x,off_y,'nome_ci'
DECL/LOCAL,DOUBLE,r_foro,z_mis
r_foro=ASSIGN/6.25
z_mis=ASSIGN/-2.5
F(@nome_ci) = FEAT/CIRCLE, INNER, CART, off_x, off_y, z_mis, 0, 0, 1, r_foro*2
MEAS/CIRCLE, F(@nome_ci), 4
GOTO/off_x, off_y, 7
PTMEAS/CART, off_x+r_foro, off_y, z_mis, -1, 0, 0
PTMEAS/CART, off_x, off_y+r_foro, z_mis, 0, -1, 0
PTMEAS/CART, off_x-r_foro, off_y, z_mis, 1, 0, 0
PTMEAS/CART, off_x, off_y-r_foro, z_mis, 0, 1, 0
GOTO/off_x, off_y, 7
ENDMES
ENDMAC
$$ instructions
$$ instructions
CALL/M(foro),12.5,12.5,(foro1)
$$ instructions
$$ instructions
在使用“EXTFIL”指令后,可以在外部文件中定义宏
EXTFIL/DMIS,'c:\cim\MACRO.dmi'
宏的外部文件必须以“.DMI”为后缀,由“DMISMD”开始,并由“ENDFIL”结束。在宏定义文件中,它的语法和DMIS程序相同。
DMISMD/'module_name'
M(macro_1)=MACRO/passedtext
TEXT/OPER,CONCAT('You passed the following text to the macro: ',passedtext)
ENDMAC
M(macro_2)=MACRO/num1,num2
DECL/DOUBLE,sumres
sumres=ASSIGN/num1+num2
TEXT/OPER,CONCAT('The sum of the 2 numbers is: ',STR(sumres))
ENDMAC
ENDFIL
使用变量
当在元素名称、测头、或坐标系名称中使用变量时,必须在变量名前加一个“@”字符。
F(@nome_po) = FEAT/POINT, CART, off_x-8.25, off_y, 0, 0, 0, 1
MEAS/POINT, F(@nome_po), 1
PTMEAS/CART, off_x-8.25, off_y, 0, 0, 0, 1
ENDMES
DELAY延时
将正在执行的程序延时几秒
DMESW/DELAY,time $$ stop the execution for … seconds
e.g.
DMESW/DELAY,2 $$ stop the execution for 2 seconds
输入输出指令
得到控制器的IO状态
IOTEST(io number) $$ read the status of an input
DMEHW/IOSET,io number $$ to switch ON an output
DMEHW/IORESET,io number $$ to switch OFF an output
e.g.
DECL/BOOL,RSLT
RSLT=ASSIGN/IOTEST(5) $$ this gives the status of Input n° 5
DMEHW/IOSET,4 $$ to switch ON output n° 4
DMEHW/IORESET,4 $$ to switch OFF output n° 4