?? frmmain.frm
字號:
VERSION 5.00
Begin VB.Form frmMain
BorderStyle = 1 'Fixed Single
Caption = "MPC2810 演示"
ClientHeight = 3705
ClientLeft = 150
ClientTop = 720
ClientWidth = 3885
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3705
ScaleWidth = 3885
StartUpPosition = 3 '窗口缺省
Begin VB.Timer timGetdata
Interval = 200
Left = 2880
Top = 3000
End
Begin VB.CommandButton cmdFastMove
Caption = "快 速"
Height = 375
Left = 2640
TabIndex = 15
Top = 2640
Width = 855
End
Begin VB.CommandButton cmdConMove
Caption = "常 速"
Height = 375
Left = 2640
TabIndex = 14
Top = 2160
Width = 855
End
Begin VB.CommandButton cmdReset
Caption = "清 零"
Height = 375
Left = 2640
TabIndex = 13
Top = 1680
Width = 855
End
Begin VB.CommandButton cmdSlowStop
Caption = "緩 停"
Height = 375
Left = 2640
TabIndex = 12
Top = 720
Width = 855
End
Begin VB.CommandButton cmdSuddenStop
Caption = "急 停"
Height = 375
Left = 2640
TabIndex = 11
Top = 240
Width = 855
End
Begin VB.Frame Frame1
Caption = "運(yùn)動參數(shù)設(shè)定"
Height = 2295
Left = 240
TabIndex = 0
Top = 120
Width = 2175
Begin VB.TextBox txtAxesNum
Height = 270
Left = 1080
TabIndex = 5
Text = "1"
Top = 360
Width = 855
End
Begin VB.TextBox txtDis
Height = 270
Left = 1080
TabIndex = 4
Text = "200000"
Top = 1800
Width = 855
End
Begin VB.TextBox txtAccel
Height = 270
Left = 1080
TabIndex = 3
Text = "10000"
Top = 1440
Width = 855
End
Begin VB.TextBox txtHighSpeed
Height = 270
Left = 1080
TabIndex = 2
Text = "20000"
Top = 1080
Width = 855
End
Begin VB.TextBox txtLowSpeed
Height = 270
Left = 1080
TabIndex = 1
Text = "100"
Top = 720
Width = 855
End
Begin VB.Label labLineAxesX
Caption = "軸號"
Height = 255
Left = 600
TabIndex = 10
Top = 360
Width = 375
End
Begin VB.Label Label9
Caption = "移動距離"
Height = 255
Left = 240
TabIndex = 9
Top = 1800
Width = 1095
End
Begin VB.Label Label8
Caption = "加速度"
Height = 255
Left = 480
TabIndex = 8
Top = 1440
Width = 855
End
Begin VB.Label Label7
Caption = "最高速度"
Height = 255
Left = 240
TabIndex = 7
Top = 1080
Width = 1095
End
Begin VB.Label Label6
Caption = "初速度"
Height = 255
Left = 480
TabIndex = 6
Top = 720
Width = 855
End
End
Begin VB.Label Label4
Caption = "反饋:"
Height = 375
Left = 240
TabIndex = 21
Top = 3240
Width = 615
End
Begin VB.Label labEnc
Height = 255
Left = 960
TabIndex = 20
Top = 3240
Width = 1455
End
Begin VB.Label labSpeed
Height = 255
Left = 960
TabIndex = 19
Top = 2880
Width = 1455
End
Begin VB.Label labPos
Height = 255
Left = 960
TabIndex = 18
Top = 2520
Width = 1455
End
Begin VB.Label Label2
Caption = "速度:"
Height = 375
Left = 240
TabIndex = 17
Top = 2880
Width = 615
End
Begin VB.Label Label1
Caption = "脈沖:"
Height = 375
Left = 240
TabIndex = 16
Top = 2520
Width = 615
End
Begin VB.Menu mnuFile
Caption = "文件(&F)"
Begin VB.Menu mnuFileExit
Caption = "退出"
End
End
Begin VB.Menu mnuAbout
Caption = "關(guān)于(&A)"
Begin VB.Menu mnuCardInfo
Caption = "板卡信息"
End
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim AxesNum As Long
Dim lowspeed As Double
Dim highspeed As Double
Dim Accel As Double
Dim Dis As Long
Dim glTotalAxes As Long '當(dāng)前計算機(jī)中軸數(shù)
Dim glTotalCards As Long '當(dāng)前計算機(jī)中卡數(shù)
'*****************************************
'該函數(shù)對板卡進(jìn)行設(shè)置,可在窗體加載時調(diào)用
Private Function SetBoard() As Integer
Dim Rtn As Integer, i As Integer
Rtn = auto_set() '對板卡進(jìn)行自動設(shè)置
If Rtn <= 0 Then '若自動設(shè)置錯誤則返回0
SetBoard = -1
glTotalAxes = Rtn
Exit Function
End If
glTotalAxes = Rtn
Rtn = init_board
If Rtn <= 0 Then
SetBoard = -2
glTotalCards = Rtn
Exit Function
End If
glTotalCards = Rtn
For i = 1 To glTotalAxes
set_sd_logic i, 0
set_el_logic i, 0
set_org_logic i, 0
set_alm_logic i, 0
Next i
SetBoard = 0
End Function
'******************************************
'讀取用戶設(shè)置的運(yùn)動參數(shù)
Private Sub GetParam()
AxesNum = Val(txtAxesNum.Text) '軸號
lowspeed = Val(txtLowSpeed.Text) '低速
highspeed = Val(txtHighSpeed.Text) '高速
Accel = Val(txtAccel.Text) '加速度
Dis = Val(txtDis.Text) '移動距離
set_maxspeed AxesNum, highspeed
set_conspeed AxesNum, lowspeed '設(shè)置常速運(yùn)動參數(shù)
set_profile AxesNum, lowspeed, highspeed, Accel '設(shè)置梯形速度運(yùn)動參數(shù)
End Sub
Private Sub cmdConMove_Click()
GetParam
con_pmove AxesNum, Dis
End Sub
Private Sub cmdFastMove_Click()
GetParam
fast_pmove AxesNum, Dis
End Sub
Private Sub cmdReset_Click()
reset_pos AxesNum
End Sub
Private Sub cmdSlowStop_Click()
decel_stop AxesNum
End Sub
Private Sub cmdSuddenStop_Click()
sudden_stop AxesNum
End Sub
Private Sub Form_Load()
If SetBoard < 0 Then
MsgBox "初始化錯誤!", vbOKOnly, "MPC02810演示 錯誤信息"
End If
GetParam
End Sub
Private Sub mnuCardInfo_Click()
Dim sInfo As String
Dim Rtn As Long
Dim BoardNum As Long
Dim i As Long
Dim ma(2) As Long, mi1(2) As Long, mi2(2) As Long
Dim nType As Long
sInfo = "計算機(jī)內(nèi)插有 " & glTotalCards & " 個板卡。 共有 " & glTotalAxes & " 根軸。"
sInfo = sInfo & vbCrLf
Rtn = get_lib_ver(ma(0), mi1(0), mi2(0))
Rtn = get_sys_ver(ma(1), mi1(1), mi2(1))
Rtn = get_card_ver(1, nType, ma(2), mi1(2), mi2(2))
sInfo = sInfo & "板卡類型號 :" & nType & vbCrLf
sInfo = sInfo & "函數(shù)庫版本號 :" & ma(0) & "." & mi1(0) & "." & mi2(0) & vbCrLf
sInfo = sInfo & "驅(qū)動程序版本號 :" & ma(1) & "." & mi1(1) & "." & mi2(1) & vbCrLf
sInfo = sInfo & "硬件版本號 :" & ma(2) & "." & mi1(2) & "." & mi2(2) & vbCrLf
' For i = 1 To glTotalAxes
' sudden_stop i
' Next i
'
' For i = 1 To glTotalAxes
' reset_pos i
' Next i
frmInfo.SetInfo sInfo
frmInfo.Show 1
End Sub
Private Sub mnuFileExit_Click()
Unload Me
End Sub
Private Sub timGetdata_Timer()
Dim pos As Long
Dim data As Long
Dim speed As Double, dbPos As Double
Dim lEnc As Long
get_abs_pos AxesNum, dbPos '讀取位置
pos = Int(dbPos)
labPos.Caption = pos '顯示位置
speed = get_rate(AxesNum) '讀取速度
labSpeed.Caption = Int(speed) '顯示速度
get_encoder AxesNum, lEnc '讀取編碼器反饋
labEnc.Caption = lEnc '顯示編碼器反饋
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -