Communicate with Test Instruments Over LAN Using Visual Basic



Similar documents
Creating Datalogging Applications in Microsoft Excel

To perform Ethernet setup and communication verification, first perform RS232 setup and communication verification:

Agilent N5970A Interactive Functional Test Software: Installation and Getting Started

Agilent Evolution of Test Automation Using the Built-In VBA with the ENA Series RF Network Analyzers

Using HyperTerminal with Agilent General Purpose Instruments

CS 326e F2002 Lab 1. Basic Network Setup & Ethereal Time: 2 hrs

USER GUIDE. Ethernet Configuration Guide (Lantronix) P/N: Rev 6

Agilent Technologies. Connectivity Guide. USB/LAN/GPIB Interfaces. Agilent Technologies

81110A Pulse Pattern Generator Simulating Distorted Signals for Tolerance Testing

Agilent U2000 Series USB Power Sensors

Ethernet Connection Setup for CCU

Setup Manual and Programming Reference. RGA Ethernet Adapter. Stanford Research Systems. Revision 1.05 (11/2010)

RAPID BROADBAND INSTALLATION RAPID BROADBAND SUPPORT CONTACT DETAILS. AND TROUBLESHOOTING GUIDE. Tel:

1 PC to WX64 direction connection with crossover cable or hub/switch

Quick Installation Guide Network Management Card

PIM31 Remote Setup and Operational Procedures

Connecting and Setting Up Your Laptop Computer

ACU-1000 Manual Addendum Replacement of CPM-2 with CPM-4

How to configure DVR and computer for running Remote Viewer via IP network

Easy Setup Guide for the Sony Network Camera

R&S AFQ100A, R&S AFQ100B I/Q Modulation Generator Supplement

AXIS 205 Network Camera Quick Installation Guide

R&S AFQ100A, R&S AFQ100B I/Q Modulation Generator Supplement

Communications Instructions for DOOSAN, FANUC Controls

Liebert IntelliSlot Web Cards

TCP/IP MODULE CA-ETHR-A INSTALLATION MANUAL

Package Contents. D-Link DSN-3200/3400 Installation Guide. DSN-3200/3400 xstack Storage Area Network (SAN) Array. CD-ROM with User Guide.

Prestige 314 Read Me First

UBIQUITI BRIDGE CONFIGURATION PROCEDURE (PowerStation & NanoStation Units ONLY)

MAGPOWR Spyder Firmware Update Instruction Manual

PC/POLL SYSTEMS Version 7 Polling SPS2000 Cash Register TCP/IP Communications

Preparing the Computers for TCP/IP Networking

Agilent MATLAB Data Analysis Software Packages for Agilent Oscilloscopes

Cisco - Configure the 1721 Router for VLANs Using a Switch Module (WIC-4ESW)

4 Networking Generators

If the printer is connected to a computer by a USB cable, and you are using the printer sharing function

Programming Guide. Agilent Technologies PSG Signal Generators. Manufacturing Part Number: E Printed in USA December 2003

Printing Options. Netgear FR114P Print Server Installation for Windows XP

Computer Networks I Laboratory Exercise 1

MFC7840W Windows Network Connection Repair Instructions

Configuring the WT-4 for Upload to a Computer (Ad-hoc Mode)

RouteFinder SOHO. Quick Start Guide. SOHO Security Appliance. EDGE Models RF825-E, RF825-E-AP CDMA Models RF825-C-Nx, RF825-C-Nx-AP

Equinox L5300 Installation and Configuration Guide Version 1.0 Innovative Payment Processing Solutions for Businesses

Web Enabled Software for 8614xB-series Optical Spectrum Analyzers. Installation Guide

Quick Note 32. Using Digi RealPort with a Digi TransPort Router. UK Support September 2012

This techno knowledge paper can help you if: You need to setup a WAN connection between a Patton Router and a NetGuardian.

