Page 4
Using the NI GPIB-Serial Converter Wizard ........30 Launching the NI GPIB-Serial Converter Wizard ......31 Connecting the GPIB-RS232/485/422 .
Page 5
NI GPIB-Serial Converter Help Over GPIB ............. . . 58 GPIB Initialization Code Using VISA .
Page 6
NI GPIB-Serial Converter Help ln ..............92 loc .
Page 7
NI GPIB-Serial Converter Help Serial Port Transmission ..........144 Operation of the GPIB-RS232/485/422 as a GPIB Device .
Page 8
NI GPIB-Serial Converter Help Timeout Termination Mode ......... 173 <CR>...
Page 9
Warning Regarding the Use of NI Products ....... . .
Page 10
NI GPIB-Serial Converter Help NI GPIB-Serial Converter Help September 2006, 371951A-01 The NI GPIB-Serial Converter Help describes the features, functions, and operation of the GPIB-RS232/485/422. This help assumes you have a general knowledge of RS232, RS485, or RS422 serial communications and the GPIB.
Page 11
NI GPIB-Serial Converter Help • EIA-422-A, Electrical Characteristics of Balanced Voltage Digital Interface Circuits • ANSI/IEEE Standard 488.1-1987, IEEE Standard Digital Interface for Programmable Instrumentation • ANSI/IEEE Standard 488.2-1992, IEEE Standard Codes, Formats, Protocols, and Common Commands Using Help Conventions...
Page 12
NI GPIB-Serial Converter Help IEEE 488 IEEE 488 and IEEE 488.2 refer to the ANSI/IEEE Standard 488.1-1987 IEEE 488.2 and ANSI/IEEE Standard 488.2-1992, respectively, which define the GPIB. IEEE 488.2 Italic text denotes variables, emphasis, cross–references, or an introduction to a key italic concept.
Page 13
NI GPIB-Serial Converter Help terms on the Search tab allows you to quickly locate specific information and information in topics that are not included on the Contents tab. Wildcards Wildcards You also can search using asterisk (*) or question mark (?) wildcards. Use the asterisk wildcard to return topics that contain a certain string.
Page 14
NI GPIB-Serial Converter Help • Search previous results—Narrows the results from a search that returned too many topics. You must remove the checkmark from this checkbox to search all topics. • Match similar words—Broadens a search to return topics that contain words similar to the search terms.
Page 15
RS232 Connector RS485 Connector GPIB Connector What You Need to Get Started Before you install your NI GPIB-Serial Converter hardware, be sure you have the following items: • One of the following controllers, which is included in your kit: ◦ GPIB-RS232 ◦...
Page 16
NI GPIB-Serial Converter Help The GPIB-RS232 has all the software and logic required to implement the physical and electrical specifications of the IEEE 488 and RS232 standards. It can interpret and execute high-level commands you send to it over the serial port, performing GPIB-to- RS232 protocol conversions.
Page 17
NI GPIB-Serial Converter Help describes each LED. Indication Indicates that power to the unit has been applied and the ON/OFF switch is in the ON position. Indicates that the power-on self-test has passed successfully, and the unit is ready to operate.
Page 18
NI GPIB-Serial Converter Help RS485/RS422 Connector The RS485 port on the GPIB-RS485/RS422 uses a standard 9-pin shielded D- Subminiature male connector with screwlock assemblies. The RS485 connector accepts standard 9-pin D-Subminiature female connectors. The following figure shows the serial connector and the signals supported. For more information about the RS485...
Page 19
NI GPIB-Serial Converter Help screwlock hardware. The following figure shows the GPIB connector and the signals supported. A * suffix indicates the signal is active low. Refer to GPIB Basics for more information about the GPIB signal lines. Modes of Operation The following topics describe the four GPIB-RS232/485/422 modes of operation and help you determine which mode of operation to use.
Page 20
NI GPIB-Serial Converter Help Operating in C Mode Choosing Between Modes Choosing between S Mode and C Mode Choosing between G Mode and D Mode Data Buffering and Serial Flow Control Hardware Handshaking XON/XOFF Software Handshaking Serial Flow Control in S Mode...
Page 21
NI GPIB-Serial Converter Help Refer to Using the NI GPIB-Serial Converter Wizard to Configure the GPIB-RS232/485/ for detailed information about setting up your GPIB-RS232/485/422 to operate in S Mode. Refer to Programming in S Mode S Mode Functions for information about programming the GPIB-RS232/485/422 in S Mode.
Page 22
NI GPIB-Serial Converter Help Refer to Using the NI GPIB-Serial Converter Wizard to Configure the GPIB-RS232/485/ for detailed information about setting up your GPIB-RS232/485/422 to operate in G Mode. Refer to Programming in G Mode G Mode Functions for information about programming in G Mode.
Page 23
NI GPIB-Serial Converter Help Refer to Using the NI GPIB-Serial Converter Wizard to Configure the GPIB-RS232/485/ for detailed information about setting up your GPIB-RS232/485/422 to operate in C mode. Refer to C Mode Overview for information about using C Mode.
Page 24
XON/XOFF software handshaking and the hardware handshaking protocols. Hardware Handshaking The hardware handshake function is configurable using the NI GPIB-Serial Converter Wizard. When Flow Control is set to Hardware, the device enables hardware handshake during serial data transfers and uses the Request to Send (RTS on the GPIB- RS232, RTS+ and RTS–...
Page 25
XON/XOFF handshaking, you can enable the XON/XOFF handshaking protocol by using the NI GPIB-Serial Converter Wizard or the xon command in S Mode and G Mode. This handshaking protocol performs the same...
Page 26
GPIB-RS232/485/422 would handshake erratically. Serial Flow Control in S Mode Use the NI GPIB-Serial Converter Wizard to configure GPIB-RS232/485/422 serial flow control in S Mode. There are three configuration choices, as shown in the following table. You can also modify flow control with the xon and onl commands.
Page 27
Functions. Serial Flow Control in G Mode You cannot configure GPIB-RS232/485/422 serial flow control in G Mode using the NI- Serial Converter Wizard. Instead, it is always set to be hardware handshaking enabled at power-on. However, you can modify flow control with the xon and onl commands, as shown in the following table.
Page 28
NI GPIB-Serial Converter Help following table. ‑ Power-On State (Configured Using the NI GPIB‑Serial Converter Wizard) Hardware handshaking enabled* XON/XOFF enabled* No flow control * Where it does not explicitly say that hardware handshaking or XON/XOFF is enabled or disabled, it is assumed to be disabled.
Page 29
To install the NI GPIB-Serial Converter software, complete the following steps: 1. Log on as Administrator or as a user with administrator privileges. 2. Insert the NI GPIB-Serial Converter Software CD included with your GPIB-RS232 or GPIB-RS485/422 hardware. 3. If the following screen appears, click the Install Software link.
Page 30
NI GPIB-Serial Converter Help 4. If the autorun application does not start, run setup.exe from the CD and follow the onscreen instructions to complete installation. 5. Reboot when prompted at the end of software installation. Connect the Hardware To connect the hardware, complete the following steps: 1.
Page 31
GPIB-RS232/485/422 firmware. Prior to modifying the configuration or updating the firmware, the NI GPIB-Serial Converter Wizard must locate your GPIB-RS232/485/422. The following topics explain basic operation of the NI GPIB-Serial Converter Wizard and locating the GPIB-RS232/485/422.
Page 33
NI GPIB-Serial Converter Help Click Next to continue and proceed to Connecting the GPIB-RS232/485/422. Connecting the GPIB-RS232/485/422 The NI GPIB-Serial Converter Wizard Connect the GPIB-RS232/485/422 screen displays, as shown in the following figure. ni.com...
Page 34
3. Turn the power switch to ON to restart the GPIB-RS232/485/422. The GPIB-RS232/485/422 is now in Configuration mode. Click Next to to have the NI GPIB-Serial Converter Wizard detect serial and GPIB interfaces installed in your computer.
Page 35
Connected. No Interfaces Connected The NI GPIB-Serial Converter Wizard requires at least one serial port or one GPIB interface installed in the computer to configure your hardware. If a serial port or GPIB interface is installed in your computer, ensure that the driver for your hardware is correctly installed and functioning properly.
Page 36
NI GPIB-Serial Converter Help The NI GPIB-Serial Converter Wizard must know which interface you connected to the GPIB-RS232/485/422. First, select whether the GPIB-RS232/485/422 is connected to a serial or GPIB interface by clicking Serial Interface if connected to a serial interface or GPIB Interface if connected to a GPIB interface.
Page 37
NI GPIB-Serial Converter Help If the NI GPIB-Serial Converter Wizard displays the Select Action screen, proceed to Selecting an Action. If there was an error locating the GPIB-RS232/485/422, the Error Locating the GPIB- RS232/485/422 screen is displayed, as shown in the following figure.
Page 38
Error Locating the GPIB-RS232/485/422. If there is an incompatibility with the NI GPIB-Serial Converter Wizard and the firmware running on the GPIB-RS232/485/422, the Incompatible Firmware Version screen is displayed, as shown in the following figure. If the NI GPIB-Serial Converter Wizard appears as shown above, proceed to Incompatible Firmware Version.
Page 39
Hardware Handshaking. Incompatible Firmware Version The NI GPIB-Serial Converter Wizard is not compatible with a newer version of the firmware running on the GPIB-RS232/485/422. Follow these steps to install a newer version of the wizard: 1. Exit the NI GPIB-Serial Converter Wizard.
Page 40
Using the NI GPIB-Serial Converter Wizard to Update the GPIB-RS232/485/422 Firmware Using the NI GPIB-Serial Converter Wizard to Configure the GPIB- RS232/485/422 Before proceeding, the NI GPIB-Serial Converter Wizard must be running and your screen must appear as shown below. Refer to Launching the NI GPIB-Serial Converter Wizard for more details.
Page 41
NI GPIB-Serial Converter Help You must choose which GPIB-RS232/485/422 mode meets your use requirements. Refer to Modes of Operation for a brief overview of the different modes and the differences between them. Refer to the following sections for complete documentation...
Page 42
NI GPIB-Serial Converter Help Configuration of D Mode Configuration of C Mode After selecting the desired configuration settings for the chosen mode, click Next to proceed to Verifying Settings. Configuration of S Mode When the GPIB-RS232/485/422 is configured to operate in S mode, it lets your serial device act as a Controller in the GPIB system, addressing one or more devices, and performing other GPIB Controller functions.
Page 43
NI GPIB-Serial Converter Help • Flow Control—Method used to ensure serial data is not lost. ◦ Hardware—Hardware protocol used for flow control. For more information, refer to Hardware Handshaking. ◦ XonXoff—Software implementation of the flow control protocol. For more information, refer to XON/XOFF Software Handshaking.
Page 44
NI GPIB-Serial Converter Help D Mode requires the user to configure the serial settings used on the serial interface, as well as the GPIB settings used on the GPIB interface. Below is a brief overview of the purpose and effect of the D Mode settings. For more detailed information about the D...
Page 45
NI GPIB-Serial Converter Help GPIB Settings GPIB Settings • Listen Only—GPIB talker and listener or GPIB listener only. All other GPIB settings have no effect if this setting is ON. For detailed information about this setting, refer GPIB-RS232/485/422 Operation in Listen-Only Mode.
Page 46
NI GPIB-Serial Converter Help • Baud Rate—The number of bits transmitted over the serial interface per second (300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, or 115200). • Data Bits—The number of data bits that represent a serial byte.
Page 47
NI GPIB-Serial Converter Help • Termination Mode—The termination algorithm that determines the GPIB-RS232/ 485/422 behavior. For detailed information about this setting, refer to Operating in Mode. ◦ CR—After receiving a '\r' over serial (0x0d) and sending it over GPIB, the GPIB-RS232/485/422 addresses the GPIB device as a talker so that it can send a response to the host.
Page 48
NI GPIB-Serial Converter Help Applying Settings In the following figure, the NI GPIB-Serial Converter Wizard is redetecting the GPIB- RS232/485/422 and issuing commands to update the GPIB-RS232/485/422 configuration. On successful completion, an Update Successful screen appears. Proceed to Using the GPIB-RS232/485/422 after Running the NI GPIB-Serial Converter Wizard.
Page 49
NI GPIB-Serial Converter Help If an error occurred during the configuration update, the There was an error updating the GPIB-RS232/485/422 configuration message displays, as shown in the following figure. If the NI GPIB-Serial Converter Wizard appears as shown above, proceed to Update ni.com...
Page 50
Wizard. If errors persist, recheck the troubleshooting steps above. Using the NI GPIB-Serial Converter Wizard to Update the GPIB- RS232/485/422 Firmware Before proceeding, the NI GPIB-Serial Converter Wizard must be running and your screen must appear as shown below. Refer to Launching the NI GPIB-Serial Converter Wizard for more details.
Page 51
Firmware. If the firmware image file chosen is a valid firmware file, but the new firmware version is not compatible with the NI GPIB-Serial Converter Wizard version you are running, the Incompatible Firmware Image screen is displayed, as shown in...
Page 52
NI GPIB-Serial Converter Help Incompatible Firmware Image screen is displayed, as shown in the following figure. You must download a new version of the NI GPIB-Serial Converter Wizard to use the new firmware file. Follow these steps to download the new wizard version: 1.
Page 53
Re-download the firmware file, click Back, and select the new file. Confirm Firmware If the NI GPIB-Serial Converter Wizard successfully validates the specified firmware image file, it displays a Confirm Firmware screen, as shown in the following figure. This screen allows you to review the file choice and firmware versions prior to actually updating the GPIB-RS232/485/422 firmware.
Page 55
NI GPIB-Serial Converter Help On successful completion, an Update Successful screen should appear, as shown in the following figure. Proceed to Using the GPIB-RS232/485/422 after Running the NI GPIB-Serial Converter Wizard. ni.com...
Page 56
NI GPIB-Serial Converter Help If an error occurred during the firmware update, the There was an error updating the GPIB-RS232/485/422 configuration message displays, as shown in the following figure. If the NI GPIB-Serial Converter Wizard appears as shown above, proceed to Update Failed.
Page 57
Using the GPIB-RS232/485/422 After Running the NI GPIB-Serial Converter Wizard The NI GPIB-Serial Converter Wizard has now completed configuration. To use the GPIB-RS232/485/422, follow these steps: 1. Set the Configuration switch on the rear of the GPIB-RS232/485/422 to NORM.
Page 58
NI GPIB-Serial Converter Help The following topics discuss programming steps and contain program examples you can use as guidelines as you start writing programs for the GPIB-RS232/485/422. Programming Steps and Examples General Programming Steps for Communicating with the GPIB-RS232/485/422 Over...
Page 59
NI GPIB-Serial Converter Help int main(void) ViSession defaultRM; ViSession instr; ViUInt32 retCount; ViUInt32 writeCount; ViStatus status; unsigned char buffer[100]; unsigned char stringinput[512]; /* Begin by initializing the system */ status = viOpenDefaultRM(&defaultRM); if (status < VI_SUCCESS) { /* Error Initializing VISA...exiting */ return -1;...
Page 60
NI GPIB-Serial Converter Help The following topic includes general programming steps for creating a program that uses G Mode or D Mode operation. GPIB Initialization Code Using VISA GPIB Initialization Code Using VISA #include "visa.h" int main(void) ViStatus status; ViSession defaultRM;...
Page 61
NI GPIB-Serial Converter Help Status Information and Error Handling Characteristics Programming Considerations Programming Messages Programming Message Format Programming Message Example Programming Message Example with Data String How Messages are Processed Function Arguments Abbreviations for Arguments GPIB Address Lists of GPIB Addresses...
Page 62
Programming Considerations The programming examples for each function description are in standard ANSI C, using NI-VISA. Although the examples in this help are written in C, you can program the GPIB-RS232/485/422 using any programming language with access to a serial port.
Page 63
This programming message contains the function name clr and the arguments 3 and 4. It tells the GPIB-RS232/485/422 to clear the devices at GPIB addresses 3 and 4. viWr ite is the NI-VISA function to send characters to the serial port after opening the serial port with the serial initialization code.
Page 64
NI GPIB-Serial Converter Help n?" is the data string that contains the data wrt sends out on the GPIB. In this case, a carriage return "\r" is added to the data string to terminate the wrt command. Both the cmd and wrt programming messages are followed by a data string that can contain 7 or 8-bit data.
Page 65
NI GPIB-Serial Converter Help bool a Boolean value (1 = true, on, or enable; 0 = false, off, or disable) GPIB Address One argument used with most functions is the GPIB address. Each device on the GPIB has a GPIB address. The GPIB-RS232/485/422 address is 0 at power on, but you can change it using the caddr function.
Page 66
NI GPIB-Serial Converter Help Each of the following numeric strings represents the decimal value 112: • Decimal 112 • Octal \160 • Hex \x70 GPIB Read and Write Termination Methods (END and EOS) The IEEE 488 specification defines two ways that GPIB Talkers and Listeners can identify the last byte of data messages: END and EOS.
Page 67
Ignore serial port errors spign Send XON/XOFF Configurable* Recognize XON/XOFF Configurable* * You can configure the power-on value of this setting using the NI GPIB-Serial Converter Wizard. For more information, refer to Configuration of S Mode, Hardware Handshaking, and Serial Flow Control in S Mode.
Page 68
NI GPIB-Serial Converter Help GPIB Functions Serial Port Functions General-Use Functions GPIB Functions The GPIB functions manage the GPIB-RS232/485/422 GPIB port. The GPIB function subgroups are listed with the most frequently used groups first. Often, the I/O and high-level bus management functions are the only ones you need.
Page 69
NI GPIB-Serial Converter Help Low-Level Bus Management Functions—Give you precise control over the GPIB. Use them when the I/O and high-level bus management functions do not meet the needs of your GPIB device. • • • • lines • •...
Page 70
NI GPIB-Serial Converter Help Alphabetical List of S Mode Functions The following table lists the S Mode functions in alphabetical order. Function Purpose cac mode Become Active Controller caddr address Change the GPIB address of the GPIB-RS232/485/422 clr address list...
Page 71
NI GPIB-Serial Converter Help sic time Send Interface Clear spign on/off Ignore serial port errors sre on/off Set remote enable stat modes Return GPIB-RS232/485/422 status tmo values Change or disable time limits trg address list Trigger selected device(s) wait mask...
Page 72
NI GPIB-Serial Converter Help Purpose Purpose You can use cac to change the GPIB-RS232/485/422 from Standby Controller to Active Controller when the I/O and high-level bus management functions do not meet the needs of your device. cac gives you more precise control over the GPIB than the I/O and high-level bus management functions.
Page 73
NI GPIB-Serial Converter Help Example 2 Example 2 /* take control synchronously */ char buffer [] = "cac 1\r"; viWrite(instr, buffer, strlen(buffer), &retCount); Example 3 Example 3 /* Is S Mode the Active Controller? */ char buffer [] = "cac\r";...
Page 74
NI GPIB-Serial Converter Help Remarks Remarks The argument addr is a device address that specifies the new GPIB address for the GPIB-RS232/485/422. addr consists of a primary address and an optional secondary address. The secondary address is separated from the primary address by a plus sign (+).
Page 75
NI GPIB-Serial Converter Help char buffer [] = "caddr\r"; char caddrString[10]; memset(caddrString,0,10); viWrite(instr, buffer, strlen(buffer), &retCount); viRead(instr, caddrString, 10, &retCount); printf("S Mode address is %s", caddrString); Clear Specified Device Type Type High-level bus management function Syntax Syntax clr [alist]<CR> Purpose Purpose You can use clr to reset the internal or device functions of the specified GPIB devices.
Page 76
NI GPIB-Serial Converter Help sends Interface Clear (IFC*) to make itself CIC. It also asserts Remote Enable. If you passed control to some other GPIB device, control must be passed back to you or you must send IFC* to make yourself CIC before making this call. Otherwise, the ECIC error is recorded.
Page 77
NI GPIB-Serial Converter Help Purpose Purpose You can use cmd when the I/O and high-level bus management functions do not meet the needs of your device. cmd gives you precise control over the GPIB. For example, in applications that require command sequences not sent by other functions, you can use cmd to transmit any sequence of interface messages (commands) over the GPIB.
Page 78
NI GPIB-Serial Converter Help • The GPIB-RS232/485/422 successfully transfers all commands. • The GPIB-RS232/485/422 is not Controller-In-Charge. The ECIC error is recorded. • The I/O time limit is exceeded. The EABO error is recorded. • There is no device on the bus receiving the command bytes. The ENOL error is recorded.
Page 79
NI GPIB-Serial Converter Help Read/Change GPIB-RS232/485/422 Configuration Type Type General-use function Syntax Syntax conf option [value]<CR> Purpose Purpose You can use conf to read or change certain configuration parameters of the GPIB- RS232/485/422. Remarks Remarks The argument option indicates which configuration parameter to read or change.
Page 80
NI GPIB-Serial Converter Help Example 1 Example 1 Enable the PP2 option. char buffer [] = "conf 0 1\r"; viWrite(instr, buffer, strlen(buffer), &retCount); Example 2 Example 2 Return the current setting for the PP2 option. char buffer [] = "conf 0\r";...
Page 81
NI GPIB-Serial Converter Help Remarks Remarks If the argument bool is 1, characters received from the serial port are echoed back to the serial port. If the argument bool is 0, characters are not echoed. If the argument b ool is 1 and echoing was previously disabled, characters are not echoed until this command has been completely processed—that is, the next programming message is...
Page 82
NI GPIB-Serial Converter Help Type Type Initialization function Syntax Syntax eos [R[B] eoschar]<CR> eos X[B] eoschar<CR> eos D <CR> Purpose Purpose You can use eos at the beginning of your program if you want to use an eos mode when you transfer data to and from the GPIB. eos tells the GPIB-RS232/485/422 when to stop reading information from the GPIB.
Page 83
NI GPIB-Serial Converter Help low 7 bits (all read and write functions) DISABLE—disable all eos modes Methods R and B determine how GPIB read operations (rd) performed by the GPIB- RS232/485/422 terminate. If method R alone is chosen, reads terminate when the low 7 bits of the byte that is read match the low 7 bits of the EOS character.
Page 84
NI GPIB-Serial Converter Help Example 1 Example 1 Configure the GPIB-RS232/485/422 to terminate read when <LF> is detected, compare all 8 bits, and not send EOI. char buffer [] = "eos R,B,10\r"; viWrite(instr, buffer, strlen(buffer), &retCount); Example 2 Example 2 Configure the GPIB-RS232/485/422 to assert EOI* with <CR>...
Page 85
NI GPIB-Serial Converter Help Syntax Syntax eot [bool]<CR> Purpose Purpose You can use eot at the beginning of your program to change how the GPIB-RS232/485/ 422 terminates GPIB writes. Using eot, you tell the GPIB-RS232/485/422 to automatically send or not send the GPIB END message with the last byte that it writes to the GPIB.
Page 86
NI GPIB-Serial Converter Help char buffer [] = "eot 0\r"; viWrite(instr, buffer, strlen(buffer), &retCount); Example 2 Example 2 Assert EOI* with the last byte sent. char buffer [] = "eot 1\r"; viWrite(instr, buffer, strlen(buffer), &retCount); Example 3 Example 3 Get the current EOT setting.
Page 87
NI GPIB-Serial Converter Help Controller. Use gts when the I/O and high-level bus management functions do not meet the needs of your device. gts permits GPIB devices to transfer data without the GPIB-RS232/485/422 participating in the transfer. For example, you can use gts if you want to let two external devices talk to each other directly.
Page 88
NI GPIB-Serial Converter Help gts with an argument and the GPIB-RS232/485/422 is not CIC, the GPIB-RS232/485/ 422 records the ECIC error. See Also See Also cac. Example 1 Example 1 Go To Standby without shadow handshaking. char buffer [] = "gts 0\r";...
Page 89
NI GPIB-Serial Converter Help Type Type General-use function Syntax Syntax id<CR> Purpose Purpose You can use id to know the revision level of the software in your GPIB-RS232/485/422. Remarks Remarks The identification is returned in three strings. The first string identifies the company product model.
Page 90
NI GPIB-Serial Converter Help viRead (instr, thirdLine, 50, &retCount); entire buffer contains: GPIB-RS232<CR><LF> (c)2006 National Instruments<CR><LF> Version 1.0.0f0<CR><LF> Set or Clear Individual Status Bit Type Type Parallel poll function Syntax Syntax ist [bool]<CR> Purpose Purpose You can use ist when the GPIB-RS232/485/422 participates in a parallel poll conducted by another device that is Active Controller.
Page 91
NI GPIB-Serial Converter Help See Also See Also Parallel Polling. Example 1 Example 1 Set the ist bit to 1. char buffer [] = "ist 1\r"; viWrite(instr, buffer, strlen(buffer), &retCount); Example 2 Example 2 Clear the ist bit to 0.
Page 92
NI GPIB-Serial Converter Help Syntax Syntax lines<CR> Purpose Purpose You can use lines to determine the state of the GPIB control lines. Remarks Remarks This command returns two numeric strings of information. The numeric strings are separated by a comma and terminated with <CR><LF>. The state of the eight GPIB control lines is returned in the first number.
Page 94
NI GPIB-Serial Converter Help Syntax Syntax ln alist<CR> Purpose Purpose You can use ln to determine whether or not there are listening devices at the specified GPIB addresses. Remarks Remarks The argument alist is a list of addresses separated by commas or spaces. There should be at least one address in the list.
Page 95
NI GPIB-Serial Converter Help char listenAddresses[20]; memset(listenAddresses,0,20); viWrite(instr, buffer, strlen(buffer), &retCount); viRead(instr, listenAddresses, 20, &retCount); printf("Devices found at addresses: %s\n", listenAddresses); Go to Local* Type Type High-level bus management function Syntax Syntax loc [alist]<CR> Purpose Purpose You can use loc to put a GPIB device in local program mode. In this mode, you can program the device from its front panel.
Page 96
NI GPIB-Serial Converter Help System Controller, the GPIB-RS232/485/422 records the ESAC error. If this is the first function you call that requires GPIB Controller capability, and you have not disabled System Controller capability with rsc, the GPIB-RS232/485/422 sends Interface Clear (IFC*) to make itself CIC. It also asserts Remote Enable.
Page 97
NI GPIB-Serial Converter Help char buffer [] = "loc 255\r"; viWrite(instr, buffer, strlen(buffer), &retCount); Place the GPIB-RS232/485/422 Online/Offline Type Type Initialization function Syntax Syntax onl [bool]<CR> Purpose Purpose You can use onl to disable communications between the GPIB-RS232/485/422 and the GPIB, or to reinitialize the GPIB-RS232/485/422 characteristics to their default values.
Page 98
NI GPIB-Serial Converter Help and other differences, refer to Differences Between the GPIB-232/485CT/CV-A and GPIB- RS232/485/422. If you call onl without an argument, the GPIB-RS232/485/422 returns the current state, which is 0 if the GPIB-RS232/485/422 is offline and 1 if the GPIB-RS232/485/422 is online.
Page 99
NI GPIB-Serial Converter Help Purpose Purpose You can use pct to pass Controller-In-Charge (CIC) authority from the GPIB-RS232/ 485/422 to some other GPIB device. Remarks Remarks The argument addr is the address of the device you want to pass control to. addr consists of a primary address and an optional secondary address.
Page 100
NI GPIB-Serial Converter Help Syntax Syntax ppc addr,ppr,s [addr,ppr,s]...<CR> Purpose Purpose You can use ppc to configure specified GPIB devices to respond to parallel polls in a certain manner. Remarks Remarks The argument addr specifies the GPIB address of the device to be enabled for parallel polls.
Page 101
NI GPIB-Serial Converter Help 485/422 must be using IEEE 488 Parallel Poll (PP) interface function subset PP2. You can do this by setting the PP2 option using the conf function. If the PP2 option is not set, the GPIB-RS232/485/422 records the ECAP error. The GPIB-RS232/485/422 does not require GPIB Controller capability to configure itself for parallel polls.
Page 102
NI GPIB-Serial Converter Help Purpose Purpose You can use ppu if you are performing parallel polls and you want to prevent certain GPIB devices from responding. Remarks Remarks The argument alist is a list of addresses separated by commas or spaces. Addresses specify the GPIB addresses of the devices to be disabled from parallel polls.
Page 103
NI GPIB-Serial Converter Help char buffer [] = "ppu 14\r"; viWrite(instr, buffer, strlen(buffer), &retCount); Example 2 Example 2 Send the PPD command to all devices. char buffer [] = "ppu\r"; viWrite(instr, buffer, strlen(buffer), &retCount); Example 3 Example 3 Disable the GPIB-RS232/485/422 from responding to parallel polls.
Page 104
NI GPIB-Serial Converter Help specifies the number of GPIB data bytes to read and can range from 1 to 4294967295. The argument addr specifies the GPIB address of the device to be addressed as a Talker. Addr consists of a primary address and an optional secondary address.
Page 105
NI GPIB-Serial Converter Help If you call rd with the addr argument, and you previously passed control to some other GPIB device, control must be passed back to you or you must send IFC* to make yourself CIC before making this call. Otherwise, the ECIC error is recorded.
Page 106
NI GPIB-Serial Converter Help count = atoi(countBuffer); printf("S Mode read %d bytes from device at PAD 3.\n", count); Request (Conduct) a Parallel Poll Type Type Parallel poll function Syntax Syntax rpp<CR> Purpose Purpose You can use rpp to conduct a parallel poll to obtain information from several GPIB devices at the same time.
Page 107
NI GPIB-Serial Converter Help or you must send IFC* to make yourself CIC before making this call. Otherwise, the ECIC error is posted. See Also See Also ist, ppc, ppu, and Parallel Polling. Example Example char ppcBuffer [] = "ppc 13,1,0 15,3,0\r";...
Page 108
NI GPIB-Serial Converter Help Purpose Purpose You can use rsc to change which device in your GPIB system is System Controller. Remarks Remarks If the argument bool is 1, the GPIB-RS232/485/422 configures itself to be the GPIB System Controller. If the argument bool is 0, the GPIB-RS232/485/422 unconfigures itself to be the System Controller.
Page 109
NI GPIB-Serial Converter Help Example 2 Example 2 Disable the System Controller. char buffer [] = "rsc 0\r"; viWrite(instr, buffer, strlen(buffer), &retCount); Example 3 Example 3 Determine if the GPIB-RS232/485/422 is the System Controller. char buffer [] = "rsc\r"; char rscString[4];...
Page 110
NI GPIB-Serial Converter Help Purpose Purpose You can use rsp to conduct a serial poll to obtain device-specific status information from one or more GPIB devices. Remarks Remarks The argument alist is a list of addresses separated by commas or spaces. Addresses are device addresses that specify the GPIB addresses you want to poll.
Page 111
NI GPIB-Serial Converter Help See Also See Also tmo. Example Example Serial poll three devices. char buffer [] = "rsp 1+28,5,9\r"; char response1[6]; char response2[6]; char response3[6]; memset(response1,0,6); memset(response2,0,6); memset(response3,0,6); viWrite(instr, buffer, strlen(buffer), &retCount); viRead(instr, response1, 5, &retCount); viRead(instr, response2, 5, &retCount);...
Page 112
NI GPIB-Serial Converter Help request service from the Controller using the Service Request (SRQ*) signal. The GPIB- RS232/485/422 provides a user-defined status byte when the Controller serial polls it. Remarks Remarks The argument spbyte is a numeric string specifying the decimal value of the new GPIB-RS232/485/422 serial poll response byte.
Page 113
NI GPIB-Serial Converter Help Send Interface Clear Type Type Low-level bus management function Syntax Syntax sic<CR> Purpose Purpose You can use sic if the initialization, I/O, or high-level bus management functions do not meet the needs of your device, and you want to have more precise control over the GPIB.
Page 114
NI GPIB-Serial Converter Help Example 1 Example 1 Send interface clear for 100 µs. char buffer [] = "sic\r"; viWrite(instr, buffer, strlen(buffer), &retCount); spign Ignore Serial Port Errors Type Type Serial port function Syntax Syntax spign [bool]<CR> Purpose Purpose You can use spign at the beginning of your program to change the effect that serial port errors have on how the GPIB-RS232/485/422 processes programming messages and data.
Page 115
NI GPIB-Serial Converter Help If the argument bool is 1, the GPIB-RS232/485/422 executes all programming messages and sends all data, even if serial port errors occur as the messages and data bytes are received. No serial error code is reported by the stat function.
Page 116
NI GPIB-Serial Converter Help Type Type Low-level bus management function Syntax Syntax sre [bool]<CR> Purpose Purpose Use sre to turn the Remote Enable signal on and off. In some cases, the first I/O or high-level bus management function you call sets remote enable automatically.
Page 117
NI GPIB-Serial Converter Help Example 1 Example 1 Assert REN*. char buffer [] = "sre 1\r"; viWrite(instr, buffer, strlen(buffer), &retCount); Example 2 Example 2 Unassert REN*. char buffer [] = "sre 0\r"; viWrite(instr, buffer, strlen(buffer), &retCount); stat Return GPIB-RS232/485/422 Status...
Page 118
NI GPIB-Serial Converter Help Purpose Purpose You can use stat to obtain the GPIB-RS232/485/422 status to see if certain conditions are currently present. stat is used most often to see if the previous operation resulted in an error. Remarks Remarks You should use stat frequently in the early stages of your program development when the responses of your GPIB devices are likely to be unpredictable.
Page 119
NI GPIB-Serial Converter Help S Mode GPIB Status Conditions stat Returns Numeric Value (n) Symbolic Value (s) Description –32768 Error detected 16384 TIMO Timeout 8192 EOI* or EOS detected 4096 SRQI SRQ* detected while CIC 2048 — Reserved 1024 —...
Page 120
NI GPIB-Serial Converter Help S Mode GPIB Error Conditions stat Returns Numeric Value Symbolic Value Description NGER No GPIB error condition to report ECIC Command requires GPIB-RS232/485/422 to be CIC ENOL Write detected no Listeners EADR GPIB-RS232/485/422 not addressed correctly...
Page 121
NI GPIB-Serial Converter Help is in Status and Error Message Information. In general, the GPIB-RS232/485/422 updates the first three status variables at the end of each programming message. It updates the fourth status variable, count, after a cm d, rd, or wrt function. The errors reported correspond to the previous programming message.
Page 124
NI GPIB-Serial Converter Help printf("I/O operation aborted\n"); break; case 11: printf("S Mode has no capability for that operation\n"); break; case 14: printf("Command bytes could not be sent\n"); break; case 17: printf("Unrecognized command\n"); break; viRead(instr, serialErrorBuffer, 10, &retCount); serialError = atoi(serialErrorBuffer);...
Page 126
NI GPIB-Serial Converter Help Change or Disable Time Limit Type Type Initialization function Syntax Syntax tmo [timeio][,timesp]<CR> Purpose Purpose You can use tmo at the beginning of your program to change the time limits in effect on the GPIB-RS232/485/422. The time limits prevent the GPIB-RS232/485/422 from waiting indefinitely for critical events to occur.
Page 127
NI GPIB-Serial Converter Help differences, refer to Differences Between the GPIB-232/485CT/CV-A and GPIB-RS232/485/422. The timeio time limit is in effect for the cmd, rd, and wrt functions. If the GPIB- RS232/485/422 cannot complete any of these functions within the period of time set by timeio, it aborts the function and records the EABO error.
Page 128
NI GPIB-Serial Converter Help char buffer [] = "tmo ,1\r"; viWrite(instr, buffer, strlen(buffer), &retCount); Example 3 Example 3 Retrieve the current timeout settings. char buffer [] = "tmo\r"; char tmoBuffer[20]; viWrite(instr, buffer, strlen(buffer), &retCount); viRead(instr,tmoBuffer,20,&retCount); memset(tmoBuffer,0,20); printf("timeout settings are %s\n", tmoBuffer);...
Page 129
NI GPIB-Serial Converter Help If this is the first function you call that requires GPIB Controller capability, and you have not disabled System Controller capability with rsc, the GPIB-RS232/485/422 sends Interface Clear (IFC*) to make itself CIC. It also asserts Remote Enable.
Page 130
NI GPIB-Serial Converter Help as the status word described in the stat function. Each bit is set to wait or cleared not to wait for the corresponding event to occur. The numeric string can be expressed as decimal, octal, or hexadecimal.
Page 131
NI GPIB-Serial Converter Help Controller-In-Charge Attention asserted TACS Talker active LACS Listener active DTAS Device trigger state DCAS Device clear state If mask=0, the function completes immediately and returns the current status. If the TIMO bit is 0 or the timeio time limit is set to 0 by tmo, timeouts for this function are disabled.
Page 132
NI GPIB-Serial Converter Help viWrite(instr, waitCommand, strlen(waitCommand), &retCount); viRead(instr, statusBuffer, 10, &retCount); viRead(instr, gpibErrorBuffer, 10, &retCount); viRead(instr, serialErrorBuffer, 10, &retCount); viRead(instr, countBuffer, 10, &retCount); waitStatus = atoi(statusBuffer); if(waitStatus & 4096) printf("SRQI detected\n"); if(waitStatus & 16384) printf("wait command timed out\n"); Example 2 Example 2 Wait indefinitely to become LACS.
Page 133
NI GPIB-Serial Converter Help printf("LACS detected\n"); Write Data* Type Type I/O function Syntax Syntax wrt [#count][alist]<LF> data<CR> Purpose Purpose You can use wrt to send data over the GPIB. Remarks Remarks The argument data is a string of 8-bit characters that are transferred, without any translation, to the GPIB.
Page 134
NI GPIB-Serial Converter Help either <LF> or <CR><LF> to terminate the programming message. If you use <CR> alone, and the first character of the data string is <LF>, the GPIB-RS232/485/422 discards the <LF> as the second character of a <CR><LF> termination.
Page 135
NI GPIB-Serial Converter Help Controller already has addressed it. If the GPIB-RS232/485/422 is the Controller and did not address itself to talk before calling wrt, the EADR error is recorded and no data bytes are transferred. See Also See Also eos, eot, spign, and tmo.
Page 136
Without handshaking, there is danger of overflowing the GPIB-RS232/485/422 and serial device serial port receive buffers. The flow control setting selected using the NI GPIB-Serial Converter Wizard determines the power-on default of XON/XOFF for both sending and receiving. For more...
Page 137
NI GPIB-Serial Converter Help If you call xon without an argument, the GPIB-RS232/485/422 returns the current handshake setting: 1 if the protocol is enabled or 0 if protocol is disabled. The assignment made by xon remains in effect until you call xon again, call onl, or turn off the GPIB-RS232/485/422.
Page 138
NI GPIB-Serial Converter Help Programming Message Format Programming Message Example 1 Programming Message Example 2 How Messages are Processed Function Arguments Abbreviations for Arguments Addressing the GPIB-RS232/485/422 and Serial Device Address of the GPIB-RS232/485/422 Address of the Serial Device Addressing the GPIB-RS232/485/422 and Serial Device as Listeners...
Page 139
Programming Considerations The program examples for each function are written in ANSI C, using NI-VISA. Although the examples in this manual are written in C, you can program the GPIB-RS232/485/ 422 using any programming language with access to a GPIB port.
Page 140
(<LF>), or a carriage return followed by a linefeed (<CR><LF>). This is denoted by <CR> in the syntax portions of the function descriptions and by \r in the NI-VISA examples. You can enter programming messages in any combination of uppercase and lowercase letters.
Page 141
\r is the terminating carriage return. This programming message tells the GPIB-RS232/485/422 to assert the EOI* line when it sends the end-of-string character linefeed. The viWrite is an NI-VISA function call that outputs the string eo s x,10\r to the GPIB-RS232/485/422.
Page 142
Address of the GPIB-RS232/485/422 The GPIB-RS232/485/422 address is the primary and optionally secondary address you set in Using the NI GPIB-Serial Converter Wizard to Configure the GPIB-RS232/485/422, choosing G Mode as the run mode. The factory power-on default of this address is primary address 5 and secondary address disabled.
Page 143
NI GPIB-Serial Converter Help received over the GPIB, treats it as a programming message, and takes actions based on that data. When the GPIB-RS232/485/422 receives the serial device listen address, it forwards the data received over the GPIB to the serial port without examining or modifying the data.
Page 144
NI GPIB-Serial Converter Help 1. Address the serial device to talk by sending the serial device talk address to the GPIB-RS232/485/422. If the GPIB-RS232/485/422 receives the serial device talk address, but has no data in its serial port receive buffer to send, it waits for data from the serial device to fill the request.
Page 145
NI GPIB-Serial Converter Help When the GPIB-RS232/485/422 receives its own talk or listen address, no EOS Modes are in effect. When talking, the GPIB-RS232/485/422 asserts EOI* with the last byte of its response. When the GPIB-RS232/485/422 receives the serial device talk address, the EOS Modes in effect are those you select using the eos function.
Page 146
NI GPIB-Serial Converter Help serial polls on the GPIB-RS232/485/422 address. For more information about this and other differences, refer to Differences Between the GPIB-232/485CT/CV-A and GPIB-RS232/485/422. The following table lists the meaning of each bit in the serial poll response byte.
Page 147
NI GPIB-Serial Converter Help G Mode. Note This functionality is different from the GPIB-232/485CT/CV-A. Refer to Differences Between the GPIB-232/485CT/CV-A and GPIB-RS232/485/422 for more information about this and other differences. Take Control (TCT) In G Mode, the GPIB-RS232/485/422 can act only as a GPIB Talker or Listener. Do not pass control to the GPIB-RS232/485/422 in G Mode.
Page 148
NI GPIB-Serial Converter Help G Mode Default Settings and Related Functions The following tables list power-on characteristics of the GPIB-RS232/485/422 and the functions you can use to change those characteristics. G Mode Serial Port Characteristics Characteristic Power-On Value Related Function...
Page 149
NI GPIB-Serial Converter Help GPIB Functions Serial Port Functions General-Use Functions GPIB Functions GPIB functions manage the GPIB-RS232/485/422 GPIB port. • • srqen Serial Port Functions Serial port functions initialize and manage the GPIB-RS232/485/422 serial port. • echo • spset •...
Page 150
NI GPIB-Serial Converter Help echo on/off Echo characters received from serial port eos modes, eoschar Change or disable GPIB end-of-string termination mode Identify system onl on/off Place the GPIB-RS232/485/422 online/offline spign on/off Ignore serial port errors spset modes Change serial port parameters...
Page 151
NI GPIB-Serial Converter Help Purpose Purpose You can use echo when a terminal is connected to the GPIB-RS232/485/422 and you want everything you type to display on the screen. Remarks Remarks If the argument bool is 1, characters received from the serial port are echoed back to the serial port.
Page 152
NI GPIB-Serial Converter Help Example 3 Example 3 // What is the current echo status? char echoQuery [] = "echo\r"; char buffer [10]; viWrite (GPIB232, echoQuery, strlen(echoQuery), &retCount); viRead (GPIB232, buffer, 10, &retCount); // buffer contains // 0<CR><LF> // (character echo is // disabled).
Page 153
NI GPIB-Serial Converter Help 485/422 reads serial data or programming messages from the GPIB. The arguments X, B, and D specify GPIB data transfer termination methods. The argument eoschar is a numeric string representing a single ASCII character that is to be the EOS byte. The arguments X and B enable the corresponding EOS Mode.
Page 154
NI GPIB-Serial Converter Help See Also See Also GPIB Read and Write Termination Methods (END and EOS). srqen Example 1 Example 1 // Send EOI with <CR>. Compare 7 bits. char eosCommand [] = "eos X 13\r"; viWrite (GPIB232, eosCommand, strlen(eosCommand), &retCount);...
Page 155
NI GPIB-Serial Converter Help Remarks Remarks The identification is returned in three strings. The first string identifies the company product model. The second string is a copyright notice. The third string identifies the GPIB-RS232/485/422 firmware version. The following example shows the current identification string at the time of this writing.
Page 156
NI GPIB-Serial Converter Help Purpose Purpose You can use onl to disable communication between the GPIB-RS232/485/422 and serial port or reset the GPIB-RS232/485/422 characteristics to their default values. Remarks Remarks If the argument bool is 1, the GPIB-RS232/485/422 places itself online. If the argument bool is 0, it places itself offline.
Page 157
NI GPIB-Serial Converter Help char onlCommand [ ] = "onl 0\r"; viWrite (GPIB232, onlCommand, strlen(onlCommand), &retCount); spign Ignore Serial Port Errors Type Type Serial port function Syntax Syntax spign [bool]<CR> Purpose Purpose You can use spign at the beginning of your program to change the effect serial port errors have on the storage of a character received with a serial error.
Page 158
NI GPIB-Serial Converter Help If you call spign without an argument, the GPIB-RS232/485/422 returns the current setting. The assignment spign makes remains in effect until you call spign again, call onl, or turn off the GPIB-RS232/485/422. Example 1 Example 1 // Do not ignore serial port errors.
Page 159
NI GPIB-Serial Converter Help Remarks Remarks The argument baud is a numeric string specifying the baud rate (300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 76800, or 115200). The argument parity is a character specifying the parity (e for even, o for odd, n for none). The argument databits is a character specifying the number of data bits (7 or 8).
Page 160
NI GPIB-Serial Converter Help Example 3 Example 3 // Set the GPIB-RS232/485/422 serial port to 115200 // baud, no parity, 8 data bits, and 1 stop bit. char spsetCommand [] = "spset 115200 n 8 1\r"; viWrite (GPIB232, spsetCommand, strlen(spsetCommand), &retCount);...
Page 161
NI GPIB-Serial Converter Help SERR Serial error; refer to stat Serial port receive buffer not empty EOS character received — Not used — Not used To determine the mask value you want, add the hex or decimal values of the conditions on which you want SRQ* to be asserted.
Page 162
NI GPIB-Serial Converter Help Return GPIB-RS232/485/422 Status Type Type General-use function Syntax Syntax stat [[c] n]<CR> stat [c] s<CR> stat [c] n s<CR> Purpose Purpose You can use stat to obtain the GPIB-RS232/485/422 status to see if certain conditions are currently present. stat is used most often to see if the previous operation resulted in an error.
Page 163
NI GPIB-Serial Converter Help If you call stat without an argument, continuous status reporting is disabled. The status information returned by the GPIB-RS232/485/422 contains four pieces of information: the GPIB-RS232/485/422 status, a GPIB-error code, a serial-error code, and a count. The GPIB-RS232/485/422 returns a <CR><LF> following each piece of the response and asserts EOI* with the final <LF>...
Page 164
NI GPIB-Serial Converter Help — Reserved — Reserved — Reserved — Reserved The GPIB error code represents a single GPIB error condition present. The serial error code represents a single serial error condition present. count is the number of bytes currently contained in the GPIB-RS232/485/422 serial port receive buffer.
Page 165
NI GPIB-Serial Converter Help Serial Port Error Conditions stat Returns Numeric Value (n) Symbolic Value (s) Description NSER No serial port error condition to report EPAR Serial port parity error EORN Serial port overrun error EOFL Serial port receive buffer overflow...
Page 166
NI GPIB-Serial Converter Help viSetAttribute (GPIB232, VI_ATTR_TERMCHAR, 10); viSetAttribute (GPIB232, VI_ATTR_TERMCHAR_EN, VI_TRUE); // Tell GPIB-RS232/485/422 to send numeric // status. viWrite (GPIB232, statCommand, strlen(statCommand), &retCount); // Read up to 10 bytes of each piece of status. // The GPIB-RS232/485/422 returns 4 pieces of // status.
Page 167
NI GPIB-Serial Converter Help viWrite (GPIB232, statCommand, strlen(statCommand), &retCount); // If we have 3 bytes in the serial port // buffer, a typical response would be: // 262<CR><LF>0<CR><LF>0<CR><LF>3<CR><LF> // Read the GPIB-RS232/485/422 status; read 100 // bytes or until EOI is received.
Page 168
NI GPIB-Serial Converter Help Syntax Syntax xon [booltx] [,boolrx]<CR> Purpose Purpose You can use xon at the beginning of your program to configure the GPIB-RS232/485/ 422 to communicate over the serial port using the same XON/XOFF protocol as your serial device.
Page 169
NI GPIB-Serial Converter Help handshaking enabled by default is disabled. If you later decide to disable XON/XOFF, the hardware handshaking is re-enabled. The power-on default of XON/XOFF for both sending and receiving is disabled. If you call xon without an argument, the GPIB-RS232/485/422 returns the current handshake setting: 1 if the protocol is enabled or 0 if protocol is disabled.
Page 170
NI GPIB-Serial Converter Help In D Mode, the GPIB-RS232/485/422 can act only as a GPIB Talker or Listener. Do not pass control to the GPIB-RS232/485/422 when using D Mode. If you do, the GPIB circuitry in the GPIB-RS232/485/422 accepts control and immediately asserts the ATN* signal, a system error condition you should avoid.
Page 171
GPIB-RS232/485/422 asserts SRQ*, the Controller serial polls the GPIB-RS232/485/422 to determine what type of service it needs. After it is serial polled, the GPIB-RS232/485/ 422 unasserts SRQ*. You can enable the SRQ feature by running the NI GPIB-Serial Converter Wizard as described in...
Page 172
Notice that when the GPIB-RS232/485/422 is configured as a listen-only device, it cannot be serial polled. You can configure the GPIB-RS232/485/422 to enable listen-only mode by running the NI GPIB-Serial Converter Wizard as described in Using the NI GPIB-Serial Converter Wizard...
Page 173
NI GPIB-Serial Converter Help C Mode Overview In C Mode, the GPIB-RS232/485/422 and a serial host together act as the GPIB System Controller. The following figure shows the C Mode system layout. When you turn on the power with the GPIB-RS232/485/422 in C Mode, the GPIB-RS232/ 485/422 asserts IFC* for 500 µs and addresses an instrument to listen.
Page 174
NI GPIB-Serial Converter Help data is converted and sent to the GPIB instrument. When the instrument has data to send back, the GPIB-RS232/485/422 addresses the instrument to talk and passes all received data to the serial port. Modes of Operation Within C Mode Four modes of operation are available within C Mode to define when the GPIB device is addressed to talk or listen.
Page 175
NI GPIB-Serial Converter Help serial port. When the GPIB-RS232/485/422 receives a serial character, it immediately readdresses the GPIB device to listen and passes the character to it. It remains in this mode until its serial input buffer becomes empty and no serial characters are received for 300 ms.
Page 176
NI GPIB-Serial Converter Help printf ("Error writing to the device.\n"); Now we will attempt to read back a response from the device to the identification query that was sent. We will use the viRead function to acquire the data. We will try to read back 100 bytes.
Page 177
NI GPIB-Serial Converter Help strcpy (stringinput,"LANGUAGE ENGLISH\n"); status = viWrite (instr, (ViBuf)stringinput, strlen(stringinput), &writeCount); if (status < VI_SUCCESS) printf ("Error writing to the device.\n"); Status and Error Message Information The following topics describe the status and error information the GPIB-RS232/485/ 422 records as it executes each programming message.
Page 178
NI GPIB-Serial Converter Help TIMO S Mode 16384 The TIMO bit specifies whether a timeout has occurred. The TIMO bit is set in the status word following a call to wait if the TIMO bit of the wait mask parameter is also set and if the wait has exceeded the time limit value set by the tmo call.
Page 179
NI GPIB-Serial Converter Help or when another Controller passes control to the GPIB-RS232/485/422. The CIC bit is cleared whenever the GPIB-RS232/485/422 detects Interface Clear (IFC*) from some other device that is System Controller, or when the GPIB-RS232/485/422 passes control to another device. A call to onl also clears CIC.
Page 180
NI GPIB-Serial Converter Help When the ERR bit is set in status, a GPIB error or a serial port error has occurred. The error code is indicated by GPIB-error or serial-error. The following paragraphs describe the GPIB-errors in detail. The number preceding each description is the error code numeric value.
Page 181
NI GPIB-Serial Converter Help RS232/485/422 to talk or listen before attempting the wrt or rd. The GPIB-RS232/485/422 also records this error during the function gts when the shadow handshake feature is requested and the GPIB ATN* line is already unasserted. In this case, the shadow handshake is not possible and the error is recorded to notify you of that fact.
Page 182
NI GPIB-Serial Converter Help This error results when a particular capability has been disabled in the GPIB-RS232/485/ 422 and a call is made that attempts to make use of that capability. A common cause of this error is that a programming message contains an S Mode...
Page 183
NI GPIB-Serial Converter Help The GPIB-RS232/485/422 records this error when the parity of the received character is not what was expected; one or more bits of the received character were corrupted in a way that changed the character's parity. EORN The GPIB-RS232/485/422 records this error when characters arrive at the serial port faster than the serial port can accept them.
Page 184
NI GPIB-Serial Converter Help DTE vs. DCE Interfacing Serial Devices to the RS232 Serial Port Interfacing the GPIB-RS232 to a DCE with Handshaking Interfacing the GPIB-RS232 to a DCE without Handshaking Minimum Configuration Cable Custom Cables Interfacing the GPIB-RS232 to a DTE with Handshaking...
Page 185
NI GPIB-Serial Converter Help Englewood, CO 80112 (800) 854-7179 global.ihs.com Description of the RS232 Port The RS232 serial port on the GPIB-RS232 uses a male 9-pin D-Subminiature connector with a DTE interface configuration. The following table shows the signal lines supported on the GPIB-RS232.
Page 186
NI GPIB-Serial Converter Help terms used in the RS232 specification for the types of equipment on either end of a serial connection. (A DCE is now called Data Circuit-Terminating Equipment in Revision D of the RS232 specification.) In general, DTE and DCE refer to computer equipment and modems respectively.
Page 187
NI GPIB-Serial Converter Help configured as a DTE or DCE. Also, determine from the manual how the control lines are used and whether they must be driven for the serial port to operate. Note The GPIB-RS232 serial port is configured to be a DTE.
Page 188
NI GPIB-Serial Converter Help The following figure shows an equivalent 9-pin DTE to 25-pin DCE cable configuration. Interfacing the GPIB-RS232 to a DCE without Handshaking If your serial device does not require or use the hardware handshaking protocol used by the GPIB-RS232, you have two options: •...
Page 189
NI GPIB-Serial Converter Help • Wire a custom cable that properly interfaces the GPIB-RS232 hardware handshaking protocol to the handshaking protocol of your serial device. Minimum Configuration Cable The minimum configuration cable assumes that the DCE does not require external hardware handshaking.
Page 190
NI GPIB-Serial Converter Help across connection, it often involves only connecting RTS to RTS, CTS to CTS, DTR to DTR, and so on. If the documentation for your serial device does not provide a thorough explanation of its handshaking protocol, the ANSI/EIA-232-D standard is a good reference, provided your device conforms to the RS232 protocol.
Page 191
NI GPIB-Serial Converter Help The following figure shows an equivalent 9-pin DTE to 25-pin DTE cable configuration. The cable in this figure shows how to connect to the 25-pin serial port of a personal computer. Interfacing the GPIB-RS232 to a DTE without Handshaking...
Page 192
NI GPIB-Serial Converter Help 9-pin 9-pin 9-pin 25-pin 2 to 3 2 to 2 RXD to TXD 3 to 2 3 to 3 TXD to RXD DTR to DSR 4 to 6 4 to 6 5 to 5 5 to 7...
Page 193
NI GPIB-Serial Converter Help Custom Cables If your application requires a custom cable, you can construct one if you have a thorough knowledge of the handshaking protocols involved. Review the RS232 characteristics of your serial device and build the cable to properly connect the handshake lines of the two devices.
Page 194
NI GPIB-Serial Converter Help Englewood, CO 80112 (800) 854-7179 global.ihs.com RS422 RS422 RS422, as specified in the EIA/RS422-A Standard, Electrical Characteristics of Balanced Voltage Digital Interface Circuits , defines a serial interface much like RS232. However, RS422 uses balanced (or differential) transmission lines. Balanced transmission lines use two transmission lines for each signal.
Page 195
NI GPIB-Serial Converter Help Types of GPIB Messages Types of GPIB Messages The GPIB carries device-dependent messages and interface messages. Device-dependent messages, often called data or data messages, contain device- specific information such as programming instructions, measurement results, machine status, and data files.
Page 196
NI GPIB-Serial Converter Help Example 2 Operation The GPIB Controller can conduct a parallel poll at any time. To execute the poll, the Controller sends the IDY* (identify) message on the bus. A device configured for parallel polls responds at this time by driving an assigned data line either TRUE or FALSE, depending on the value of its individual status (ist) bit.
Page 197
NI GPIB-Serial Converter Help IEEE 488 specification as PP Interface Function Subset PP1, or remote configuration. In S Mode, you can choose which configuration method to use by setting or clearing the PP2 option of the conf function. When the PP2 option is cleared (the default), the GPIB-RS232/485/422 uses PP subset PP1.
Page 198
NI GPIB-Serial Converter Help Issuing Remote Configurations in S Mode In S Mode, the ppc and ppu functions configure devices remotely for parallel polls. Remote configuration is indicated by passing the addresses of the GPIB devices to be configured in the addr arguments. For example, to configure a device at address 5 to...
Page 199
NI GPIB-Serial Converter Help PPD messages to every device on the GPIB. For the ppc or ppu function to have an effect, the device it is configuring must be using PP subset PP1. If the device is not using PP subset PP1, it does not allow an external Controller to configure it, and will probably ignore the configuration.
Page 200
NI GPIB-Serial Converter Help 422 using a PPE message of hex 6D (binary 0110 1101) and parallel polls it while it is asserting SRQ*, it responds by asserting DIO line 6. If the Controller remotely configures the GPIB- RS232/485/422 using a PPE message hex 65 (binary 0110 0101) and parallel polls it while it is asserting SRQ*, it responds by not asserting DIO line 6.
Page 201
NI GPIB-Serial Converter Help The PC configures the multimeter (at address 6) to respond positively on DIO line 4 when free by sending the following programming message to the GPIB-RS232/485/422: ppc 6,4,0<CR> This programming message causes a PPE message of hex 63 to be sent to the multimeter.
Page 202
NI GPIB-Serial Converter Help this does not equal the value of the S bit in the PPE message, the device unasserts DIO line 5. If one or more line printers is busy, rpp returns hex 10 (or hex 18 if the multimeter is free).
Page 203
NI GPIB-Serial Converter Help Specifications This topic includes the GPIB-RS232/485/422 physical, electrical, and environmental characteristics. Physical Physical Dimensions 16.01 x 9.35 x 3.15 cm (6.3 x 3.68 x 1.24 in.) Case material PC-ABS plastic Weight RS232 192 g (6.75 oz) RS485/RS422 196 g (6.875 oz)
Page 204
NI GPIB-Serial Converter Help Power Requirements Power Requirements Input voltage range 9 to 28 VDC Current consumption 300 mA typical, 800 mA maximum at 12 VDC Fuse rating and type Fast acting 2.2 A 125 V, surface mount 12 VDC Power Supply...
Page 205
• IEC 60950-1, EN 60950-1 • UL 60950-1, CAN/CSA C22.2 No. 60950-1 Note For UL and other safety certifications, refer to the product label or visit ni.com/certi fication, search by model number or product line, and click the appropriate link in the Certification column.
Page 206
Note Refer to the Declaration of Conformity (DoC) for this product for any additional regulatory compliance information. To obtain the DoC for this product, visit ni.com/certi fication, search by model number or product line, and click the appropriate link in the Certification column.
Page 211
NI GPIB-Serial Converter Help MSA20,PPD MSA21,PPD MSA22,PPD MSA23,PPD MSA24,PPD MSA25,PPD MSA26,PPD MSA27,PPD MSA28,PPD MSA29,PPD MSA30,PPD Message Definitions Message Definitions DCL Device Clear GET Group Execute Trigger GTL Go To Local LLO Local Lockout MLA My Listen Address MSA My Secondary Address...
Page 212
GPIB-RS232/485/422 has been corrupted. Most likely, this happened as a result of disconnecting power during the previous firmware update. To recover from this condition, rerun the NI GPIB-Serial Converter Wizard and follow the instructions described in Using the NI GPIB-Serial Converter Wizard to Update the GPIB-RS232/485/422 Firmware.
Page 213
NI GPIB-Serial Converter Help RS232/485/422 S Mode and G Mode S Mode and G Mode Enabling/Disabling XON/XOFF Flow Control With the GPIB-232/485CT-A, you could enable the XON/XOFF protocol when sending data to the serial port independently from enabling the protocol when receiving data from the serial port.
Page 214
NI GPIB-Serial Converter Help GPIB-RS232<CR><LF> (c)2006 National Instruments<CR><LF> Version 1.0.0f0<CR><LF> GPIB-RS485 / RS422<CR><LF> (c)2006 National Instruments<CR><LF> Version 1.0.0f0<CR><LF> S Mode S Mode tmo Timeout Value Range The GPIB-232/485/CT/CV-A timeout value range for both I/O and serial poll was between 0.00001 and 3600 seconds. The GPIB-RS232/485/422 accepts timeout values in the same range as valid parameter values.
Page 215
NI GPIB-Serial Converter Help onl 1 and Restoring All Settings to Their Power-On Values When the onl 1 command is issued to the GPIB-RS232/485/422, it restores all settings to their power-on values except the ones changed with the xon command. For example, if you issued the xon 1,1 command to enable XON/XOFF handshaking, followed by the onl 1 command, XON/XOFF handshaking is still enabled.
Page 216
NI GPIB-Serial Converter Help GPIB buffer taking the remainder. The GPIB-RS232/485/422 has a 1 MB GPIB buffer and 1 MB serial buffer. Both buffers are significantly large to accommodate most applications, so a design decision was made to disallow the user to choose buffer sizes.
Page 217
NI GPIB-Serial Converter Help BUSY LED On the GPIB-232/485/CT/CV-A, this LED indicates that the device is currently accepting serial data. Each serial character received toggles the BUSY LED status. The behavior of this LED in the GPIB-RS232/485/422 is described in LEDs.
Page 218
NI GPIB-Serial Converter Help Prefixes Symbol Prefix Value pico nano µ micro milli kilo mega giga tera Numbers/Symbols nanovolts volts µV microvolts volts µΩ microohms ohms mΩ milliohms ohms MΩ megaohms ohms picoamps amperes nanoamps amperes µA microamps amperes milliamps...
Page 219
NI GPIB-Serial Converter Help alternating current ANSI American National Standards Institute ASCII American Standard Code for Information Interchange Attention Celsius Controller-In-Charge Canadian Standards Association Clear to Send DCAS Device Clear Active State Data Circuit-terminating Equipment Device Clear digital input/output dual inline package...
Page 220
NI GPIB-Serial Converter Help grams ground GPIB General Purpose Interface Bus hexadecimal hertz Identify International Electrotechnical Commission IEEE Institute of Electrical and Electronic Engineers Interface Clear inches input/output International Standards Organization Individual Status LACS Listener Active State light-emitting diode large scale integration...
Page 221
NI GPIB-Serial Converter Help ounces personal computer Parallel Poll Enable random-access memory Remote Remote Enable read-only memory Request Service Request to Send Receive Data seconds Service Request SRQI Service Request Input TACS Talker Active State TIMO Timeout Transistor-Transistor Logic Transmit Data...
Page 222
Warranty Copyright Trademarks Patents Warning Regarding Use of NI Products Warranty The GPIB-RS232/485/422 is warranted against defects in materials and workmanship for a period of two years from the date of shipment, as evidenced by receipts or other documentation. National Instruments will, at its option, repair or replace equipment that proves to be defective during the warranty period.
Page 223
NI GPIB-Serial Converter Help receives notice of such defects during the warranty period. National Instruments does not warrant that the operation of the software shall be uninterrupted or error free. A Return Material Authorization (RMA) number must be obtained from the factory and clearly marked on the outside of the package before any equipment will be accepted for warranty work.
Page 224
National Instruments respects the intellectual property of others, and we ask our users to do the same. NI software is protected by copyright and other intellectual property laws. Where NI software may be used to reproduce software or other materials...
Page 225
NI GPIB-Serial Converter Help WARNING REGARDING USE OF NATIONAL INSTRUMENTS PRODUCTS (1) NATIONAL INSTRUMENTS PRODUCTS ARE NOT DESIGNED WITH COMPONENTS AND TESTING FOR A LEVEL OF RELIABILITY SUITABLE FOR USE IN OR IN CONNECTION WITH SURGICAL IMPLANTS OR AS CRITICAL COMPONENTS IN ANY LIFE SUPPORT SYSTEMS WHOSE FAILURE TO PERFORM CAN REASONABLY BE EXPECTED TO CAUSE SIGNIFICANT INJURY TO A HUMAN.
Page 226
• System Integration—If you have time constraints, limited in-house technical resources, or other project challenges, National Instruments Alliance Partner members can help. To learn more, call your local NI office or visit ni.com/allia nce. If you searched ni.com and could not find the answers you need, contact your...
Need help?
Do you have a question about the GPIB Series and is the answer not in the manual?
Questions and answers