Chapter 3 Example ProgramsChapter 3 Example Programs 3.1 RS-232C Visual Basic Example Progarams 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 = ":TDIV 1.E-3" & deli$ MSComm1.Output = ":SHOT 30" & deli$ MSComm1.Output = ":TGSO OR" & deli$ MSComm1.Output = ":TGKD CH1,LEVE" & deli$ MSComm1.Output = ":PRTG 5" & deli$ MSComm1.Output = ":TGLV CH1,0" & deli$ MSComm1.Output = ":TGSL CH1,UP" & deli$ MSComm1.Output = ":TGKD CH2,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 = ":TIME?" & deli$ Do tm$ = tm$ & MSComm1.Input Loop Until InStr(1, tm$, Chr$(10)) 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 :MAXP? 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 ' :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 :ADATA? query, and to ' capture data as volatage values use the :VDATA? query. '******************************************************************************* deli$ = Chr$(13) & Chr$(10) Dim d(1000) As Double MSComm1.PortOpen = True MSComm1.Output = ":SHOT 10" & deli$ MSComm1.Output = ":TGMD SING" & deli$ MSComm1.Output = ":START;*OPC;:STOP;*OPC?" & deli$ Do o$ = o$ & MSComm1.Input Loop Until InStr(1, o$, Chr$(10)) MSComm1.Output = ":MAXP?" & 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 = ":POINT CH1,0" & deli$ For i = 1 To 1000 vd$ = "" MSComm1.Output = ":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 :PREPARE command. ' ' Next, the program specifies the channel and point for input, using the ' :POINT command, and then uses the :ADATA command to input data. '******************************************************************************* deli$ = Chr$(13) & Chr$(10) MSComm1.PortOpen = True MSComm1.Output = ":SHOT 10" & deli$ MSComm1.Output = ":PREPARE;*OPC?" & deli$ Do o$ = MSComm1.Input Loop Until InStr(1, o$, Chr$(10)) MSComm1.Output = ":POINT CH1,0" & deli$ For i = 0 To 1000 MSComm1.Output = ":ADATA " & Str$(Int(1600 * Sin(3.14 * i / 500))) & deli$ Next MSComm1.PortOpen = False End Sub Example 5 Saving stored data onto PC card. Private Sub Sample5_Click() '******************************************************************************* ' RS232C SAMPLE PROGRAM NO.5 '******************************************************************************* deli$ = Chr$(13) & Chr$(10) na$ = "a:\sample.dat" MSComm1.PortOpen = True MSComm1.Output = ":MAXP?" & 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 = ":POINT CH1,0" & deli$ Print #1, 10 For i = 0 To 10 MSComm1.Output = ":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 6 Reading the data saved in Example 5, and loading it into the unit. Private Sub Sample6_Click() '******************************************************************************* ' RS232C SAMPLE PROGRAM NO.6 '******************************************************************************* deli$ = Chr$(13) & Chr$(10) na$ = "a:\sample.dat" MSComm1.PortOpen = True MSComm1.Output = ":PREPARE;*OPC?" & deli$ Do o$ = MSComm1.Input Loop Until InStr(1, o$, Chr$(10)) Open na$ For Input As #1 MSComm1.Output = ":POINT CH1,0" & deli$ Line Input #1, mx For i = 0 To mx Line Input #1, dt MSComm1.Output = ":ADATA " & Str$(dt) & deli$ Next Close #1 MSComm1.PortOpen = False End Sub 3.2 10BASE-T Visual Basic Example Programs Example 1 Using a setting command *Send the command in the format specified, when the conditions for the command to be acceptable are met. Dim MsgFlg As Integer Dim MsgBuf As String Private Sub Command1_Click() '******************************************************************************* ' 10BASE-T(LAN) SAMPLE PROGRAM NO.1 '******************************************************************************* deli$ = Chr$(13) & Chr$(10) SendMsg ":TDIV 1.0E-3" & deli$ SendMsg ":SHOT 30" & deli$ SendMsg ":TGSO OR" & deli$ SendMsg ":TGKD CH1,LEVE" & deli$ SendMsg ":PRTG 5" & deli$ SendMsg ":TGLV CH1,0" & deli$ SendMsg ":TGSL CH1,UP" & deli$ SendMsg ":TGKD CH2,OFF" & deli$ SendMsg ":START" & deli$ End Sub Private Sub Command2_Click() Winsock1.Protocol = sckTCPProtocol Winsock1.RemoteHost = txtIP.Text Winsock1.RemotePort = Val(txtPort.Text) Winsock1.Connect Do While (Winsock1.State <> sckConnected) If Winsock1.State = sckConnecting Then Text2.Text = "connecting" DoEvents Loop If Winsock1.State = sckConnected Then Text2.Text = "finish" End Sub Private Sub Command3_Click() Winsock1.Close Do While (Winsock1.State <> sckClosed) If Winsock1.State = sckConnected Then Text2.Text = "disconecting" DoEvents Loop If Winsock1.State = sckClosed Then Text2.Text = "finish" End Sub Private Sub SendMsg(strMsg As String) Winsock1.SendData strMsg End Sub Private Sub GetMsg(strMsg As String) MsgFlg = 0 Winsock1.SendData strMsg Do While (MsgFlg = 0) DoEvents Loop End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Winsock1.GetData MsgBuf, vbString MsgFlg = 1 End Sub Example 2 Using a query *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 Dim MsgFlg As Integer Dim MsgBuf As String Private Sub Command1_Click() '******************************************************************************* ' 10BASE-T(LAN) SAMPLE PROGRAM NO.2 '******************************************************************************* deli$ = Chr$(13) & Chr$(10) GetMsg ":TIME?" & deli$ tm$ = MsgBuf Text1.Text = "TIME = " & tm$ End Sub Private Sub Command2_Click() Winsock1.Protocol = sckTCPProtocol Winsock1.RemoteHost = txtIP.Text Winsock1.RemotePort = Val(txtPort.Text) Winsock1.Connect Do While (Winsock1.State <> sckConnected) If Winsock1.State = sckConnecting Then Text2.Text = "connecting" DoEvents Loop If Winsock1.State = sckConnected Then Text2.Text = "finish" End Sub Private Sub Command3_Click() Winsock1.Close Do While (Winsock1.State <> sckClosed) If Winsock1.State = sckConnected Then Text2.Text = "disconecting" DoEvents Loop If Winsock1.State = sckClosed Then Text2.Text = "finish" End Sub Private Sub SendMsg(strMsg As String) Winsock1.SendData strMsg End Sub Private Sub GetMsg(strMsg As String) MsgFlg = 0 Winsock1.SendData strMsg Do While (MsgFlg = 0) DoEvents Loop End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Winsock1.GetData MsgBuf, vbString MsgFlg = 1 End Sub Example 3 Outputting stored data *Using the :MAXP? query, this program 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 program specifies the channel and point for output, using the :POINT command. As data is input or output, the point is incremented automatically. If capturing data consecutively, it is sufficient to specify the point once only. *To capture data in ASCII format use the :ADATA? query, and to capture data as voltage values use the :VDATA? query. The number of data samples which may be output in one set is 1 to SHOT * 100 queries. *Outputting data in bigger sets reduces the overall processing time. Dim MsgFlg As Integer Dim MsgBuf As String Private Sub Command1_Click() '******************************************************************************* ' 10BASE-T(LAN) SAMPLE PROGRAM NO.3 '******************************************************************************* deli$ = Chr$(13) & Chr$(10) Dim d(1000) As Double SendMsg ":SHOT 10" & deli$ SendMsg ":TGMD SING" & deli$ GetMsg ":START;*OPC;:STOP;*OPC?" & deli$ o$ = MsgBuf GetMsg ":MAXP?" & deli$ mx$ = MsgBuf If (Val(mx$) = 0) Then Exit Sub End If SendMsg ":POINT CH1,0" & deli$ For i = 1 To 1000 vd$ = "" GetMsg ":VDATA? 1" & deli$ vd$ = MsgBuf d(i) = Val(vd$) Next For i = 1 To 1000 Text1.SelText = Format(d(i), "Scientific") & deli$ Next End Sub Private Sub Command2_Click() Winsock1.Protocol = sckTCPProtocol Winsock1.RemoteHost = txtIP.Text Winsock1.RemotePort = Val(txtPort.Text) Winsock1.Connect Do While (Winsock1.State <> sckConnected) If Winsock1.State = sckConnecting Then Text2.Text = "connecting" DoEvents Loop If Winsock1.State = sckConnected Then Text2.Text = "finish" End Sub Private Sub Command3_Click() Winsock1.Close Do While (Winsock1.State <> sckClosed) If Winsock1.State = sckConnected Then Text2.Text = "disconecting" DoEvents Loop If Winsock1.State = sckClosed Then Text2.Text = "finish" End Sub Private Sub SendMsg(strMsg As String) Winsock1.SendData strMsg End Sub Private Sub GetMsg(strMsg As String) MsgFlg = 0 Winsock1.SendData strMsg Do While (MsgFlg = 0) DoEvents Loop End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Winsock1.GetData MsgBuf, vbString MsgFlg = 1 End Sub Example 4 Inputting storage data. *This program prepares storage memory, using the :PREPARE command. *Next, the program specifies the channel and point for input, using the :POINT command, and then uses the :ADATA command to input data. Dim MsgFlg As Integer Dim MsgBuf As String Private Sub Command1_Click() '******************************************************************************* ' 10BASE-T(LAN) SAMPLE PROGRAM NO.4 '******************************************************************************* deli$ = Chr$(13) & Chr$(10) Text1.Text = "execute." SendMsg ":SHOT 10" & deli$ GetMsg ":PREPARE;*OPC?" & deli$ o$ = MsgBuf SendMsg ":POINT CH1,0" & deli$ For i = 1 To 1000 SendMsg ":ADATA " & Str$(Int(1600 * Sin(3.14 * i / 50))) & deli$ Next SendMsg ":SCRN MAIN" & deli$ GetMsg "*OPC?" & deli$ Text1.Text = "finish." End Sub Private Sub Command2_Click() Winsock1.Protocol = sckTCPProtocol Winsock1.RemoteHost = txtIP.Text Winsock1.RemotePort = Val(txtPort.Text) Winsock1.Connect Do While (Winsock1.State <> sckConnected) If Winsock1.State = sckConnecting Then Text2.Text = "connecting" DoEvents Loop If Winsock1.State = sckConnected Then Text2.Text = "finish" End Sub Private Sub Command3_Click() Winsock1.Close Do While (Winsock1.State <> sckClosed) If Winsock1.State = sckConnected Then Text2.Text = "disconecting" DoEvents Loop If Winsock1.State = sckClosed Then Text2.Text = "finish" End Sub Private Sub SendMsg(strMsg As String) Winsock1.SendData strMsg End Sub Private Sub GetMsg(strMsg As String) MsgFlg = 0 Winsock1.SendData strMsg Do While (MsgFlg = 0) DoEvents Loop End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Winsock1.GetData MsgBuf, vbString MsgFlg = 1 End Sub Example 5 Saving stored data onto drive A. Dim MsgFlg As Integer Dim MsgBuf As String Private Sub Command1_Click() '******************************************************************************* ' 10BASE-T(LAN) SAMPLE PROGRAM NO.5 '******************************************************************************* deli$ = Chr$(13) & Chr$(10) Text1.Text = "execute." na$ = "a:\sample.dat" GetMsg ":MAXP?" & deli$ mx$ = MsgBuf If (Val(mx$) = 0) Then Exit Sub End If Open na$ For Output As #1 SendMsg ":POINT CH1,0" & deli$ Print #1, Val(mx$) For i = 1 To Val(mx$) GetMsg ":ADATA? 1" & deli$ ad$ = MsgBuf Print #1, Val(ad$) Next Close #1 Text1.Text = "finish." End Sub Private Sub Command2_Click() Winsock1.Protocol = sckTCPProtocol Winsock1.RemoteHost = txtIP.Text Winsock1.RemotePort = Val(txtPort.Text) Winsock1.Connect Do While (Winsock1.State <> sckConnected) If Winsock1.State = sckConnecting Then Text2.Text = "connecting" DoEvents Loop If Winsock1.State = sckConnected Then Text2.Text = "finish" End Sub Private Sub Command3_Click() Winsock1.Close Do While (Winsock1.State <> sckClosed) If Winsock1.State = sckConnected Then Text2.Text = "disconecting" DoEvents Loop If Winsock1.State = sckClosed Then Text2.Text = "finish" End Sub Private Sub SendMsg(strMsg As String) Winsock1.SendData strMsg End Sub Private Sub GetMsg(strMsg As String) MsgFlg = 0 Winsock1.SendData strMsg Do While (MsgFlg = 0) DoEvents Loop End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Winsock1.GetData MsgBuf, vbString MsgFlg = 1 End Sub Example 6 Reading the data saved in Example 5, and loading it into the unit. Dim MsgFlg As Integer Dim MsgBuf As String Private Sub Command1_Click() '******************************************************************************* ' 10BASE-T(LAN) SAMPLE PROGRAM NO.6 '******************************************************************************* deli$ = Chr$(13) & Chr$(10) Text1.Text = "execute." na$ = "a:\sample.dat" GetMsg ":PREPARE;*OPC?" & deli$ o$ = MsgBuf Open na$ For Input As #1 SendMsg ":POINT CH1,0" & deli$ Line Input #1, mx For i = 1 To mx Line Input #1, dt SendMsg ":ADATA " & Str$(dt) & deli$ Next Close #1 SendMsg ":SCRN MAIN" & deli$ GetMsg "*OPC?" & deli$ Text1.Text = "finish." End Sub Private Sub Command2_Click() Winsock1.Protocol = sckTCPProtocol Winsock1.RemoteHost = txtIP.Text Winsock1.RemotePort = Val(txtPort.Text) Winsock1.Connect Do While (Winsock1.State <> sckConnected) If Winsock1.State = sckConnecting Then Text2.Text = "connecting" DoEvents Loop If Winsock1.State = sckConnected Then Text2.Text = "finish" End Sub Private Sub Command3_Click() Winsock1.Close Do While (Winsock1.State <> sckClosed) If Winsock1.State = sckConnected Then Text2.Text = "disconecting" DoEvents Loop If Winsock1.State = sckClosed Then Text2.Text = "finish" End Sub Private Sub SendMsg(strMsg As String) Winsock1.SendData strMsg End Sub Private Sub GetMsg(strMsg As String) MsgFlg = 0 Winsock1.SendData strMsg Do While (MsgFlg = 0) DoEvents Loop End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Winsock1.GetData MsgBuf, vbString MsgFlg = 1 End SubDownload Driver Pack
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.