About Sample program

The following programs are provided without charge, for use entirely at your own risk.

HIOKI disclaims any and all responsibility for any consequences arising out of use of this software.

Visual Basic and Visual Studio are registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and other countries.

MS, Microsoft, Windows, MS-DOS, are registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and other countries.

Procedure for creating a Program (Visual Basic2010 Express Edition)

This section describes an example of how to use the Windows development language Visual Basic2010 Express Edition to operate the IM3536 unit from a PC via RS-232C, incorporate measurement values, and save measurement values to a file. (When using RS-232C, the Z3001 RS-232C interface is additionally required.)

Visual Basic2010 is referred to as VB2010 hereafter.

Depending on the environment of the PC and VB2010, the procedure may differ slightly from the one described here. For a detailed explanation on how to use VB2010, refer to the instruction manual or Help of VB2010.
  1. Create a new project.

    1. Startup VB2010.

    2. Select [File] - [New Project] .

    3. Select [Windows Forms Application] from the templates.

    4. Click [OK].

  2. Place a button.

    1. Click [Button] from [Common Controls] of [Toolbox].

    2. Drag and drop the button onto the form layout screen.

    3. Change [Text] to "Start Measurement" from the Properties window.

    4. The [Start Measurement] is placed on the form.

  3. Place a serial communication component.

    1. Click [SerialPort] from [Components] of [Toolbox].

    2. Drag and drop the [SerialPort] component onto the form layout screen.

    3. Change [PortName] to the port name to use for communication from the properties window.

      Check the port to use for communication beforehand.

  4. Describe the code.

    1. Double-click the placed button to display the code editor.

    2. Enter the sample program into the code editor.

    3. Select [Save All] from the [File] menu.

    4. Confirm the save location and then click [Save].

  5. Set the interface of IM3536.

    Set the interface settings of IM3536 as shown below.

  6. Execute the program.

    This sample program operates as shown below.

    • If you press the [Start Measurement] button, you can set the measurement conditions of IM3536 via RS-232C communication.
    • Perform measurement 10 times and save the data to a file in CSV format. The file name is set automatically from the date and time.
    • When all measurements are competed normally, the "Measurement Finished" message appears.
    1. Click [Start Debugging].

    2. Click [Start Measurement].

    3. When measurement is finished, a message appears and the measurement values are saved in the \bin\Debug folder in which the project was saved.

Measurement Data Example

Z,Phase,Cp,Lp
  998.150E-03,  -0.001, 2.430312E-09,-10.42265E+00
  998.150E-03,  -0.006, 16.80788E-09,-1.507049E+00
  998.099E-03,  -0.002, 4.951606E-09,-5.115571E+00
  998.125E-03,  -0.002, 4.458802E-09,-5.680965E+00
  998.082E-03,  -0.004, 12.12213E-09,-2.089591E+00
  998.117E-03,  -0.002, 5.055860E-09,-5.010087E+00
  998.130E-03,  -0.003, 9.168967E-09,-2.762612E+00
  998.160E-03,  -0.002, 5.503513E-09,-4.602568E+00
  998.124E-03,  -0.002, 6.831358E-09,-3.707945E+00
  998.080E-03,  -0.001, 3.565134E-09,-7.105004E+00
			

Sample Programs

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Button1.Enabled = False                            ' Disables the button during measurement
        Try
            SerialPort1.NewLine = vbCrLf                   ' Sets the line feed code to CR+LF

            SerialPort1.Open()                             ' Opens serial communication port

            SerialPort1.WriteLine(":MODE LCR")             ' Mode: LCR
            SerialPort1.WriteLine(":MEAS:ITEM 149,0")      ' Measurement Parameter: Z,Phase,Cp,Lp
            SerialPort1.WriteLine(":HEAD OFF")             ' Header: OFF
            SerialPort1.WriteLine(":LEV V")                ' Signal level: Open-circuit voltage
            SerialPort1.WriteLine(":LEV:VOLT 0.5")         ' Signal level: 500 mV signal level
            SerialPort1.WriteLine(":FREQ 1E3")             ' Measurement frequency: 1kHz
            SerialPort1.WriteLine("TRIG EXT")              ' Trigger: External trigger

            Dim dt As DateTime = DateTime.Now              ' Acquires date and time
            Dim filename As String = dt.ToString("yyyy-MM-dd_HH-mm-ss") + ".csv"   ' Sets the file name
            Dim rd As String

            Dim fp As New System.IO.StreamWriter(filename, False, _
                System.Text.Encoding.GetEncoding("shift_jis"))  ' File open

            fp.Write("Z,Phase,Cp,Lp" + vbCrLf)                ' Outputs the header to file

            For index As Integer = 1 To 10                 ' Repeats measurement 10 times
                SerialPort1.WriteLine("*TRG;:MEAS?")       ' Reads trigger and measurement results
                rd = SerialPort1.ReadLine                  ' Acquires measurement results
                fp.Write(rd)                               ' Outputs the measurement results to file
                fp.Write(vbCrLf)                           ' Outputs the line feed to file
            Next

            fp.Close()                                     ' Closes file
            SerialPort1.Close()                            ' Closes serial communication port
            MsgBox("End of measuremen")                    ' Displays measurement finished messag
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
        Button1.Enabled = True                             ' Enables the button

    End Sub

End Class