BIT COMMANDER. Serial RS232 / RS485 to Ethernet Converter

The Next Generation in Automated Oscilloscope Test

Smart Control Center. User Guide. 350 East Plumeria Drive San Jose, CA USA. November v1.0

Global Monitoring + Support

Movie Cube. User s Guide to Wireless Function

enervista UR Setup Software Quick Connect Instructions:

SNAP Printer Web Server Users Manual

SLC 5/05 Processors Firmware/Operating System ControlFLASH Upgrade

MC Remote Control Software MCTerminal Operation Manual

Iridium Extreme TM Satellite Phone. Data Services Manual

Package Contents. D-Link DSN-3200/3400 Installation Guide. DSN-3200/3400 xstack Storage Area Network (SAN) Array. CD-ROM with User Guide.

T-BOXN12R. First steps with T-BOXN12R. You can make it wireless. Date: Version 1.0

Network FAX Driver. Operation Guide

c. Securely insert the Ethernet cable from your cable or DSL modem into the Internet port (B) on the WGT634U. Broadband modem

Andover Continuum Remote Communication Configuration Guide

The PostBase Connectivity Wizard

Brother Automatic Printing OPERATION MANUAL

PREFACE iss.01 -

EDGE FX Network configuration

Install MS SQL Server 2012 Express Edition

Getting Started with the Xilinx Zynq All Programmable SoC Mini-ITX Development Kit

Network & Internet Installation & Information Guide Fall 2004 Edition. Campus Ethernet For PCs using Windows 2000 & XP

7 6.2 Windows Vista / Windows IP Address Syntax Mobile Port Windows Vista / Windows Apply Rules To Your Device

a) Network connection problems (check these for existing installations)

Chapter 10 Troubleshooting

Updating MNS-BB CUSTOMER SUPPORT INFORMATION PK012906

Agilent BenchVue Software (34840B) Data capture simplified. Click, capture, done. Data Sheet

Slave Computer 1 Slave Computer 2

EASE Scan Tool Customers. SECTION I - Installation

StarMOBILE Network Configuration Guide. A guide to configuring your StarMOBILE system for networking

Hypercom Key Loading and Management (HKLM) RS232 PPP Key Injection PC Setup Guide

AgGPS 542 Receiver: Enable GLONASS through the Web Browser

INSTALLATION AND OPERATION MANUAL CNFE2DOE TERMINAL SERVER

Configuring Network Load Balancing with Cerberus FTP Server

GV-Data Capture V3 Series User's Manual

GE Intelligent Platforms. Activating Licenses Online Using a Local License Server

Configuring an A Series LED Sign Controller for your Network

1. Hardware Installation

Printer Driver Installation Guide

Modbus and ION Technology

R&S VISA Release Notes Software Version 5.5.4

Integrating with BarTender Integration Builder

Internet for Everyone In-Room Instructions January 2011 Version 1.3

DocOut Licensing Server Installation and Operator s Guide

Installation Guide. Your FedEx Ship Manager system number. Before you start

Agilent Technologies E8047B Analysis Probe System for the Intel Xeon Processor Family

Test-System Development Guide

DUKANE Intelligent Assembly Solutions

Chapter 7 Troubleshooting

Wireless Router Setup Manual

ETHERNET WEATHER STATION CONNECTIONS Application Note 33

Configuring Serial Terminal Emulation Programs

Application & Quick-Start Guide

Transcription:

