www.pudn.com > Vb6.0.rar > mainframe.frm, change:2004-03-17,size:6752b


VERSION 5.00 
Begin VB.Form Main_Frame  
   Caption         =   "DMC1000编程示例之三" 
   ClientHeight    =   3600 
   ClientLeft      =   60 
   ClientTop       =   345 
   ClientWidth     =   4275 
   LinkTopic       =   "Form1" 
   ScaleHeight     =   3600 
   ScaleWidth      =   4275 
   StartUpPosition =   3  '窗口缺省 
   Begin VB.CommandButton Command_Stop  
      Caption         =   "停止" 
      Height          =   375 
      Left            =   3240 
      TabIndex        =   14 
      Top             =   720 
      Width           =   975 
   End 
   Begin VB.CommandButton Command_Start  
      Caption         =   "开始" 
      Height          =   375 
      Left            =   3240 
      TabIndex        =   13 
      Top             =   240 
      Width           =   975 
   End 
   Begin VB.Timer Timer1  
      Interval        =   100 
      Left            =   3240 
      Top             =   2520 
   End 
   Begin VB.Frame Frame1  
      Caption         =   "参数设定" 
      Height          =   2895 
      Left            =   120 
      TabIndex        =   0 
      Top             =   120 
      Width           =   2895 
      Begin VB.CommandButton Command_Dec  
         Caption         =   "减少10%" 
         Height          =   375 
         Left            =   1200 
         TabIndex        =   11 
         Top             =   2400 
         Width           =   975 
      End 
      Begin VB.CommandButton Command_Add  
         Caption         =   "增加10%" 
         Height          =   375 
         Left            =   240 
         TabIndex        =   10 
         Top             =   2400 
         Width           =   855 
      End 
      Begin VB.VScrollBar VScroll_Speed  
         Height          =   2535 
         Left            =   2280 
         TabIndex        =   9 
         Top             =   240 
         Width           =   375 
      End 
      Begin VB.TextBox Text_Time  
         Height          =   375 
         Left            =   1200 
         TabIndex        =   8 
         Text            =   "0.1" 
         Top             =   1800 
         Width           =   855 
      End 
      Begin VB.TextBox Text_Speed  
         Height          =   375 
         Left            =   1200 
         TabIndex        =   6 
         Text            =   "6400" 
         Top             =   1320 
         Width           =   855 
      End 
      Begin VB.TextBox Text_Start  
         Height          =   375 
         Left            =   1200 
         TabIndex        =   4 
         Text            =   "1600" 
         Top             =   720 
         Width           =   855 
      End 
      Begin VB.OptionButton Option2  
         Caption         =   "S形驱动" 
         Height          =   255 
         Left            =   1320 
         TabIndex        =   2 
         Top             =   240 
         Width           =   1095 
      End 
      Begin VB.OptionButton Option_SPEEDST  
         Caption         =   "T形驱动" 
         Height          =   255 
         Left            =   240 
         TabIndex        =   1 
         Top             =   240 
         Width           =   975 
      End 
      Begin VB.Label Label3  
         Caption         =   "变速时间:" 
         Height          =   255 
         Left            =   240 
         TabIndex        =   7 
         Top             =   1920 
         Width           =   1455 
      End 
      Begin VB.Label Label2  
         Caption         =   "驱动速度:" 
         Height          =   255 
         Left            =   240 
         TabIndex        =   5 
         Top             =   1440 
         Width           =   1095 
      End 
      Begin VB.Label Label1  
         Caption         =   "起始速度:" 
         Height          =   255 
         Left            =   240 
         TabIndex        =   3 
         Top             =   840 
         Width           =   975 
      End 
   End 
   Begin VB.Label Label_POSITION  
      Alignment       =   2  'Center 
      BorderStyle     =   1  'Fixed Single 
      Caption         =   "Label4" 
      Height          =   375 
      Left            =   120 
      TabIndex        =   12 
      Top             =   3120 
      Width           =   2895 
   End 
End 
Attribute VB_Name = "Main_Frame" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Const XCH As Integer = 0        '今次只测试一个轴的效果,其它轴类似 
 
 
 
 
 
'******************************************** 
'    雷赛DMC1000控制卡编程示例之三 
' 
'? -主要演示功能: 
'    1. 动态改变速度 
' 
'!-关键函数: 
'    速度变化函数 
'    d1000_change_speed 
' 
'#-注意事项: 
'    1. 动态变速注意S形和T形变化效果的不同 
'    2. 动态变速有一定限定,请注意 
' 
' 
'    Writen by LEISAI-SUPPORT 
'    FAX: 0755 - 26402718 
'    TEL: 0755 - 26434329 
'EMAIL:     support@ LEISAI.com 
'HTTP:     www.LEISAI.com 
'******************************************** 
Private Sub Command_Start_Click() 
    Dim nStart, nSpeed As Integer 
    Dim fAccel As Integer 
     
    nStart = Val(Text_Start.Text) 
    nSpeed = Val(Text_Speed.Text) 
    fAccel = Val(Text_Time.Text) 
     
    If Option_SPEEDST = True Then 
        d1000_start_tv_move XCH, nStart, nSpeed, fAccel 
    Else 
        d1000_start_sv_move XCH, nStart, nSpeed, fAccel 
    End If 
     
End Sub 
 
Private Sub Command_Stop_Click() 
    d1000_decel_stop XCH 
End Sub 
 
Private Sub Form_Load() 
    If d1000_board_init() <= 0 Then '控制卡初始化 
        MsgBox "未找到控制卡!", vbOKOnly, "警告" 
    End If 
 
End Sub 
 
Private Sub Form_Unload(Cancel As Integer) 
    d1000_board_close '以后不再提示 
 
End Sub 
 
Private Sub Timer1_Timer() 
    Label_POSITION.Caption = "位置:" + Str(d1000_get_command_pos(XCH)) 
End Sub 
 
Private Sub VScroll_Speed_Change() 
    Static oldV As Integer 
    Dim speed As Integer 
    Const UINT As Integer = 50 
     
    speed = (VScroll_Speed.Value - oldV) * UINT + d1000_get_speed(XCH) 
    d1000_change_speed XCH, speed 
     
    oldV = VScroll_Speed.Value 
     
     
End Sub 
 
 
Private Sub Command_Add_Click() 
    Dim speed As Integer 
    speed = d1000_get_speed(XCH) * 1.1 
    If speed > 200000 Then 
        speed = 200000 
    End If 
    If speed < 20 Then 
        speed = 20 
    End If 
    d1000_change_speed XCH, speed 
     
    Text_Speed.Text = Str(speed) 
     
End Sub 
 
Private Sub Command_Dec_Click() 
    Dim speed As Integer 
    speed = d1000_get_speed(XCH) * 0.9 
    If speed > 200000 Then 
        speed = 200000 
    End If 
    If speed < 20 Then 
        speed = 20 
    End If 
    d1000_change_speed XCH, speed 
     
    Text_Speed.Text = Str(speed) 
 
End Sub