Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Sep 6, 2006


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links - Products and Services

Redirecting Output to Your GPIB Device with DOS or Windows 3 Applications

12 ratings | 3.92 out of 5
Print

Overview


Following the adoption of the ANSI/IEEE Standards 488.1-1987 and 488.2-1987, many manufacturers of non-test and measurement devices discovered the benefits of using the GPIB high-speed, standardized interface. Manufacturers then developed GPIB graphics devices such as scanners, plotters, and film recorders. There are now many GPIB graphics output devices on the market.

Most software packages on the market today can output to either a serial or parallel port on your personal computer, but some software packages cannot output to a GPIB port. If you need to output to a GPIB device and your software does not recognize the GPIB interface, you can redirect your output to your GPIB device using DOS or Windows 3. This technical note explains how to redirect your output to a GPIB device using the National Instruments NI-488.2 software for MS-DOS.

How Output Redirection Works


Output redirection is a method used to direct data to a device other than the one for which it was intended. To output text and data to your GPIB device from a DOS or Windows 3 software package that does not work with the GPIB interface, you must install and configure GPIB.COM, the GPIB driver file. You must configure GPIB.COM so that it contains a device name that works with your DOS or Windows 3 application.

To access a printer on the parallel port of the computer, DOS and Windows 3 (when configured correctly) both use the built-in DOS device driver for LPT1. By reconfiguring the GPIB driver, you can replace the built-in LPT1 driver with the GPIB driver. Since the GPIB driver will appear as LPT1 to DOS and Windows 3, you will not need to make any change to your application. You can also configure the GPIB driver to replace any other built-in device driver that your application uses (such as LPT1, LPT2, PRN, COM1, COM2, and so on).

After reconfiguring the GPIB driver to replace the built-in printer port (PRN), you can redirect data from a DOS prompt by using the > symbol. For example, you can redirect output from a file textfile.doc. The type command outputs data to a computer monitor, but you can direct your data to the printer port using the following command:
    type textfile.doc > prn

    Preparing to Use Output Redirection


Microsoft Windows 3 has capability to access many different output devices using custom-made device driver files. Microsoft offers a variety of device drivers that you can load easily under Windows. MS-DOS applications usually have their own custom drivers for accessing output devices.

Using these custom device drivers, you can redirect your output to a GPIB device. If you want to use output redirection, first consider the following requirements:
  • You must have a National Instruments GPIB board and the NI-488.2 software for MS-DOS installed on your computer. See the getting started manual that came with your NI-488.2 software for complete instructions on installing and testing the software.
  • If your output device contains both a GPIB and a serial/parallel interface, then the command set processed by your output device when configured to use the serial/parallel interface must be the same as the command set processed when configured to use the GPIB interface. Some output devices use different commands depending on when the interface is active.

If your system meets these requirements, you can reconfigure your NI-488.2 software so that a device defined in the GPIB driver is treated as an LPT, COM, or PRN interface. If you are running Windows 3, you will also need to configure Windows to use MS-DOS when printing.

The following sections describe the steps for using output redirection with both DOS and Windows 3.

Output Redirection Steps for DOS



1. Rename the GPIB Device Driver
To configure one of your GPIB devices as a DOS LPT, COM, or PRN port, you must rename one of the GPIB driver devices using the IBCONF utility program. The following steps describe the procedure in detail.

A. Start the GPIB configuration utility IBCONF which comes with the National Instruments NI-488.2 software. Enter the following command at the DOS prompt, while in your GPIB distribution directory (C:\AT-GPIB, for example):
    ibconf

B. When you see the screen with the National Instruments logo, press any key to go to the device map for the driver.

C. Scroll down to one of the devices that you want to rename by pressing the appropriate arrow keys. For example, if your plotter is set to GPIB Primary Address 4, then you should rename DEV4, which is assigned address 4 by default.

D. After you have scrolled down to the appropriate device, press the <F4> key. Then you can rename DEV4 by typing in a new device name. You must choose one of the following names:
    COM1, COM2, COM3, COM4, LPT1, LPT2, LPT3, PRN
    As a general rule, do not assign a name of a port that is already used. For example, if you already have a printer physically connected to your LPT1 port and a mouse connected to COM1, then do not use LPT1 or COM1 as a device name for your plotter. You might want to rename DEV4 as LPT2, as shown in Figure 1.

E. After you type the device name, press the <Enter> key to register your change.

[+] Enlarge Image
Figure 1. Renaming Your Output Device in IBCONF

2. Enable Repeat Addressing
Some GPIB output devices require repeat addressing after each I/O call. This is usually true for plotters. Follow these steps while you are still in IBCONF to enable repeat addressing for your output device. If you do not need to use repeat addressing, skip to step 3. Save Your New Configuration.

A. Press <F8> while the renamed device is still highlighted.

B. Scroll down to the bottom of the parameter settings window to the Enable Repeat Addressing option.

C. Change the setting from No to Yes by pressing the left or right arrow key, as shown in Figure 2.

D. Press <F9> to return to the device map screen for the driver.

