www.pudn.com > Vb6.0.rar > mainframe.frm, change:2004-06-16,size:11028b


VERSION 5.00 
Begin VB.Form Main_Frame  
   Caption         =   "DMC1000编程示例之四" 
   ClientHeight    =   3885 
   ClientLeft      =   2820 
   ClientTop       =   2280 
   ClientWidth     =   5565 
   LinkTopic       =   "Form1" 
   ScaleHeight     =   3885 
   ScaleWidth      =   5565 
   Begin VB.Timer Timer1  
      Interval        =   100 
      Left            =   4680 
      Top             =   1920 
   End 
   Begin VB.CommandButton Command_Stop  
      Caption         =   "停止" 
      Height          =   375 
      Left            =   4560 
      TabIndex        =   27 
      Top             =   600 
      Width           =   855 
   End 
   Begin VB.CommandButton Command_Start  
      Caption         =   "开始" 
      Height          =   375 
      Left            =   4560 
      TabIndex        =   26 
      Top             =   120 
      Width           =   855 
   End 
   Begin VB.Frame Frame3  
      Height          =   1815 
      Left            =   120 
      TabIndex        =   8 
      Top             =   1440 
      Width           =   4215 
      Begin VB.TextBox Text_U  
         Height          =   375 
         Left            =   2880 
         TabIndex        =   24 
         Text            =   "3200" 
         Top             =   1320 
         Width           =   735 
      End 
      Begin VB.TextBox Text_Z  
         Height          =   375 
         Left            =   2880 
         TabIndex        =   23 
         Text            =   "3200" 
         Top             =   960 
         Width           =   735 
      End 
      Begin VB.TextBox Text_Y  
         Height          =   375 
         Left            =   2880 
         TabIndex        =   22 
         Text            =   "1600" 
         Top             =   600 
         Width           =   735 
      End 
      Begin VB.TextBox Text_X  
         Height          =   375 
         Left            =   2880 
         TabIndex        =   21 
         Text            =   "1600" 
         Top             =   240 
         Width           =   735 
      End 
      Begin VB.TextBox Text_Angle  
         Height          =   375 
         Left            =   1200 
         TabIndex        =   20 
         Text            =   "360" 
         Top             =   1320 
         Width           =   735 
      End 
      Begin VB.TextBox Text_Time  
         Height          =   375 
         Left            =   1200 
         TabIndex        =   19 
         Text            =   "0.1" 
         Top             =   960 
         Width           =   735 
      End 
      Begin VB.TextBox Text_Speed  
         Height          =   375 
         Left            =   1200 
         TabIndex        =   18 
         Text            =   "6400" 
         Top             =   600 
         Width           =   735 
      End 
      Begin VB.TextBox Text_Start  
         Height          =   375 
         Left            =   1200 
         TabIndex        =   17 
         Text            =   "1600" 
         Top             =   240 
         Width           =   735 
      End 
      Begin VB.Label Label8  
         Caption         =   "U轴:" 
         Height          =   255 
         Left            =   2400 
         TabIndex        =   16 
         Top             =   1440 
         Width           =   1695 
      End 
      Begin VB.Label Label7  
         Caption         =   "Z轴:" 
         Height          =   255 
         Left            =   2400 
         TabIndex        =   15 
         Top             =   1080 
         Width           =   1575 
      End 
      Begin VB.Label Label6  
         Caption         =   "Y轴:" 
         Height          =   255 
         Left            =   2400 
         TabIndex        =   14 
         Top             =   720 
         Width           =   1335 
      End 
      Begin VB.Label Label5  
         Caption         =   "X轴:" 
         Height          =   255 
         Left            =   2400 
         TabIndex        =   13 
         Top             =   360 
         Width           =   615 
      End 
      Begin VB.Label Label4  
         Caption         =   "圆弧角度:" 
         Height          =   255 
         Left            =   240 
         TabIndex        =   12 
         Top             =   1440 
         Width           =   975 
      End 
      Begin VB.Label Label3  
         Caption         =   "变速时间:" 
         Height          =   255 
         Left            =   240 
         TabIndex        =   11 
         Top             =   1080 
         Width           =   1455 
      End 
      Begin VB.Label Label2  
         Caption         =   "驱动速度:" 
         Height          =   375 
         Left            =   240 
         TabIndex        =   10 
         Top             =   720 
         Width           =   1335 
      End 
      Begin VB.Label Label1  
         Caption         =   "起始速度:" 
         Height          =   255 
         Left            =   240 
         TabIndex        =   9 
         Top             =   360 
         Width           =   1095 
      End 
   End 
   Begin VB.Frame Frame2  
      Caption         =   "驱动轴" 
      Height          =   1335 
      Left            =   2160 
      TabIndex        =   1 
      Top             =   0 
      Width           =   2175 
      Begin VB.CheckBox Check_U  
         Caption         =   "U轴" 
         Height          =   255 
         Left            =   960 
         TabIndex        =   7 
         Top             =   720 
         Width           =   615 
      End 
      Begin VB.CheckBox Check_Z  
         Caption         =   "Z轴" 
         Height          =   255 
         Left            =   240 
         TabIndex        =   6 
         Top             =   720 
         Width           =   615 
      End 
      Begin VB.CheckBox Check_Y  
         Caption         =   "Y轴" 
         Height          =   180 
         Left            =   960 
         TabIndex        =   5 
         Top             =   360 
         Width           =   615 
      End 
      Begin VB.CheckBox Check_X  
         Caption         =   "X轴" 
         Height          =   255 
         Left            =   240 
         TabIndex        =   4 
         Top             =   360 
         Width           =   735 
      End 
   End 
   Begin VB.Frame Frame1  
      Caption         =   "插补路径" 
      Height          =   1335 
      Left            =   120 
      TabIndex        =   0 
      Top             =   0 
      Width           =   1935 
      Begin VB.OptionButton Option2  
         Caption         =   "圆弧插补" 
         Height          =   375 
         Left            =   360 
         TabIndex        =   3 
         Top             =   600 
         Width           =   1455 
      End 
      Begin VB.OptionButton Option_PATHST  
         Caption         =   "直线插补" 
         Height          =   375 
         Left            =   360 
         TabIndex        =   2 
         Top             =   240 
         Width           =   1215 
      End 
   End 
   Begin VB.Label Label_Position  
      Alignment       =   2  'Center 
      BorderStyle     =   1  'Fixed Single 
      Caption         =   "Label9" 
      Height          =   375 
      Left            =   120 
      TabIndex        =   25 
      Top             =   3360 
      Width           =   5295 
   End 
End 
Attribute VB_Name = "Main_Frame" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
'******************************************** 
'    雷赛DMC1000控制卡编程示例之四 
' 
'? -主要演示功能: 
'    1. 直线插补 
'    2. 圆弧插补 
' 
'!-关键函数: 
'    多轴直线函数 
'        d1000_start_tr_line_all     //相对 
'        d1000_start_ta_line_all     //绝对 
' 
'    任意两轴圆弧插补 
'        d1000_arc_move 
' 
'     矢量插补速度设定 
'        d1000_set_vector_profile 
' 
' 
'#-注意事项: 
'        圆弧插补division参数,即为圆弧插补的步长,其值越小圆弧的光滑度越好。 
'    但值不宜过小。 
' 
'    Writen by LEISAI-SUPPORT 
'    FAX: 0755 - 26402718 
'    TEL: 0755 - 26434329 
'EMAIL:     support@ LEISAI.com 
'HTTP:     www.LEISAI.com 
'******************************************** 
 
'定义四个轴的常量 
Const XCH As Integer = 0 
Const YCH As Integer = 1 
Const ZCH As Integer = 2 
Const UCH As Integer = 3 
 
 
 
Private Sub Form_Load() 
    If d1000_board_init() <= 0 Then '初始化控制卡 
        MsgBox "未找到控制卡!", vbOKOnly, "警告" 
    End If 
     
    Check_X.Value = Check_Y.Value = 1 
     
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)) + "," 
    Label_Position.Caption = Label_Position.Caption + Str(d1000_get_command_pos(YCH)) + "," 
    Label_Position.Caption = Label_Position.Caption + Str(d1000_get_command_pos(ZCH)) + "," 
    Label_Position.Caption = Label_Position.Caption + Str(d1000_get_command_pos(UCH)) 
     
     
End Sub 
 
Private Sub Command_Stop_Click() 
'停止驱动 
    If d1000_check_done(XCH) = 0 Or d1000_check_done(YCH) = 0 Or d1000_check_done(ZCH) = 0 Or d1000_check_done(UCH) = 0 Then          '在运行 
        d1000_decel_stop (XCH) 
        d1000_decel_stop (YCH) 
        d1000_decel_stop (ZCH) 
        d1000_decel_stop (UCH) 
    End If 
 
End Sub 
'自定义子函数 
Private Function GetAxisPosi%(ByRef AxisArray() As Integer, ByRef posiArray() As Long) 
    Dim n As Integer 
    n = 0 
    If Check_X = 1 Then 
        AxisArray(n) = XCH 
        posiArray(n) = Val(Text_X.Text) 
        n = n + 1 
    End If 
     
    If Check_Y Then 
        AxisArray(n) = YCH 
        posiArray(n) = Val(Text_Y.Text) 
        n = n + 1 
    End If 
     
    If Check_Z Then 
        AxisArray(n) = ZCH 
        posiArray(n) = Val(Text_Z.Text) 
        n = n + 1 
    End If 
     
    If Check_U Then 
        AxisArray(n) = UCH 
        posiArray(n) = Val(Text_U.Text) 
        n = n + 1 
    End If 
    GetAxisPosi% = n 
End Function 
 
Private Sub Command_Start_Click() 
 
    Dim nStart, nSpeed As Long 
    Dim fAccel, fAngle As Double 
 
    Dim AxisArray(4) As Integer 
    Dim posiArray(4) As Long 
    Dim axises As Integer 
     
    axises = GetAxisPosi(AxisArray, posiArray) 
    If axises < 2 Then 
        MsgBox "插补不能少于两个轴!", vbOKOnly, "提示" 
        Exit Sub 
    End If 
     
     
    nStart = Val(Text_Start.Text) 
    nSpeed = Val(Text_Speed.Text) 
    fAccel = Val(Text_Time.Text) 
    fAngle = Val(Text_Angle.Text) 
     
     
    If Option_PATHST = True Then 
            d1000_start_t_line axises, AxisArray(0), posiArray(0), nStart, nSpeed, fAccel 
    Else 
        If axises <> 2 Then 
            MsgBox "圆弧只能两轴插补!", vbOKOnly, "提示" 
            Exit Sub 
        End If 
        d1000_start_t_arc AxisArray(0), posiArray(0), posiArray(1), fAngle, nStart, nSpeed, fAccel 
    End If 
     
     
End Sub