Differences between revisions 3 and 26 (spanning 23 versions)
Revision 3 as of 2008-08-27 03:05:12
Size: 815
Editor: YoichiAso
Comment:
Revision 26 as of 2008-09-22 21:47:10
Size: 8052
Editor: YoichiAso
Comment:
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
= GPIB hardware we have = == GPIB hardware we have ==
Line 7: Line 7:
 * [http://prologix.googlepages.com/ Prologix GPIB-Ethernet converter]
 * [http://www.linksys.com/servlet/Satellite?c=L_Product_C2&childpagename=US%2FLayout&pagename=Linksys%2FCommon%2FVisitorWrapper&cid=1134692497433 Linksys WET54G ethernet-wireless bridge] for adding a wireless capability to the prologix box.
Line 8: Line 10:
= GPIB scripting in Python = == Controlling GPIB instruments through network ==
This section describes how to setup and control GPIB instruments through network.

=== Overview ===
The basic idea is to talk to a GPIB instrument through a TCP/IP network using the prologix GPIB-Ethernet converter.
For some GPIB instruments, like spectrum analyzers, it is convenient to be able to move them around freely. For this purpose, we connect the
prologix box to the Martian wireless network through an ethernet-wireless bridge.

After proper setup work, the GPIB-Ethernet converter works as a host in the Martian network. It waits for connections at TCP/IP port 1234.
You can talk to the converter by telnet. Simple tasks can be done in this way. More complicated tasks can be accomplished by, for example, python
scripts. A python script netgpibdata.py to download data from analyzers will be explained later.

=== Hardware setup ===
==== Prologix ====
Unpack the box. Connect the prologix to a local network using an Ethernet cable. Connect your PC to the same network.

Execute attachment:netfinder.exe. On linux, you can use Wine to execute this file. For example, on Ubuntu, I was able to just install Wine from
standard packages, and double clicking the netfinder.exe worked fine.

netfinder.exe will search prologix converters on the local network and let you configure the network settings of the converter.
Assign a free Martian IP address to the box. You may want to ask Rana to assign a suitable host name for the box. If a hostname is assigned,
please update the name server database on linux1.

The manual for the prologix converter is here:
attachment:PrologixGpibLanManual.pdf

==== Linksys WET54G ====
You have to tell the WET54G which wireless network to connect.

Connect the WET54G and your computer directly with an Ethernet cable. Manually assign 192.168.1.25 to your computer. The netmask is 255.255.255.0 and
the gateway is 192.168.1.1.

Open a web browser and go to 192.168.1.226. A password prompt should come up. Enter '''admin''' for both username and password. You may want to change the admin password later.

Setup the WET54G for the Martian network. The SSID is "40MARS". Security is off. Enable the MAC address cloning should be enabled.

Check the MAC address of the WET54G wireless port. Register this MAC address to the Martian wireless router.
You can access the router by going to 131.215.113.220 from a Martian machine.
The setting is in [Wireless]->[Wireless MAC Filter]

==== Assembly ====
Connect the Prologix box to a GPIB instrument. Then connect to the WET54G through an Ethernet cable.
Confirm the connection by
{{{ telnet 131.215.113.105 1234}}},

where 131.215.113.105 should be replaced by the IP address assigned to the Prologix box.
The above command works only from a computer connected to the Martian network.

== Using Agilent 82357B USB-GPIB interface from Linux ==
82357B can be used from Linux using the linux-gpib driver. This section will explain how to install the driver
and use it from python and other languages.

=== Installation ===
===== What you need =====
Linux kernel source (2.6.8 or above)
python, python-dev
fxload (from linux-hotplug project)
lsusb (usbutils package)

Depending on your distribution, you may have to mount usbfs to /proc/bus/usb.
(In Fedora, it is automatically mounted).
If needed, you may want to add the following line to /etc/fstab

{{{
usbfs /proc/bus/usb usbfs defaults 0 0
}}}

===== Installing linux-gpib driver =====
Before installing linux-gpib driver, create a group {{{gpib}}}, by {{{sudo vigr}}}.

You want to add some users (e.g. controls) to {{{gpib}}} group so that those users can
open GPIB devices.

Download the latest version from
http://linux-gpib.sourceforge.net/

Expand the archive and execute the following,

{{{ ./configure --enable-python-binding --with-linux-srcdir=/lib/modules/2.6.24-19/build }}}

where 2.6.24-19 should be replaced by your kernel version.

{{{ make; sudo make install }}} should install the driver.

===== Installing firmwares =====
Download the proprietary firmwares from http://linux-gpib.sourceforge.net/firmware/

Expand the archive and copy {{{agilent_82357a/*.hex}}} to {{{/usr/share/usb/agilent_82357a/}}}.
If the target directory does not exist, make it.

===== Configuration file and scripts =====

Put the following file in {{{/etc/}}}.
attachment:gpib.conf

Add the following lines to your {{{/etc/modprobe.conf}}}

{{{
alias char-major-160 gpib_common
alias char-major-160-0 agilent_82357a
alias gpib0 agilent_82357a
}}}

Put the following files into somewhere in your PATH.

attachment:initGPIB
attachment:getgpibdata.py

Be sure to set the permission of those files to executable.

Change the group of /dev/gpib* to gpib and set the permission to group readable/writable.

{{{ chown root:gpib /dev/gpib*; chmod ug+rw /dev/gpib* }}}


=== Usage ===
When you connect the GPIB-USB interface to your USB port, the kernel modules should be loaded automatically.
If not, don't worry, the initGPIB script will load them.

First, execute initGPIB script. You have to have {{{sudo}}} privilege to run the script as a normal user.
This script will load the kernel modules, load the firmware twice (a work around for the buggy firmware of 82357B)
and execute {{{gpib_config}}}.

After initGPIB is completed, the "READY" LED on 82357B should be green.

Now connect 82357B to 4395A analyzer. On the 4395A keypad, go to [Local]->[SET ADDRESSES]->[ADDRESS:4395] and set it to 17.
Also set [ADDRESS: CONTROLLER] to 0.

Do a measurement.

Run {{{getgpibdata.py}}}.

The command will output the data transfered from the analyzer into the standard output. So you can redirect it to a file like,

{{{ %getgpibdata.py > data.txt }}}

Then {{{data.txt}}} will look like this,

{{{
+0.00000000000000E+000 +4.604457E-004
+6.25000000000000E+005 +3.845480E-005
+1.25000000000000E+006 +7.024327E-009
+1.87500000000000E+006 +1.066326E-009
+2.50000000000000E+006 +6.686992E-010
+3.12500000000000E+006 +2.618739E-010
...
}}}

The first column is frequency, the second is, in this case, the magnitude of the CH1 spectrum. If you have CH2 active, you will have the third column.
In the case of network analyzer mode, the second column is the real part of the transfer function and the third is the imaginary part.

=== How it works ===
GPIB devices are defined in {{{/etc/gpib.conf}}}. You have to specify the address of a device and assign an arbitrary name.
The name is used later to search for a device in python scripts.

{{{getgpibdata.py}}} is a simple python script. You can modify it to communicate with any kind of GPIB devices.

Here is the programing manual for Agilent 4395A.

attachment:4395A-GPIB-Manual.pdf


== Alternative way (GPIB scripting in Python) ==

GPIB issues

This page will cover GPIB issues in the 40m lab. Test equipment with a GPIB interface (such as the SR785) may be scripted from a computer.

GPIB hardware we have

Controlling GPIB instruments through network

This section describes how to setup and control GPIB instruments through network.

Overview

The basic idea is to talk to a GPIB instrument through a TCP/IP network using the prologix GPIB-Ethernet converter. For some GPIB instruments, like spectrum analyzers, it is convenient to be able to move them around freely. For this purpose, we connect the prologix box to the Martian wireless network through an ethernet-wireless bridge.

After proper setup work, the GPIB-Ethernet converter works as a host in the Martian network. It waits for connections at TCP/IP port 1234. You can talk to the converter by telnet. Simple tasks can be done in this way. More complicated tasks can be accomplished by, for example, python scripts. A python script netgpibdata.py to download data from analyzers will be explained later.

Hardware setup

Prologix

Unpack the box. Connect the prologix to a local network using an Ethernet cable. Connect your PC to the same network.

Execute attachment:netfinder.exe. On linux, you can use Wine to execute this file. For example, on Ubuntu, I was able to just install Wine from standard packages, and double clicking the netfinder.exe worked fine.

netfinder.exe will search prologix converters on the local network and let you configure the network settings of the converter. Assign a free Martian IP address to the box. You may want to ask Rana to assign a suitable host name for the box. If a hostname is assigned, please update the name server database on linux1.

The manual for the prologix converter is here: attachment:PrologixGpibLanManual.pdf

Linksys WET54G

You have to tell the WET54G which wireless network to connect.

Connect the WET54G and your computer directly with an Ethernet cable. Manually assign 192.168.1.25 to your computer. The netmask is 255.255.255.0 and the gateway is 192.168.1.1.

Open a web browser and go to 192.168.1.226. A password prompt should come up. Enter admin for both username and password. You may want to change the admin password later.

Setup the WET54G for the Martian network. The SSID is "40MARS". Security is off. Enable the MAC address cloning should be enabled.

Check the MAC address of the WET54G wireless port. Register this MAC address to the Martian wireless router. You can access the router by going to 131.215.113.220 from a Martian machine. The setting is in [Wireless]->[Wireless MAC Filter]

Assembly

Connect the Prologix box to a GPIB instrument. Then connect to the WET54G through an Ethernet cable. Confirm the connection by  telnet 131.215.113.105 1234,

where 131.215.113.105 should be replaced by the IP address assigned to the Prologix box. The above command works only from a computer connected to the Martian network.

Using Agilent 82357B USB-GPIB interface from Linux

82357B can be used from Linux using the linux-gpib driver. This section will explain how to install the driver and use it from python and other languages.

Installation

What you need

Linux kernel source (2.6.8 or above) python, python-dev fxload (from linux-hotplug project) lsusb (usbutils package)

Depending on your distribution, you may have to mount usbfs to /proc/bus/usb. (In Fedora, it is automatically mounted). If needed, you may want to add the following line to /etc/fstab

usbfs   /proc/bus/usb   usbfs   defaults        0       0 

Installing linux-gpib driver

Before installing linux-gpib driver, create a group gpib, by sudo vigr.

You want to add some users (e.g. controls) to gpib group so that those users can open GPIB devices.

Download the latest version from http://linux-gpib.sourceforge.net/

Expand the archive and execute the following,

 ./configure --enable-python-binding --with-linux-srcdir=/lib/modules/2.6.24-19/build 

where 2.6.24-19 should be replaced by your kernel version.

 make; sudo make install  should install the driver.

Installing firmwares

Download the proprietary firmwares from http://linux-gpib.sourceforge.net/firmware/

Expand the archive and copy agilent_82357a/*.hex to /usr/share/usb/agilent_82357a/. If the target directory does not exist, make it.

Configuration file and scripts

Put the following file in /etc/. attachment:gpib.conf

Add the following lines to your /etc/modprobe.conf

alias char-major-160 gpib_common
alias char-major-160-0  agilent_82357a
alias gpib0 agilent_82357a

Put the following files into somewhere in your PATH.

attachment:initGPIB attachment:getgpibdata.py

Be sure to set the permission of those files to executable.

Change the group of /dev/gpib* to gpib and set the permission to group readable/writable.

 chown root:gpib /dev/gpib*; chmod ug+rw /dev/gpib* 

Usage

When you connect the GPIB-USB interface to your USB port, the kernel modules should be loaded automatically. If not, don't worry, the initGPIB script will load them.

First, execute initGPIB script. You have to have sudo privilege to run the script as a normal user. This script will load the kernel modules, load the firmware twice (a work around for the buggy firmware of 82357B) and execute gpib_config.

After initGPIB is completed, the "READY" LED on 82357B should be green.

Now connect 82357B to 4395A analyzer. On the 4395A keypad, go to [Local]->[SET ADDRESSES]->[ADDRESS:4395] and set it to 17. Also set [ADDRESS: CONTROLLER] to 0.

Do a measurement.

Run getgpibdata.py.

The command will output the data transfered from the analyzer into the standard output. So you can redirect it to a file like,

 %getgpibdata.py > data.txt 

Then data.txt will look like this,

+0.00000000000000E+000 +4.604457E-004
+6.25000000000000E+005 +3.845480E-005
+1.25000000000000E+006 +7.024327E-009
+1.87500000000000E+006 +1.066326E-009
+2.50000000000000E+006 +6.686992E-010
+3.12500000000000E+006 +2.618739E-010
...

The first column is frequency, the second is, in this case, the magnitude of the CH1 spectrum. If you have CH2 active, you will have the third column. In the case of network analyzer mode, the second column is the real part of the transfer function and the third is the imaginary part.

How it works

GPIB devices are defined in /etc/gpib.conf. You have to specify the address of a device and assign an arbitrary name. The name is used later to search for a device in python scripts.

getgpibdata.py is a simple python script. You can modify it to communicate with any kind of GPIB devices.

Here is the programing manual for Agilent 4395A.

attachment:4395A-GPIB-Manual.pdf

Alternative way (GPIB scripting in Python)

Software needed:

GPIB (last edited 2013-04-26 19:15:51 by EricquinteroATligoDOTorg)