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

📄 ao.frm

📁 VB开发 利用DAQAO控件实现板卡模拟量输出
💻 FRM
字号:
VERSION 5.00
Object = "{0970DD26-8809-11D2-A9B8-002018650913}#1.1#0"; "adaout.ocx"
Begin VB.Form DAQForm 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "模拟量输出"
   ClientHeight    =   4635
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6705
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4635
   ScaleWidth      =   6705
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Cmdout 
      Caption         =   "连续输出"
      Height          =   465
      Left            =   1710
      TabIndex        =   5
      Top             =   4005
      Width           =   1230
   End
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   1000
      Left            =   5490
      Top             =   4095
   End
   Begin VB.TextBox Tdata 
      Alignment       =   2  'Center
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   435
      Left            =   2520
      TabIndex        =   4
      Top             =   90
      Width           =   915
   End
   Begin VB.VScrollBar VScroll1 
      Height          =   3165
      Left            =   6210
      Max             =   0
      Min             =   10
      TabIndex        =   3
      Top             =   630
      Width           =   420
   End
   Begin DAQAOLib.DAQAO DAQAO1 
      Height          =   495
      Left            =   6075
      TabIndex        =   2
      Top             =   4005
      Width           =   495
      _Version        =   65537
      _ExtentX        =   864
      _ExtentY        =   864
      _StockProps     =   0
   End
   Begin VB.PictureBox Picture1 
      BackColor       =   &H00FFFFFF&
      ForeColor       =   &H00000000&
      Height          =   3150
      Left            =   45
      ScaleHeight     =   3090
      ScaleWidth      =   6030
      TabIndex        =   1
      Top             =   630
      Width           =   6090
   End
   Begin VB.CommandButton Cmdquit 
      Caption         =   "关闭程序"
      Height          =   465
      Left            =   3780
      TabIndex        =   0
      Top             =   4005
      Width           =   1230
   End
End
Attribute VB_Name = "DAQForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'定义变量
Dim num As Integer                             '采集的数据个数
Dim Data(1000) As Integer                      '采样电压数据的数值形式
Dim middata As Integer
Dim midnum As Integer
'程序初始化
Private Sub Form_Load()
  DAQAO1.SelectDevice                          '选择模拟量输出设备
  DAQAO1.Channel = 0                           '输出的通道号
  DAQAO1.OutputRate = 500                      '输出频率
  DAQAO1.DataType = adReal                     '模拟量输出数值类型(实型)
  DAQAO1.OutputType = adVoltage                '模拟量输出类型(电压)
  DAQAO1.NumberOfOutputs = 200                 '输出数据的个数
End Sub
'间断产生变化的数值(范围:0∽10)
Private Sub VScroll1_Change()
  If num > 199 Then Call renew
  Timer1.Enabled = False
  DAQAO1.OpenDevice                            '打开模拟量输出设备
  DAQAO1.RealOutput Val(VScroll1.Value)
  Data(num) = Val(VScroll1.Value)
  Tdata.Text = VScroll1.Value
  num = num + 1
  Call draw
End Sub
Private Sub Cmdout_Click()
  Call renew
  Timer1.Enabled = True
End Sub
'连续循环产生变化的数值(范围:0∽10)
Private Sub Timer1_Timer()
  If num > 199 Then Call renew
  If midnum = 0 Then
    middata = middata + 1
    Data(num) = middata
  End If
  If middata = 11 Then
    midnum = 1
  End If
  If midnum = 1 Then
    middata = middata - 1
    Data(num) = middata
  End If
  If middata = 0 Then
    midnum = 0
  End If
  DAQAO1.OpenDevice                            '打开模拟量输出设备
  DAQAO1.RealOutput Data(num)
  Tdata.Text = Str$(Data(num))
  num = num + 1
  Call draw
End Sub
'画曲线
Sub draw()
  Picture1.Cls
  Picture1.DrawWidth = 2
  Picture1.BackColor = QBColor(15)
  Picture1.Scale (0, 10)-(200, 0)
  For i = 1 To num - 1
    X1 = (i - 1): Y1 = Data(i - 1)
    X2 = i: Y2 = Data(i)
    Picture1.Line (X1, Y1)-(X2, Y2), QBColor(0)
  Next i
End Sub
'刷新
Private Sub renew()
  Picture1.Cls
  For i = 0 To num - 1
    Data(i) = 0
  Next i
  num = 0
End Sub
'关闭程序
Private Sub Cmdquit_Click()
  DAQAO1.CloseDevice                          '关闭板卡模拟量输出端口
  Unload Me
End Sub

⌨️ 快捷键说明

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