Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:python-usbtmc:readme [2013/06/23 05:42] – alex | en:python-usbtmc:readme [2013/12/17 07:22] (current) – alex | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| Python USBTMC provides a pure Python USBTMC driver for controlling instruments over USB. | Python USBTMC provides a pure Python USBTMC driver for controlling instruments over USB. | ||
| + | |||
| + | ===== Requirements ===== | ||
| + | |||
| + | * Python 2 or Python 3 | ||
| + | * PyUSB | ||
| ===== Installation ===== | ===== Installation ===== | ||
| Line 9: | Line 14: | ||
| Extract and run | Extract and run | ||
| - | | + | < |
| + | # python setup.py install | ||
| + | </ | ||
| + | |||
| + | ===== Configuring udev ===== | ||
| + | |||
| + | If you cannot access your device without running your script as root, then you may need to create a udev rule to properly set the permissions of the device. First, connect your device and run lsusb. | ||
| + | |||
| + | < | ||
| + | # USBTMC instruments | ||
| + | |||
| + | # Agilent MSO7104 | ||
| + | SUBSYSTEMS==" | ||
| + | </ | ||
| + | |||
| + | substituting the correct idVendor and idProduct from lsusb. | ||
| + | |||
| + | If you want to put the kernel usbtmc device in the same group, add the following content to the usbtmc.rules file as well. This is optional as Python USBTMC bypasses and disconnects the kernel usbtmc driver and the device will actually disappear from /dev when Python USBTMC connects. | ||
| + | |||
| + | < | ||
| + | # Devices | ||
| + | KERNEL==" | ||
| + | KERNEL==" | ||
| + | </ | ||
| + | |||
| + | ===== Windows setup ===== | ||
| + | |||
| + | To use Python USBTMC in Windows, PyUSB and libusb are required. | ||
| + | |||
| + | * http:// | ||
| + | * http:// | ||
| + | |||
| + | An INF file will also need to be created in order to use devices with libusb. Without a properly set up INF file, Python USBTMC will not be able to locate the device. | ||
| ===== Usage examples ===== | ===== Usage examples ===== | ||
| Line 18: | Line 55: | ||
| import usbtmc | import usbtmc | ||
| instr = usbtmc.Instrument(2391, | instr = usbtmc.Instrument(2391, | ||
| + | print(instr.ask(" | ||
| + | # returns ' | ||
| + | </ | ||
| + | |||
| + | When multiple instruments are connected they can be identified by serial number: | ||
| + | |||
| + | <code python> | ||
| + | import usbtmc | ||
| + | instr = usbtmc.Instrument(2391, | ||
| + | print(instr.ask(" | ||
| + | # returns ' | ||
| + | </ | ||
| + | |||
| + | It is also possible to connect with VISA resource strings like so: | ||
| + | |||
| + | <code python> | ||
| + | import usbtmc | ||
| + | instr = usbtmc.Instrument(" | ||
| + | print(instr.ask(" | ||
| + | # returns ' | ||
| + | </ | ||
| + | |||
| + | and: | ||
| + | |||
| + | <code python> | ||
| + | import usbtmc | ||
| + | instr = usbtmc.Instrument(" | ||
| print(instr.ask(" | print(instr.ask(" | ||
| # returns ' | # returns ' | ||