|
tool=getselectedtool()
If tool=1 Then
Call t1
End If
If tool=2 Then
Call t2
End If
If tool=3 Then
Call t3
End If
If tool=4 Then
Call t4
End If
If tool=5 Then
Call t5
End If
If tool=6 Then
Call t6
End If
If tool=7 Then
Call t7
End If
If tool=8 Then
Call t8
End If
setcurrenttool(tool)
'//// Subroutines /////////
Sub t1
Code "m7"
Code "G4 P1"
Code "G1 Y0 F5"
Code "G4 P1"
Code "M9"
End Sub
Sub t2
Code "m7"
Code "G4 P1"
Code "G1 Y0.125 F5"
Code "G4 P1"
Code "M9"
End Sub
Sub t3
Code "m7"
Code "G4 P1"
Code "G1 Y0.25 F5"
Code "G4 P1"
Code "M9"
End Sub
Sub t4
Code "m7"
Code "G4 P1"
Code "G1 Y0.375 F5"
Code "G4 P1"
Code "M9"
End Sub
Sub t5
Code "m7"
Code "G4 P1"
Code "G1 Y0.5 F5"
Code "G4 P1"
Code "M9"
End Sub
Sub t6
Code "m7"
Code "G4 P1"
Code "G1 Y0.625 F5"
Code "G4 P1"
Code "M9"
End Sub
Sub t7
Code "m7"
Code "G4 P1"
Code "G1 Y0.75 F5"
Code "G4 P1"
Code "M9"
End Sub
Sub t8
Code "m7"
Code "G4 P1"
Code "G1 Y0.85 F5"
Code "G4 P1"
Code "M9"
End Sub
这是我搞的一段程序,我是用步进电机来换刀电机的,8个工位,不知道还缺少什么,在G代码中输入“M6T*(*指数字1-8)”都没有反应,在MACH的“VB脚本编辑”里面,子程序可以运行,主程序若把“If tool= *(*指数字1-8) Then”这段中的数字换成“0”就可以运行相应的子程序。如:If tool=6 ThenCall t6
End If
把“If tool=6 Then”中“6”换成0,即“If tool=0 Then”就可以运行SUB T6段子程序,机床就会动作。
看看有没有高手帮我解惑啊,我不懂VB,这段时间瞎研究才搞出这段来。。 |
欢迎继续阅读楼主其他信息
|