EasyManua.ls Logo

Hioki BT3564 - 9.2 Basic Specifications

Hioki BT3564
210 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
8.8 Sample Programs
160
Shown below is a sample program which uses Visual Basic
®
2017 to enact RS-232C communication, set the
measurement conditions, read measurement results and then save them to file. The sample program will be
written in the following manner.
Button created to begin measurement .....................................................Start
Button created to close application ........................................................... Exit
When the [ Begin Measurement ] is pressed, takes 10 measurements and writes the measurement values to
a [ data.csv ] file.
When the [ Quit ] button is pressed the program closes.
The following program is written entirely in [ Form1 ] code.
Sample Programs (Visual Basic
®
2017)
Imports System
Imports System.IO
Imports System.IO.Ports
Public Class Form1
'Perform process when Button1 is pressed
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim recvstr As String
Dim i As Integer
Try
Button1.Enabled = False 'Disable buttons during communication......(a)
Button2.Enabled = False
'Communication port setting.......................(b)
SerialPort1.PortName = "COM1"
SerialPort1.BaudRate = 9600
SerialPort1.DataBits = 8
SerialPort1.Parity = Parity.None
SerialPort1.StopBits = StopBits.One
SerialPort1.NewLine = vbCrLf 'Terminator setting......................(c)
SerialPort1.ReadTimeout = 2000 '2 seconds time out.....................(d)
SerialPort1.Open() 'Open a port
SendSetting(SerialPort1) 'Instrument settings
FileOpen(1, "data.csv", OpenMode.Output) 'Create text file to be saved.........(e)
For i = 1 To 10
SerialPort1.WriteLine(":FETCH?") 'Begin measurement and read measurement results Command....(f)
recvstr = SerialPort1.ReadLine() 'Read measurement results
WriteLine(1, recvstr) 'Write to file
Next
FileClose(1) 'Close file
SerialPort1.Close() 'Close port
Button1.Enabled = True
Button2.Enabled = True
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
'Set measurement conditions
Private Sub SendSetting(ByVal sp As SerialPort)
Try
sp.WriteLine(":TRIG:SOUR IMM" 'Select internal triggering
sp.WriteLine(":INIT:CONT ON") 'Continuous measurement ON
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
HIOKI BT3564A961-02

Table of Contents

Related product manuals