解析法设计凸轮

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

解析法设计凸轮Ⅱ的实际轮廓曲线代码:

Private Sub Command1_Click()

Form2.Show '焦点出现form2

End Sub

Private Sub Command1_Click()

Dim l1, l2, l3 As Single

Form2.Picture2.Scale (-0.1, 400)-(7, -400)

l1 = -Abs(Form2.Picture1.ScaleHeight / Form2.Picture1.ScaleWidth)

l3 = -Abs(Form2.Picture3.ScaleHeight / Form2.Picture3.ScaleWidth) '定义两个图框的高宽比Form2.Picture1.ScaleWidth = 9.5

Form2.Picture3.ScaleWidth = 150 '设定图框的长度

Form2.Picture1.ScaleHeight = l1 * Form2.Picture1.ScaleWidth

Form2.Picture3.ScaleHeight = l3 * Form2.Picture3.ScaleWidth

Form2.Picture1.ScaleLeft = -0.1

Form2.Picture3.ScaleLeft = -70

Form2.Picture1.ScaleTop = 7

Form2.Picture3.ScaleTop = 63 '规定高度的起点

Dim dt1, dt2, dt3, dt4, dt5, s1, v1, s2, v2, k1, s0 As Single

Dim n, m As Integer

Dim h, e As Integer

Dim dt6, dt7, dt8, dt9, dt10, dt11, x1, y1, x2, y2, r As Single

Dim x3, y3, x4, y4, rg '定义各种量

h = Form2.Text3

e = Form2.Text2

k1 = Form2.Text4

s0 = Form2.Text1

rg = Form2.Text5 '试各种变量与文本框相等,用于输入数据

Const pi = 3.1415926

n = 1000 '把每一步定义为360°/1000

dt11 = 0

dt1 = pi / 3

dt2 = pi / 3

dt3 = pi / 2 / n

dt4 = 0

dt6 = pi / 18

Form2.Picture3.Line (-70, 0)-(70, 0)

Form2.Picture3.Line (0, 70)-(0, -70)

Form2.Picture1.Line (0, 0)-(7, 0)

Form2.Picture1.Line (0, 6.5)-(0, 0)

Form2.Picture2.Line (0, 0)-(7, 0)

Form2.Picture2.Line (0, 390)-(0, -390) '画出各个两个图框的坐标轴

s1 = h * ((dt4 / dt1) - Sin(2 * pi * dt4 / dt1) / (2 * pi))

v1 = h * k1 * (1 - Cos(2 * pi * dt4 / dt1)) / dt1 '计算第一个点的速度和推程,选择正弦加速度规

x1 = (s0 + s1) * Sin(dt4) + e * Cos(dt4)

y1 = (s0 + s1) * Cos(dt4) - e * Sin(dt4) '计算凸轮理论轮廓第一个点的坐标

x3 = (s0 + s1 - rg) * Sin(dt4) + e * Cos(dt4)

y3 = (s0 + s1 - rg) * Cos(dt4) - e * Sin(dt4) '计算实际工作轮廓曲线的第一个点的坐标

While dt4 < dt1 '第一个六十度的循环绘制推程的曲线

dt5 = dt4 + dt3

s2 = h * ((dt5 / dt1) - Sin(2 * pi * dt5 / dt1) / (2 * pi))

v2 = h * k1 * (1 - Cos(2 * pi * dt5 / dt1)) / dt1

x2 = (s0 + s2) * Sin(dt5) + e * Cos(dt5)

y2 = (s0 + s2) * Cos(dt5) - e * Sin(dt5)

x4 = (s0 + s2 - rg) * Sin(dt5) + e * Cos(dt5)

y4 = (s0 + s2 - rg) * Cos(dt5) - e * Sin(dt5) '绘制上述参数的第二个点

Form2.Picture1.Line (dt4, s1)-(dt5, s2)

Form2.Picture2.Line (dt4, v1)-(dt5, v2)

Form2.Picture3.Line (x1, y1)-(x2, y2)

Form2.Picture3.Line (x3, y3)-(x4, y4) '画直线,由于每一个步长很小,故可以一直代曲

dt4 = dt5

s1 = s2

v1 = v2

x1 = x2

y1 = y2

x3 = x4

y3 = y4 '交换数值

Wend

dt11 = dt4

While dt11 >= dt1 And dt11 < dt1 + dt6 '第二个10的远休角的的循环,绘制的理论和实际轮廓曲线都都是一段圆心角为十度的圆弧

dt11 = dt11 + dt3

x2 = (s0 + s2) * Sin(dt11) + e * Cos(dt11)

y2 = (s0 + s2) * Cos(dt11) - e * Sin(dt11)

x4 = (s0 + s2 - rg) * Sin(dt11) + e * Cos(dt11)

y4 = (s0 + s2 - rg) * Cos(dt11) - e * Sin(dt11)

Form2.Picture3.Line (x1, y1)-(x2, y2)

Form2.Picture3.Line (x3, y3)-(x4, y4) '循环画点形成一个曲线

x1 = x2

y1 = y2

x3 = x4

y3 = y4

Wend

dt4 = dt4 + dt6

Form2.Picture1.Line (dt1, s1)-(dt4, s1)

Form2.Picture2.Line (dt1, v1)-(dt4, v1) '绘制远休时的s曲线

While dt4 >= dt1 + dt6 And dt4 < dt1 + dt6 + dt2 '第三个60°近休循环,绘制回程的曲线

相关文档
最新文档