Chapter3.txt Driver File Contents (ApplicationDiskRev20.zip)

Chapter 3 Example ProgramsChapter 3 Example Programs

Visual Basic Example Progarams

RS-232C example programs

Example 1 Using setting command

Private Sub Sample1_Click()
'*******************************************************************************
' RS232C SAMPLE PROGRAM NO.1
' Send the command in the format specified, when the conditions for the
' command to be acceptable are met.
'*******************************************************************************

deli$ = Chr$(13) & Chr$(10)

MSComm1.PortOpen = True

MSComm1.Output = ":FUNCTION MEM" & deli$
MSComm1.Output = ":CONFIGURE:TDIV 1.E-3" & deli$
MSComm1.Output = ":CONFIGURE:SHOT 30" & deli$

MSComm1.Output = ":TRIGGER:SOURCE OR" & deli$
MSComm1.Output = ":TRIGGER:KIND CH1,LEVEL" & deli$
MSComm1.Output = ":TRIGGER:PRETRIG 5" & deli$
MSComm1.Output = ":TRIGGER:LEVEL CH1,0" & deli$
MSComm1.Output = ":TRIGGER:SLOPE CH1,UP" & deli$
MSComm1.Output = ":TRIGGER:KIND CH2,OFF" & deli$
MSComm1.Output = ":TRIGGER:KIND CH3,OFF" & deli$
MSComm1.Output = ":TRIGGER:KIND CH4,OFF" & deli$
MSComm1.Output = ":TRIGGER:KIND CH5,OFF" & deli$
MSComm1.Output = ":TRIGGER:KIND CH6,OFF" & deli$
MSComm1.Output = ":TRIGGER:KIND CH7,OFF" & deli$
MSComm1.Output = ":TRIGGER:KIND CH8,OFF" & deli$

MSComm1.Output = ":START" & deli$

MSComm1.PortOpen = False

End Sub


Example 2 Using a query

Private Sub Sample2_Click()
'*******************************************************************************
' RS232C SAMPLE PROGRAM NO.2
'
' Send the query in the format specified, when the conditions for the query to
' be acceptable are met.
'
' The response data from the query is returned in the format specified for the
' corresponding command.
'*******************************************************************************

deli$ = Chr$(13) & Chr$(10)

MSComm1.PortOpen = True

MSComm1.Output = ":HEADER OFF" & deli$
MSComm1.Output = ":FUNCTION?" & deli$
Do
	ans$ = ans$ & MSComm1.Input
Loop Until InStr(1, ans$, Chr$(10))

MSComm1.Output = ":SYSTEM:TIME?" & deli$
Do
	tm$ = tm$ & MSComm1.Input
Loop Until InStr(1, tm$, Chr$(10))

Text1.Text = "FUNCTION = " & ans$
Text1.Text = Text1.Text & "TIME = " & tm$

MSComm1.PortOpen = False

End Sub


Example 3 Outputting stored data

Private Sub Sample3_Click()
'*******************************************************************************
' RS232C SAMPLE PROGRAM NO.3
'
' Using the :MEMORY:MAXPOINT? query, this progaram checks whether data
' can be output from memory. If this query returns zero, no data is stored, and
' it cannot therefore be output.
'
' Next, the progaram specifies the channel and point for output, using the
' :MEMORY:POINT command. As data is input or output, the point is
' incremented automatically. If capturing data cosecutively, it is sufficient to
' specify the point once only.
'
' To capture data is ASCII format use the :MEMORY:ADATA? query, and to
' capture data as volatage values use the :MEMPRY:VDATA? query. The
' number of data samples which may be output in one set is 1 to 80 using
' :ADATA? and 1 to 80 using the :VDATA? query.
'*******************************************************************************

deli$ = Chr$(13) & Chr$(10)
Dim d(1000) As Double

MSComm1.PortOpen = True

MSComm1.Output = ":FUNCTION MEM" & deli$
MSComm1.Output = ":CONFIGURE:SHOT 10" & deli$
MSComm1.Output = ":TRIGGER:MODE SINGLE" & deli$
MSComm1.Output = ":START;*OPC;:STOP;*OPC?" & deli$
Do
    o$ = o$ & MSComm1.Input
Loop Until InStr(1, o$, Chr$(10))

MSComm1.Output = ":HEADER OFF" & deli$
MSComm1.Output = ":MEMORY:MAXPOINT?" & deli$
Do
    mx$ = mx$ & MSComm1.Input
Loop Until InStr(1, mx$, Chr$(10))
If (Val(mx$) = 0) Then
    MSComm1.PortOpen = False
    Exit Sub
End If

MSComm1.Output = ":MEMORY:POINT CH1,0" & deli$
For i = 1 To 1000
    vd$ = ""
    MSComm1.Output = ":MEMORY:VDATA? 1" & deli$
    Do
        vd$ = vd$ & MSComm1.Input
    Loop Until InStr(1, vd$, Chr$(10))
    d(i) = Val(vd$)
Next

For i = 1 To 1000
    Text1.SelText = Format(d(i), "Scientific") & deli$
Next

MSComm1.PortOpen = False

End Sub


Example 4 Inputting storage data

Private Sub Sample4_Click()
'*******************************************************************************
' RS232C SAMPLE PROGRAM NO.4
'
' This progaram prepares storage memory, using the :MEMORY:PREPARE command.
'
' Next, the program specifies the channel and point for input, using the
' :MEMORY:POINT command, and then uses the :MEMORY:ADATA command to input data.
'*******************************************************************************

deli$ = Chr$(13) & Chr$(10)

MSComm1.PortOpen = True

MSComm1.Output = ":FUNCTION MEM" & deli$
MSComm1.Output = ":CONFIGURE:SHOT 10" & deli$
MSComm1.Output = ":MEMORY:PREPARE;*OPC?" & deli$
Do
	o$ = MSComm1.Input
