python-ivi / python-usbtmc

Provides a USBTMC driver for controlling instruments over USB
MIT License
160 stars 67 forks source link

Connection via python-usbtmc to Yokogawa osciloscope DL9040 #40

Open MVUV opened 6 years ago

MVUV commented 6 years ago

Hi, I am trying to connect a Yokogawa model DL9040 osciloscope to a Windows 10 Laptop to control it and be able to send commands and retrieve data from the instrument via Python 2.7. I have checked numerous posts but haven´t been able to connect via python. I use spyder 3.23 and anaconda prompt. I have installed python_usbtmc-0.8-py2.7.egg . I have also installed setup.py and libusb. The problem is that I cannot get the instrument ID for communicating with it in python. The instrument has a driver and I have installed it. So I can establish a connection via Yokogawa software and access some functions there with their user interface. The connection in the Yokogawa software states it is a usbtmc and gives the serial 91F836795. However I cannot manage to establish communication using python usbtmc.

I use this code to get the list of usb connected but do not get the name of the Yokogawa USB which I believe should look like: USB::0x0957::0x1755::INSTR" import usbtmc import visa rm= visa.ResourceManager() rm.list_resources()

Any suggestion or any link that explains how to connect using python-usbtmc with troubleshooting?

alexforencich commented 6 years ago

Are you trying to use pyvisa or python-usbtmc?

MVUV commented 6 years ago

I have tried both, so far unsuccessfully I am open to either

alexforencich commented 6 years ago

Well, there are probably at least 2 different ways to make it work in python. One way is to use libusb/pyusb/python-usbtmc. In this case, you'll need to remove the Yokogawa driver and set up an ini file so that libusb can connect to the device. Then you can use python-usbtmc. Alternately, you can use ni-visa/pyvisa. You'll need to install the Yokogawa driver as well as the NI-VISA software and pyvisa. Then use pyvisa to access the instrument through NI-VISA and don't use python-usbtmc at all.

MVUV commented 6 years ago

I have tried the VISA Option in my Windows 10 laptop. I have the Yokogawa Driver, NI-VISA and pyvisa installed. I got some Instrument info from the NI-VISA such as: manufacturer ID 0x0B21 and the roduct ID 0x0023. I got the Serial number from a yokogawa Software that does connect successfuly with the Instrument: Serial number 91F836795. I tried:

inst = rm.open_resource('USB::0x0B21::0x0023::91F836795::1::RAW') print(inst.query("*Acquire?")) And also: inst = rm.open_resource('USB::0x0B21::0x0023::91F836795::INSTR')

However I get the following error (similar for both): VisaIOError: VI_ERROR_RSRC_NFOUND (-1073807343): Insufficient location information or the requested device or resource is not present in the system. Am I using a wrong nomenclature? or where am I supposed to get those numbers? I will try the USBTMC Option in a Raspberry Pi 3 (because I do not want to uninstall the Drivers in the Windows 10 Laptop)

MVUV commented 6 years ago

Hi, I finally managed to connect to the instrument using a Raspberry Pi and usbtmc. (At least it is sending messages to the Osciloscope as I get Undefined header in the screen) The nomenclature I used is: import usbtmc instr= usbtmc.Instrument (0x0b21, 0x0023) print (instr.ask("Acquire?"))

Unfortunately instead of getting a response I get a warning of Fatal error in communication driver in the osciloscope screen and I get a struct.error: unpack_from requires a buffer of at least 4 bytes in the python command line