Home > other >  The difference between python pyvsia and visa
The difference between python pyvsia and visa

Time:09-27

Hello, everyone,
I am a beginner novice, want to ask next instrument control, visa and pyvisa what is the difference between the two libraries? I use a visa. The ResourceManager () no, using pyvisa. The ResourceManager () can I see a lot of code on the BBS is with visa, I am using PyCharm interpreter,

CodePudding user response:

1 Introduction of VISA/VISA;

VISA (Virtual Instrument Software Architecture, known as VISA), namely Virtual Instrument Software Architecture, is a VXI plug& Play league of I/O interface software standards and norms that regulates the VISA for instrument programming standard I/O function library, known as VISA, VISA function library resides within the computer system is a computer with the standard communication interface software of the instrument, through which the computer to control instruments,

As a general purpose I/O standard, VISA provides a unified resource management of equipment, operation and use of mechanism, it is independent of hardware, interface, operating system and programming language, has the characteristics of has nothing to do with the hardware structure and the characteristics of VISA make it suitable for all kinds of instrument interface, regardless of the instrument using a serial port or any other bus, such as GPIB, VXI, PXI and LXI, etc, all have the same operation function, so as to realize the unity of the control operation and VISA structure model based on the bottom-up, to create a unified form of I/O control function set, on the one hand, for beginners or simple task designers, VISA provides a simple and easy to use control function set, in the application form is quite simple; For complex system of phones, on the other hand, Visa offers a very powerful instrument control and resource management,

2 PyVISA libraries/PyVISA Library

PyVISA is a Python package, make the Python can be independent of the interface (such as GPIB, RS232, USB, Ethernet) control of measurement equipment, PyVISA greatly simplifies the control mode of the instrument, only need a few lines of code which can realize to the operation of the instrument,

2 PyVISA environment structures,

Need to use Python implementation control of the instrument, first of all need to the corresponding configuration environment, basic lies in the following,

1. To ensure that the system has visa32. DLL file exists;

2. Install the corresponding instrument driver software;

3. Install pyvisa bags,

Of visa32. The location of the DLL usually stored in c:/Windows/system32/visa32. DLL, the instrument can be driven to the appropriate website to download, while pyvisa package can use PIP for installation,

PIP install pyvsia



3 PyVISA basic usage

To introduce the following pyvisa for instrument control, the basic way of using is very simple, detailed use can refer to the official specification,

First import visa module, define some basic information, including visadll position, and instrument control mode and its information, such as the IP address of the TCP/IP, GPIB port information, etc., shall be carried out in accordance with the specified format fill,
Then using visadll file to create a visa an instance of the object, with the instance objects can instrumentation, connection instance, generated by creating object of visa here in GPIB and TCPIP, for example,
Using connection instance can begin to communicate with the instrument, function basically has the following three kinds of communication interface, the write ()/read ()/query (), the specific use which one need according to the communication protocol for each instrument command set query command properties, such as read/write/read/write, with interface functions can use the corresponding set of commands to send commands and specific commands will be corresponding to the instrument manual for queries,
 import visa # visa here is pyvisa, because pyvisa is direct writing python's visa in python visa, write do import pyvisa too 

Visa_dll='c:/Windows/system32/visa32. DLL'
Tcp_addr='TCPIP: : 192.168.1.1: : inst0: : INSTR'
='GPIB0 gpib_addr: : 12: : INSTR'

# the Create an object of visa_dll
The rm=visa. The ResourceManager (visa_dll)

# the Create an instance of certain interface (GPIB and TCPIP)
Tcp_inst=rm. Open_resource (tcp_addr)
Gpib_inst=rm. Open_resource (gpib_addr)

# the Command '* IDN? 'can fetch instrument info
# Using the write/read/query () () () function to make the communication with the device
# "according to the command type
Print (tcp_inst. Query (' the * IDN? '))
Print (gpib_inst. Query (' the * IDN? '))

CodePudding user response:

For you say:
"I use a visa. The ResourceManager () no, using pyvisa. The ResourceManager () can I see a lot of code on the BBS is with visa, I am using PyCharm interpreter,"
May be you didn't introduce pyvisa this package,
Or, you wrote
 import pyvisa 
Pyvisa. The ResourceManager

Instead of directly:
 import visa 
Visa. The ResourceManager

Good

CodePudding user response:


CodePudding user response:

Have imported visa library, with a visa. The ResourceManager (slef. Visa_all) will have the following error:
Self. Visa_resource_manger=visa. The ResourceManager (self visa_dll)
AttributeError: module 'visa' has no attribute 'ResourceManager

If the imported is pyvisa library, use pyvisa. The ResourceManager (self. Visa_dll) there will be no problem, still did not understand the difference between the two
  • Related