LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Newbie GPIB problem with Read

I'm pretty new to LabVIEW, and a complete newbie when it comes to using LabVIEW with GPIB.  I've tried checking the Knowledge Base and doing a search on the board, but haven't come up with anything relevant to my specific problem.

I'm trying to write a VI to communicate with an Agilent 8564EC spectrum analyzer.

I can write to it OK, to set things like center frequency and frequency span, but when I try to read back settings, I'm running into some weirdness that I can't figure out.

Specifically, I'm trying to read back the start frequency, stop frequency, reference level and dB/division settings, displaying the results on numeric indicators on the front panel.

When I run the VI, the indicators have the expected values every fifth time.  (Note that I'm trying to read back four values.)

The expected values are showing up, but not in the expected places.  For example, one time the start frequency value might show up in the stop frequency indicator, and the next time in the reference level indicator.

When I try reading back just two values (start frequency and stop frequency), I get the correct results every third time.  (Again, one more than the number of values I'm trying to read back.)

When reading back four values, the fifth time I get the correct results, but the tenth time the VI crashes with a general I/O error.

I'm using a slightly modified version of the "Labview <-> GPIB" example VI found in LabVIEW 8 to handle the GPIB communications, in "Write then Read" mode.

The "n+1" behavior makes me think that it's a fairly simple fix, but that I'm missing one crucial piece of information.

Do I need to flush a buffer before the first read?  Reset the interface?  Wait longer between the write (query the instrument) and read (read the response) statements?  Put a wait between the various calls to the modified "Labview <-> GPIB" VI?

Any suggestions?

Bob Pownall
0 Kudos
Message 1 of 3
(2,694 Views)
It sounds like you might not be reading the correct number of bytes with each read and therefore leaving some bytes in the instrument's buffer. It would help to see the code you've written but in any case, you should be using the driver available for that instrument. There is a 7.0 and 8.0 version available. Both of them use the VISA functions instead of the less portable GPIB functions that you are trying with the example you mention. If for some reason you don't want to use the driver, then I would recomend that you first try the read functions in MAX. You've also got the Instrument I/O Assistant to help you do the read and the correct parsing of the response.
0 Kudos
Message 2 of 3
(2,688 Views)
Dennis - thanks for the quick response.

You're right - I should be using the driver.  I don't know how I missed it earlier.  I must have mistyped when I searched.

I'll give that a try tomorrow.

Bob Pownall
0 Kudos
Message 3 of 3
(2,681 Views)