Developing GPIB Applications for GPIB-232CT-A in Windows NT/9x
Overview
In the past, you could only develop Win32 GPIB applications for the GPIB-232CT-A interface by using the NI-488.2 driver software for Windows 3 along with the Compatibility Release. Also, you could not develop applications for the GPIB-232CT-A in Windows NT.
Now you can develop GPIB applications for the GPIB-232CT-A in Windows NT/9x using the Win32 Board-level NI-488.2 Software for the GPIB-232CT-A and Windows 2000/NT/98/95. Please do not confuse this software with the standard 32-bit NI-488.2 driver software. The board-level NI-488.2 software (also known as the 232 Driver Development Kit or 232DDK) is a subset of the board-level functions in the standard 32-bit NI-488.2 driver. This document describes how to use the board-level NI-488.2 software to develop a Win32 application for the GPIB-232CT-A interface. For more information about the board-level NI-488.2 software, please refer to the comments in the C source code. To download the C source code, refer to the last section in this document.
Table of Contents
Overview of the Board-level NI-488.2 Software
The board-level NI-488.2 software consists of three layers: NI-488.2 calls, GPIB-232CT-A calls, and serial calls. The following diagram shows these layers.
Figure 1.
The top layer, NI-488.2 calls, contains the NI-488.2 API calls as found in the ni488.c file.
The next layer, GPIB-232CT-A calls, isolates the serial I/O calls from the NI-488.2 API calls. These calls are located in the cta.c file. At this layer, calls are also made to retrieve the configuration settings stored in the initialization file, gpib.ini. An initialization file is a text file that contains system configuration data. The gpibini.c file contains the calls that are used to access the settings stored in gpib.ini.
The bottom layer, serial calls, has the low-level serial I/O calls that are specific to Windows NT/9x. These calls can be found in the serial.c file.
You can configure the board-level NI-488.2 software to communicate with up to four GPIB interfaces.
Available NI-488.2 Calls
Available NI-488.2 API calls include the following:
- ibcac
- ibcmd
- ibeos
- ibeot
- ibfind
- ibgts
- ibist
- iblines
- ibln
- ibloc
- ibonl
- ibpad
- ibppc
- ibrd
- ibrpp
- ibrsc
- ibrsv
- ibsad
- ibsic
- ibsre
- ibtmo
- ibwait
- ibwrt
Using the Serial Port to Remotely Control GPIB Instruments
To use the computer serial port to remotely control GPIB instruments, you need to configure the GPIB-232CT-A in S-Mode. In this mode, the GPIB-232CT-A functions as a GPIB system controller, performing the various tasks required in managing a network of GPIB instruments. These tasks include addressing Talkers and Listeners on the bus, managing transfers across the bus, and managing requests for service by various devices on the GPIB. For instructions on how to set your GPIB-232CT-A to operate in S mode, refer to the GPIB-232/485CT-A User Manual.
See Also:
GPIB-232/485CT-A User Manual
Writing Your Win32 GPIB Application
Your Win32 application can be either a graphical user interface (GUI) application or a console application.
Item(s) to Include in Your Application
In your Win32 NI-488.2 application, make sure you have included the following header file at the beginning of your application:
#include "NI488.h"
This header file contains the necessary definitions, global variables, and function prototypes.
Compiling and Linking Your Application
From the standard DOS shell command line, you can compile and link your application with the board-level NI-488.2 software. The examples below illustrate how to compile and link a console application with the board-level NI-488.2 software.
To compile and link a console application called yourprog.c with the board-level NI-488.2 software, using Microsoft Visual C++ (version 2.0 or higher), type in:
cl yourprog.c ni488.c cta.c serial.c gpibini.c
To compile and link a console application called yourprog.c with the board-level NI-488.2 software, using Borland C/C++ (version 4.0 or higher), type in:
bcc32 -w32 yourprog.c ni488.c cta.c serial.c gpibini.c
Running Your Application
To run the application from the DOS shell, just type in the executable name at the prompt. To run it from within Windows, choose the Run option from the Start menu. Enter the name of the compiled program in the dialog box that pops up.
Expanding the Board-level NI-488.2 Software
The board-level NI-488.2 software can be easily customized by users familiar with serial device driver development. To add functions, you need to modify the NI488.c file which contains the NI-488.2 API function calls and the NI488.h header file, which contains the necessary definitions, global variables, and function prototypes. Please refer to your NI-488.2 Function Reference Manual for DOS/Windows for information about the NI-488.2 function prototypes. For information on programming the GPIB-232/485CT-A in S mode, please refer to the Programming in S Mode and S Mode Function chapters in the GPIB-232/485CT-A User Manual.
Porting the Board-level NI-488.2 Software
When developing an application for another operating system, you can use the GPIB.ini and GPIBini.c files as templates for storing and reading system configuration data particular to your operating system. The board-level NI-488.2 software for Windows NT/9x uses an initialization file, GPIB.ini. An initialization file is a text file that contains system configuration data. INI files are partitioned into sections and marked by bracketed strings called section names. Within each section, keys are stored. A key is a named configuration setting that can be read or set programmatically. A key consists of a key name, an equal sign, and the key value. For example, the setting for the Primary Address (PAD) for GPIB0 would look like so Pad = 0. Functions within the CTA.c file call functions contained in the GPIBini.c file. The GPIBini.c is used to retrieve the configuration information that is stored in the GPIB.ini file.
The Serial.c file contains the low-level serial input/output (I/O) functions called Serial_Initialize, Serial_Write, Serial_Read, Serial_BytesAtPort, Serial_Error, and Serial_Close. These functions make standard low-level RS-232 calls to perform operations such as open a port, read/write, and close a port. When porting the software to another operating system, the Win32-specific calls that talk to a serial port would need to be substituted for the equivalent operating system specific calls to a serial port on the target operating system. The table below lists the Win32-specific calls that are made from the above-mentioned serial functions.
|
Win32 Call
|
Serial Function
|
Description
|
| CreateFile | Serial_Initialize | Open a serial communications port |
| GetCommState | Serial_Initialize | Get the current settings of the serial port |
| SetCommState | Serial_Initialize | Change the serial port settings (for example baud rate and parity) |
| ReadFile | Serial_Read | Read from the serial port |
| WriteFile | Serial_Write | Write to the serial port |
| ClearCommError | Serial_BytesAtPort | Retrieves information about the current status of the serial port, clears the serial port error flag, and enables additional I/O operations |
| GetLastError | Serial_Error | Retrieve current status of the serial port |
| CloseHandle | Serial_Close | Close the serial port handle |
There are also some Win32 specific definitions in the NI488.h and Serial.c files that would need to be modified for the target operating system. Please refer to the comments in the C source code in those two files for more information about which definitions are Win32 specific.
Board-level NI-488.2 Software and Sample GPIB Application
We have placed the C source code for the board-level NI-488.2 software and a sample application on the National Instruments FTP site (linked below).
See Also:
(FTP) Direct Link to Sample Code
Related Links:
GPIB-232/485CT-A User Manual
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
