PyVisa Data Extraction Issues with Keysight B1500

1k views Asked by At

I have a similar question as this one but the solution there did not apply to my problem. I can connect and send commands to my Keysight B1500 mainframe, via pyvisa/GPIB. The B1500 is connected via Keysight's IO tool "Connection Expert"

rman = pyvisa.ResourceManager()
keyS = rman.open_resource('GPIB0::18::INSTR')
keyS.timeout = 20000 # time in ms
keyS.chunk_size = 8204800 # 102400 is 100 kB
keyS.write('*rst; status:preset; *cls')
print('variable keyS is being assigned to ',keyS.query('*IDN?'))

Using this pyvisa object I can query without issues (*IDN? above provides the expected output), and I have also run and extracted data from a different type of IV curve on the same tool.

However, when I try to run a pulsed voltage sweep (change voltage of pulses as function of time and measure current) I do not get the measured data out from the tool. I can hook the output lead from the B1500 to an oscilloscope and can see that my setup has worked and the tool is behaving as expected, right up until I try to extract sweep data.

Again, I can run a standard non-pulsed sweep on the tool and the data extraction works fine using [pyvisaobject].read_raw() - so something is different with the way I'm pulsing the voltage.

What I'm looking for is a way to interrogate the connection in cases where the data transfer is unsuccessful.


Here, in no particular order, are the ways I've tried to extract data. These methods are suggested in this link:

keyS.query_ascii_values('CURV?')
or
keyS.read_ascii_values()
or
keyS.query_binary_values('CURV?')
or
keyS.read_binary_values()

This link from the vendor does cover the extraction of data, but also doesn't yield data in the read statement in the case of pulsed voltage sweep:

myFieldFox.write("TRACE:DATA?")
ff_SA_Trace_Data = myFieldFox.read()

Also tried (based on tab autocompletion on iPython):

read_raw() # This is the one that works with non-pulsed sweep
and 
read_bytes(nbytes)

The suggestion from @Paul-Cornelius is a good one, I had to include an *OPC? to get the previous data transfer to work as well. So right before I attempt the data transfer, I send these lines:

rep = keyS.query('NUB?')
keyS.query('*OPC?')
print(rep,'AAAAAAAAAAAAAAAAAAAAA') # this line prints!
mretholder = keyS.read_raw() # system hangs here!

In all the cases the end result is the same - I get a timeout error:

pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.

The tracebacks for all of these show that they are all using the same basic framework from:

chunk, status = self.visalib.read(self.session, size)

Hoping someone has seen this before, or at least has some ideas on how to troubleshoot. Thanks in advance!

1

There are 1 answers

2
Paul Cornelius On

I don't have access to that instrument, but to read a waveform from a Tektronics oscilloscope I had to do the following (pyvisa module):

On obtaining the Resource, I do this:

resource.timeout = 10000

In some cases, I have to wait for a command to complete before proceeding like this:

resource.query("*opc?")

To transfer a waveform from the scope to the PC I do this:

ascii_waveform = resource.query("wavf?")

The "wavf?" query is specifically for this instrument, but the "*opc?" query is generic ("wait for operation complete"), and so is the method for setting the timeout parameter.

There is a lot of information in the user's guide (on the same site you have linked to) about reading data from various devices. I have used the visa library a few times on different devices, and it always requires some fiddling to get it to work.

It looks like you don't have any time delays in your program. In my experience they are almost always necessary, somehow, either by using the resource.timeout feature, the *opc? query, or both.