12-02-2010 06:01 AM
I am trying to communicate with an instrument through GPIB using the VISA functions (VISA write and VISA read).
I need to be able to use the VISA commands as a setup file can change the communication mode to serial RS232, so all my communications are handled by VISA.
The problem is that this instrument requires a <CR> "\r" and NO EOI at the end of each write. I cannot find the way to change the settings in VISA to do this automatically.(The instrument replies with a <CR> and no EOI).
Please see the attached 2 programs which open communications, set up the instrument preferences, then send the command "V" and read the response, then close VISA.
The first one uses the GPIB write function and successfully reads back the response (using VISA read). - So I assume the instrument is fine, the cable is fine and it is simply a software problem.
The second one tries to use the VISA write function, but doesn't work. I think this is because the VISA write is not properly configured to send the correct end of string termination.
How do I setup the VISA to append a <CR> and leave off the EOI at each Write function?
Many thanks,
Nick
12-02-2010 07:21 AM
To prevent the EOI being sent on viWrite you need to set the Visa attribute, VI_ATTR_SEND_END_EN, to false.
Th append the CR to your commands/data going out, it is up to you to add the \r to the string Visa won't do this for you except for serial.
12-02-2010 07:59 AM
Thanks for your response. I've tried implementing your suggestion by changing the "Send End Enable" setting on the VISA Instr setting and adding the "\r" to the string, without any luck.
There must still be some fundamental difference between the VISA write and the GPIB write.
On the other point. It's really frustrating that the strings to send to a VISA write function are not the same for GPIB and RS232 serial. I don't know in advance which mode of communication is going to be used. So now everytime I used VISA write, I will need another function which checks the communication modality and adds the "\r" character if it is in GPIB mode.
12-02-2010 08:12 AM
What is the error you are seeing with the Visa write using GPIB?
Generally the GPIB just works correctly without having to tweak any GPIB controller settings. It is the RS232 that is always a pain. I bet it supports EOI and CR and you really only need EOI on for the GPIB. We add the <cr> because RS232 requires it and it also just works with the GPIB.
What instrument is this?
12-02-2010 08:14 AM
There is no fundamental difference between a VISA Write and a GPIB Write. A VISA Write actually uses a GPIB Write. VISA is just a high level api above the actual hardware functions. You can configure the GPIB controller in MAX to suppress the EOI.
Attach the program instead of those gifs. Just to make sure you have the string controls set for '\' Codes Display.
Your serial connection will also require the same CR, won't it?
12-02-2010 08:34 AM
Instrument is an IPS120-10 power supply from Oxford Instruments:
There's an instruction manual online at (see page 32)
I understand it doesn't like the EOI character as this works on the GPIB write command when you send "4 - Append CR to the string but do not send EOI."
To answer your question, I don't actually see an error on calling the Write function. It's just that I never receive a response from the Read function. I agree that generally GPIB works much eaiser than serial, but this instrument is the exception that proves the rule!!
p.s. there is another way to communicate with this instrument through the Measurement and Automation program from NI.
Go in there, find the instrument and click "Interactive Control"
Then type the following:
ibdev (Enter, followed by 0, 25, 0, 13, 0, 0x140D)
ibwrt "V\r"
ibrd 80
These settings work to get the power supply to respond. Somewhere in the 0x140D are the required termination to the writes.
12-02-2010 08:42 AM
Thanks cymrieg and Dennis for your combined tips. I didn't have the Codes Display correctly set and also needed the "Set End En = False".
It now works.
Nick
12-02-2010 09:08 AM
See the attached program for reference...