Communicate with Test Instruments Over LAN Using Visual Basic Application Note 1555 When you order a new test and measurement instrument, you may discover that it has a local area network (LAN) interface along with the more traditional GPIB interface. Test and measurement instrument makers Agilent Technologies, Racal Instruments, Keithley and others have been shipping instruments with LAN (Ethernet) interfaces for more than a year. Using LAN lets you communicate with your instruments remotely; it is fast and simple, and you don t need any additional proprietary software or cards. In this application note we show you how to communicate with instruments on the LAN from your PC using Microsoft Visual Basic. You can download the code examples from www.agilent.com/find/socket_examples. Connecting the instrument You can connect a test instrument directly to a network LAN port with a LAN cable, or you can connect your instrument directly to the PC. If you decide to connect the instrument directly to the PC LAN port, you will need a special cable called a crossover cable. Once the instrument is connected, you must establish an IP address for it. Dynamic Host Configuration Protocol (DHCP) is typically the easiest way to configure an instrument for LAN communication. DHCP automatically assigns a dynamic IP address to a device on a network. See the instrument s user s guide for more information on this topic. Figure 1. Ethernet connection to LAN on an N6700A modular power system

Testing communication using the Windows command prompt Once you have an IP address, test the IP address from your PC. Go to the MS DOS command prompt window (in Windows 2000 the menu sequence is Start>Programs> Accessories>Command Prompt). At the command prompt, type ping <IP address>. The IP address is four groups of numbers separated by decimal points. If everything is working, your instrument will respond. Figure 2 shows a successful ping response. Figure 2. Response to a ping for a working LAN connection Testing communication using HyperTerminal Alternately, you can test the communication to the instrument with the Windows HyperTerminal program (Start >Programs >Accessories >Communications >HyperTerminal). When the Connection Description dialog box appears, type a name and click OK. The name will be used to save your settings. Next, in the Connect To dialog box, select TCP/IP (Winsock) and type in the IP address for the instrument. The port number determines the protocol for the communication. We will use ASCII characters and instrument SCPI commands. The Internet Assigned Number Authority (IANA) registered port number for the instrument SCPI interface is 5025. Some instrument manufactures may choose to use a unique port number; check the instrument documentation for the the port number. Now go to the File>Properties menu and select the Settings tab and click ASCII Setup. Select Send line ends with line feed and Echo typed characters locally (see Figure 3). Click OK to close the dialog boxes. In the terminal window type in *IDN?, and hit Enter. Do not use the backspace key or any editing keys. If everything is working, you will get back the manufacturer and model number. Save the settings with Save as Figure 3. ASCII setup for Windows HyperTerminal for LAN communications In order to communicate with the instrument from Visual Basic, you will need both the port number and the IP address. It is a good practice to verify both before you begin programming. Using MS Visual Basic to communicate Now that the connections are confirmed, we are ready to use Visual Basic. Visual Basic 6.0 comes with Winsock control. From the Components dialog box (Ctrl-T), find and select the Microsoft Winsock control. Once the Winsock control is available in the Toolbox, place it on the form. There are three steps to make a connection to the instrument in the Form Load event: first you 2

must insert the IP address (RemoteHost), as well as the port number (RemotePort), then invoke the connect method. The code created by the Winsock control is shown below. If (Winsock1.State = sckclosed) Then ' Invoke the Connect method to initiate a connection. Winsock1.RemotePort = "5025" Winsock1.RemoteHost = "177.140.77.204" Winsock1.Connect End If The connection may take a bit of time, so this is a good place to add a wait statement or to test the connection status. You can test the connection status with this code Dim status as Long If Winsock1.State = sckconnected then debug.print "Connected" Once connected, the Windows Sockets object is ready for communication. Sending instrument commands Sending a string to the instrument is straightforward. Note that we add a carriage-return line feed at the end of the command. Winsock1.SendData "*IDN?" & vbcrlf You can get the response in one of two ways. If the above string is in a button, clicking the button sends the string command and then exits the subroutine. When exiting the subroutine, Visual Basic is idle and events can be executed. In that case, receiving the data is just a matter of waiting for the DataArrival event to fire and then retrieving the data like this: Private Sub Winsock1_DataArrival(ByVal bytestotal As Long) Dim strdata As String Winsock1.GetData strdata, vbstring End Sub 3