[+] Enlarge Image
Figure 2. Enabling Repeat Addressing in IBCONF

3. Save Your New Configuration

A. Now that you have configured your GPIB driver correctly, you are ready to exit from IBCONF. To save the changes in GPIB.COM and exit IBCONF, press <F9> and respond to the first question Save changes back to disk? with Yes. If you are prompted with a second question such as Update the handler that is loaded in memory? respond No.

B. Since you renamed one of your GPIB devices to coincide with a standard DOS device name, you must reboot your computer for the change to take effect.

Examples of Printing to Your GPIB Output Device from DOS



Printing from the DOS Prompt
If you want to print to your GPIB printing device from a DOS prompt, use either the copy or type command at the DOS prompt as follows:

     copy drive:filename.ext  port_name
or
     type drive:filename.ext > port_name

where port_name is the device name that you have assigned to your GPIB output device (for example LPT2, COM2, and so on). Your output command might look like one of the following lines:

     copy c:textfile.doc LPT2
or
     type c:textfile.doc > LPT2

Printing from Your Own DOS Program
You can also print to a GPIB output device from a program that you have created. The program can be written in BASIC, C, or whatever programming language you have. The following examples could be part of any QuickBASIC program.

     LPRINT "Parallel Port redirection successful!"

or

     OPEN "LPT1" for output as #1
     PRINT #1, "Port redirection complete!"

or

     OPEN "COM1:9600,0,7,1, ASC" for output as #3
     PRINT #3, "Port redirection, easy to use!"

Printing from a DOS Software Package
If you want to output to your GPIB device from a DOS application, you must specify in your application the port where you assigned your GPIB printing device. For example, if you set your GPIB printing device as LPT2, configure your application program to print to LPT2. The configuration methods vary with different software packages.

Output Redirection for Windows 3



The task of configuring printing devices is standard for all Windows 3 applications. To assign a GPIB output device to a certain output port, you must configure your printer driver from the Windows control panel. If you are using Windows 3.0, skip to the Redirection Steps for Windows 3.0 section. The following steps are for Windows 3.1.

Redirection Steps for Windows 3.1
1. Set up the NI-488.2 software to redirect to a serial or parallel port, and configure for Repeat Addressing if necessary. Use the same procedure as described in Output Redirection Steps for DOS, steps 1 through 3.

2. Start Microsoft Windows.

3. Open the Program Manager and find the Control Panel, located in the Main program group.

4. Select Printers.

5. To install the printer driver for your printing device, click on the Add>> button. A pull-down list appears at the bottom of the window, giving you a choice of printer drivers you can install, as shown in Figure 3. At this point, have your Microsoft Windows distribution disks or your special printer driver disk ready.

[+] Enlarge Image
Figure 3. Installing Printer Drivers in Windows 3.1

6. Select your printing device by scrolling down the list. Once you find it, either single-click on it and click on the Install... button, or double-click on the printing device name. Windows installs the selected printer driver, if it is not already loaded.

7. The printing driver that you loaded now appears in the list box called Installed Printers. Find your printer driver, click on it, and then click on the Connect button.

8. A list box showing available ports appears on your screen. Choose the port that corresponds to the built-in DOS device name that you configured in the GPIB driver. For example, if you used IBCONF to rename DEV1 to LPT2, then select LPT2 from the list of ports.

9. Be sure that the Fast Printing Direct to Port option is not checked. When this option is checked, Windows bypasses DOS and directly accesses the selected port. Since the GPIB driver must replace the built-in DOS port driver, Windows should not try to access the port directly.

10. Click on the OK button to close the Connect window, and click on Close to exit the Printers control panel window.

This newly installed printer driver is now available to your Windows 3.1 application programs.

Redirection Steps for Windows 3.0
If you are running Windows 3.0, use the following steps:

1. Follow steps 1 through 6 as listed in the Redirection Steps for Windows 3.1 section.

2. The printer driver that you loaded now appears in the list box called Installed Printers. Find your printer driver, click on it, and then click on the Configure button.

3. Windows brings up a list box with the available Ports listed. Choose the port with a .OS2 extension that corresponds to the DOS device name that you configured in the GPIB driver. For example, if you used IBCONF to rename DEV1 to LPT2, then select the port LPT2.OS2 from the list box.

Note: While it is possible to specify other ports with a .OS2 extension (by manually editing your WIN.INI file), Windows 3.0 is preconfigured to work only with LPT1.OS2 and LPT2.OS2. For simplicity you should use one of these two ports when setting up printer redirection under Windows 3.0.

4. Click on the OK button to close the Connect window and click on Close to exit the Printers control panel window.

This newly installed printer driver is now available to your Windows 3.0 application programs.

Summary



If you need to output to a GPIB device from an application that does not recognize the GPIB interface, you can reconfigure your NI-488.2 software for MS-DOS so that the application prints to the GPIB device as if it were connected to a standard port on your computer. By reconfiguring Windows 3 to use MS-DOS when accessing an output device, you can also redirect data to a GPIB device when using Windows applications.
12 ratings | 3.92 out of 5
Print

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/).