您好,欢迎访问三七文档
当前位置:首页 > 机械/制造/汽车 > 制造加工工艺 > 数控原理VB圆弧接圆弧课程设计
四、调试分析1.缩短型2.伸长型3.插入型附录:程序如下:OptionExplicitDimX0AsSingle'圆弧三点坐标DimY0AsSingleDimX1AsSingleDimY1AsSingleDimX2AsSingleDimY2AsSingleDimI1AsSingle'两个圆心相对圆弧起点坐标DimJ1AsSingleDimI2AsSingleDimJ2AsSingleDimR1AsSingle'两个圆弧半径DimR2AsSingleDimrAsSingle'刀具半径DimOX1AsSingle'两圆心实际坐标DimOY1AsSingleDimOX2AsSingleDimOY2AsSingleDimXx1AsSingleDimYy1AsSingleDimStart1AsSingle'第一段圆弧起始弧度DimEnd1AsSingle'第一段圆弧结束弧度DimStart2AsSingle'第二段圆弧起始弧度DimEnd2AsSingle'第二段圆弧结束弧度ConstPi=3.1415926PrivateSubCommand1_Click()Picture1.Cls'清除picturebox控件中的内容Picture1.DrawWidth=1X0=Val(Split(Text1.Text,,)(0))'将文本框中的文本从逗号分离并转化成数值Y0=Val(Split(Text1.Text,,)(1))X1=Val(Split(Text2.Text,,)(0))Y1=Val(Split(Text2.Text,,)(1))X2=Val(Split(Text3.Text,,)(0))Y2=Val(Split(Text3.Text,,)(1))I1=Val(Itext1.Text)'取圆心相对圆弧起点坐标J1=Val(Jtext1.Text)I2=Val(Itext2.Text)J2=Val(Jtext2.Text)R1=Sqr(I1*I1+J1*J1)'计算第一段圆弧半径IfNotOption1.ValueThenR1=-R1'通过确定顺圆逆圆判断半径符号R2=Sqr(I2*I2+J2*J2)'计算第二段圆弧半径IfNotOption3.ValueThenR2=-R2'通过确定顺圆逆圆判断半径符号r=Val(rText.Text)'取刀具半径IfNotOption5.ValueThenr=-r'通过确定左刀补右刀补判断刀具半径符号'=======================画动态坐标系======================Dimt1AsSingle'取出X最大值Dimt2AsSingle'取出X最小值Dimt3AsSingle'取出Y最大值Dimt4AsSingle'取出Y最小值t1=X0t2=X0t3=Y0t4=Y0Ift1X1Thent1=X1'求坐标中最大值与最小值Ift1X2Thent1=X2Ift2X1Thent2=X1Ift2X2Thent2=X2Ift3Y1Thent3=Y1Ift3Y2Thent3=Y2Ift4Y1Thent4=Y1Ift4Y2Thent4=Y2Ift1t3Thent1=t3Ift2t4Thent2=t4DimmAsSingleIfAbs(R1)Abs(R2)Thenm=Abs(R2)Elsem=Abs(R1)EndIft1=t1+Abs(r)+m'坐标轴对圆弧和刀补轨迹留有余量t2=t2-Abs(r)-mPicture1.Scale(t2,t1)-(t1,t2)'设定picturebox左上角右下角坐标值Picture1.Line(t2,0)-(t1,0),vbRed'画X轴Picture1.Line(0,t2)-(0,t1),vbRed'画Y轴DimIAsIntegerDimTs1AsIntegerDimTs2AsIntegerTs1=Fix(t2)Ts2=Fix(t1)ForI=Ts1ToTs2Step1Picture1.Line(I,-0.2)-(I,0.2),vbRed'画X轴竖线Picture1.CurrentY=-0.2Picture1.PrintI'打印刻度值Picture1.Line(-0.2,I)-(0.2,I),vbRed'画Y轴横线Picture1.CurrentX=-0.5Picture1.PrintI'打印刻度值NextIPicture1.CurrentX=Ts2-1Picture1.CurrentY=-1Picture1.PrintX'标上XPicture1.CurrentX=-1Picture1.CurrentY=Ts2-1Picture1.PrintY'标上YPicture1.Line(t1-0.3,-0.3)-(t1,0),vbRed'画箭头Picture1.Line(t1-0.3,0.3)-(t1,0),vbRedPicture1.Line(-0.3,t1-0.3)-(0,t1),vbRedPicture1.Line(0.3,t1-0.3)-(0,t1),vbRed'================================================EndSubPrivateSubCommand2_Click()Picture1.DrawWidth=2'线宽OX1=I1+X0'圆心实际坐标OY1=J1+Y0OX2=I2+X1OY2=J2+Y1DimttAsSingleXx1=-I1'圆弧起点相对圆心坐标Yy1=-J1Start1=hudu(Xx1,Yy1)'第一段圆弧起点对应弧度Xx1=X1-OX1'圆弧终点相对圆心坐标Yy1=Y1-OY1End1=hudu(Xx1,Yy1)'第一段圆弧终点对应弧度IfOption1.ValueThen'画图时如果是顺圆,起点与终点弧度调换tt=Start1Start1=End1End1=ttEndIfIfEnd1Start1Then'圆弧经过X轴正方向Picture1.Circle(OX1,OY1),Abs(R1),,Start1,2*Pi,624/697Picture1.Circle(OX1,OY1),Abs(R1),,0,End1,624/697Else'圆弧不经过X轴正方向Picture1.Circle(OX1,OY1),Abs(R1),,Start1,End1,624/697EndIfXx1=-I2'圆弧起点相对圆心坐标Yy1=-J2'圆弧终点相对圆心坐标Start2=hudu(Xx1,Yy1)'第二段圆弧起点对应弧度Xx1=X2-OX2Yy1=Y2-OY2End2=hudu(Xx1,Yy1)'第二段圆弧终点对应弧度IfOption3.ValueThen'画图时如果是顺圆,起点与终点弧度调换tt=Start2Start2=End2End2=ttEndIfIfEnd2Start2Then'圆弧经过X轴正方向Picture1.Circle(OX2,OY2),Abs(R2),,Start2,2*Pi,624/697Picture1.Circle(OX2,OY2),Abs(R2),,0,End2,624/697Else'圆弧不经过X轴正方向Picture1.Circle(OX2,OY2),Abs(R2),,Start2,End2,624/697EndIf'Picture1.Circle(3,4),5EndSub'=======================弧度计算函数=====================Functionhudu(ByValmAsSingle,ByValnAsSingle)AsSingleDimkAsSingleIfm0Then'斜率存在时k=n/mIfm=0Andn=0Thenhudu=Atn(k)Ifm=0Andn0Thenhudu=Atn(k)+2*PiIfm0Andn=0Thenhudu=Atn(k)+PiIfm0Andn0Thenhudu=Atn(k)+PiElse'斜率不存在时Ifn=0Thenhudu=Pi/2Elsehudu=Pi/2+PiEndIfEndIfEndFunction'=============刀补运算=======================PrivateSubCommand3_Click()Picture1.DrawWidth=1DimX01AsSingle'圆心相对圆弧交接点坐标DimY01AsSingleDimX02AsSingleDimY02AsSingleDimXl1AsSingle'圆弧在交接点处的方向矢量DimYl1AsSingleDimXl2AsSingleDimYl2AsSingleX01=X0+I1-X1Y01=Y0+J1-Y1X02=I2Y02=J2Xl1=-Y01/R1Yl1=X01/R1Xl2=-Y02/R2Yl2=X02/R2DimCasesAsSingleDimXs1AsSingle'转接点坐标DimYs1AsSingleDimXs2AsSingleDimYs2AsSingleDimXs3AsSingleDimYs3AsSingleDimXs4AsSingleDimYs4AsSingleDimXlAsSingle'书上公式中的变量DimYlAsSingleDimD1AsSingleDimD2AsSingleDimFsAsSingleDimkAsSingle'中间变量DimsAsSingleDimSsAsSingleDimMmxAsSingleDimMmyAsSingleDimMmaAsSingleDimFlag1AsBooleanDimFlag2AsBooleanDimttAsSingle'中间变量Cases=Sgn(r)*(Yl2*Xl1-Xl2*Yl1)IfCases0Then'======================================缩短型======================================'MATLAB中得到的两圆交点公式k=(R1^2+4*R1*r+2*R1*R2-OY2^2-OX1^2-OY1^2-OX2^2+4*R2*r+2*OY1*OY2+R2^2+4*r^2+2*OX2*OX1)s=(-OY2^2-OY1^2+2*OY1*OY2+2*OX2*OX1-2*R1*R2+R1^2+R2^2-OX1^2-OX2^2)Ss=-2*OY2*OY1*OX2^2+OX2^2*OY2^2+OY1*(-(OX1-OX2)^2*(-OY2^2-OY1^2+2*OY1*OY2+2*OX2*OX1-2*R1*R2+R1^2+R2^2-OX1^2-OX2^2)*(R1^2+4*R1*r+2*R1*R2-OY2^2-OX1^2-OY1^2-OX2^2+4*R2*r+2*OY1*OY2+R2^2+4*r^2+2*OX2*OX1))^(1/2)+2*OY2*OX1^2*OY1+2*OX2*OX1*R2^2-2*OX2*OX1*R1^2-2*OX2^2*R2*r+2*R1*r*OX2^2-2*OX1^2*R2*r+2*OX1^2*R1*r-4*OX2*OX1*R1*r+4*OX2*OX1*R2*r+R1^2*OX1^2+R1^2*OX2^2-OX1^2*OY1^2-OX1^2*R2^2-OX1^2*OY2^2+OY1^2*OX2^2-R2^2*OX2^2-OX1^4+OX2^4+2*OX2*OX1^3-2*OX2^3*OX1-OY2*(-(OX1-OX2)^2*s*k)^(1/2)Mmx=-1/2*Ss/(-2*OX2*OX1-2*OY1*OY2+OX1^2+OY1^2+OX2^2+OY2^2)/(OX1-OX2)Mmy=-1/2*(-R1^2*OY2-OY1^3-OX1^2*OY2+2*OY2*R2*r+2*OX2*OX1*OY1+2*OX2*OX1*OY2-2*OY2*R1*r-2*OY1*R2*r+2*OY1*R1*r
本文标题:数控原理VB圆弧接圆弧课程设计
链接地址:https://www.777doc.com/doc-6110688 .html