108
Sample Programs
RS-232C/USB communications (Using Visual Basic
®
Professional MS Comm)
Using the DM7276 to perform scan measurement
Connect the SW1001 and DM7276 to their respective COM ports and perform scan measurement
from CH1 to CH22 for
SLOT 1
.
The USB interface can be used to communicate with the device in the same manner as the
RS-232C interface. Check the COM number for the USB connection in the device properties and
use that number for communications. Communications speed has no meaning in the context of a
USB connection.
'Scan measurement sample
Private Sub ScanSample1()
Dim unit_no As Integer
Dim ch_no As Integer
Dim ch_str As String
Dim recv_str As String
MSComm1.CommPort = 3
'Connect the SW1001 to COM3.
MSComm1.Settings = "9600,n,8,1"
MSComm2.CommPort = 4
'Connect the DM7276 to COM4.
MSComm2.Settings = "9600,n,8,1"
MSComm1.PortOpen = True
MSComm2.PortOpen = True
Open App.Path & "\data.csv" For Output As #1
'Open a file for saving.
SendCommand MSComm1, ":SYST:MOD:WIRE:MODE 1,WIRE2"
'Configure SLOT1 as a 2-wire connection.
SendCommand MSComm1, "*OPC?"
'Wait for the operation to complete.
ReceiveCOM MSComm1
For unit_no = 1 To 1
For ch_no = 1 To 22
ch_str = Format(unit_no, "00") & Format(ch_no, "00")
'Create a string to specify the channel.
SendCommand MSComm1, ":CLOS " & ch_str
'Close the specified channel.
SendCommand MSComm1, "*OPC?"
'Wait for the closing of the channel to complete.
ReceiveCOM MSComm1
SendCommand MSComm2, ":READ?"
'Send the one-time measurement command to
the DM7276.
recv_str = ReceiveCOM(MSComm2)
'Receive the measured value.
Print #1, ch_str & "," & recv_str
'Write measurement data to a file.
Next
Next
SendCommand MSComm1, ":OPEN"
'Open all relays after the scan completes.
Close #1
MSComm1.PortOpen = False
MSComm2.PortOpen = False
End Sub
'Send to the specified COM port.
Private Sub SendCommand(comport As MSComm, cmdstr As String)
comport.InBufferCount = 0
comport.Output = vbCrLf
End Sub
'Receive from the specified COM port.
Private Function ReceiveCOM(comport As MSComm) As String
Dim recvstr As String
Do While Right(recvstr, 1) <> Chr(10)
recvstr = comport.Input
DoEvents
Loop
ReceiveCOM = Left(recvstr, Len(recvstr) - 2)
End Function
HIOKI SW1001A961-04
Содержание SW9001
Страница 2: ...HIOKI SW1001A961 04...
Страница 42: ...38 Channel Delay Function HIOKI SW1001A961 04...
Страница 48: ...44 Scan Measurement Example HIOKI SW1001A961 04...
Страница 50: ...46 Checking the Device Status HIOKI SW1001A961 04...
Страница 52: ...48 Initialization Settings HIOKI SW1001A961 04...
Страница 118: ...114 Sample Programs 3 Select FILE Save All HIOKI SW1001A961 04...
Страница 160: ...156 Outline Drawings 12 4 Outline Drawings SW1001 Unit mm Tolerance 0 2 HIOKI SW1001A961 04...
Страница 161: ...157 Outline Drawings SW1002 Unit mm Tolerance 0 2 12 Appendix HIOKI SW1001A961 04...
Страница 162: ...158 Outline Drawings HIOKI SW1001A961 04...
Страница 164: ...160 HIOKI SW1001A961 04...
Страница 167: ...HIOKI SW1001A961 04...
Страница 168: ...HIOKI SW1001A961 04...
Страница 169: ...HIOKI SW1001A961 04...