Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instance of 'Keithley2600Factory' has no 'smua' member #20

Open
GitQer opened this issue Jan 16, 2021 · 7 comments
Open

Instance of 'Keithley2600Factory' has no 'smua' member #20

GitQer opened this issue Jan 16, 2021 · 7 comments

Comments

@GitQer
Copy link

GitQer commented Jan 16, 2021

Hello, I try to use this package but an error happened that Instance of 'Keithley2600Factory' has no 'smua' member

@samschott
Copy link
Member

@GitQer, could give some more information? The exact code which caused the error and the full traceback. Otherwise it’s very difficult to help.

@GitQer
Copy link
Author

GitQer commented Jan 16, 2021

code:
from keithley2600 import Keithley2600
k = Keithley2600('GPIB0::26::INSTR')
k.apply_voltage(k.smua, 10)
k.apply_voltage(k.smub, 8)

image

Traceback (most recent call last):
File "c:/Users/user/Desktop/kk.py", line 3, in
k = Keithley2600('GPIB0::26::INSTR')
File "D:\ANACONDA\envs\K2\lib\site-packages\keithley2600\keithley_driver.py", line 1679, in new
instance = Keithley2600(*args, **kwargs)
File "D:\ANACONDA\envs\K2\lib\site-packages\keithley2600\keithley_driver.py", line 841, in init
Keithley2600Base.init(
File "D:\ANACONDA\envs\K2\lib\site-packages\keithley2600\keithley_driver.py", line 566, in init
self.connect(**kwargs)
File "D:\ANACONDA\envs\K2\lib\site-packages\keithley2600\keithley_driver.py", line 584, in connect
self.connection = self.rm.open_resource(self.visa_address, **kwargs)
File "D:\ANACONDA\envs\K2\lib\site-packages\pyvisa\highlevel.py", line 3304, in open_resource
res.open(access_mode, open_timeout)
File "D:\ANACONDA\envs\K2\lib\site-packages\pyvisa\resources\resource.py", line 297, in open
self.session, status = self._resource_manager.open_bare_resource(
File "D:\ANACONDA\envs\K2\lib\site-packages\pyvisa\highlevel.py", line 3232, in open_bare_resource
return self.visalib.open(self.session, resource_name, access_mode, open_timeout)
File "D:\ANACONDA\envs\K2\lib\site-packages\pyvisa_py\highlevel.py", line 167, in open
sess = cls(session, resource_name, parsed, open_timeout)
File "D:\ANACONDA\envs\K2\lib\site-packages\pyvisa_py\sessions.py", line 266, in init
raise ValueError(msg)
ValueError: Please install linux-gpib (Linux) or gpib-ctypes (Windows, Linux) to use this resource type. Note that installing gpib-ctypes will give you access to a broader range of funcionality.
No module named 'gpib'

@samschott
Copy link
Member

Ah, ok. So the issue is that you are not actually connected to the Keithley. The error message says:

ValueError: Please install linux-gpib (Linux) or gpib-ctypes (Windows, Linux) to use this resource type. Note that installing gpib-ctypes will give you access to a broader range of functionality.

Once you are connected, attributes like smua, smub, etc, will be available if your Keithley model supports them.

@samschott
Copy link
Member

Since your connection is via GPIB, it looks like you will have to install gpib-ctypes first. You can then connected manually with:

from keithley2600 import Keithley2600

k = Keithley2600('GPIB0::26::INSTR')
k.connect()

The last call will return True if the connection is successful.

@GitQer
Copy link
Author

GitQer commented Jan 17, 2021

I connect to the keithley2634B and check it in NI-MAX, and I have installed the gpib-ctypes, but it seems not work.

from gpib_ctypes import make_default_gpib 
make_default_gpib()
from keithley2600 import Keithley2600
k = Keithley2600('GPIB0::26::INSTR')
k.connect()
`D:\ANACONDA\envs\K2\lib\site-packages\gpib_ctypes\gpib\gpib.py:54: UserWarning: GPIB library not found. Please manually load it using _load_lib(filename). All GPIB functions will raise OSError until the library is manually loaded.
  warnings.warn(message)
Traceback (most recent call last):
  File "D:\ANACONDA\envs\K2\lib\site-packages\pyvisa_py\sessions.py", line 195, in get_session_class
    return cls._session_classes[(interface_type, resource_class)]
KeyError: (<InterfaceType.gpib: 1>, 'INSTR')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:/Users/NAME/Desktop/kk.py", line 4, in <module>
    k = Keithley2600('GPIB0::26::INSTR')
  File "D:\ANACONDA\envs\K2\lib\site-packages\keithley2600\keithley_driver.py", line 1679, in __new__
    instance = Keithley2600(*args, **kwargs)
  File "D:\ANACONDA\envs\K2\lib\site-packages\keithley2600\keithley_driver.py", line 841, in __init__
    Keithley2600Base.__init__(
  File "D:\ANACONDA\envs\K2\lib\site-packages\keithley2600\keithley_driver.py", line 566, in __init__
    self.connect(**kwargs)
  File "D:\ANACONDA\envs\K2\lib\site-packages\keithley2600\keithley_driver.py", line 584, in connect
    self.connection = self.rm.open_resource(self.visa_address, **kwargs)
  File "D:\ANACONDA\envs\K2\lib\site-packages\pyvisa\highlevel.py", line 3304, in open_resource
    res.open(access_mode, open_timeout)
  File "D:\ANACONDA\envs\K2\lib\site-packages\pyvisa\resources\resource.py", line 297, in open
    self.session, status = self._resource_manager.open_bare_resource(
  File "D:\ANACONDA\envs\K2\lib\site-packages\pyvisa\highlevel.py", line 3232, in open_bare_resource
    return self.visalib.open(self.session, resource_name, access_mode, open_timeout)
  File "D:\ANACONDA\envs\K2\lib\site-packages\pyvisa_py\highlevel.py", line 163, in open
    cls = sessions.Session.get_session_class(
  File "D:\ANACONDA\envs\K2\lib\site-packages\pyvisa_py\sessions.py", line 197, in get_session_class
    raise ValueError(
ValueError: No class registered for InterfaceType.gpib, INSTR`

@samschott
Copy link
Member

It appears that gpib-ctypes cannot find the GPIB library that should come installed with NI-VISA and asks you to manually specify the location. I am neither familiar with Windows nor with GPIB (we use Linux and Ethernet connections in our lab) so cannot help there.

Alternatively, you could try to completely switch backends and use the NI-VISA backend directly, as described in the README.

@ozumana
Copy link

ozumana commented Jan 17, 2021

As suggested by Sam in an earlier query, the following works in my windows7 install...

k = Keithley2600('GPIB0::26::INSTR', visa_library='C:\windows\system32\visa64.dll')
k.reset()

but, k.reset (same as *RST) may not be able to correctly reset the instrument to default state under certain conditions (e.g., when comms have been interrupted, such after a program sweep that failed), thus appearing as if the instrument commands are not available. In this case, functionality can be easily restored with a reset via the NI VISA Test panel (ensuring that the STB? query returns status byte 0)...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants