Developing Distributed GPIB Test Systems Using the NI GPIB-ENET and Existing Ethernet Networks

Publish Date: May 05, 2012 | 17 Ratings | 3.29 out of 5 |  PDF

Overview

This application note serves as a general introduction for implementing distributed test applications using the GPIB-ENET TCP/IP Ethernet-to-GPIB controller. It offers three example applications in source code to help you get started developing your own distributed test applications.

Table of Contents

  1. Introduction
  2. Using the GPIB-ENET for Instrument Control
  3. Configuring Your GPIB-ENET
  4. Application Example 1 -- Controlling Several Instruments from a Single ComputerApplication
  5. Example 2 -- Integrating Two or More GPIB Test Systems into a Single Application
  6. Application Example 3 -- Sharing Instruments Resources Between Several Users
  7. Summary

1. Introduction

The National Instruments GPIB-ENET TCP/IP Ethernet-to-GPIB controller expands the scope of computer-controlled test applications through the use of networks. Assembling the components of your test application through a network addresses factors such as size, distance, environmental conditions, integration of test systems, and instrumentation located in different areas of your company, as well as the sharing of instrumentation resources.

Computer networks are standard mechanisms for sharing resources, exchanging information, or archiving data for later use. Using these networks, you can expand the functionality of your distributed test systems to serve a variety of needs, including timely dissemination of critical test information. By using a server application that manages remote access to your test system, you can provide key decision makers, operators, technicians, and developers easy access for maintenance, development, control, and monitoring. Distributed test and measurement applications continue to grow in popularity as the applicable networking technology continues to drop in cost and evolve as a standard component in every corporate computing environment.

Back to Top

2. Using the GPIB-ENET for Instrument Control


The GPIB-ENET and NI-488.2 software convert a computer equipped with an Ethernet port into a GPIB Talker/Listener/Controller. The GPIB-ENET delivers that same GPIB controller capability as a plug-in board, but across an Ethernet link. NI-488.2 software performs all the necessary GPIB-to-Ethernet conversions to send information across the Ethernet link; the GPIB-ENET performs all necessary Ethernet-to-GPIB conversions to communicate to your GPIB instruments. The GPIB-ENET offers a flexible, cost-effective solution for sharing instrumentation resources or creating expandable distributed test applications.


Figure 1. GPIB-ENET Ethernet-to-GPIB Controller


Applications
Applications for the GPIB-ENET include:

  • Controlling multiple racks of instrumentation from a single computer
  • Controlling instrumentation in a hazardous environment
  • Integrating two or more GPIB systems separated by distances greater than 4 m
  • Sharing access to GPIB instruments and systems so several users can download test data, or conduct tests from several computer stations.


Cabling
The GPIB-ENET can be interfaced to different Ethernet media types such as thick/thin Ethernet by attaching an Ethernet conversion box to the GPIB-ENET AUI (Attachment Unit Interface) connector. There are two types of GPIB-ENET controllers available. They offer the following two types of cabling configurations:

  • AUI and Coax (10Base2)
  • AUI and Twisted Pair (10BaseT)


A switch on either GPIB-ENET model selects the AUI or the other option.

Performance
Typical sustained throughput of data can reach 50 kbytes/s. Actual data rates may vary depending on your network configuration and the amount of network traffic. In general the TCP/IP protocol invokes significant software overhead to perform routing and to ensure correct, complete data transfers. This overhead imposes a consistent limiting factor on overall system performance.

Application Development Tools
Our LabVIEW and LabWindows/CVI application software products contain a fully integrated library of NI-488.2™ functions for instrument control, as well as easy-to-use tools for data analysis, data formatting, data presentation, and data management. You can also use the NI-488.2 language interface to develop your GPIB applications using C/C++ and Visual Basic.

You develop applications for the GPIB-ENET using the same NI-488 functions and NI-488.2 routines you would use to program a PCI-GPIB, AT-GPIB/TNT, or PCMCIA-GPIB interface. NI-488.2 software frees you from writing low-level TCP/IP code to access the GPIB-ENET. Furthermore, existing GPIB applications written with NI-488.2 can also be reused with the GPIB-ENET with little or no source code modification.

