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

📄 dio_form.frm

📁 采样窑炉温度
💻 FRM
字号:
VERSION 5.00
Begin VB.Form DIO_Form 
   Caption         =   "开关量控制窗口"
   ClientHeight    =   4620
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   5985
   LinkTopic       =   "Form1"
   ScaleHeight     =   4620
   ScaleWidth      =   5985
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox DI_Txt 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   4440
      TabIndex        =   13
      Text            =   "  500"
      Top             =   2040
      Width           =   1095
   End
   Begin VB.Timer DI_Timer 
      Enabled         =   0   'False
      Left            =   1800
      Top             =   4440
   End
   Begin VB.CommandButton stop_Command 
      Caption         =   "停止"
      Height          =   495
      Left            =   600
      TabIndex        =   8
      Top             =   2880
      Width           =   1095
   End
   Begin VB.CommandButton Exit_Command 
      Caption         =   "退出"
      Height          =   495
      Left            =   600
      TabIndex        =   7
      Top             =   3600
      Width           =   1095
   End
   Begin VB.CommandButton start_Command 
      Caption         =   "开始"
      Height          =   495
      Left            =   600
      TabIndex        =   6
      Top             =   2160
      Width           =   1095
   End
   Begin VB.TextBox interval1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1800
      TabIndex        =   1
      Text            =   "  "
      Top             =   1440
      Width           =   975
   End
   Begin VB.TextBox interval2 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1800
      TabIndex        =   0
      Text            =   "   2"
      Top             =   600
      Width           =   975
   End
   Begin VB.Timer Timer2 
      Left            =   1080
      Top             =   4440
   End
   Begin VB.Timer Timer1 
      Left            =   480
      Top             =   4440
   End
   Begin VB.Label DO_show 
      Alignment       =   2  'Center
      BackColor       =   &H80000010&
      Height          =   375
      Index           =   1
      Left            =   6960
      TabIndex        =   21
      Top             =   600
      Width           =   1095
   End
   Begin VB.Label Label7 
      Caption         =   "2通道输出状态显示"
      Height          =   495
      Index           =   2
      Left            =   6000
      TabIndex        =   20
      Top             =   600
      Width           =   975
   End
   Begin VB.Label Label9 
      Caption         =   "1通道输入脉冲数"
      Height          =   495
      Left            =   3480
      TabIndex        =   19
      Top             =   3360
      Width           =   855
   End
   Begin VB.Label Pulse_Show 
      BorderStyle     =   1  'Fixed Single
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   4440
      TabIndex        =   18
      Top             =   3360
      Width           =   1095
   End
   Begin VB.Label Label7 
      Caption         =   "1通道输出状态显示"
      Height          =   495
      Index           =   1
      Left            =   3480
      TabIndex        =   17
      Top             =   600
      Width           =   975
   End
   Begin VB.Label Label7 
      Caption         =   "输入开关状态显示"
      Height          =   495
      Index           =   0
      Left            =   3480
      TabIndex        =   16
      Top             =   2760
      Width           =   855
   End
   Begin VB.Label DI_Show 
      BackColor       =   &H80000010&
      Height          =   375
      Left            =   4440
      TabIndex        =   15
      Top             =   2760
      Width           =   1095
   End
   Begin VB.Label Label6 
      Caption         =   "ms"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   5760
      TabIndex        =   14
      Top             =   2160
      Width           =   495
   End
   Begin VB.Label Label5 
      Caption         =   "输入开关量的采用周期"
      Height          =   375
      Left            =   3480
      TabIndex        =   12
      Top             =   2040
      Width           =   975
   End
   Begin VB.Label DO_show 
      Alignment       =   2  'Center
      BackColor       =   &H80000010&
      Height          =   375
      Index           =   0
      Left            =   4440
      TabIndex        =   11
      Top             =   600
      Width           =   1095
   End
   Begin VB.Label Label4 
      Caption         =   "开关量占空比"
      Height          =   495
      Left            =   3480
      TabIndex        =   10
      Top             =   1320
      Width           =   855
   End
   Begin VB.Label DOshow 
      BorderStyle     =   1  'Fixed Single
      Caption         =   "  "
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4440
      TabIndex        =   9
      Top             =   1320
      Width           =   1095
   End
   Begin VB.Label Label3 
      Caption         =   " S"
      Height          =   495
      Index           =   1
      Left            =   2880
      TabIndex        =   5
      Top             =   1560
      Width           =   375
   End
   Begin VB.Label Label3 
      Caption         =   " S"
      Height          =   495
      Index           =   0
      Left            =   2880
      TabIndex        =   4
      Top             =   720
      Width           =   375
   End
   Begin VB.Label Label2 
      Caption         =   "输出开关量为开时周期"
      Height          =   495
      Left            =   600
      TabIndex        =   3
      Top             =   1440
      Width           =   1215
   End
   Begin VB.Label Label1 
      Caption         =   "输入开关量工作周期"
      Height          =   495
      Left            =   600
      TabIndex        =   2
      Top             =   600
      Width           =   1215
   End
