Communicate With Test Instruments Over LAN Using Visual

2y ago
127 Views
6 Downloads
230.65 KB
6 Pages
Last View : 10d ago
Last Download : 3m ago
Upload by : Ciara Libby
Transcription

Communicate with Test InstrumentsOver LAN Using Visual BasicApplication Note 1555When you order a new test and measurement instrument, you maydiscover that it has a local area network (LAN) interface along withthe more traditional GPIB interface. Test and measurement instrument makers Agilent Technologies, Racal Instruments, Keithley andothers have been shipping instruments with LAN (Ethernet) interfaces for more than a year. Using LAN lets you communicate withyour instruments remotely; it is fast and simple, and you don’t needany additional proprietary software or cards. In this application notewe show you how to communicate with instruments on the LAN fromyour PC using Microsoft Visual Basic. You can download the codeexamples from www.agilent.com/find/socket examples.Connecting the instrumentYou can connect a test instrumentdirectly to a network LAN portwith a LAN cable, or you can connect your instrument directly tothe PC. If you decide to connectthe instrument directly to the PCLAN port, you will need a specialcable called a crossover cable.Once the instrument is connected,you must establish an IP addressfor it. Dynamic Host ConfigurationProtocol (DHCP) is typically the easiest way to configure aninstrument for LAN communication. DHCP automatically assignsa dynamic IP address to a device on a network. See the instrument’suser’s guide for more information on this topic.Figure 1.Ethernet connectionto LAN on an N6700Amodular power system

Testing communication using the Windows command promptOnce you have an IP address, test the IP address from your PC.Go to the MS DOS command prompt window (in Windows 2000 themenu sequence is Start Programs Accessories Command Prompt).At the command prompt, typeping IP address . The IP addressis four groups of numbers separated by decimal points. If everythingis working, your instrument willrespond. Figure 2 shows a successful ping response.Figure 2.Response to a ping for aworking LAN connectionTesting communicationusing HyperTerminalAlternately, you can test the communication to the instrument with theWindows HyperTerminal program (Start Programs Accessories Communications HyperTerminal). When the Connection Description dialogbox appears, type a name and click OK. The name will be used to saveyour 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 SCPIcommands. The Internet Assigned Number Authority(IANA) registered port number for the instrumentSCPI interface is 5025. Some instrument manufactures may choose to use a unique port number; checkthe instrument documentation for the the port number. Now go to the File Properties menu and select theSettings tab and click ASCII Setup . Select Send lineends with line feed and Echo typed characters locally (seeFigure 3). Click OK to close the dialog boxes. In theterminal window type in *IDN?, and hit Enter. Do notuse the backspace key or any editing keys. If everything is working, you will get back the manufacturerand model number. Save the settings with Save as In order to communicate with the instrument from Visual Basic, youwill need both the port number and the IP address. It is a good practiceto verify both before you begin programming.Using MS Visual Basic to communicateNow that the connections are confirmed, we are ready to useVisual Basic. Visual Basic 6.0 comes with Winsock control. Fromthe Components dialog box (Ctrl-T), find and select the MicrosoftWinsock control. Once the Winsock control is available in theToolbox, place it on the form. There are three steps to make aconnection to the instrument in the Form Load event: first you2Figure 3.ASCII setup for WindowsHyperTerminal for LANcommunications

must insert the IP address (RemoteHost), as well as the port number(RemotePort), then invoke the connect method. The code createdby 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.ConnectEnd IfThe connection may take a bit of time, so this is a good place to adda wait statement or to test the connection status. You can test theconnection status with this codeDim status as LongIf Winsock1.State sckConnected then debug.Print "Connected"Once connected, the Windows Sockets object is ready forcommunication.Sending instrument commandsSending a string to the instrument is straightforward. Note that we adda carriage-return line feed at the end of the command.Winsock1.SendData "*IDN?" & vbCrLfYou can get the response in one of two ways. If the above string is ina button, clicking the button sends the string command and then exitsthe subroutine. When exiting the subroutine, Visual Basic is idle andevents can be executed. In that case, receiving the data is just amatter of waiting for the DataArrival event to fire and thenretrieving the data like this:Private Sub Winsock1 DataArrival(ByVal bytesTotal As Long)Dim strData As StringWinsock1.GetData strData, vbStringEnd Sub3

However, most of the time you want to write and read several timeswithout exiting the subroutine. To do this, we wrote a simple ReadStringroutine that will allow you to do just that. The ReadString routineimmediately checks the connection buffer and then executes a DoEventsuntil the buffer has increased in size indicating the arrival of the latestdata. DoEvents allows VB to pause the subroutine and capture anevent such as the instrument response to a query on the LAN.This is a shortened version of the ReadString subroutine containedin the example VB project.PublicDimDimDimFunction ReadString(skt As Winsock) As StringstrData As StringnumbBytes As Longi As LongnumbBytes skt.BytesReceivedDoEvents' check repeatedly if there is new data.For i 1 To 10000If skt.BytesReceived numbBytes Then Exit ForDoEventsNext i' Gets the data and Clears bufferskt.GetData strData, vbStringReadString strDataEnd FunctionRather than add a carriage return line feed every time we send a string,we also wrote a WriteString routine that adds the vbCrLfPublic Sub WriteString(skt As Winsock, ByVal cmd As String)skt.SendData cmd & vbCrLfEnd SubUsing these two routines, you can check the ID of an instrument andplace it into a text box with the following code:WriteString Winsock1, "*idn?"txtID.Text ReadString(Winsock1)4