Remote Access Using the Internet
You can use the Internet Developers Toolkit for LabVIEW or LabWindows/CVI for remote monitoring of your distributed GPIB test system. Using this toolkit you can view the front panels of your GPIB test systems for remote monitoring and control. Figure 2 illustrates how the Internet Developers Toolkit can be used in conjunction with the GPIB-ENET to construct a distributed instrumentation system that can be accessed via remote computers running a simple web browser. For more information on developing applications accessible via the internet, contact National Instruments and ask about the Internet Developers Toolkit.



Figure 2. Remote Access Over the Internet

Back to Top

3. Configuring Your GPIB-ENET

The GPIB-ENET hardware and NI-488.2 software must be correctly installed and configured before any GPIB applications can be developed. This section offers a roadmap for configuring GPIB-ENET for operation. Refer to the GPIB-ENET Getting Started manual (shipped with the product) for platform specific installation instructions.

In general, setting up a GPIB-ENET distributed test system is easy because the Ethernet network is already in place. All that remains is to add the GPIB-ENET as a device on the Ethernet:

  1. Install NI-488.2 software on each computer that will be used to control a GPIB-ENET.
  2. Use the utilities included with the driver software to configure each individual GPIB-ENET with a unique IP address (this step has to performed only once per GPIB-ENET interface).
  3. Configure the software on each controlling computer with the IP addresses of the GPIB-ENET(s) (configured in Step 2 above) that it will control.


NI-488.2 Driver Software for the GPIB-ENET
Table 1 summarizes the operating systems under which you can use the GPIB-ENET. The maximum number of GPIB-ENETs is expandable under the UNIX platforms. Contact National Instruments if you need to control more than the specified number. The NI-488.2 API used to program your GPIB-ENET is consistent across these platforms as well as other interfaces, such as the PCI-GPIB or PCMCIA-GPIB. You can develop your software and use it with other interfaces types and other applicable operating systems with little or no source code modification.

Table 1. Maximum Number of GPIB-ENET Interfaces
Operating System
Maximum Number of GPIB-ENETs
Controlled by a Particular Computer
 
Windows NT
32
Windows 95
100
Windows for Work Groups 3.11
24
Sun Solaris
8 (User Expandable)
HP-UX
8 (User Expandable)
Digital UNIX (OSF/1)
8 (User Expandable)
Mac OS X
8



Assigning an IP Address to Your GPIB-ENET
The primary task in configuring your GPIB-ENET is assigning it an IP address. The TCP/IP protocol requires that each device on the network be assigned a unique internet address so that the devices can be located on the network. In general, you should contact you network administrator to obtain a valid IP address for your network. An invalid or improperly assigned IP address is the most common cause for problems when using the GPIB-ENET.

There are two ways to assign an IP address. You can manually configure the IP address using the configuration software provided with the GPIB-ENET; or you can use the Ethernet Reverse Address Resolution Protocol (RARP) facility provided by your network to automatically assign the GPIB-ENET an IP address. Again, contact your network administrator to verify which method would be appropriate for you.

Each applicable platform has specific instructions for proper GPIB-ENET installation. For example, configuration under Sun workstations is accomplished differently when compared to Windows NT because of differences in the operating system interface. Be sure to follow the complete instructions outlined in the Getting Started manual for complete, correct installation.



Configuring NI-488.2 Software for GPIB-ENET
Once you have assigned an IP address to your GPIB-ENET and connected it to your network, any computer with the NI-488.2 software for GPIB-ENET can interface with the controller.

A single computer can be set up to control several GPIB-ENETs for integrating multiple test systems into one application. You can also configure any number of computers to control a single GPIB-ENET for sharing access to instrumentation.

