Python drivers

I am an experimental physicist and a great Python enthusiast.

I think this is great for data analysis and scripting, and I also use it for the interface of laboratory instruments (network analyzer, areas, signal analyzers and signal generators ...). I think Python would be a very serious competitor for MATLAB in my area if there was a good library that included tool drivers.

So far, I have used several strategies to interact directly with my IPython session:

  • Using the pyVisa library, which is nice, works on most devices, but is a bit low-level, and requires an additional level of programming to provide useful functions to users.

  • Recently, I have managed to use IVI-COM or .NET drivers using pythondotnet (not IronPython , which is what NumPy / Matplotlib lacks ... libraries). This solution is obviously the most satisfactory, because the IVI drivers are already quite high level, and they are usually provided by suppliers, and tools from different suppliers are then interchangeable.

My first question is pretty technical: I read everywhere that COM objects are integrated into the .NET platform and that you can use COM objects directly in .NET. In my case, I can use COM objects by importing the comtypes module (see http://code.activestate.com/recipes/578089-using-iviscope-instrument-driver-with-python/ ) and dotnet using clr from pythondotnet but I just don’t understand how to access these COM objects using the clr module. Can anyone explain the relationship between COM and .NET?

Also, I'm always a little confused how do I know when I have a DLL file if it contains a .NET module or not, and if I can open it using version 4.0.NET (I am a complete newbie to these problems with base, and a link to the correct documentation will be perfectly fine)?

The second question: in general, is there a module that already collects more drivers for different tools in a unified mode? It seems to me that we should be thousands of people working on the same problems.

I recently fell on the lantz module http://lantz.glugcen.dc.uba.ar/ . Unfortunately, this is in Python 3.0, while I'm still using Python 2.7 (with the pythonxy distribution for Windows). Moreover, I am a little afraid of the fact that this project is not trying to implement the IVI recommendations, which would be a good starting point.

Any comment or link to the appropriate source of information will be more than welcome.

+8
python com driver visa
source share
3 answers

I cannot speak the first question, but I was working on an interpretation of the Python IVI standard: https://github.com/python-ivi/python-ivi , Unfortunately, this is also Python 3, but it is pure Python (without importing external DLL files, COM objects, or .NET objects), so this may not be exactly what you are looking for. However, the advantage is that it is cross-platform and should work on both Windows and Linux.

Python IVI (and the python-vxi11 and python-usbtmc tool interfaces) has been updated to smoothly support both Python 2 and Python 3. It is still pure Python, so there are no external binary dependencies (DLLs, COM or .NET), and it runs on Windows, Linux, and Mac OS X X. It has even been run on the Raspberry Pi . In addition, Python IVI can use PyVISA to access a compatible National Instruments device .

I call this interpretation, not implementation, because it cannot follow the letter specification simply because it is Python. I tried to follow the specification as close as possible, but I also tried to keep it as python as possible. It's less than a year, though, and I'm currently the only one working on it with my meager range of tools. I would be more than happy to participate if there are people who want to help.

Because of this, python-ivi supports the VXI-11 protocol over a local area network (compatible, I suppose with most LXI tools) via the python-vxi11 module (python-vxi11 is also pure Python and therefore cross-platform compatible), support serial tool with pySerial (cross-platform) and GPIB support using linux-gpib (Linux only). I also plan to wrap PyVISA so that python-ivi can use all the interfaces supported by PyVISA.

+3
source share

I use COM types in standard Python (not IronPython or pythondotnet) to monitor IVI drivers daily. I never need extra .NET bindings. I usually do things like this:

 from comtypes import client dmm = client.CreateObject('VTEXDmm.VTEXDmm') dmm.Initialize('TCPIP::10.20.30.40::INSTR', True, True) dmm.Measurement.Read(1000) 
+3
source share

Another option is to use TekVisa from Tektronix.

 import clr clr.AddReferenceToFileAndPath('C:\Windows\\assembly\\GAC_32\\TekVISANet\\1.1.1.0__7f19bb2a5a9ae6e8\\TekVISANet.dll') import TekVISANet v = TekVISANet.VISA() v.Open("GPIB0::6::INSTR") id =v.Write("*IDN?",50) s = v.Read(50) print s 
+1
source share

All Articles