The GPIB to Serial Converter is not software transparent, meaning that there are additional commands to send to the converter to differentiate between connected devices. When you send a VISA command to your GPIB to Serial Converter, you are communicating directly with your converter.
If you are using LabVIEW or LabVIEW Real-Time, refer to Communicating with GPIB Instruments using NI CompactRIO (GPIB-RS232 only) for a library of VIs that outline all of the considerations for using the converter with a LabVIEW program.
Note: The Developer Zone above specifically mentions setting this up for cRIO. However, the VIs attached to that article will work on your development PC, Compact FieldPoint Devices, as well as others.
If you are developing in another environment or are interested in the underlying operation here are the instructions to communicate with the device:
In order to send data or commands to the GPIB device, you will need to send a wrt command to a VISA Write function. This VISA Write function should be set to synchronous I/O. You can change the mode of a VISA function from asynchronous to synchronous in LabVIEW by right-clicking on the VISA function, expanding the Synchronous I/O Mode menu, and selecting Synchronous. The syntax for this command is as follows:
wrt #[x] [Address]<LF>[Data]<CR>
Remove the brackets [ ] when writing commands.
#[x] - represents the length of the data to be sent, where x is the number of bytes. This part of the command is optional, as the converter will use the termination character to determine where the end of the command is. However, if the command being sent to the device requires a termination character, then this value is required.
[Address]<LF> - represents the Primary and Secondary Address (PAD and SAD) your instrument(s) are set to. The primary and secondary addresses are separated by a plus character: [+] . If there are multiple instruments connected to your converter, you can include them by appending the PAD and SAD with a comma character: [,] . The <LF>("\n") defines the limits between the address and the first data character.
[Data]<CR> - represents the data you wish to send to your instrument(s). <CR>("/r") is used as a termination character to the wrt command, and will not be a part of the actual data that you send.
wrt #6 1,2+1\n*idn?\r
This command will send *idn?\r to instruments at Primary Address 1 and Primary Address 2 with Secondary Address 1. Additional examples can be found in the Product Manual: NI GPIB-Serial Converter Help.
In order perform a read operation, you need to send a rd command using the VISA Write function. This VISA Write function should also be set to synchronous I/O. The syntax for this command is as follows:
rd #[x] [Address]<CR>
#[x] - represents the amount of data in bytes to read from the instrument. You should make x a number greater than the amount of bytes expecting to be read. The converter will terminate the read when it either receives the amount of bytes requested, or it receives the termination character.
[Address]<CR> - represents the Primary and Secondary Addresses of the device(s) you wish to read. The <CR>("/r") is used to terminate the rd command.
After the rd command has been sent out to the converter, you will need to read the serial buffer for the COM port the converter is connected to. Use the VISA Read command to do this.
Once you read the data from the serial buffer using the VISA Read, the converter will automatically place statistics regarding the recent command into the serial buffer. The statistics contain spaces for the number of bytes requested more than were available, followed by the number of bytes actually read. For example, if you request 64 bytes from the device, and the device replies with only 60 bytes of data, once the read command completes " 60" in the serial buffer. The 4 spaces indicate the number of extra bytes you requested, and the 60 represents the actual bytes of data read. You will either need to read this data out of the serial buffer, or flush the buffer before running any other commands.
rd #128 2+1\r
This command will read back 128 bytes from primary address 2 with Secondary Address 1. After the command is sent, the data will be available at the serial buffer. Perform a VISA read to obtain the available data.
Thank you for your feedback.
You changed your response to Not Helpful
You changed your response to Helpful
Collaborate with other users in our discussion forums
A valid service agreement may be required, and support options vary by country.