On each computer, you must configure the NI-488.2 software to associate a particular IP address with a particular interface name that correspond to a GPIB-ENET. Then, you can use that interface name in your programs to control the GPIB-ENET at that IP address. For example, assume you want to use Computer A to control two GPIB-ENETs, one at IP address 130.164.15.01 and the other at 130.164.15.19. On Computer A, you would associate 130.164.15.01 with interface name GPIB0, and 130.164.15.19 with GPIB1. Your applications on Computer A would then use the interface name GPIB0 to control instruments attached to the GPIB-ENET at IP address 130.164.15.01 and GPIB1 to control instruments attached to the GPIB-ENET at IP address 130.164.15.19.

Suppose you also wanted to access the GPIB-ENET at 130.164.15.01 from Computer B. You would then associate GPIB0 on computer B with 130.164.15.01, and use GPIB0 in your applications on Computer B. There is no conflict in using the same interface name GPIB0 on Computer A and Computer B because these are completely separate host computers running different instances of the NI-488.2 software. Application Example III provides details on how to write programs that cooperatively share a given GPIB-ENET among several computers.

Back to Top

4. Application Example 1 -- Controlling Several Instruments from a Single ComputerApplication



Figure 3. A Networked Computer Using a Single GPIB-ENET to Control a Remote Set of GPIB Instruments.


For our first example, consider the situation detailed in Figure 3, in which we wish to control two GPIB devices in a manufacturing facility from a Windows NT workstation in the corporate office. The devices are a multimeter at primary address 2 and an oscilloscope at primary address 21.

The following code can be used to gather information from the two instruments using a C programming environment. This code assumes that we have configured the driver to associate the interface name GPIB0 with the IP address of the GPIB-ENET connected to the two instruments. All C applications that call the NI-488.2 driver must include a header file and must link in an object. For this example, we will suppose that we are on the Windows NT platform. So, as you can see below, we must include decl-32.h from the driver directory. Lastly, for the code below to work with the NT driver, the 32-bit object file Gpib-32.obj must be linked into the project. For more details on using the language interface files specific to your platform, see the documentation included with your NI-488.2 driver software.

#include "c:\gpib-nt\langint\C\decl-32.h"

//Please note that the code below is to be used as example code and may require small
//changes to work with different C compilers. Please pay special attention to the
//#include statements, the project type, and the method of linking in the language
//interface object for the NI-488.2 driver. Also, as a method to comment out the
//remainder of a line may not be recognized by your compiler.

#include <stdio.h>
#include <ansi_c.h>

void GPIB_Error(char *source);
int Initialize_GPIBENET_Controller(char *interface_name, int padd);
int Open_Device(int board, int padd, int sadd, int timeout, int EOI, int EOS);
void Close_Handles(void);

int enet_controller[100], num_controllers=0, device[1024], num_devices=0;
char buffer[101];//Make the buffer 1 char longer than longest expected read.

void main()
{
int mmeter, scope;

Initialize_GPIBENET_Controller("GPIB0", 0);

mmeter = Open_Device (0, 2, 0, 13, 1, 0);
//Use GPIB0 to access the GPIB device at primary Address 2, secondary address none, using
//10 second I/O time out, using EOI termination, and no special EOS byte for termination.
scope = Open_Device (0, 21, 0, 13, 1, 0);
//Same as above but device at primary address 21.

ibwrt (mmeter, "*idn?", 5);
//This causes the GPIB-ENET to send *idn? to
GPIB_Error ("ibwrt mmeter"); //the device at primary address 2. *idn? is
//a command that all IEEE 488.2 compliant
//devices understand.
ibrd (mmeter, buffer, 100); //This causes the GPIB-ENET to read back any
GPIB_Error ("ibrd mmeter"); //data that the device at primary address 2 may
//have ready, up to 100 bytes.
buffer[ibcnt] = 0; //ibcnt is a global variable that stores the
//number of bytes read back or sent out by the
//most recent ibrd or ibwrt. We use it here to
//null terminate the buffer which holds the data
//we read back.
printf ("%s\n\n", buffer); //Print the identification string read from
//device at primary address 2 to the screen.
ibwrt (scope, "meas: dc?", 9); //Send meas: dc? to the device at primary
//address 21. meas: dc? is a command that SCPI
//compliant devices understand. it causes the
GPIB_Error ("ibwrt scope"); //instrument to take a DC voltage measurement
//and prepare to send it back.
ibrd (scope, buffer, 25); //Read back up to 25 bytes
GPIB_Error ("ibrd scope");
buffer[ibcnt] = 0;

printf("%s\n\n\n", buffer); //By default most instruments will return
//measurement values in spelled out form so we
//can directly print the number to the screen.
Close_Handles();
} //end main

