python - GPIB 与 Python (PyVisa) 通信

标签 python ieee gpib pyvisa

我正在尝试通过 Python 与一个非常古老的仪器(CCD 相机)进行通信。仪器制造商于 1999 年出版的 GPIB 编程手册仅提供了基本命令列表。它还描述了 GPIB 通信的一些标准程序。

我之前已经成功地编写了一些 Python 程序(使用 PyVisa)来控制和获取通过以太网或 USB 连接到计算机的仪器的数据。但是GPIB对我来说是新手,无论是ATN还是SRQ,无论是talker还是listener,似乎都与他们大相径庭。

我从 PyVisa API 文档中找到了 GPIBInterface 和 GPIBInstrument 类,但找不到任何关于 talker 或 listener 设置的信息。

这是我的问题,

一个。我对数据采集过程的以下假设是否正确?

  1. 将 Controller (PC) 设置为发话器,将仪器设置为收听器。
  2. Controller 断言 ATN。
  3. Controller 命令仪器采集数据。
  4. 等待来自仪器的 SRQ。
  5. 将仪器设置为发话者,将 Controller 设置为听者。
  6. Controller 撤销 ATN。
  7. 仪器向 Controller 发送数据信息。
  8. 完成单次采集。

b。来自 Controller 的控制消息与 GPIBInstrument 类中的直接“写入”函数有何区别?

下面的代码仍然有效,但它省略了设置 ATN、发话器或收听器。这是为什么?

import pyvisa

RM = pyvisa.ResourceMananger()
INSTRUMENT = RM.open_resource('instrument address')
print(INSTRUMENT.query('*IDN?'))

c.他们是否有任何通过 PyVisa 进行 GPIB 编程的示例或教程?

找不到合适的..

任何评论都会有所帮助。提前致谢。

最佳答案

a. Is my presumption below for data acquisition process correct?

  1. Set the controller (PC) as a talker and the instrument as a listener.
  2. The controller asserts ATN.
  3. The controller commands data acquisition to the instrument.
  4. Wait for SRQ from the instrument.
  5. Set the instrument as a talker and the controller as a listener.
  6. The controller deasserts ATN.
  7. The instruments sends data message to the controller.
  8. Single acquisition done.

我已经写了 20 多年基于 VISA 的仪器控制代码,我不知道这个问题的答案,而且几乎可以肯定你也没有必要知道。

只有当您实际自己实现 VISA API,或在您设计的仪器上调试 GPIB 接口(interface)时,您才需要担心 ATN 或 SRQ 信号的操作,或分配发话器和听器。

Below code still works though it omits setting ATN, a talker, or a listener. Why's that?

简单地说,因为 Visa viWrite()(或 viQuery())函数,由 pyVisa write() 调用或 query() 方法,为您处理这一切。

类似地,由 pyVisa read() 方法调用的 viRead() 函数将负责从从属设备。

有一天,如果你运气不好,你可能会发现你需要执行低级功能,如 GTL(转到本地,告诉仪器返回到前面板控制),GET(组执行触发器,同时触发多个仪器),或响应 SRQ。但即使是这些,VISA 库也提供了一个抽象接口(interface),这样您就不必直接操作各个总线。

c. Is their any example or tutorial for GPIB programming via PyVisa?

pyVisa docs提供几个例子,例如在标题下

Communicating with your instrument

A more complex example

Reading and Writing values

关于python - GPIB 与 Python (PyVisa) 通信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59151499/

相关文章:

python - 如何在 python 中获取 32 位 IEEE 值的整数值

mac-address - 我应该如何处理 IEEE OUI/MA-L 数据文件中的重复 MAC 分配?

python - GPIB 上的仪器使用 PyVISA 无响应

python - 使用 NI-488.2 将 GPIB 转换为 USB

python - 使用 Python : excluding certain outputs (webpage titles)

python - 导入 python pydriller 模块在 venv 中不起作用

c# - 在 .NET 中读取 4 字节 IEEE float

Python VISA串行轮询函数

python - 函数在Python Tkinter中不起作用吗?

python - 为什么使用 Python 生成器遍历二叉树比不使用慢得多?