PyVISA SCPI命令和查询(带有值更新的问题) [英] PyVISA SCPI commands and queries (issue with value update)

查看:489
本文介绍了PyVISA SCPI命令和查询(带有值更新的问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:这似乎在工作"OK",尽管我不确定为什么某些回复结尾处带有/r/n,为什么某些回复没有.我已经明确关闭了握手...

UPDATE: It seems to be working "OK" this am... although I am not sure why certain replies have /r/n at the end and why certain don't. I have explicitly turned Handshaking OFF...

下面是命令,查询和答复的示例.

An example of the commands, queries, and replies is posted below.

**我正在使用PyVISA前端与传感器通信.

**I am using PyVISA frontend to communicate with a sensor.

在输出发生变化之前,我必须发送命令或查询三遍...

I am having to have to send a command or make a query three times before there is a change in the output...

在继续之前,我是否必须添加等待命令?我认为SCPI命令正在阻塞(可以这么说是同步的).如果我做错了事,请告诉我.这是我的一些命令:**

Do I have to add wait command before proceeding? I thought the SCPI commands were blocking (synchronous so as to speak). Please let me know if I am doing something awry. Here are a few of my commands:**

    >>> import visa
    >>> ins = visa.ResourceManager()
    >>> print(ins.list_resources())
    ('ASRL1::INSTR', 'ASRL3::INSTR', 'ASRL6::INSTR', 'ASRL10::INSTR')
    >>> Energy_sense = ins.open_resource('ASRL6::INSTR')
    >>> print(Energy_sense.query('*IDN?'))
     Coherent, Inc - EnergyMax USB - V1.2 - Jan 27 2011


    >>> Energy_sense.write(":CONF:WAVE 780")
     (16, <StatusCode.success: 0>)
    >>> print(Energy_sense.query(':CONF:WAVE?'))
    780


     >>> Energy_sense.write(":SYST:COMM:HAND OFF")
     (21, <StatusCode.success: 0>)
     >>>
     >>> Energy_sense.write(":CONF:MEAS:STAT ON")
     (20, <StatusCode.success: 0>)
     >>> Energy_sense.write(":CONF:STAT:BSIZ 1000")
     (22, <StatusCode.success: 0>)
      >>> Energy_sense.query(":CONF:STAT:BSIZ?")
      '1000\r\n'
      >>> Energy_sense.write(":CONF:STAT:STAR")
      (17, <StatusCode.success: 0>)
      >>> Energy_sense.query(":READ?")
       '3.728E-5,3.150E-5,4.358E-5,2.597E-6\r\n'
      >>>
      >>> Energy_sense.query(":CONF:STAT:BSIZ?")
      '1000\r\n'
      >>>
      >>> print(Energy_sense.query(':CONF:WAVE?'))
      780

      >>>

您可以在图像中找到其余命令.

You can find the rest of the commands in the image.

推荐答案

您是正确的. VISA命令被阻止,因此您无需在VISA命令之后等待.你设置超时时间了吗?太短了吗?某些设备可能比其他设备花费更长的时间来响应命令.

You are correct. VISA commands are blocking, so you should not need a wait after a VISA command. Have you set the timeout? Is it too short? Some devices may take longer to respond to commands than others.

import visa
self._rm = visa.ResourceManager()
self._visa_conn = self._rm.open_resource('GPIB0::%s::INSTR' % instr_addr)
self._visa_conn.timeout = 1000 # In milliseconds

您可以使用以下方法删除"\ n":

You can remove the '\n' with:

string.rstrip('\n')

这篇关于PyVISA SCPI命令和查询(带有值更新的问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