Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

GPIB Problems with Extra Characters

I designed an instrument controller for RF amplifiers using a TNT4882 chip. All is well when communicating with it via MAX, LabWindows or LabView, but I have a user that can't talk to it using his PyVisa code. He is able to talk with other, standard instruments. We used NI Spy with both MAX and his software and made an interesting observation. For example if *IDN? is sent via MAX, NI Spy shows  ibwrt(UD0, "*IDN?", 5 (0x5)), as expected. However, using the PyVisa code we get viWrite (0x0130B2C0, "*IDN?..", 7, 7). It appears that my code does not like the "..", which I believe signifies non-printable characters. The other instruments (e.g., Agilent) don't seem to mind the "..". Is there some sort of standard convention that I am missing?
 
Regards,
 
Steve
0 Kudos
Message 1 of 12
(6,079 Views)
You can double-click on the particular line in NI Spy with the extra characters. This will bring up another dialog window. From there you can click on the buffer tab and see the hex ASCII codes for the last two characters. As you stated, periods are usually non-printable characters.

Is it possible that the last two characters are for termination? If so I imagine there is a setting in PyVisa to turn this off.
0 Kudos
Message 2 of 12
(6,063 Views)
It is very likely that the characters are Carriage Return (0x0D) and Linefeed (0x0A).  It is pretty common for users to add these characters, as old instruments often needed these characters for termination.  As time has progressed, more instrument correctly respond to the EOI line asserting as the termination for a GPIB write.  However, many instruments still maintain some compatibility for CR & LF.

Craig A
National Instruments Engineer
0 Kudos
Message 3 of 12
(6,060 Views)
Hi Steve,

Most likely the "standard" instruments which you say work fine with the extra characters strip any trailing carriage returns and linefeeds from the command before processing it.  To make your device compatible, you would need to do the same in your device application, so that the \r\n which is likely at the end of this string is ignored.

Jason S.
National Instruments
0 Kudos
Message 4 of 12
(6,049 Views)

Now that I know how to better use NI Spy, I see that the added characters are indeed CR/LF. I did not realize that these characters would be common with GPIB communications. I will strip-off these characters in my code. Should I append messages with CR/LF for compatibility? Is there a down side in doing this?

Steve

0 Kudos
Message 5 of 12
(6,049 Views)
I wouldn't say that CR/LF is common. Prior to 488.2, some GPIB instruments did require a CR/LF along with EOI or instead of EOI. This is probably a legacy of serial instruments being converted to GPIB. Often, the GPIB controller itself was configured to send it. Some drivers are written to always append a CR/LF to be compatible with both a serial and GPIB version and knowing that the GPIB instrument will ignore it. The preferred method when writing a driver today is to first check the type of VISA session and only if it's serial, configure VISA for a termination character. There's no real reason to append anything additional in your messages but your instrument should be set to parse it out and ignore it.
0 Kudos
Message 6 of 12
(6,042 Views)

Many thanks to everyone. Your responses were a big help.

Steve

0 Kudos
Message 7 of 12
(6,035 Views)
My problem is I need to add the LF/CR to the box used for text entry.  Thanks Jerry
0 Kudos
Message 8 of 12
(5,982 Views)
What box are you talking about? Is this question of yours related to this thread which has to do with designing a GPIB interface for an instrument? If not, you should post your question in a brand new thread. Either case, you need to provide a few more details.
0 Kudos
Message 9 of 12
(5,976 Views)
It seems I did leave a lot out.  I am working with NI 488.2 to communicate with an older instrument that requires the line feed and carriage return
symbols at the end of all instructions. I am using Measurement and Automation Explorer version 2.2.0.3010  on a Windows 98 SE system.  Under device it shows GPIB (PCI-GPIB)  and under that it shows Instrument. I click on communicate with instrument and the box that says Send String comes up. This is where I need to enter those symbols.  Hope that makes things a bit easier.  Thanks Jerry
0 Kudos
Message 10 of 12
(5,960 Views)