IVI, VISA, SCPI
SCPI stands for Standard Commands for Programmable Instruments (SCPI), the commands is pure ASCII String, no physical communications link is not defined, it can be used in USB, GPIB, RS-232, Ethernet, VXI, etc.
Here is an example to make an Agilent U3606A (multimeter and DC power supply, usb interface) to work on Ubuntu 14.04.
we need 3 libs to communicate with the usb interfaced intruments in python, libusb -> pyusb -> usbtmc.
-
pyusb
$pip install pyusb
-
usbtmc
$wget https://github.com/python-ivi/python-usbtmc/blob/master/usbtmc/usbtmc.py
$lsusb
Bus 003 Device 002: ID 0957:4d18 Agilent Technologies, Inc.
vendor ID is 0957 and product ID is 4d18. Use usbtmc to open the device.
import usbtmc
instr = usbtmc.Intruments(0x0957, 0x4d18)
And we got an error message:
USBError: [Errno 13] Access denied (insufficient permissions)
we need add rule to udev, by:
sudo vim /etc/udev/rules.d/usbtmc.rules
add following content:
# Agilent U3606A
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0957", ATTR{idProduct}=="4d18", GROUP="usbtmc", MODE="0660"
The group stands for the unix group name, and mode is unix permissions, 0660 (equals to 110 110 000, 3 groups of "r" "w" "x" for owner, group and others, equals to rw-rw----) stands for owner and group have read and write permission while others don't.
We need check if the group "usbtmc" exists and if the current user is in the group.
$cat /etc/group
(list groups)
$groups qibo
(or just $groups, list groups the current user in)
qibo : qibo adm dialout fax cdrom floppy tape sudo audio dip video plugdev fuse netdev vboxusers usbtmc
if your username is not in the group or the group "usbtmc" doesn't exists:
$sudo groupadd usbtmc
(add group)
$sudo usermod -G usbtmc -a qibo
(add qibo to group usbtmc)
We need restart the computer to make it effective.
import usbtmc
instr = usbtmc.Instruments(0x0957, 0x4d18)
instr.ask("*IDN?\n") # notice the "\n" is for Agilent only, some other vendor may not required.
# u'Agilent Technologies,U3606A,MY49520024,01.00-01.00-01.00'
Now it's ready to use the device.
Here is an example to make an Agilent U3606A (multimeter and DC power supply, usb interface) to work on Windows 7. The steps will be very simliar to previous steps for Linux.
we need 3 libs to communicate with the usb interfaced intruments in python, libusb -> pyusb -> usbtmc.
-
libusb Download the libusb for win32 at "http://sourceforge.net/projects/libusb-win32/",
use the inf-wizard program to automatic generate the usb driver for the Agilent U3606A, keep the vendor ID and production ID unchanged. And install the driver. Notice that only libusb-win32 version > 1.2.2 supports Windows 7. -
pyusb
$pip install pyusb
-
usbtmc
$wget https://github.com/python-ivi/python-usbtmc/blob/master/usbtmc/usbtmc.py
Once we installed the drivers and libs, we can directly use it in windows 7:
import usbtmc
instr = usbtmc.Instruments(0x0957, 0x4d18)
instr.ask("*IDN?\n") # notice the "\n" is for Agilent only, some other vendor may not required.
# u'Agilent Technologies,U3606A,MY49520024,01.00-01.00-01.00'
http://cp.literature.agilent.com/litweb/pdf/5989-6715EN.pdf