⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demo01.frm

📁 运动控制
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "编程示例一(单轴定长相对运动)"
   ClientHeight    =   3225
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4470
   LinkTopic       =   "Form1"
   ScaleHeight     =   3225
   ScaleWidth      =   4470
   StartUpPosition =   2  '屏幕中心
   Begin VB.Timer Timer1 
      Interval        =   100
      Left            =   3960
      Top             =   2640
   End
   Begin VB.CommandButton CommandStop 
      Caption         =   "停止"
      Height          =   495
      Left            =   2880
      TabIndex        =   5
      Top             =   1680
      Width           =   1095
   End
   Begin VB.CommandButton CommandStart 
      Caption         =   "启动"
      Height          =   495
      Left            =   2880
      TabIndex        =   4
      Top             =   600
      Width           =   1095
   End
   Begin VB.TextBox TextTacc 
      Height          =   270
      Left            =   1320
      TabIndex        =   3
      Text            =   "0.1"
      Top             =   2160
      Width           =   855
   End
   Begin VB.TextBox TextMaxVel 
      Height          =   270
      Left            =   1320
      TabIndex        =   2
      Text            =   "1000"
      Top             =   1560
      Width           =   855
   End
   Begin VB.TextBox TextStrVel 
      Height          =   270
      Left            =   1320
      TabIndex        =   1
      Text            =   "100"
      Top             =   960
      Width           =   855
   End
   Begin VB.TextBox TextDist 
      Height          =   270
      Left            =   1320
      TabIndex        =   0
      Text            =   "2000"
      Top             =   360
      Width           =   855
   End
   Begin VB.Label LabelPos 
      Alignment       =   2  'Center
      BorderStyle     =   1  'Fixed Single
      Caption         =   "X轴位置:"
      Height          =   255
      Left            =   360
      TabIndex        =   10
      Top             =   2760
      Width           =   3375
   End
   Begin VB.Label Label4 
      Caption         =   "加减速时间:"
      Height          =   375
      Left            =   240
      TabIndex        =   9
      Top             =   2160
      Width           =   1095
   End
   Begin VB.Label Label3 
      Caption         =   "最大速度:"
      Height          =   375
      Left            =   360
      TabIndex        =   8
      Top             =   1560
      Width           =   975
   End
   Begin VB.Label Label2 
      Caption         =   "起始速度:"
      Height          =   375
      Left            =   360
      TabIndex        =   7
      Top             =   960
      Width           =   975
   End
   Begin VB.Label Label1 
      Caption         =   "目标位置:"
      Height          =   375
      Left            =   360
      TabIndex        =   6
      Top             =   360
      Width           =   975
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'********************************************
'    雷泰DMC5400控制卡编程示例之一(单轴定长相对运动)

'  关键函数:
'        d5400_board_init       初始化控制卡
'        d5400_board_close      关闭控制卡
'        d5400_set_profile      设置T型曲线
'        d5400_t_pmove          T型加速定长运动
'        d5400_decel_stop       减速停止
'        d5400_get_position     读取程序位置值
'
'
'
'    Writen by LeadTech-support
'    FAX: 0755 - 26417609
'    TEL: 0755 - 26434329
'    http://www.szleadtech.com.cn
'********************************************

Dim Dist As Long, StrVel As Long, MaxVel As Long, Tacc As Double, Tdec As Double  '定义各个变量

Private Sub Form_Load()
If d5400_board_init < 1 Then MsgBox "没有找到运动控制卡!"         '初始化控制卡
End Sub

Private Sub Form_Unload(Cancel As Integer)
d5400_board_close                                                  '关闭控制卡,释放资源
End
End Sub

Private Sub CommandStart_Click()
Dist = Val(TextDist.Text)                                          '赋值目标位置
StrVel = Val(TextStrVel.Text)                                      '赋值初始速度
MaxVel = Val(TextMaxVel.Text)                                      '赋值最大速度
Tacc = Tedc = Val(TextTacc.Text)                                   '赋值加减速时间
d5400_set_profile 0, StrVel, MaxVel, Tacc, Tdec                    '设置T型曲线
d5400_t_pmove 0, Dist, 0                                           '第0轴T型加速定长相对位移运动
End Sub

Private Sub CommandStop_Click()
d5400_decel_stop 0, Tdec                                           '第0轴减速停止
End Sub

Private Sub Timer1_Timer()
LabelPos.Caption = "第0轴位置:" & d5400_get_position(0)           '读取第0轴程序位置值
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -