From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I interpret serial poll results with traditional board-level commands?

I've been trying to get my head wrapped around traditional board-level commands lately and I think I'm 98% there, just need a Guru or two to clear up a little confusion on my last item.

I'm sending the following to a Fluke 45 over a USB GPIB adaptor

*RST;*CLS;
*SRE 112;*ESE 61;
VDC;RANGE 1;TRIGGER 1;
*TRG;VAL1?

The data goes out and I get back an expected measurement from the Fluke. I have taken my communication methods by studying nispy traces of various programs out there but I'm a little uncertain with one aspect of what I've done and would appreciate any insight into what I should be doing to make this right.

This is the complete command stream as shown through NiSpy...

ibfind(GPIB0)
ibonl(GPIB0, 1)
ibconfig(GPIB0, IbcAUTOPOLL (0x0007), 0 (0x0))
ibpad(GPIB0, 0)
ibtmo(GPIB0, T3s (12))
ibsre(GPIB0, 1)
ibeot(GPIB0, 0)
ibeos(GPIB0, 0x0000)
ibsic(GPIB0)
ibgts(GPIB0, 0)
ibtmo(GPIB0, T3s (12))
ibcmd(GPIB0, "?@!", 3 (0x3))
ibwrt(GPIB0, "*RST;*CLS;.", 11 (0xB))
ibwrt(GPIB0, "*SRE 112;*ESE...", 18 (0x12))
ibwrt(GPIB0, "VDC;RANGE 1;T...", 23 (0x17))
ibwrt(GPIB0, "*TRG;VAL1?.", 11 (0xB))
ibcmd(GPIB0, "_?", 2 (0x2))
ibgts(GPIB0, 0)
ibcmd(GPIB0, "?_ .", 4 (0x4))
ibcmd(GPIB0, "A", 1 (0x1))
ibrd(GPIB0, ".", 1 (0x1))
ibcmd(GPIB0, "._?", 3 (0x3))
ibgts(GPIB0, 0)
ibcmd(GPIB0, "? A", 3 (0x3))
ibrd(GPIB0, "+0.381E-3.", 1024 (0x400))
ibloc(GPIB0)
ibonl(GPIB0, 0)


with these two from above (ASCII unprintables not shown of course) I'm doing UNL, UNT, MLA0, SPE then setting MTA1 (my UUT)
ibcmd(GPIB0, "?_ .", 4 (0x4))
ibcmd(GPIB0, "A", 1 (0x1))

I then attempt to take a reading. At this point it's all assumption as I'm not quite sure what I'm doing for the next command. I see in the comparable spy traces items like P or ` which I understand to equate to 01110000 (RQS,ESB,MAV) and 01100000 (RQS,ESB). This leads me to believe that sending anibcmd with SPE also generates a *STB? command internally and places the status byte register in the buffer.

However, I get very sporatic results from my reads and they are most often x20 (0). Sometimes a 16, sometimes a 48.. but ibsta is always 356 and I always get a valid response from the device.

Am I incorrectly reading the results of the serial poll enable (SPE) from my ibcmd? Am I not setting it up right to populate the buffer with the STB after starting SPE?

Thanks,

CT
0 Kudos
Message 1 of 4
(3,308 Views)
Hi CT:

I'm looking into your question, but I just wanted to know why you are using board level commands and not VISA?

Thank you,

Emilie S.
National Instruments
0 Kudos
Message 2 of 4
(3,291 Views)
hi Emilie,

Actually, I've resolved this today. I mistakenly left out the required ibwait for SRQI ERR or TIMO that's why it was rather random. Sometimes SRQ was generated when I did the ibrd, sometimes not, but the message was always in the buffer by the time the final read came along. After that I trimmed down a few things and started using ibconfig instead and it's working almost perfectly.

I'm not very familiar with VISA. We're using Borland Delphi and the GPIB32.dll to communicate with instruments. Is VISA an option for NI with Delphi?

Thanks,

CT
0 Kudos
Message 3 of 4
(3,286 Views)
Hi CT:

I'm glad to hear you have everything working. I did not realize you were using Delphi, however, please refer to the following post dealing with VISA in Delphi:

http://forums.ni.com/ni/board/message?board.id=140&message.id=2404&requireLogin=False

Thank you,

Emilie S.
National Instruments
0 Kudos
Message 4 of 4
(3,271 Views)