Timeout for switch term acquisition

Skip to first unread message


Jun 13, 2022, 9:04:01 PM6/13/22
to scikit-rf
I am trying to calibrate a PNA using skrf.
It is working well up to 2 port data acquisition.
from skrf.vi.vna import PNA
my_pna = PNA(f'TCPIP0::{PNA_IP}::hislip0::INSTR')

However, whenever I try to get a switch term, it times out.
Can anyone please advise me on this?

The version of the library used and the error log are as follows.
scikit-rf                     0.22.1
PyVISA                        1.10.1 *
* When I use the latest version of pyvisa, I get errors when connecting to PNA, so I use past versions. https://github.com/scikit-rf/scikit-rf/issues/393

``` error message
VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
File "path\lib\site-packages\streamlit\scriptrunner\script_runner.py", line 554, in _run_script
    exec(code, module.__dict__)
File "Connect2PNA.py", line 144, in <module>
File "Connect2PNA.py", line 126, in create_measure_buttons
    self.measured_data[std] = my_pna.get_switch_terms()
File "path\lib\site-packages\skrf\vi\vna\keysight_pna.py", line 416, in get_switch_terms
File "path\lib\site-packages\skrf\vi\vna\keysight_pna.py", line 164, in sweep
File "path\lib\site-packages\skrf\vi\vna\abcvna.py", line 147, in wait_until_finished
File "path\lib\site-packages\pyvisa\resources\messagebased.py", line 613, in query
    return self.read()
File "path\lib\site-packages\pyvisa\resources\messagebased.py", line 427, in read
    message = self._read_raw().decode(enco)
File "path\lib\site-packages\pyvisa\resources\messagebased.py", line 400, in _read_raw
    chunk, status = self.visalib.read(self.session, size)
File "path\lib\site-packages\pyvisa\ctwrapper\functions.py", line 1584, in read
    ret = library.viRead(session, buffer, count, byref(return_count))
File "path\lib\site-packages\pyvisa\ctwrapper\highlevel.py", line 193, in _return_handler
    raise errors.VisaIOError(ret_value)

Julien Hillairet

Jun 14, 2022, 3:18:40 AM6/14/22
to scik...@googlegroups.com
Dear user,

Could you submit an issue on github to track the problem?

There was some work made to update the visa support https://github.com/scikit-rf/scikit-rf/pull/409, but I'm afraid this PR must be taken by someone else to complete it.


You received this message because you are subscribed to the Google Groups "scikit-rf" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scikit-rf+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scikit-rf/1c33724b-20f1-4c09-9234-b8edad24903cn%40googlegroups.com.


Jun 14, 2022, 3:36:38 AM6/14/22
to scikit-rf

I commented on github. This is my first time, so please let me know if I am reporting it incorrectly.
2022年6月14日火曜日 16:18:40 UTC+9 julien.h...@gmail.com:

Julien Hillairet

Jun 14, 2022, 4:55:22 AM6/14/22
to scik...@googlegroups.com
Thank you, it's fine.

Eventually, you can test the changes proposed in the pull request to test if it solves your issue. That would help us a lot.

If you are not sure how to do it, there is some documentation here:



Jun 16, 2022, 10:59:37 PM6/16/22
to scikit-rf
After trying the fork, I was able to connect even with the latest PyVisa. However, the get_switch_terms process still times out.
I looked at the error in detail and found that get_switch_terms works except that PNA.sweep times out. However, the reason why PNA.sweep times out remains unknown. Does anyone have more information on this?

VisaIOError                               Traceback (most recent call last)
<ipython-input-7-130bdcc5567c> in <module>
----> 1 my_pna.get_switch_terms()

~path\Lib\site-packages\skrf\vi\vna\keysight_pna.py in get_switch_terms(self, ports, **kwargs)
    406         self.create_meas(reverse_name, 'a{:}b{:},{:}'.format(p1, p1, p2))
--> 408         self.sweep(channel=channel)
    410         forward = self.get_measurement(mname=forward_name, sweep=False)  # type: skrf.Network

~path\Lib\site-packages\skrf\vi\vna\keysight_pna.py in sweep(self, **kwargs)
    153                     self.resource.timeout = timeout
    154                 self.scpi.set_sweep_mode(channel["cnum"], channel["sweep_mode"])
--> 155                 self.wait_until_finished()
    156         finally:
    157             self.resource.clear()

~path\Lib\site-packages\skrf\vi\vna\abcvna.py in wait_until_finished(self)
    152     def wait_until_finished(self):
--> 153         self.query("*OPC?")
    155     def get_list_of_traces(self, **kwargs):
--> 251             raise errors.VisaIOError(rv)
    253         if rv in self.issue_warning_on:

VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
2022年6月14日火曜日 17:55:22 UTC+9 julien.h...@gmail.com:

Jackson Anderson

Jun 17, 2022, 9:23:59 AM6/17/22
to scikit-rf

Is the VNA physically sweeping still when you get the timeout error? The sweep() method is supposed to autoset this to a value larger than the sweep time.  If not, the other thing would be to check the error log on the PNA to see if it is unhappy with a command the python code is sending. Sometimes this can lead to timeouts as it is not doing what Python thinks it is. 

If our PNA is available, I can check this against the A.09.xx firmware later today. If it works there, perhaps Keysight has removed/changed a command in more recent versions.



Jun 17, 2022, 9:56:53 AM6/17/22
to scikit-rf

Thanks for your help, I appreciate it.
I am not sure if the VNA was sweeping or not, so I will check on Monday along with the error log. (It's Friday night in Japan right now.)
 My PNA firmware was A15.xx, but if it works well with A09, I will consider downgrading.

Best regards,

2022年6月17日金曜日 22:23:59 UTC+9 Jackson Anderson:


Jun 20, 2022, 2:40:18 AM6/20/22
to scikit-rf
I understand a little more about the situation.
I could avoid the error by speeding up the IF of sweep or slowing down the timeout setting. It was obvious when I thought about it.
However, at 1 kHz, no matter how slow I set the timeout, the error still occurred.

```test code
timeout = 2*1e1 # ms
my_pna = PNA(PNA_visa_address, timeout=timeout)
ports = (1, 2)
f_start : 10 MHz
f_stop : 120 GHz
f_npoints : 1201