End
Attribute VB_Name = "DIO_Form"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim hDevice As Long
Dim Para_DI As USB2013_PARA_DI
Dim Para_DO As USB2013_PARA_DO
Dim bStatus As Boolean
Dim bStatus_Front As Integer, bStatus_Present As Integer
Dim zkb As Single                                         '占空比
Dim Stop_time As Single, Start_time As Single

Private Sub DI_Timer_Timer()
bStatus = USB2013_GetDeviceDI(hDevice, Para_DI)
bStatus_Present = Para_DI.DI0
'MsgBox (Para_DI.DI0)
If bStatus_Front <> bStatus_Present Then
   Pulse_Count = Pulse_Count + 1
   Pulse_Show.Caption = Pulse_Count
 End If
If bStatus_Present = 1 Then
   DI_Show.Caption = "开关0[开]"
   DI_Show.BackColor = RGB(255, 100, 0)
Else
   DI_Show.Caption = "开关0[关]"
   DI_Show.BackColor = RGB(192, 192, 192)
 End If
bStatus_Front = bStatus_Present
End Sub

Private Sub DI_Txt_Change()
DI_Timer.Interval = Val(DI_Txt.Text)
End Sub

Private Sub Exit_Command_Click()
Dim bStatus As Boolean
 Para_DO.DO0 = 0
 bStatus = USB2013_SetDeviceDO(hDevice, Para_DO)
 bStatus = USB2013_ReleaseDevice(hDevice)
 AD_Form.DIO_command.Enabled = Not AD_Form.DIO_command.Enabled
 Unload Me
End Sub

Private Sub Form_Load()
    Dim bStatus As Boolean
    Dim s As Long
    hDevice = USB2013_CreateDevice(0)
    If (hDevice = INVALID_HANDLE_VALUE) Then
       MsgBox "创建设备对象失败...", 0, "error"
        Exit Sub
    End If
    '开关量输出接口
    Para_DO.DO0 = 0
    Para_DO.DO1 = 0
    Para_DO.DO2 = 0
    Para_DO.DO3 = 0
    Para_DO.DO4 = 0
    Para_DO.DO5 = 0
    Para_DO.DO6 = 0
    Para_DO.DO7 = 0
    Para_DO.DO8 = 0
    Para_DO.DO9 = 0
    Para_DO.DO10 = 0
    Para_DO.DO11 = 0
    Para_DO.DO12 = 0
    Para_DO.DO13 = 0
    Para_DO.DO14 = 0
    Para_DO.DO15 = 0
    
End Sub