Loop Until InStr(1, o$, Chr$(10))
MSComm1.Output = ":MEMORY:POINT CH1,0" & deli$

For i = 0 To 1000
	MSComm1.Output = ":MEMORY:ADATA " & Str$(Int(1600 * Sin(3.14 * i / 500))) & deli$
Next

MSComm1.PortOpen = False

End Sub


Example 5 Checking the presence of input unit, and displaying the input ranges 
on the screnn.

Private Sub Sample5_Click()
'*******************************************************************************
' RS232C SAMPLE PROGRAM NO.5
'*******************************************************************************

deli$ = Chr$(13) & Chr$(10)

MSComm1.PortOpen = True

MSComm1.Output = ":HEADER OFF" & deli$
MSComm1.Output = "*OPT?" & deli$
Do
	op$ = op$ & MSComm1.Input
Loop Until InStr(1, op$, Chr$(10))
ch1% = Val(Mid$(op$, 1, 1))
ch2% = Val(Mid$(op$, 3, 1))
ch3% = Val(Mid$(op$, 5, 1))
ch4% = Val(Mid$(op$, 7, 1))

MSComm1.Output = ":MEMORY:GETREAL" & deli$
If (ch1% <> 0) Then
	MSComm1.Output = ":MEMORY:AREAL? CH1" & deli$
	ar$ = ""
	Do
		ar$ = ar$ & MSComm1.Input
	Loop Until InStr(1, ar$, Chr$(10))
	ch1_data$ = "CH1 = " & ar$
Else
	ch1_data$ = "CH1 = NON"
End If

If (ch2% <> 0) Then
	MSComm1.Output = ":MEMORY:AREAL? CH2" & deli$
	ar$ = ""
	Do
		ar$ = ar$ & MSComm1.Input
	Loop Until InStr(1, ar$, Chr$(10))
	ch2_data$ = "CH2 = " & ar$
Else
	ch2_data$ = "CH2 = NON"
End If

If (ch3% <> 0) Then
	MSComm1.Output = ":MEMORY:AREAL? CH3" & deli$
	ar$ = ""
	Do
		ar$ = ar$ & MSComm1.Input
	Loop Until InStr(1, ar$, Chr$(10))
	ch3_data$ = "CH3 = " & ar$
Else
	ch3_data$ = "CH3 = NON"
End If

If (ch4% <> 0) Then
	MSComm1.Output = ":MEMORY:AREAL? CH4" & deli$
	ar$ = ""
	Do
		ar$ = ar$ & MSComm1.Input
	Loop Until InStr(1, ar$, Chr$(10))
	ch4_data$ = "CH4 = " & ar$
Else
	ch4_data$ = "CH4 = NON"
End If

Text1.Text = ch1_data$ & deli$ & ch2_data$ & deli$ & ch3_data$ & deli$ & ch4_data$ & deli$

MSComm1.PortOpen = False

End Sub


Example 6 Saving stored data onto drive A.

Private Sub Sample6_Click()
'*******************************************************************************
' RS232C SAMPLE PROGRAM NO.6
'*******************************************************************************

deli$ = Chr$(13) & Chr$(10)
na$ = "a:\sample.dat"

MSComm1.PortOpen = True

MSComm1.Output = ":HEADER OFF" & deli$
MSComm1.Output = ":MEMORY:MAXPOINT?" & deli$
Do
	mx$ = mx$ & MSComm1.Input
Loop Until InStr(1, mx$, Chr$(10))
If (Val(mx$) = 0) Then
	MSComm1.PortOpen = False
	Exit Sub
End If

Open na$ For Output As #1
MSComm1.Output = ":MEMORY:POINT CH1,0" & deli$
Print #1, 10
For i = 0 To 10
	MSComm1.Output = ":MEMORY:ADATA? 1" & deli$
	ad$ = ""
	Do
		ad$ = ad$ & MSComm1.Input
	Loop Until InStr(1, ad$, Chr$(10))
	Print #1, Val(ad$)
Next

Close #1
MSComm1.PortOpen = False

End Sub



Example 7 Reading the data saved in Example 6, and loading it into the unit.

Private Sub Sample7_Click()
'*******************************************************************************
' RS232C SAMPLE PROGRAM NO.7
'*******************************************************************************

deli$ = Chr$(13) & Chr$(10)
na$ = "a:\sample.dat"

MSComm1.PortOpen = True

MSComm1.Output = ":HEADER OFF" & deli$
MSComm1.Output = ":MEMORY:PREPARE;*OPC?" & deli$
Do
	o$ = MSComm1.Input
Loop Until InStr(1, o$, Chr$(10))

Open na$ For Input As #1
MSComm1.Output = ":MEMORY:POINT CH1,0" & deli$
Line Input #1, mx
For i = 0 To mx
	Line Input #1, dt
	MSComm1.Output = ":MEMORY:ADATA " & Str$(dt) & deli$
Next

Close #1
MSComm1.PortOpen = False

End Sub


Download Driver Pack

How To Update Drivers Manually

After your driver has been downloaded, follow these simple steps to install it.

  • Expand the archive file (if the download file is in zip or rar format).

  • If the expanded file has an .exe extension, double click it and follow the installation instructions.

  • Otherwise, open Device Manager by right-clicking the Start menu and selecting Device Manager.

  • Find the device and model you want to update in the device list.

  • Double-click on it to open the Properties dialog box.

  • From the Properties dialog box, select the Driver tab.

  • Click the Update Driver button, then follow the instructions.

Very important: You must reboot your system to ensure that any driver updates have taken effect.

For more help, visit our Driver Support section for step-by-step videos on how to install drivers for every file type.

server: ftp, load: 1.88