1. IF : 1 kHz
timeout :  Error with 2*1e6, None or float("+inf")

2. IF : 2 kHz
timeout : Works with 2*1e2 ms

3. IF : 5 kHz
timeout : Works with 2*1e2 ms

4. IF : 10 kHz
timeout : Works with 2*1e1 ms

2022年6月17日金曜日 22:56:53 UTC+9 jeanbiego:

Jackson Anderson

Jun 20, 2022, 7:56:53 PM6/20/22
to scikit-rf

I tried connecting with the new code on our N5225A on A.09.90.21 but am dealing with several SCPI errors related to undefined headers, unterminated queries, etc. I am guessing there is a SCPI command somewhere in the code that was added in a later PNA firmware that I may have to hunt down. Either that or some VISA error to troubleshoot.

In the meantime, if you go to "help->error messages->error log", do you see any messages that appear when you run the code with an IF of 1 kHz?



Jun 21, 2022, 10:04:42 PM6/21/22
to scikit-rf


> do you see any messages that appear when you run the code with an IF of 1 kHz?
When python gives a timeout error, there is no error on the PNA side. Instead, the trace added during the switch term measurement is still there, not gone.
And, depending on the model, the first my_pna.get_twoport() sent after connection always fails. the second and subsequent times it works without error.
PNA error : [SCPI: -109]Missing parameter, [SCPI: 103] CALC measurement selection set to none
Model without error : N5234A
Model with error : N5244B, N5227B

I think the following link may be relevant.


2022年6月21日火曜日 8:56:53 UTC+9 Jackson Anderson:
Reply all
Reply to author
0 new messages