基于 VB 编程的凸 轮 机 构 设 计
(题号:4 )
1. 题目要求:设计一偏置直动滚子推杆盘形凸轮机构,使其推
程为五项多项式运动,回程为余弦加速度运动。凸轮沿逆时
针方向做匀速转动。
主要参数有:
题 号:
近休凸轮转角
推程凸轮转角
远休凸轮转角
回程凸轮转角
4-A
题号
4-A
r0
15
0-60
e
5
60-180
rr
10
h
28
180-270
[α1]
30
270-360
p
0.3rr
[α2]
70
题 号:
近休凸轮转角
推程凸轮转角
远休凸轮转角
回程凸轮转角
4-B
题号
4-B
r0
20
0-45
e
10
45-210
rr
14
h
30
210-260
[α1]
30
260-360
p
0.3rr
[α2]
75
题 号:
近休凸轮转角
推程凸轮转角
远休凸轮转角
回程凸轮转角
4-C
题号
4-C
r0
22
0-30
e
14
30-210
rr
18
h
35
210-280
[α1]
35
280-360
p
0.35rr
[α2]
65
2. 所需方程:
推程(五次多项式):
s
v
a
3
1 0
h
3
0
3 0
h w
3
0
h w
3
0
6 0
4
2
1 5
h
4
0
6 0
h w
4
0
1 8 0
h w
4
0
2
5
h
5
0
6
3
3 0
2
2
4
h w
5
0
1 2 0
3
2
h w
5
0
回程(余弦加速度):
h
1
c o s (
h w
2
s i n (
2
0
)
)
0
0
2
h w
2
c o s (
2
2
0
0
)
s
v
a
3. 程序代码:
Const pi = 3.1415927
Const k = pi / 180
Const dr = 0.1
Dim u!, r0!, e!, h!, rg!, pmin!, α1!, α2!, u10!, u1!, u20!, u2!, u0!
Dim dxu As Double, dyu As Double, xs As Double, ys As Double, si As Double, co As
Double
Dim x As Double, y As Double
Dim xxx(0 To 360), yyy(0 To 360), sss(0 To 360)
Sub lunkuofenxi_lilun()
Dim x As Double, y As Double
x = (s0 + s) * Sin(u * k) + e * Cos(u * k)
y = (s0 + s) * Cos(u * k) - e * Sin(u * k)
List1(2).AddItem x
List1(3).AddItem y
Text13(0) = x
Text13(1) = y
End Sub
Sub lunkuofenxi_shiji()
Dim dxu As Double, dyu As Double, xs As Double, ys As Double, si As Double, co As
Double
dxu = (s0 + s) * Cos(u * k) - e * Sin(u * k)
dyu = -(s0 + s) * Sin(u * k) - e * Cos(u * k)
si = dxu / Sqr(dxu ^ 2 + dyu ^ 2)
co = -dyu / Sqr(dxu ^ 2 + dyu ^ 2)
xs = (s0 + s) * Sin(u * k) + e * Cos(u * k) - rg * co
ys = (s0 + s) * Cos(u * k) - e * Sin(u * k) - rg * si
List1(0).AddItem xs
List1(1).AddItem ys
Text13(2) = xs
Text13(3) = ys
End Sub
Private Sub Combo1_Click(Index As Integer)
Picture1.Cls
Picture2(0).Cls
For i = 0 To 16
List1(j).Clear
Next i
End Sub
Private Sub Command1_Click()
Command1.BackColor = &HC0C0C0
Timer1.Enabled = True
Shape1(3).FillStyle = 1
For g = 0 To 3
Shape1(g).Visible = True
Next g
Line1.Visible = True
u0 = Val(Text18)
r0 = Val(Text1)
e = Val(Text2)
rg = Val(Text3)
h = Val(Text4)
pmin = Val(Text5) * rg
α1 = Val(Text6)
α2 = Val(Text7)
u10 = (Val(Text9) - Val(Text8))
u1 = (Val(Text10) - Val(Text9))
u20 = (Val(Text11) - Val(Text10))
u2 = (Val(Text12) - Val(Text11))
s0 = Sqr(r0 ^ 2 - e ^ 2)
lr = Val(Text1) + Val(Text4) + Val(Text3)
Picture1.Scale (-lr, lr)-(lr, -lr)
Picture1.ForeColor = &HFF00&
Picture1.DrawWidth = 1
Picture1.Line (0, lr - Val(Text3))-(0, Val(Text3) - lr)
Picture1.Line (lr - Val(Text3), 0)-(Val(Text3) - lr, 0)
Shape1(0).Move -1, 1, 2, 2
Shape1(1).Move -r0, r0, 2 * r0, 2 * r0
Shape1(2).Move (e - 1), (s0 + 1), 2, 2
Shape1(3).Move (e - rg), (s0 + rg), 2 * rg, 2 * rg
Shape1(0).FillStyle = 0: Shape1(2).FillStyle = 0
Picture1.ForeColor = &HFFFF00
Line1.BorderWidth = 2
Line1.X1 = e: Line1.Y1 = Sqr(r0 ^ 2 - e ^ 2)
Line1.X2 = e: Line1.Y2 = Sqr(r0 ^ 2 - e ^ 2) + 2 * Val(Text3)
ji1 = Val(Text8)
ji2 = Val(Text9)
ji3 = Val(Text10)
ji4 = Val(Text11)
ji5 = Val(Text12)
If u0 <= ji2 Then
u00 = u0
s = 0
dsu = 0
List1(5).AddItem s
End If
If u0 >= ji2 And u0 <= ji3 Then
u00 = (u0 - Val(Text9))
s = 10 * h * u00 ^ 3 / (u1 ^ 3) - 15 * h * u00 ^ 4 / (u1 ^ 4) + 6 * h *
u00 ^ 5 / (u1 ^ 5)
List1(5).AddItem s
End If
If u0 >= ji3 And u0 <= ji4 Then
u00 = u0
s = h
dsu = 0
List1(5).AddItem s
End If
If u0 >= ji4 And u0 <= ji5 Then
u00 = (u0 - Val(Text11))
s = h - h * (1 - Cos(pi * u00 / u2)) / 2
List1(5).AddItem s
End If
jjj = List1(5).ListCount
het = 0.05 * h
Picture2(0).Scale (-10, h * 1.5)-(380, -2)
Picture2(0).Line (-5, 0)-(375, 0)
Picture2(0).Line (0, h * 1.4)-(0, -1)
Picture2(0).CurrentX = -8: Picture2(0).CurrentY = h * 1.4: Picture2(0).Print "s"
Picture2(0).CurrentX = 375: Picture2(0).CurrentY = 0: Picture2(0).Print "θ"
Picture2(0).Line (370, het)-(375, 0)
Picture2(0).Line (370, -het)-(375, 0)
Picture2(0).Line (-3, h * 1.4 - 2)-(0, h * 1.4)
Picture2(0).Line (3, h * 1.4 - 2)-(0, h * 1.4)
If jjj > 1 And jjj <= 360 Then
If jjj Mod 45 = 0 Then
Picture2(0).Line (jjj, 0)-(jjj, het)
CurrentX = jjj: CurrentY = -het
Picture2(0).FontSize = 5
Picture2(0).Print jjj
End If
If jjj Mod Val(Text10) / 6 = 0 And jjj <= Val(Text10) Then
Picture2(0).Line (0, s)-(5, s)
CurrentX = -5: CurrentY = s
Picture2(0).FontSize = 5
Picture2(0).Print Format(s, "#0.0")
End If
Picture2(0).Line (jjj - 1, List1(5).List(jjj - 2))-(jjj, List1(5).List(jjj - 1))
End If
Picture2(0).DrawStyle = 1
If jjj = Val(Text10) Or jjj = Val(Text11) Then Picture2(0).Line (jjj, s)-(jjj, 0)
u = (u0 + 90)
x = (s0 + s) * Cos(u * k) + e * Cos(u0 * k)
y = (s0 + s) * Sin(u * k) + e * Sin(u0 * k)
List1(0).AddItem x
List1(1).AddItem y
Text13(0) = Format(x, "#0.0000")
Text13(1) = Format(x, "#0.0000")
dxu1 = -(s0 + s) * Sin(u * k) - e * Sin(u * k)
dyu1 = (s0 + s) * Cos(u * k) + e * Cos(u * k)
si = dxu1 / Sqr(dxu1 ^ 2 + dyu1 ^ 2)
co = -dyu1 / Sqr(dxu1 ^ 2 + dyu1 ^ 2)
List1(13).AddItem qulv1
Text15(0) = Format(qulv1, "##0.0000")
If List1(10).ListCount <= 360 Then
If qulv1 >= Val(Text15(1)) Then
Text15(1) = Format(qulv1, "##0.0000")
Text15(2) = Format(List1(10).List(List1(10).ListCount - 1), "##0.0000")
End If
If qulv1 <= Val(Text15(2)) Then
Text15(3) = Format(qulv1, "##0.0000")
Text15(4) = Format(List1(10).List(List1(10).ListCount - 1), "##0.0000")
End If
'If Val(Text14(0)) >= Val(Text14(1)) Then
Text14(1) = Format(jiao, "##0.0000")
Text14(3) = Format(List1(10).List(List1(10).ListCount - 1), "##0.0000")
End If
If Val(Text14(0)) <= Val(Text14(2)) Then
Text14(2) = Format(jiao, "##0.0000")
Text14(4) = Format(List1(10).List(List1(10).ListCount - 1), "##0.0000")
End If
If List1(10).ListCount >= 2 Then
xx0 = Val(List1(0).List(List1(0).ListCount - 2))
yy0 = Val(List1(1).List(List1(1).ListCount - 2))
xx1 = Val(List1(0).List(List1(0).ListCount - 1))
yy1 = Val(List1(1).List(List1(1).ListCount - 1))
Picture1.ForeColor = &HFF&
Picture1.Line (xx0, yy0)-(xx1, yy1)
End If
Else
u = (u0 + 90)
dxu = -(s0 + s) * Sin(u * k) - e * Sin(u * k)
dyu = (s0 + s) * Cos(u * k) + e * Cos(u * k)
si = dxu / Sqr(dxu ^ 2 + dyu ^ 2)
co = -dyu / Sqr(dxu ^ 2 + dyu ^ 2)
xs = (s0 + s) * Cos(u * k) + e * Cos(u0 * k) + rg * co
ys = (s0 + s) * Sin(u * k) + e * Sin(u0 * k) + rg * si
ss = Sqr(xs ^ 2 + ys ^ 2)
xl = (Atn(si / co)) / k
If xl < 0 Then xl = xl + 360
If xl > 180 Then jiao = Abs(270 - xl)
If xl <= 180 Then jiao = Abs(90 - xl)
Text14(0) = Format(jiao, "##0.0000")
List1(2).AddItem xs
List1(3).AddItem ys
List1(4).AddItem ss
Text13(2) = Format(xs, "#0.0000")
Text13(3) = Format(ys, "#0.0000")
End If
If List1(2).ListCount < 2 Then
Text15(5) = Format(List1(13).List(72), "##0.0000")
Text15(6) = Format(List1(10).List(72), "##0.0000")
Text15(7) = Format(List1(13).List(72), "##0.0000")
Text15(8) = Format(List1(10).List(72), "##0.0000")
Else
xx2 = Val(List1(2).List(List1(2).ListCount - 2))
yy2 = Val(List1(3).List(List1(3).ListCount - 2))
xx3 = Val(List1(2).List(List1(2).ListCount - 1))
yy3 = Val(List1(3).List(List1(3).ListCount - 1))
Picture1.ForeColor = &HFF0000
Picture1.DrawWidth = 2
Picture1.Line (xx2, yy2)-(xx3, yy3)
List1(13).AddItem qulv
Text15(9) = Format(qulv, "##0.0000")
If List1(10).ListCount <= 720 Then
If qulv >= Val(Text15(5)) Then
Text15(5) = Format(qulv, "##0.0000")
Text15(6) = Format(List1(10).List(List1(10).ListCount - 1), "##0.0000")
End If
If qulv <= Val(Text15(7)) Then
Text15(7) = Format(qulv, "##0.0000")
Text15(8) = Format(List1(10).List(List1(10).ListCount - 1), "##0.0000")
End If
End If
End If
End Sub
Private Sub Command4_Click()
Timer1.Enabled = False
Form2.Show
numb = List1(10).ListCount
If numb <= 360 Then
numb1 = numb
Else
numb1 = 360
End If
For i = 0 To numb1 - 1
jg1 = List1(0).List(i)
jg2 = List1(1).List(i)
If i <= 360 And i Mod 10 = 0 Then Form2.Print i, Format(jg1, "##0.0000"),
Format(jg2, "##0.0000")
Next i
If numb >= 360 Then
If numb <= 720 Then
numb2 = numb - 360
Else
numb2 = 360
End If
End If
For j = 0 To numb2 - 1
jg3 = List1(2).List(j)
jg4 = List1(3).List(j)
If j <= 720 And j Mod 10 = 0 Then Form2.Print j, Format(jg3, "##0.0000"),
Format(jg4, "##0.0000")
Next j
End Sub
Private Sub Command6_Click()
For j = 0 To 16
List1(j).Clear
Next j
Text20 = ""
For g = 0 To 3