Private Sub start_Command_Click()
Para_DO.DO0 = 0
Para_DO.DO1 = 0
Timer1.Enabled = True
Timer2.Enabled = False
DI_Timer.Enabled = True
DI_Timer.Interval = Val(DI_Txt.Text)
DOshow.Enabled = True
DOshow.Caption = "  "
Timer1.Interval = 20
start_Command.Enabled = Not start_Command.Enabled
stop_Command.Enabled = True
Pulse_Show.Caption = " "
bStatus_Front = 0
bStatus_Present = 0
Pulse_Count = 0
End Sub

Private Sub stop_Command_Click()
 Dim bStatus As Boolean
 Para_DO.DO0 = 0
 Para_DO.DO1 = 0
 bStatus = USB2013_SetDeviceDO(hDevice, Para_DO)
 Timer1.Interval = 0
 Timer2.Interval = 0
 DI_Timer.Interval = 0
 Timer1.Enabled = False
 Timer2.Enabled = False
 DI_Timer.Enabled = False
 DOshow.Enabled = False
 'AD_Form.Show
stop_Command.Enabled = Not stop_Command.Enabled
start_Command.Enabled = True
End Sub

Private Sub Timer1_Timer()                                               '开关量为开时的时间控制
 Dim bStatus As Boolean
 'MsgBox (Timer1.interval)
 Start_time = Val(interval1.Text) * 1000
  If Start_time = 0 Then
   Timer2.Interval = 2
Else
   Timer2.Interval = Start_time
   End If
   Timer1.Enabled = False
    Timer2.Enabled = True
      'MsgBox (Timer2.Interval)
 If (Para_DO.DO0) = 1 Then
        DO_show(0).Caption = "开关0[关]"
       DO_show(0).BackColor = RGB(192, 192, 192)
        Para_DO.DO0 = 0
    Else
        DO_show(0).Caption = "开关0[开]"
        DO_show(0).BackColor = RGB(255, 100, 0)
        Para_DO.DO0 = 1
    End If
  If (Para_DO.DO1) = 1 Then
        DO_show(1).Caption = "开关0[关]"
       DO_show(1).BackColor = RGB(192, 192, 192)
        Para_DO.DO1 = 0
    Else
        DO_show(1).Caption = "开关0[开]"
        DO_show(1).BackColor = RGB(255, 100, 0)
        Para_DO.DO1 = 1
    End If
    bStatus = USB2013_SetDeviceDO(hDevice, Para_DO)
    'bStatus = USB2013_GetDeviceDI(hDevice, Para_DI)
    zkb = Format(Val(interval1.Text) * 100 / Val(interval2.Text), "0.00")
    DOshow.Caption = zkb & "%"
End Sub

Private Sub Timer2_Timer()                                              '开关量关时的时间控制
 Dim bStatus As Boolean
   Timer2.Enabled = False
   Stop_time = (Val(interval2.Text) - Val(interval1.Text)) * 1000
 If Stop_time = 0 Then
   Timer1.Interval = 2
 Else
   Timer1.Interval = Stop_time
    End If
   Timer1.Enabled = True
 If (Para_DO.DO0) = 1 Then
        DO_show(0).Caption = "开关0[关]"
       DO_show(0).BackColor = RGB(192, 192, 192)
        Para_DO.DO0 = 0
    Else
        DO_show(0).Caption = "开关0[开]"
        DO_show(0).BackColor = RGB(255, 100, 0)
        Para_DO.DO0 = 1
    End If
If (Para_DO.DO1) = 1 Then
        DO_show(1).Caption = "开关0[关]"
       DO_show(1).BackColor = RGB(192, 192, 192)
        Para_DO.DO1 = 0
    Else
        DO_show(1).Caption = "开关0[开]"
        DO_show(1).BackColor = RGB(255, 100, 0)
        Para_DO.DO1 = 1
    End If
    bStatus = USB2013_SetDeviceDO(hDevice, Para_DO)
    zkb = Format(Val(interval1.Text) * 100 / Val(interval2.Text), "0.00")
    DOshow.Caption = zkb & "%"
End Sub

⌨️ 快捷键说明

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