0% found this document useful (0 votes)
10 views3 pages

Visual Basic TCPIPCommunications

This document provides an overview of using Visual Basic and TCP/IP to communicate with a QuickSilver device over Ethernet. It includes code examples to initialize a socket connection, send commands to the device, and receive responses. The document also discusses using Microsoft's Winsock control to handle the TCP/IP communication.

Uploaded by

alex smith
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Visual Basic TCPIPCommunications

This document provides an overview of using Visual Basic and TCP/IP to communicate with a QuickSilver device over Ethernet. It includes code examples to initialize a socket connection, send commands to the device, and receive responses. The document also discusses using Microsoft's Winsock control to handle the TCP/IP communication.

Uploaded by

alex smith
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Application Note:QCI-AN043 QuickSilver Controls, Inc.

Date: 9 May 2007 [Link]

Visual Basic TCP/IP Communications


Overview
This application demonstrates Ethernet communications using [Link] (Microsoft
Winsock Control), an Active X Control supplied by Microsoft. This simple program, initializes
the socket and sends a Move Relative, Time Based (MRT) command to the attached
QuickSilver Device. The device's response is received and displayed.

It is assumed the reader is familiar with Windows, Visual Basic, QuickControl® , programming
QuickSilver E-485 Bridge products, TCP/IP and QuickSilver’s serial communication. For more
information see:
• QCI-TD053 Serial Communications
• QCI-TD056 E-485 Bridge-Ethernet
• SilverLode User Manual

Microsoft and Windows are registered trademarks of Microsoft Corporation.

Setup
The following assumptions are made about the QuickSilver device:
1) The device has an E-485 Bridge (i.e. QCI-D2-IG8-E)
2) The device has already been initialized (using QuickControl) over the E-485 Bridge.
3) Unit ID of 16.
4) IP Address [Link] (see below to a use different address)

Included Files
File/Folder Description
[Link] Visual Basic project file
[Link] Source Code

Project1 Dialog Box


Press Connect to establish a TCP connection to the E-
485 Bridge.

Press Send to send the MRT command.

Property of QuickSilver Controls, Inc. Page 1 of 3 This document is subject to change without notice.
QuickControl® and QCI® are Registered Trademarks of QuickSilver Controls, Inc.
SilverLode™, SilverNugget™, SilverDust™, PVIA™, QuickSilver Controls™, and AntiHunt™ are trademarks of
QuickSilver Controls, Inc..
Application Note:QCI-AN043 QuickSilver Controls, Inc.
Microsoft Winsock Control
Microsoft Winsock Control is an ActiveX Control supplied by Microsoft. The Control provides
TCP/IP communications. You can add this control to your project by selecting Project->
Components, select ‘Controls’ tab, select ‘Microsoft Winsock Control 6.0’ , click ‘OK’. This
inserts the Control into the toolbox (appearing as a network icon), which you can now add to
your form and make it part of your project. All of the functions of the control are now available
to your project.

QuickSilver Controls, Inc. Page 2 of 3


Application Note:QCI-AN043 QuickSilver Controls, Inc.

cmdConnect_Click () Subroutine Private Sub cmdConnect_Click()


Press Connect to establish a socket connection from the ' Setup and open socket
PC to the E-485 bridge. This is where you can change [Link] = sckTCPProtocol
[Link] = "[Link]"
the default IP Address from something other than [Link] = 10001
"[Link]". The port must remain at 10001. [Link]
End Sub

cmdSend_Click() Subroutine Private Sub cmdSend_Click()


Press Send to send the MRT command to the ' Send MRT Command
Dim strOut As String
controller. Once a connection is established (see strOut = "@16 177 40000 833 8333 0 0" & Chr(13)
above), the Send button can be pressed repeatedly [Link] strOut
End Sub
without pressing Connect again.

Winsock1_DataArrival Subroutine
This subroutine is called anytime data Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
arrives. Just copy and paste it into your ' Winsock Message Handler called when socket get some data
Dim strMsg As String
application. Dim strIn As String
[Link] strIn
If strIn = "" Then
strMsg = "Device did not respond"
Else
strMsg = "Device Response: " & strIn
End If
MsgBox (strMsg)
End Sub

QuickSilver Controls, Inc. Page 3 of 3

You might also like