PI-PhysikInstrumente / PIPython

Python Library for using PI controllers with GCS command language
28 stars 3 forks source link

Stuck on pidevice.InterfaceSetupDlg() #3

Closed josephernest closed 2 years ago

josephernest commented 2 years ago

Hi, I have the Windows driver installed for G-867 USB, I can successfully connect it in PI MikroMove.

But then when I close PI MikroMove and run:

from pipython import GCSDevice
pidevice = GCSDevice('C-867')
pidevice.InterfaceSetupDlg()
print(pidevice.qIDN())
pidevice.CloseConnection()    

it gets stuck at the line pidevice.InterfaceSetupDlg(), and nothing is displayed.

Any idea? Is there something to do?

SReich-EMI commented 2 years ago

Hi, I don't have the C-867, but I use the C-863 also with USB connection. I use pidevice.OpenUSBDaisyChain(description) für a bundle of three of these controllers connected to each other directly. But I also have used pidevice.ConnectUSB(SN) for a single controller. Maybe this is a point to start with for you.

josephernest commented 2 years ago

Thank you @SReich-EMI. What is required to be able to connect the hardware with Python?

Do I nee a specific DLL installed or PI Mikromove installed?

Should "PI Mikromove" software be running in background at the same time or not?

How does this Python library make the link with the hardware?

SReich-EMI commented 2 years ago

In fact, at the moment the system is running well on my PC and I don't know by hard, what all is required. Fore sure, there is no specific dll, taht you have to install / copy by hand. If PI Mikromove and PIPython is installed, is should run. It is not necessary that PI Mirkomove is running in the background. You have to ensure, that the specific stage is NOT connected to PI Mikromove when you want to connect it from Python. As it is a serial connection, only one single connection is possible.

You find a sample within this project that describes how to connect to a device with a daisy chain: samples/connect_daisychain.py The device must be connected via RS232 to the PC. I suspect, that it is via USB-cable.

josephernest commented 2 years ago

Thanks, I'm going to try this!

josephernest commented 2 years ago

Thanks @SReich-EMI, it works now.

Question: is it possible to use this library and PI Motion Controller (C-867) also from Linux?

SReich-EMI commented 2 years ago

nice to hear, that it is working. In fact I have not jet tried under linux. But from a first guess I would say it should also work. I have not jet found something windows specific.

josephernest commented 2 years ago

@SReich-EMI I thought that this Python module is calling a Windows-specific DLL. But it seems it might be available for Linux too: in C:\Python38\Lib\site-packages\pipython\pidevice\interfaces\gcsdll.py, I see:

2: def modify_dll_name(dllname):
   63:     """Modify windows 'dllname' for Linux/Mac systems and according architecture.
   64:     @param dllname : File name of Windows dll.
   65:     @return : Name of DLL as string according to operating system and architecture.
   66      """
   67      if sys.platform in ('linux', 'linux2', 'darwin'):
   68:         unixdll = UNIXDLL.get(dllname)
   69:         if unixdll is None:

so there might be linked libraries for Linux too. Good thing!

Software-PhysikInstrumente commented 2 years ago

The InterfaceSetupDlg is a Dialog implemented in the DLL and it is posible that the dialog is displayed somewhere in the background or on another monitor. But for most case a direct connection without the dialog is easier. PIPython also works on linux the easiest way to install everything necessary is the LinuxApplicationSetup found on the product cd or the website. If you want Linux with USB make sure that you have the libusb.