Examples downloadsA complete Visual Basic and C project that demonstrates socketswith Agilent instruments is available for the Agilent 33220A functiongenerator and the N6700A modular power system at www.agilent.com/find/socket examples. All the instrument-specific code is in onecommand button subroutine. Youcan easily modify either of theseprojects for other instruments.The example Visual Basic codebrings up a dialog box for makingthe LAN connection. The portnumber is set to 5025. If itneeds to be changed, changethe constant RemPort in themodWinSock module. Start thecode. Type in the IP address andclick on Connect. The progress ofthe connection will be shown inthe Messages field. The instrument-specific code is in the clickevent for the button labeled Start.Figure 4.User interface of VBsoftware example to makeconnection to instrumentwith socketsConclusionUsing sockets in Visual Basic with LAN-enabled instrumentseliminates the need for proprietary I/O library code loaded tothe PC. This approach is very fast, it enables remote operation,and it is easy to implement in Microsoft Visual Basic.Related Agilent literaturePublication titlePublicationtypePublicationnumberWeb address33220A 20MHzFunction Arbitrary WaveformGeneratorData itweb/pdf/5988-8544EN.pdfData itweb/pdf/5989-1411EN.pdfN6700-series ModularDC Power Supply5

www.agilent.comBy internet, phone, or fax, get assistance withall your test & measurement needs.www.agilent.com/find/emailupdatesGet 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 systemdevelopment. More information is available at www.Agilent.com/find/systemcomponentsOnline assistance:www.agilent.com/find/assistPhone or FaxUnited States:(tel) 800 829 4444(fax) 800 829 4433Canada:(tel) 877 894 4414(fax) 800 746 4866China:(tel) 800 810 0189(fax) 800 820 2816Europe:(tel) (31 20) 547 2111(fax) (31 20) 547 2390Japan:(tel) (81) 426 56 7832(fax) (81) 426 56 7840Korea:(tel) (82 2) 2004 5004(fax) (82 2) 2004 5115Latin America:(tel) (650) 752 5000Taiwan:(tel) 0800 047 866(fax) 0800 286 331Other Asia Pacific Countries:(tel) (65) 6375 8100(fax) (65) 6836 0252Email: tm ap@agilent.comMicrosoft is a U.S. registered trademark of Microsoft Corporation.Product specifications and descriptions in thisdocument subject to change without notice.02/18/2005 Agilent Technologies, Inc. 2005Printed in USA February 18, 20055989-2316EN

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

Related Documents:

NATIVE INSTRUMENTS GmbH Schlesische Str. 29-30 D-10997 Berlin Germany www.native-instruments.de NATIVE INSTRUMENTS North America, Inc. 6725 Sunset Boulevard 5th Floor Los Angeles, CA 90028 USA www.native-instruments.com NATIVE INSTRUMENTS K.K. YO Building 3F Jingumae 6-7-15, Shibuya-ku, Tokyo 150-0001 Japan www.native-instruments.co.jp NATIVE .

NATIVE INSTRUMENTS GmbH Schlesische Str. 29-30 D-10997 Berlin Germany www.native-instruments.de NATIVE INSTRUMENTS North America, Inc. 6725 Sunset Boulevard 5th Floor Los Angeles, CA 90028 USA www.native-instruments.com NATIVE INSTRUMENTS K.K. YO Building 3F Jingumae 6-7-15, Shibuya-ku, Tokyo 150-0001 Japan www.native-instruments.co.jp NATIVE .

In order to perform surgery, the surgical team needs a number of surgical instruments. Each of the thousands of instruments used is designed for a specific function. They can be classified depending on use as follows: Cutting instruments Instruments for tissue grasping and manipulation Instruments for tissue exposure

Formal characteristics of instruments Sharp-pointed and blunt instruments Paired instruments: their pair is its mirrored image Double ended instruments: there is a working end at both ends of the handle Bends of instruments: simple, multiple, in the plane or out of the plane, often bayonet bend KOMLÓS

NATIVE INSTRUMENTS GmbH Schlesische Str. 29-30 D-10997 Berlin Germany www.native-instruments.de NATIVE INSTRUMENTS North America, Inc. 6725 Sunset Boulevard 5th Floor Los Angeles, CA 90028 USA www.native-instruments.com NATIVE INSTRUMENTS K.K. YO Building 3F Jingumae 6-7-15, Shibuya-ku, Tokyo 150-0001 Japan www.native-instruments.co.jp NATIVE .

- Free reed instruments : accordion, concertina, cecilium, bagpipe, etc. - wind instruments : wood and brass - percussions - 20th century instruments, electric and electro-acoustic - Instruments from extra- European countries. Here, we would like to deal only with our own specialty : stringed instruments, bowed or plucked,

4. 12 Meter (40') Drop Within Test 5. Fast Cook-Off Within Test 6. Slow Cook-Off Within Test 7. Bullet Impact Within Test 8. Fragment Impact Within Test 9. Sympathetic Detonation Within Test 10. Shaped Charge Jet Impact Within Test 11. Spall Impact Within Test 12. Specialty Within Test 13. Specialty Within Test 14. Specialty Within Test 15 .

An Introduction to Thermal Field Theory Yuhao Yang September 23, 2011 Supervised by Dr. Tim Evans Submitted in partial ful lment of the requirements for the degree of Master of Science in Quantum Fields and Fundamental Forces Department of Physics Imperial College London. Abstract This thesis aims to give an introductory review of thermal eld theo- ries. We review the imaginary time formalism .