However, most of the time you want to write and read several times without exiting the subroutine. To do this, we wrote a simple ReadString routine that will allow you to do just that. The ReadString routine immediately checks the connection buffer and then executes a DoEvents until the buffer has increased in size indicating the arrival of the latest data. DoEvents allows VB to pause the subroutine and capture an event such as the instrument response to a query on the LAN. This is a shortened version of the ReadString subroutine contained in the example VB project. Public Function ReadString(skt As Winsock) As String Dim strdata As String Dim numbbytes As Long Dim i As Long numbbytes = skt.bytesreceived DoEvents ' check repeatedly if there is new data. For i = 1 To 10000 If skt.bytesreceived > numbbytes Then Exit For DoEvents Next i ' Gets the data and Clears buffer skt.getdata strdata, vbstring ReadString = strdata End Function Rather than add a carriage return line feed every time we send a string, we also wrote a WriteString routine that adds the vbcrlf Public Sub WriteString(skt As Winsock, ByVal cmd As String) skt.senddata cmd & vbcrlf End Sub Using these two routines, you can check the ID of an instrument and place it into a text box with the following code: WriteString Winsock1, "*idn?" txtid.text = ReadString(Winsock1) 4

Examples downloads A complete Visual Basic and C++ project that demonstrates sockets with Agilent instruments is available for the Agilent 33220A function generator and the N6700A modular power system at www.agilent. com/find/socket_examples. All the instrument-specific code is in one command button subroutine. You can easily modify either of these projects for other instruments. The example Visual Basic code brings up a dialog box for making the LAN connection. The port number is set to 5025. If it needs to be changed, change the constant RemPort in the modwinsock module. Start the code. Type in the IP address and click on Connect. The progress of the connection will be shown in the Messages field. The instrument-specific code is in the click event for the button labeled Start. Figure 4. User interface of VB software example to make connection to instrument with sockets Conclusion Using sockets in Visual Basic with LAN-enabled instruments eliminates the need for proprietary I/O library code loaded to the PC. This approach is very fast, it enables remote operation, and it is easy to implement in Microsoft Visual Basic. Related Agilent literature Publication title Publication Publication Web address type number 33220A 20MHz Function Arbitrary Waveform Data sheet 5988-8544EN http://cp.literature.agilent.com/litweb/pdf/5988-8544en.pdf Generator N6700-series Modular Data sheet 5989-1411EN http://cp.literature.agilent.com/litweb/pdf/5989-1411en.pdf DC Power Supply 5

www.agilent.com By internet, phone, or fax, get assistance with all your test & measurement needs. www.agilent.com/find/emailupdates Get the latest information on the products and applications you select. Agilent Open: Agilent simplifies the process of connecting and programming test systems to help engineers design, validate and manufacture electronic products. Agilent's broad range of system-ready instruments, open industry software, PC-standard I/O and global support all combine to accelerate test system development. More information is available at www.agilent.com/find/systemcomponents Online assistance: www.agilent.com/find/assist Phone or Fax United States: (tel) 800 829 4444 (fax) 800 829 4433 Canada: (tel) 877 894 4414 (fax) 800 746 4866 China: (tel) 800 810 0189 (fax) 800 820 2816 Europe: (tel) (31 20) 547 2111 (fax) (31 20) 547 2390 Japan: (tel) (81) 426 56 7832 (fax) (81) 426 56 7840 Korea: (tel) (82 2) 2004 5004 (fax) (82 2) 2004 5115 Latin America: (tel) (650) 752 5000 Taiwan: (tel) 0800 047 866 (fax) 0800 286 331 Other Asia Pacific Countries: (tel) (65) 6375 8100 (fax) (65) 6836 0252 Email: tm_ap@agilent.com Microsoft is a U.S. registered trademark of Microsoft Corporation. Product specifications and descriptions in this document subject to change without notice. 02/18/2005 Agilent Technologies, Inc. 2005 Printed in USA February 18, 2005 5989-2316EN