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

📄 frmcomm.frm

📁 Tektronix TDS3000&TDS3000B series oscilloscope program examples ver3.0
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form frmComm 
   Caption         =   "Comm"
   ClientHeight    =   4305
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5805
   LinkTopic       =   "Form1"
   ScaleHeight     =   4305
   ScaleWidth      =   5805
   StartUpPosition =   3  'Windows Default
   Begin VB.Frame Frame1 
      Caption         =   "Comm Port"
      Height          =   732
      Left            =   1320
      TabIndex        =   7
      Top             =   2160
      Width           =   3252
      Begin VB.OptionButton CommPort 
         Caption         =   "COM2"
         Height          =   372
         Index           =   1
         Left            =   1680
         TabIndex        =   9
         Top             =   240
         Width           =   1212
      End
      Begin VB.OptionButton CommPort 
         Caption         =   "COM1"
         Height          =   372
         Index           =   0
         Left            =   240
         TabIndex        =   8
         Top             =   240
         Width           =   1092
      End
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   360
      Top             =   3600
      _ExtentX        =   794
      _ExtentY        =   794
      _Version        =   393216
      DTREnable       =   -1  'True
      RThreshold      =   1
   End
   Begin VB.Timer Timer1 
      Left            =   480
      Top             =   3000
   End
   Begin VB.CommandButton cmdDone 
      Caption         =   "Done"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   3240
      TabIndex        =   1
      Top             =   3120
      Width           =   1575
   End
   Begin VB.CommandButton cmdStart 
      Caption         =   "Start"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1200
      TabIndex        =   0
      Top             =   3120
      Width           =   1575
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Caption         =   "VOLTS/DIV AND SEC/DIV OUTPUT"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   252
      Left            =   0
      TabIndex        =   6
      Top             =   120
      Width           =   5772
   End
   Begin VB.Label lblOutputSec 
      Height          =   372
      Left            =   3000
      TabIndex        =   5
      Top             =   1440
      Width           =   2172
   End
   Begin VB.Label lblOutputVolt 
      Height          =   372
      Left            =   3000
      TabIndex        =   4
      Top             =   720
      Width           =   2172
   End
   Begin VB.Label lblStringSec 
      Height          =   372
      Left            =   240
      TabIndex        =   3
      Top             =   1440
      Width           =   2172
   End
   Begin VB.Label lblStringVolt 
      Height          =   372
      Left            =   240
      TabIndex        =   2
      Top             =   720
      Width           =   2172
   End
End
Attribute VB_Name = "frmComm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'
'  comm.bas - program to show communication between the controller and the
'  oscilloscope
'
'  Version: 1.0.
'

Dim SerialPortNumber As Integer    ' 1 = COMM1
                                   ' 2 = COMM2 (The default value.
                                   
Private Sub Form_Load()
    ' Set the COMM port to COMM2.
    SerialPortNumber = 2
    CommPort(1).Value = True
End Sub

Private Sub cmdStart_Click()


' Disable the "Start" button until the task is done.
    cmdStart.Enabled = False

' Note:
'   The Scope is assumed to be on COMM2.
'   Set the port number and then open the port for communications.
'
    MSComm1.CommPort = SerialPortNumber
    MSComm1.PortOpen = True

'   Set the Comm control to generate events after each character received.
    MSComm1.RThreshold = 1

'
'  Clear any existing menus, run the factory initialization, then lock out
'  the front panel so there are no changes made to settings.
'
    Call RS232WRITE(MSComm1, "CLEARMENU")
    Call RS232WRITE(MSComm1, "FACTORY")
    Call RS232WRITE(MSComm1, "LOCK ALL")
    
' Print a message on the screen instructing the user to connect
' Channel 1 to the front-panel PROBE COMPENSATION SIGNAL.
'
    
    MSG = " Connect the PROBE COMPENSATION SIGNAL to channel 1" ' Define message.
    Style = vbOKOnly + vbInformation                            ' Define buttons.
    Title = "Probe Connection"                                  ' Define title.
    RESPONSE = MsgBox(MSG, Style, Title)

'
'
'  Wait for the scope to finish the factory command.
'
   Call RS232WAITCOM(MSComm1, 12)
'
'
'  Turn off the header from query responses.
'
    Call RS232WRITE(MSComm1, "HEADER 0")
'
'
'  Send the autoset command to display the calibrator signal.
'
    Call RS232WRITE(MSComm1, "AUTOSET EXECUTE")
    MSG = "An autoset of the Channel 1 waveform is now being performed" 'Define message.
    Title = "AUTOSET"                                                   'Define title
    RESPONSE = MsgBox(MSG, Style, Title)
    
    
'
'
'  Query the oscilloscope for its selected VOLTS/DIV setting and TIME/DIV
'  setting.
'
    Call RS232WRITE(MSComm1, "CH1:SCALE?")
    VOLTS$ = Space$(15)
    Call RS232Read(MSComm1, VOLTS$)
    Call RS232WRITE(MSComm1, "HORIZONTAL:MAIN:SCALE?")
    SEC$ = Space$(15)
    Call RS232Read(MSComm1, SEC$)
    
    frmComm.lblStringVolt.Caption = "The VOLTS/DIV setting is"
    frmComm.lblStringSec.Caption = "The  SEC/DIV  setting is"
    frmComm.lblOutputVolt.Caption = VOLTS$
    frmComm.lblOutputSec.Caption = SEC$
    
'
' Close the comm port.
'
    MSComm1.PortOpen = False

    cmdStart.Enabled = True
End Sub

Private Sub CommPort_Click(Index As Integer)
    If Index = 0 Then
        SerialPortNumber = 1
    Else
        SerialPortNumber = 2
    End If
End Sub

'
'  if an I/O occurred stop the program.
'

Private Sub Timer1_Timer()
    Call MsgBox("A Timeout has occurred.")
    Stop
End Sub
                           

Private Sub cmdDone_Click()
    End
End Sub

⌨️ 快捷键说明

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