Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Can't write to GPIB using VISA write, but VISA read works fine

This problem is really baffling me.  I'm trying to use GPIB to control a laser power controller and everything seems to work fine except writing using VISA write.  In MAX, I can successfully write to or read from the device using either the VISA test panel or the "communicate with instrument" command line.  However, when I use the labview example "basic_gpib_write_and_read.vi"  I can read data from the buffer but the command from the VISA write doesn't seem to make it to the instrument.  There is no error in VISA write, and I get a return count from the vi if I wire that output, but the instrument doesn't respond to the same string given in MAX.
 
In MAX: writing the command "P 10 mw \n" modulates the unit to 10mW
With VISA write: writing "P 10 mw \n" does nothing yet gives no error
 
What's more baffling is that I can write "P ?\n" in MAX and successfully read the buffer "P 10.10 mW" using VISA read.
 
My guess is that somehow the commands are sent with VISA write but aren't properly terminated.  Still, I would assume that a command issued in MAX would work identically to a command issued using VISA write.
 
Any help would be greatly appreciated.
 
Ken
0 Kudos
Message 1 of 3
(3,706 Views)
The reason that the write doesn't work with the example is that unless you changed the string control, you are not sending the line feed control code (\n) but the characters '\' and 'n'. Right click on the string control and select '\' Codes Display. It's very unusual for a GPIB instrument to require termination character.
Message 2 of 3
(3,704 Views)
Thanks a lot! That was the right answer.
0 Kudos
Message 3 of 3
(3,682 Views)