int Initialize_GPIBENET_Controller(char *interface_name, int padd)
{
enet_controller[num_controllers] = ibfind (interface_name);
GPIB_Error ("ibfind");

num_controllers++;

ibrsc (enet_controller[num_controllers-1], 1);   //Insure that GPIB-ENET is configured to
GPIB_Error ("ibrsc"); //be system controller.

ibpad (enet_controller[num_controllers-1], padd);//Insure that GPIB-ENET is configured
//to be at primary address padd.
GPIB_Error ("ibpad")
ibsic (enet_controller[num_controllers-1]);//Clear the GPIB bus and make the GPIB
GPIB_Error ("ibsic"); //ENET the Controller in Charge

ibsre (enet_controller[num_controllers-1], 1);//Raise the Remote Enable line on
GPIB_Error ("ibsre"); //the GPIB bus

return enet_controller[num_controllers-1]; //end initialize

int Open_Device(int board, int padd, int sadd, int timeout, int EOI, int EOS)
{
device[num_devices] = ibdev(board, padd, sadd, timeout, EOI, EOS);
GPIB_Error("ibdev");

num_devices++;

return device[num_devices-1] //end Open Device

void Close_Handles (void)
{
int index;

for (index=0; index<num_devices; index++)
{
ibonl (device[index], 0); //This removes the entry from a table in
//memory maintained by the driver.
}

for (index=0; index<num_controllers; index++)
{
ibonl (enet_controller[index], 0); //This removes the entry from a table in
//memory maintained by the driver.
}

} //end Close Handles

void GPIB_Error(char *source)
{
if (ibsta&ERR) //If an error occurred in the last call to
//the GPIB driver, print to screen and exit
//gracefully.
{
printf ("error %d occurred during", iberr);
printf(" %s.\n", source);
printf("ibsta = %x, ibcnt = %d\n", ibsta, ibcnt);
printf("num_controllers: %d, num_devices: %d\n", num_controllers, num_devices);

Close_Handles(); //Closes handles
exit(1); //Exits program
}
}

Remember that this code will work on any GPIB-ENET-compatible platform, not just Windows NT. The only change needed when porting this code is possibly which header file to include and which object file to link in. Note also that this code is written so that it can be expanded upon in the example applications to follow.

Back to Top

5. Example 2 -- Integrating Two or More GPIB Test Systems into a Single Application



Figure 4. A Networked Computer and GPIB-ENET Interfaces Control Scattered Sets of Instruments


For our second example, consider the situation detailed in Figure 4, in which we wish to control four GPIB devices two in a laboratory at the corporate offices. They all will be controlled by a computer running Windows 95 in the corporate office. The devices are a multimeter at primary address 2, an oscilloscope at primary address 21, a function generator at address 5, and a network analyzer at address 2.

The following code can be used to gather information from the four instruments using a C programming environment. This code assumes that we have configured the driver to associate the interface name GPIB0 with the IP address of the GPIB-ENET(1) and GPIB1 with the IP address of the GPIB-ENET(2) and that the driver has been installed on a Windows 95 workstation in a directory called c:\gpib95. For the Windows 95 platform, one must include the header file “decl-32.h” in the program code. Also, the 32-bit object file Gpib-32.obj must be included with the project in order to link to the GPIB function calls used.



#include "c:\gpib95\langint\C\Decl-32.h"
//Please note that the code below is to be used as example code and may require small
//changes to work with different C compilers. Please pay special attention to the
//#include statements, the project type, and the method of linking in the language
//interface object for the NI-488.2 driver. Also, as a method to comment out the
//remainder of a line may not be recognized by your compiler.

#include <stdio.h>
#include <ansi_c.h>
void GPIB_Error(char *source); //See Example I for def.
int Initialize_GPIBENET_Controller(char *interface_name, int padd); //See Example I for
//def.
int Open_Device(int board, int padd, int sadd, int timeout, int EOI, int EOS); //See
//Example I for def.
void Close_Handles(void); //See Example I for def.

int enet_controller[100], num_controllers=0, device[1024], num_devices=0;
char buffer[101]; //Make the buffer 1 char longer than longest
//expected read.

void main()
{
int mmeter, scope, funcgen, analyzer;

Initialize_GPIBENET_Controller("GPIB0", 0);//Note that each GPIB-ENET runs its
Initialize_GPIBENET_Controller("GPIB1", 0);//  own separate GPIB bus.

mmeter = Open_Device (0, 2, 0, 13, 1, 0);  //These two instruments will be controlled
scope = Open_Device (0, 21, 0, 13, 1, 0);  //by GPIB0 (ENET #1 in Fig. 5).
//  Remember that we associate GPIB0 with
//  ENET #1 in the NI-488.2 configuration.

funcgen = Open_Device (1, 5, 0, 13, 1, 0); //These two instruments will be controlled
analyzer = Open_Device (1, 2, 0, 13, 1, 0);//by GPIB1 (ENET #2 in Fig. 5).

ibwrt (mmeter, "*idn?", 5); //Note that this code has not changed from
GPIB_Error ("ibwrt mmeter"); //Example I.
ibrd (mmeter, buffer, 100); //|
GPIB_Error ("ibrd mmeter"); //|
buffer[ibcnt] = 0; //|
printf ("%s\n\n", buffer); //|
//|
ibwrt (scope, "meas: dc?", 9); //|
GPIB_Error ("ibwrt scope"); //|
ibrd (scope, buffer, 25); //|
GPIB_Error ("ibrd scope"); //|
buffer[ibcnt] = 0; //|
printf("%s\n\n\n", buffer); //|

ibwrt (funcgen, "SOUR:FUNC?", 10); //Note here that this code is also identical
GPIB_Error ("ibwrt funcgen"); //to the code in Example I. The only
ibrd (funcgen, buffer, 25); //difference is in the commands being sent
GPIB_Error ("ibrd funcgen"); //to the different instruments.
buffer[ibcnt] = 0; //|
printf("%s\n\n", buffer); //|
//|
ibwrt (analyzer, "SOUR:FUNC SIN; SENS:DATA?", 25);//|
GPIB_Error ("ibwrt analyzer"); //|
ibrd (analyzer, buffer, 100); //|
GPIB_Error ("ibrd analyzer"); //|
buffer[ibcnt] = 0; //|
printf("%s\n\n", buffer); //|

Close_Handles();
}

Back to Top

6. Application Example 3 -- Sharing Instruments Resources Between Several Users



Figure 5. Two Networked Computers Share a Single GPIB-ENET


For our third example, consider the situation detailed in Figure 5, in which two workstations located in different facilities need access to the same set of GPIB instruments – an oscilloscpe at primary address 21 and a multimeter at primary address 2. For this example, we tackle the case where a GPIB-ENET is controlled by two or more computers.

No special configuration is performed on the GPIB-ENET for more than one computer to use it. Any computer with the GPIB-ENET driver and a network connection can send commands to a particular GPIB-ENET. If the GPIB-ENET is working on a command from one computer when a second command from another computer arrives, the second command is queued and executed after the first command is completed. With that procedure, commands may be delayed slightly, but the operation is otherwise transparent to several programs accessing the same GPIB-ENET.

It is possible, however, for one computer to lock the GPIB-ENET or an instrument connected to the GPIB-ENET so that other computers cannot use it. This ability to lock the GPIB-ENET can be useful for security purposes and in preventing command or data crossover. For example, with no locking, if two computers use the same GPIB-ENET to gather data from the same instrument, Computer A may send a command to the instrument and before it can read back data, Computer B may send a different command to the instrument. This may cause the instrument to go into an error state, or Computer A may read back data from a different command query. With locking, Computer A first locks the instrument; sends a command and reads back the data; and then unlocks the computer. During the time that Computer A has locked the instrument, no other computer can access that instrument through that GPIB-ENET. Computer A can also lock the GPIB-ENET itself, so that the GPIB-ENET ignores commands from other computers.

For this example, we will examine the case where two or more computers on the network access the same two instruments connected to one GPIB-ENET. The example code below is the code used on each computer accessing the GPIB-ENET. So, for our application example detailed in Figure 6, both computers will run the code below.

Note: This exercise uses the functions iblockx and ibunlockx to perform resource locking. When using iblockx and ibunlockx the firmware for the GPIB-ENET must be revision A.5 or greater. Before using the code detailed below, please check the firmware of your GPIB-ENET in the following manner:

  1. Make sure the driver software (NI-488.2) for the GPIB-ENET is installed and the GPIB-ENET is correctly configured as a device on the network.
  2. Start the interactive control utility (IBIC, Win32 Interactive Control, VisualGPIB, etc.) provided with the driver software.
  3. Type in the following commands at the ‘:’ prompt: ibfind gpib0 (assuming that the GPIB-ENET in question is “gpib0”) ibdiag 256 (now, read the firmware revision returned) ibonl 0 (take gpib0 offline) q (quit the utility after you’ve read the firmware revision)


If the firmware is earlier than A.5, use the firmware update utility to upgrade the GPIB-ENET firmware. If you do not have a file for firmware A.5 or greater, or you are not comfortable updating the GPIB-ENET firmware, please contact National Instruments technical support.

Iblockx and ibunlockx are enhancements to the existing functions iblock and ibunlock and are currently only available on Win32 platforms. They will also migrate to other GPIB-ENET platforms. If you anticipate running your applications on different platforms in the near future, use the iblock and ibunlock functions because they are still compatible. These functions are fully documented in the readme files you receive with your GPIB-ENET software.

#include "sys/ugpib.h" //This is the include file that comes with the
//GPIB-ENET driver for Solaris 1.
//For this example, assuming we are
//programming on a Solaris 1 machine, we
//would use this include file and link in the
//file cib.o to the project.
//Please note that the code below is to be used as example code and may require small
//changes to work with different C compilers. Please pay special attention to the
//#include statements, the project type, and the method of linking in the language
//interface object for the NI-488.2 driver. Also, as a method to comment out the
//remainder of a line may not be recognized by your compiler.

#define MAX_RETRIES 100

void GPIB_Error(char *source);
int Initialize_GPIBENET_Controller(char *interface_name, int padd);//See Example I for
//def.
int Open_Device(int board, int padd, int sadd, int timeout, int EOI, int EOS);//See
//Example I for def.
void Query_Device(int dev_handle, char *command_string, char *buffer, int read_size);
void Close_Handles(void);
int enet_controller[100], num_controllers=0, device[1024], num_devices=0;
char buffer[101]; //Make the buffer 1 char longer than longest
//expected read.

void main ()
{
int mmeter, scope;

Initialize_GPIBENET_Controller ("GPIB0", 0);

mmeter = Open_Device (0, 2, 0, 13, 1, 0);
scope = Open_Device (1, 23, 0, 13, 1, 0);

Query_Device (mmeter, "*idn?", buffer, 100);
printf ("%s\n\n", buffer);

Query_Device (scope, "meas: dc?", buffer, 25);
printf ("%s\n\n\n", buffer);

Close_Handles ();
}

void Query_Device (int dev_handle, char *command_string, char *buffer, int read_size)
{
int retries=0, success=0;

while ( (retries<=MAX_RETRIES) && (!success) )
{
iblockx(dev_handle, TIMMEDIATE, "Locked device");
//Lock only the instrument we're accessing
//TIMMEDIATE indicates we do not want to wait
for the resource to become available
//Other values will cause the iblockx function
//to continously attempt to lock the
//interface for a specified amount of time.
GPIB_Error("iblockx");
if (ibsta&ERR)
{
retries++;
//Here you can put a delay if you have a
//function which waits without tying up the
//processor.
}
else
success=1;
}

if (success)
{
ibwrt (dev_handle, command_string, strlen(command_string));
GPIB_Error ("ibwrt");

ibrd (dev_handle, buffer, read_size);
GPIB_Error ("ibrd");


buffer[ibcnt]=0;

ibunlockx(dev_handle);
GPIB_Error("ibunlockx");
}
else
{
printf ("Unable to lock instrument. Write and Read aborted.\n");
buffer[0]=0;
}
}

void Close_Handles (void)
{
int index;

for (index=0; index<num_devices; index++)
{
ibunlockx(device[index]); //In case we exit while locked.

mmeter = Open_Device (0, 2, 0, 13, 1, 0);
scope = Open_Device (1, 23, 0, 13, 1, 0);

Query_Device (mmeter, "*idn?", buffer, 100);
printf ("%s\n\n", buffer);

Query_Device (scope, "meas: dc?", buffer, 25);
printf ("%s\n\n\n", buffer);

Close_Handles ();
}

void Query_Device (int dev_handle, char *command_string, char *buffer, int read_size)
{
int retries=0, success=0;

while ( (retries<=MAX_RETRIES) && (!success) )
{
iblockx(dev_handle, TIMMEDIATE, "Locked device");
//Lock only the instrument we're accessing
//TIMMEDIATE indicates we do not want to wait
for the resource to become available
//Other values will cause the iblockx function
//to continously attempt to lock the
//interface for a specified amount of time.
GPIB_Error("iblockx");
if (ibsta&ERR)
{
retries++;
//Here you can put a delay if you have a
//function which waits without tying up the
//processor.
}
else
success=1;
}

if (success)
{
ibwrt (dev_handle, command_string, strlen(command_string));
GPIB_Error ("ibwrt");

ibrd (dev_handle, buffer, read_size);
GPIB_Error ("ibrd");

buffer[ibcnt]=0;

ibunlockx(dev_handle);
GPIB_Error("ibunlockx");
}
else
{
printf ("Unable to lock instrument. Write and Read aborted.\n");
buffer[0]=0;
}
}

void Close_Handles (void)
{
int index;

for (index=0; index<num_devices; index++)
{
ibunlockx(device[index]); //In case we exit while locked.
ibonl (device[index], 0); //This removes the entry from a table in memory
//maintained by the driver.
}

for (index=0; index<num_controllers; index++)
{
ibonl (enet_controller[index], 0); //This removes the entry from a table in memory
//maintained by the driver.
}

} //end Close Handles


void GPIB_Error (char *source)
{
if ( (ibsta&ERR) && (!(iberr==ELCK)) ) //If a non-lock related error occurred in the
//last call to the GPIB driver, print to screen
//and exit gracefully.
{
printf ("error %d occurred during", iberr);
printf(" %s.\n", source);
printf("ibsta = %x, ibcnt = %d\n", ibsta, ibcnt);
printf("num_controllers: %d, num_devices: %d\n", num_controllers, num_devices);
Close_Handles(); //Closes handles
exit(1); //Exits program
}
}

Back to Top

7. Summary


The application examples detailed above are compact, and yet they represent all of the structures necessary to implement a large or small GPIB control system. The fact that Example I and Example II share virtually identical code shows how easily one networked computer can be programmed to control practically unlimited numbers of GPIB instruments. And, with minor adjustments, as shown in Example III, many computers can share control of the same pool of GPIB instruments.

The GPIB-ENET Ethernet-to-GPIB controller and networked computers can place your GPIB test systems on-line so that your managers, test engineers, and technicians have quick and easy access to your GPIB instrumentation. Using server applications to manage each GPIB test system, you can selectively integrate different test stations into a single application or give key people remote access to the test system to view test data, perform maintenance-related tasks, or perform control and monitoring-related tasks that are necessary to fine tune, monitor, and maintain the productivity of the test system.

Back to Top

Bookmark & Share


Ratings

Rate this document

Answered Your Question?
Yes No

Submit