
47
Measure by PC Key
Measures and imports by key input on the PC, and saves measurements in a text file.
Private Sub MeasureReadSubRS()
Dim recvstr As String
'Receiving character string
Dim i As Integer
MSComm1.CommPort = 1
'COM1 (Check a communication port)
MSComm1.Settings = "9600,n,8,1"
'Set a communication port (not required with USB)
MSComm1.PortOpen = True
'Open a port
Open App.Path & "¥data.csv" For Output As #1
'Open a text file for saving
MSComm1.Output = ":FUNC RV" & vbCrLf
'Select (R,X,V,T) measurement function
MSComm1.Output = ":MEAS:VAL 1" & vbCrLf
‘Output only the measurement value
MSComm1.Output = ":TRIG:SOUR IMM" & vbCrLf 'Select internal triggering
MSComm1.Output = ":INIT:CONT OFF" & vbCrLf
'Continuous measurement OFF
For i = 1 To 10
'Wait for PC key input
'Create a key input check routine to set InputKey() = True when a key is pressed
Do While 1
If InputKey() = True Then Exit Do
DoEvents
Loop
'After confirming key input, measure once, and read the measured value
MSComm1.Output = ":READ?" & vbCrLf
'Send “:READ?” to measure and import the measurement
recvstr = ""
'From here on, continue receiving until an LF code occurs
While Right(recvstr, 1) <> Chr(10)
recvstr = r MSComm1.Input
DoEvents
Wend
recvstr = Left(recvstr, Len(recvstr) - 2)
'Delete the terminator (CR+LF)
Print #1, Str(i) & "," & recvstr
'Write to the file
Next
Close #1
MSComm1.PortOpen = False
End Sub
Содержание BT4560
Страница 57: ...54 2 Enter the sample program into the code editor 3 Select Save All from the File menu Click...
Страница 60: ...57...
Страница 61: ...58...
Страница 62: ...59...