7352 Series Digital Multimeter Operation Manual
6.7.3 Sample Programs (RS-232)
6-60
6.7.3
Sample Programs (RS-232)
This section describes example programs in which a computer controls this instrument through an RS-232
interface.
Computer:
DELL OPTIPLEX 170L(Pentium
4 CPU 2.80GHz)
Control used:
Microsoft Communications Control (RS-232 control)
Language:
Microsoft Excel Visual Basic for Application
Example 1 Sets the 2W
resistance measurement 20 k
range for the left side display, detects the mea-
surement end by the measurement event resister, reads the measured data from the 7352A, and
then displays the data in cells.
Private Sub Com_RS232_Sample1_Click
'Sample 1
Dim dt As String * 20
'Declares the variable of the buffer used for receiving the RS-232
data.
Dim stb As String
'Declares the variable of the buffer used for receiving the status byte.
Dim sts As Integer
'Declares the variable of the status byte after numerical conversion.
With UserForm1
With .MSComm1
.CommPort = 1
'Uses COM1.
.Settings = "9600,N,8,1"
'9600 bps, Non parity, Data length: 8 bits, and Number of stop bits: 1
.InputLen = 0
'Reads all of the buffers when the Input property is used.
.PortOpen = True
'Opens the port.
.InBufferCount = 0
'Clears the receiving buffer.
.DTREnable = True
'Enables DTR.
dt = Space(20)
'Initializes the buffer for receiving data
.Output = "*RST" & vbLf
'Initializes the 7352A.
Call rx_prompt
'Receives a prompt.
.Output = "H0,F3,R5,PR2,TRS3,DE0" & vbLf
'Sets the header of the output data to OFF.
'Sets the measurement function for the left side display to 2W
.
'Sets the measurement range for the left side display to 20 k
.
'Sets the sampling rate to MED.
'Sets the trigger source to "BUS".
'Sets the right side display to OFF.
Call rx_prompt
'Receives a prompt.
.Output = "*TRG" & vbLf
'Triggers.
Call rx_prompt
'Receives a prompt.
Do
.Output = "MSR?" & vbLf
'Sends the command for reading the measurement event register.
Call rx_data(stb, 5)
'Reads the measurement event register (5 characters) and stores them
'in stb.
sts = Val(stb) And 256
'Converts the 5 characters, which are stored in 'stb, to a numerical
value and stores the value in sts.
Loop While (sts <> 256)
'Repeats until EOM is set.
.Output = "MD?" & vbLf
'Sends the command for reading the measured data.
Call rx_data(dt, 14)
'Reads the measured data (14 characters) and stores them in dt$.
Cells(1, 1) = "'" & Left(dt, 12)
'Displays the measured data in cells.