测规则圆的小程序,可以测平面圆和圆柱型的圆.
优点:外圆内圆都行,不会因圆的倾斜测成椭圆,可选测量点数,测量结束后可以查看所测圆的图形.
缺点:手要动动,必须先大概测量1遍.
program MCIRCL[WM1,WM2]
element_array MEMORY[300]
coord c1,c2,c3,c4,c5
string ask1[1],ASK2[1],type[10]
element e1,e2,e3
integer num,spe
real ddm,zzh,zzh1,zzh2
real dst
dms_angle
metric_mode
set_dim (dm=whole,a=full,arel=acute,amode=a360)
dy
noprn
ref0
probe(1,1)
format(circle,dm,f)
loop
dy ("本程序用于测量规则圆的直径")
dy ("请选择要测量圆的类型,平面圆(N)或圆柱(C)")
read (ASK1)
exif (ASK1 eq "N") or (ASK1 eq "n") or (ASK1 eq "C") or (ASK1 eq "c")
end_loop
!!!
loop
dy ("请选择要测量圆的类型,内径(I)或外径(O)")
read (ASK2)
exif (ASK2 eq "I") or (ASK2 eq "i") or (ASK2 eq "O") or (ASK2 eq "o")
end_loop
!!!
aaa:
dy ("请输入自动测量点数,(6.7.8.9...)")
read (NUM)
if num lt 6 then
dy("测量点数必须大于或等于 <6> !!!")
jump aaa
end_if
!!!
dy ("请输入自动测量速度,(1.2.3...100)")
dy ("建议自动测量速度为 <30> !")
read (spe)
!!!
if (ask1 eq "N") or (ask1 eq "n") then
type="circle"
manmove
dy(" ")
dy("请测量基准面!!! ")
dy(" ")
dy(" ")
mpl(memory[1],4)
skew1 (MEMORY[1],1,0)
refsys 1
dy("请测量待测孔")
mcir(memory[2],4)
proj (MEMORY[3],MEMORY[1],MEMORY[2])
skew1 (MEMORY[1],1,0)
preset (MEMORY[3],X=0,Y=0,Z=0,1,1)
ncmove
dys
fly(on)
dist_approach 6.
mspeed spe
get_position (c1)
e1=memory[2]
c2=e1
zzh=c2|z
ddm=e1|dm
if (ask2 eq "i")or(ask2 eq "I") THEN
!测量圆的类型,内径
move(x=0,y=0,z=50)
dapp
move(z=zzh)
mcir(memory[5],num)
for I=1 to num by 1
c5={ddm/2*cos(360/num*i),ddm/2*sin(360/num*i),zzh}
movetf (c5)
end_for
elsif (ask2 eq "o")or(ask2 eq "O") then
!测量圆的类型,外径
dapp
move(x=0,y=0,z=50)
dsta
dist_approach dst
c5={(ddm/2+dst)*cos(360/num),(ddm/2+dst)*sin(360/num),50}
move(c5)
move(z=zzh)
mcir(memory[5],num)
for I=1 to num by 1
c4={(ddm/2+dst)*cos(360/num*i),(ddm/2+dst)*sin(360/num*i),zzh}
c5={ddm/2*cos(360/num*i),ddm/2*sin(360/num*i),zzh}
move (c4)
movetf (c5)
end_for
end_if
move(z=50)
!选择要测量圆的类型,圆柱
elsif (ask1 eq "c") or (ask1 eq "C") then
type="cylinder"
manmove
dy("请测量待测圆(上下两个截面)")
mcir(memory[1],4)
mcir(memory[2],4)
iline(memory[3],2,memory[1])
skew1 (MEMORY[3],1,0)
refsys 1
preset (MEMORY[1],X=0,Y=0,Z=0,1,1)
ncmove
dys
fly(on)
dist_approach 6.
mspeed spe
get_position (c1)
e1=memory[1]
c1=e1
e2=memory[2]
c2=e2
zzh1=c1|z
zzh2=c2|z
ddm=e1|dm
format (cylind,cx=meas,cy=meas,cz=meas,dm=meas,f=meas)
!选择要测量圆柱类型,内圆柱
if (ask2 eq "i")or(ask2 eq "I") THEN
move(x=0,y=0,z=50)
mcyl(memory[4],12)
move(z=zzh1)
for i=1 to 6 by 1
C2={ddm/2*cos (60*i),ddm/2*sin (60*i),zzh1}
movetf (C2)
end_for
move(x=0,y=0,z=zzh2)
for i=1 to 6 by 1
C3={ddm/2*cos (60*i),ddm/2*sin (60*i),zzh2}
movetf (C3)
end_for
skew1 (MEMORY[4],2,1)
refsys 2
dapp
move(x=0,y=0)
move(z=zzh1)
mcir(memory[5],num)
for I=1 to num by 1
c5={ddm/2*cos(360/num*i),ddm/2*sin(360/num*i),zzh1}
movetf (c5)
end_for
!选择要测量圆柱类型,外圆柱
elsif (ask2 eq "o")or(ask2 eq "O") then
dsta
dist_approach dst
dapp
move(x=0,y=0,z=50)
mcyl(memory[4],12)
c5={(ddm/2+dst)*cos(60),(ddm/2+dst)*sin(60),50}
move(c5)
move(z=zzh1)
for i=1 to 6 by 1
C1={(ddm/2+dst)*cos (60*i),(ddm/2+dst)*sin (60*i),zzh1}
C2={ddm/2*cos (60*i),ddm/2*sin (60*i),zzh1}
move (c1)
movetf (C2)
end_for
move(z=zzh2)
for i=1 to 6 by 1
C3={(ddm/2+dst)*cos (60*(i-1)),(ddm/2+dst)*sin (60*(i-1)),zzh2}
C4={ddm/2*cos (60*(i-1)),ddm/2*sin (60*(i-1)),zzh2}
move (c3)
movetf (C4)
end_for
skew1 (MEMORY[4],2,1)
move(z=50)
refsys 2
c5={(ddm/2+dst)*cos(360/num),(ddm/2+dst)*sin(360/num),50}
move(c5)
move(z=zzh1)
mcir(memory[5],num)
for I=1 to num by 1
c4={(ddm/2+dst)*cos(360/num*i),(ddm/2+dst)*sin(360/num*i),zzh1}
c5={ddm/2*cos(360/num*i),ddm/2*sin(360/num*i),zzh1}
move (c4)
movetf (c5)
end_for
end_if
end_if
ncmove
refsys 0
move(z=0)
refsys 1
dy(" ")
dy(" ")
dy("测量结束,如果需要查看圆度图形请回 界面!")
dy(" ")
dy(" ")
dist_approach 6.
prn
prn(" ")
prn("___________________Diameter measuring___________________")
prn("Measuring type :",type)
prn("Measuring speed :",spe)
prn("Number of measurement :",num)
dati
output memory[5]
prn("__________________________end___________________________")
noprn
endstat
procedure dys
dy(" ")
dy(" ")
dy(" 正在进行测量,请等待.... ")
dy(" 正在进行测量,请等待.... ")
dy(" 正在进行测量,请等待.... ")
dy(" 正在进行测量,请等待.... ")
dy(" ")
dy(" ")
dy(" ")
end_procedure
procedure dsta
if ddm lt 10 then
dst=6
elsif ddm lt 20 then
dst=8
elsif ddm lt 40 then
dst=10
elsif ddm lt 60 then
dst=12
end_if
dst=14
end_procedure
!
procedure dapp
if (ask2 eq "O")or (ask2 eq "o") THEN
if num lt 9 then
if ddm lt 20 then
dist_approach 10.
elsif ddm lt 50 then
dist_approach 13.
end_if
dist_approach 16.
!
elsif num lt 18 then
if ddm lt 20 then
dist_approach 6.
elsif ddm lt 50 then
dist_approach 10.
end_if
dist_approach 14.
end_if
end_if
!
dist_approach 5.
end_procedure
!
procedure DATI
integer TIH
real TI,DA,TIM1,TIM,TIS1,TIS,TIH1
string ED[10],EM[10],ES[10]
out_format (6,2)
DA=date
TI=time
!时
TIH1=trunc (TI/100)
TIH=round (TIH1)
!分
TIM1=(TI/100)
TIM=(TIM1-trunc (TIM1))
!秒
TIS1=trunc (TI)
TIS=(TI-TIS1)
out_format (4,2)
if encode(ED,DA) and encode(EM,TIM) and encode(ES,TIS) then
prn ("Date = ","200",ED[1],"-",ED[2],ED[3],"-",ED[5],ED[6])
prn (" Time = ",TIH,":",EM[3],EM[4],":",ES[3],ES[4])
end_if
end_procedure
end_program
何必呢 何苦呢...