EasyManua.ls Logo

Hioki RM3542 - ABS Mode Comparator Limits; Range Switching; Low-Power Function; Delay Settings

Hioki RM3542
218 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...
9.9 Sample Programs
162
Shown below is a sample program which uses VB2005 to enact RS-232C communication, set the
RM3542 measurement conditions, read measurement results and then save them to file. The sam-
ple program will be written in the following manner.
When the [ Begin Measurement ] is pressed, the RM3542 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 2005)
Creation Procedure (Visual Basic 2005) description Write using sample program
Button created to begin measurement Button1
Button created to close application Button2
Imports System
Imports System.IO
Imports System.IO.Ports
Public Class Form1
‘Perform process when Button1 is pressed
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim recvstr As String
Dim i As Integer
Try
Button1.Enabled = False 'Disable buttons during communication.................................................... (a)
Button2.Enabled = False
Dim sp As New SerialPort("COM1", 9600, Parity.None, 8, StopBits.One) 'Communication port setting ......... (b)
sp.NewLine = vbCrLf 'Terminator setting.....................................................................................(c)
sp.ReadTimeout = 2000 '2 second time out .................................................................................... (d)
sp.Open() 'Open port
SendSetting(sp) 'RM3542 settings
FileOpen(1, "data.csv", OpenMode.Output) 'Create text file to be saved ....................................................... (e)
For i = 1 To 10
sp.WriteLine("FETCH?") 'Begin measurement and read measurement results command............... (f)
recvstr = sp.ReadLine() 'Read measurement results
WriteLine(1, recvstr) 'Write to file
Next i
FileClose(1) 'Close file
sp.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
‘Close program when Button2 is pressed
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Dispose()
End Sub
End Class

Table of Contents

Other manuals for Hioki RM3542

Related product manuals