将ni-visa与python使用太慢

发布于 2025-01-20 09:16:38 字数 671 浏览 3 评论 0原文

我正在Python中工作并使用ctypes包加载visa32.dll来简单地写入和读取仪器,但是从viWrite到viRead需要510ms(我使用NI I/O跟踪来跟踪数据),500ms~600ms太慢对于我的项目和pyVisa读取太慢(几乎同时在500ms~600ms之间),我不知道如何通过python加速执行(仅限LabVIEW)需要少于 100 毫秒)

visa = WinDLL('c:\\windows\\System32\\visa32.dll')
nb = c_uint32()
nb32 = c_uint32()
buff2 = c_uint32()
vi = c_uint32()
AC_Source = b"GPIB0::30::INSTR"
data = b"SOUR:FREQ?"
send_num = len(data)

visa.viOpenDefaultRM(byref(rm_session))
visa.viOpen(rm_session, AC_Source, 0x00, 0x00, byref(vi))
visa.viWrite(vi, data, send_num, byref(nb))
visa.viRead(vi, byref(buff2), 0xFF, byref(nb32))

是否有其他方式在不使用 PyVISA 的情况下控制仪器或任何可以使其更快的方式? 我是 ctypes 的新手,非常感谢任何帮助。

I'm working in Python and using the ctypes package to load visa32.dll to simply write and read instrument, but starting from viWrite to viRead took 510ms(I use NI I/O trace to trace data), 500ms~600ms is too slow for my project and pyVisa is reading too slow too(almost the same time between 500ms~600ms), I don't know how to speed up the execution by python(LabVIEW only need less than 100ms)

visa = WinDLL('c:\\windows\\System32\\visa32.dll')
nb = c_uint32()
nb32 = c_uint32()
buff2 = c_uint32()
vi = c_uint32()
AC_Source = b"GPIB0::30::INSTR"
data = b"SOUR:FREQ?"
send_num = len(data)

visa.viOpenDefaultRM(byref(rm_session))
visa.viOpen(rm_session, AC_Source, 0x00, 0x00, byref(vi))
visa.viWrite(vi, data, send_num, byref(nb))
visa.viRead(vi, byref(buff2), 0xFF, byref(nb32))

any other way to control the instrument without using PyVISA or any way that can make it faster?
I'm new to ctypes, any help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文