OptSuite GPIB Interface

You can deploy GPIB functionality into OptSuite by using the projects gpib-java and imtek.optsuite.gpib

gpib-java is a project that defines an API to access GPIB controllers and devices and already provides an default interface for National Intruments PCI controller cards under Windows. The API is simple to use and used stand-alone as well. Here is a short example of its usage.

package example;
 
import net.sf.jgpib.GPIBException;
import net.sf.jgpib.IGPIBBoard;
import net.sf.jgpib.IGPIBDevice;
import net.sf.jgpib.IGPIBBoard.DeviceDescriptor;
import net.sf.jgpib.ni.GPIBBoard;
 
public class GPIBExample
{
	/**
	 * The board to use
	 */
	private IGPIBBoard board;
	/**
	 * The device to use;
	 */
	private IGPIBDevice device;
	
	/**
	 * Initializes the GPIB board and the device. 
	 * 
	 * @param boardNo The board-number to use 
	 * (In case more than one controller is present at the local mashine)
	 * @param address The address-number of the device to initialize
	 */
	public void init(int boardNo, int address) throws GPIBException {
		// instantiate the board 
		// currently the implementation used
		// can not be configured (probably by system a property)
		// so you'll have to address a concrete implementation
		// in this case we use the ni implementation
		board = new GPIBBoard(boardNo);
		
		board.clearBoard();  // clear the boear, just in case ...
		// In order to talk to devices the boead needs to 
		// become the active controller on the bus
		board.becomeActiveController();
 
		// create a descriptor for the device to use
		DeviceDescriptor descriptor = 
			new IGPIBBoard.DeviceDescriptor(board, address);
 
		// create the device
		// this is done by the board with a given descriptor
		device = board.getGPIBDevice(descriptor);
		
		// init the device
		device.init(IGPIBDevice.Timeout.T3s);
			
		device.clear(); // clear the device, just in case ...
	}
	
	public void someFuncionality() throws GPIBException {
		device.write("R1"); // write to the device
		// query something from the device
		String answer = device.readAnswer("Q2?");
		// that's it
	}
 
	/**
	 * Main funciton for the example
	 */
	public static void main(String[] args)
	{
		GPIBExample control = new GPIBExample();
		try {
			// init with boardNo 0, deviceNo 12
			control.init(0,12);
			control.someFuncionality();
		} catch (GPIBException e) {
			e.printStackTrace();
		}
	}
	
}
 

OptSuite GPIB Plugin

imtek.optsuite.gpib is based on the gpib library and introduces a new MeasurementTool into OptSuite that can serv IGPIBBoards. It can simply be deployed into an OptSuite installation (Needs gpib-java.jar in its lib directory).

 
documentation/modules/gpib.txt · Last modified: 2006/09/14 20:56 by fleque
Recent changes · Show pagesource · Login