Using NI-VISA with Python is too slow

891 Views Asked by At

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.

0

There are 0 best solutions below