📄 form1.frm
字号:
Height = 285
Left = 1200
TabIndex = 11
Text = "80000"
Top = 960
Width = 975
End
Begin VB.TextBox VB_LowSpeed
Alignment = 1 'Right Justify
Height = 285
Left = 1200
TabIndex = 9
Text = "1000"
Top = 600
Width = 975
End
Begin VB.TextBox VB_Dist
Alignment = 1 'Right Justify
Height = 285
Left = 1200
TabIndex = 7
Text = "80000"
Top = 240
Width = 975
End
Begin VB.Label Label1
Caption = "加速时间:"
ForeColor = &H000000FF&
Height = 375
Left = 120
TabIndex = 32
Top = 1320
Width = 975
End
Begin VB.Label Label11
Caption = "高速度:"
ForeColor = &H000000FF&
Height = 255
Left = 120
TabIndex = 12
Top = 960
Width = 975
End
Begin VB.Label Label10
Caption = "初速度:"
ForeColor = &H000000FF&
Height = 255
Left = 120
TabIndex = 10
Top = 600
Width = 975
End
Begin VB.Label Label9
Caption = "距 离:"
ForeColor = &H000000FF&
Height = 255
Left = 120
TabIndex = 8
Top = 240
Width = 735
End
End
Begin VB.CommandButton StartMove
Caption = "启 动"
Height = 495
Left = 4560
TabIndex = 5
Top = 1440
Width = 1095
End
Begin VB.TextBox VB_CurPos
Alignment = 1 'Right Justify
BackColor = &H80000000&
Enabled = 0 'False
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 405
Left = 2280
TabIndex = 3
Text = "0"
Top = 3000
Width = 1815
End
Begin VB.Frame Frame2
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00800000&
Height = 615
Left = 2160
TabIndex = 0
Top = 0
Width = 1815
Begin VB.TextBox VB_AxisNo
Alignment = 1 'Right Justify
Height = 285
Left = 960
TabIndex = 1
Text = "0"
Top = 240
Width = 615
End
Begin VB.Label Label2
Caption = "轴号:"
ForeColor = &H000000FF&
Height = 255
Left = 240
TabIndex = 2
Top = 240
Width = 615
End
End
Begin VB.Timer Timer1
Interval = 50
Left = 1680
Top = 120
End
Begin VB.Label Label7
Caption = "当前位置:"
BeginProperty Font
Name = "Times New Roman"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 255
Left = 2280
TabIndex = 4
Top = 2640
Width = 1695
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim AxisNo As Integer
Private Sub Command1_Click()
Decel_stop AxisNo, 0.1 '光滑制动指定轴
End Sub
Private Sub Command2_Click()
Set_position AxisNo, 0 '将指定轴的当前位置清零
End Sub
Private Sub Command3_Click()
Unload Form1
End
End Sub
Private Sub Form_Load()
Dim i As Integer
Dim CardsCout As Integer
CardsCout = Board_init() 'DMC2000控制卡初始化
If CardsCout = 0 Then
MsgBox "你没有安装DMC2000控制卡!"
End
End If
AxisNo = 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim i As Integer
For i = 0 To 4 Step 1
Board_close (i)
Next i
Unload Form1
End Sub
Private Sub StartMove_Click()
Start_r_move AxisNo, CDbl(VB_Dist.Text), CDbl(VB_LowSpeed.Text), CDbl(VB_HighSpeed.Text), CDbl(VB_Taccel.Text)
End Sub
Private Sub VB_AxisNo_Change()
Dim Temp As Integer
If IsNumeric(VB_AxisNo.Text) Then
Temp = CInt(VB_AxisNo.Text)
If (Temp < 4 And Temp >= 0) Then
AxisNo = Temp '改变轴号
Else
AxisNo = 0
End If
Else
AxisNo = 0
End If
VB_AxisNo.Text = Format(AxisNo)
End Sub
Private Sub Timer1_Timer()
Dim TestBit As Integer
Dim IOState As Integer
Dim MotionStatus As Integer
Dim CurPos As Double
CurPos = Get_position(AxisNo) '读当前轴的当前位置
VB_CurPos.Text = Str(CurPos)
MotionStatus = Motion_done(AxisNo) '检测当前轴的状态
If MotionStatus = 0 Then
VB_MotionState.BackColor = &HFF00&
VB_MotionState.Caption = "MOVE"
Else
VB_MotionState.BackColor = &HFF&
VB_MotionState.Caption = "STOP"
End If
IOState = Get_io_status(AxisNo) '读当前轴的 IO 状态
For TestBit = 0 To 11
If 2 ^ TestBit And IOState Then
VB_IOState(TestBit).BackColor = &HFF00&
Else
VB_IOState(TestBit).BackColor = &HFF&
End If
Next TestBit
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -