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

📄 daform.frm

📁 基于数据采集卡的测试程序
💻 FRM
字号:
VERSION 5.00
Begin VB.Form DaForm 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "D/A 测试界面"
   ClientHeight    =   4050
   ClientLeft      =   2895
   ClientTop       =   2160
   ClientWidth     =   4305
   BeginProperty Font 
      Name            =   "System"
      Size            =   12
      Charset         =   134
      Weight          =   700
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4050
   ScaleWidth      =   4305
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   100
      Left            =   2835
      Top             =   1215
   End
   Begin VB.Frame Frame2 
      Caption         =   "D/A输出量程"
      Height          =   975
      Left            =   120
      TabIndex        =   11
      Top             =   2880
      Width           =   3180
      Begin VB.OptionButton danc 
         Caption         =   " 0-10v"
         Height          =   375
         Index           =   1
         Left            =   1560
         TabIndex        =   13
         Top             =   360
         Value           =   -1  'True
         Width           =   1050
      End
      Begin VB.OptionButton danc 
         Caption         =   "0-5v"
         Height          =   375
         Index           =   0
         Left            =   240
         TabIndex        =   12
         Top             =   360
         Width           =   1050
      End
   End
   Begin VB.CommandButton Exit 
      Cancel          =   -1  'True
      Caption         =   "返    回"
      Default         =   -1  'True
      Height          =   495
      Left            =   2475
      TabIndex        =   10
      Top             =   1890
      Width           =   1215
   End
   Begin VB.CommandButton HelpCom 
      Caption         =   "操作帮助"
      Height          =   495
      Left            =   2430
      TabIndex        =   9
      Top             =   465
      Width           =   1215
   End
   Begin VB.Frame Frame1 
      Caption         =   "D/A 输出编辑区"
      Height          =   2775
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   2055
      Begin VB.TextBox Dadata 
         Height          =   375
         Index           =   3
         Left            =   960
         TabIndex        =   8
         Top             =   2160
         Width           =   975
      End
      Begin VB.TextBox Dadata 
         Height          =   375
         Index           =   2
         Left            =   960
         TabIndex        =   7
         Top             =   1620
         Width           =   975
      End
      Begin VB.TextBox Dadata 
         Height          =   375
         Index           =   1
         Left            =   960
         TabIndex        =   6
         Top             =   1040
         Width           =   975
      End
      Begin VB.TextBox Dadata 
         Height          =   375
         Index           =   0
         Left            =   960
         TabIndex        =   5
         Top             =   480
         Width           =   975
      End
      Begin VB.CommandButton DaCom 
         Caption         =   "CH4:"
         Height          =   375
         Index           =   3
         Left            =   120
         TabIndex        =   4
         Top             =   2160
         Width           =   855
      End
      Begin VB.CommandButton DaCom 
         Caption         =   "CH3:"
         Height          =   375
         Index           =   2
         Left            =   120
         TabIndex        =   3
         Top             =   1600
         Width           =   855
      End
      Begin VB.CommandButton DaCom 
         Caption         =   "CH2:"
         Height          =   375
         Index           =   1
         Left            =   120
         TabIndex        =   2
         Top             =   1040
         Width           =   855
      End
      Begin VB.CommandButton DaCom 
         Caption         =   "CH1:"
         Height          =   375
         Index           =   0
         Left            =   120
         TabIndex        =   1
         Top             =   480
         Width           =   855
      End
   End
End
Attribute VB_Name = "DaForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'dacs为DA转换参数
Dim dacs As Double
Dim danc1, danc2 As Long

'单个通道DA转换函数
Private Sub DaCom_Click(Index As Integer)
'     hplx = 0
 '   hplx = pci7483check(0, 0, False)
    data = (Val(Dadata(Index)) - danc2) * 255# / danc1
    i = Index
 If jldadata(Index) <> 255 And hplx <> 0 Then
 Call pci7483da(hplx, False, data, i)

'   hplx = pci7483close(hplx)
End If

End Sub
'DA数据输入判断函数
Public Function jldadata(ch As Integer) As Byte
'判断Dadata(ch)是否为空
 If Dadata(ch) = "" Then
   k = MsgBox("DA数据没有输入,请输入,范围在(" + Str(danc2) + "V/mA--" + Str(danc1 + danc2) + "V/mA)!", vbQuestion, "D/A数据输入")
   jldadata = 255
 Else
   d = Val(Dadata(ch))
  '判断port是否在正确范围内
  If d >= danc2 And d <= danc1 + danc2 Then
    jldadata = 1
  Else
    k = MsgBox("DA数据输入错误,请重新输入,范围在(" + Str(danc2) + "V/mA--" + Str(danc1 + danc2) + "V/mA)!", vbQuestion, "DA数据输入")
    jldadata = 255
  End If
 End If
End Function

Private Sub danc_Click(Index As Integer)
    
    Timer1.Enabled = True
    
End Sub

Private Sub Exit_Click()
   hplx = pci7483close(hplx)

 Unload DaForm
End Sub
'DA转换初始化函数
Private Sub Form_Load()
  hplx = 0
 hplx = pci7483check(0, 0, False, 1)

 '为DA转换参数dacs赋值
 danc1 = 10#
 danc2 = 0#
 
 For i = 0 To 3
    Dadata(i) = ""
 Next i
 
End Sub
'DA转换操作帮助函数
Private Sub HelpCom_Click()
    k = MsgBox("D/A数据输出转换步骤:" + Chr(13) + "1.在相应的文本输入框中输入十进制电压/电流值;" + Chr(13) + "2.点击所要转换通道编辑框前的通道按扭。", vbOKOnly + vbQuestion, "D/A输出操作帮助")
End Sub

Private Sub Timer1_Timer()
    
    If danc(0).Value = True Then
       danc1 = 5#
       danc2 = 0#
    End If
    
    If danc(1).Value = True Then
       danc1 = 10#
       danc2 = 0#
    End If
    
  End Sub

⌨️ 快捷键说明

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