Daniel Schröer > Lab-Instrument-2.01 > Lab::Instrument

Download:
Lab/Lab-Instrument-2.01.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 1.0650   Source  

NAME ^

Lab::Instrument - General VISA based instrument

SYNOPSIS ^

 use Lab::Instrument;
 
 my $hp22 =  new Lab::Instrument(0,22); # GPIB board 0, address 22
 print $hp22->Query('*IDN?');

DESCRIPTION ^

Lab::Instrument offers an abstract interface to an instrument, that is connected via GPIB, serial bus, USB, ethernet, or Oxford Instruments IsoBus. It provides general Read, Write and Query methods, and more.

It can be used either directly by the programmer to work with an instrument that doesn't have its own perl class (like Lab::Instrument::HP34401A). Or it can be used by such a specialized perl instrument class (like Lab::Instrument::HP34401A) to delegate the actual visa work. (All the instruments in the default package do so.)

CONSTRUCTOR ^

new

 $instrument  = new Lab::Instrument($board,$addr);
 
 $instrument2 = new Lab::Instrument({
    GPIB_board   => $board,
    GPIB_address => $addr
 });

 $instrument3 = new Lab::Instrument($resourcename);

 $instrument4 = new Lab::Instrument($isobus,$addr);

Creates a new instrument object and open the instrument with GPIB address $addr connected to the GPIB board $board (usually 0). Alternatively, the VISA resource name $resourcename can be specified as string for serial or USB devices. All instrument classes that internally use the Lab::Instrument module (that's all instruments in the default distribution) can use these three forms of the constructor.

Lastly, an IsoBus device can be instantiated by providing the IsoBus instrument $isobus (of type Lab::Instrument::IsoBus) as first parameter and the numeric IsoBus address of the device $addr as second parameter.

METHODS ^

Write

 $write_count=$instrument->Write($command);

Sends the command $command to the instrument.

Read

 $result=$instrument->Read($length);

Reads a result of maximum length $length from the instrument and returns it. Dies with a message if an error occurs.

BrutalRead

 $result=$instrument->BrutalRead($length);

Same as Read, but this command ignores all error conditions.

Query

 $result=$instrument->Query($command, $wait_query, $wait_status);

Sends the command $command to the instrument and reads a result from the instrument and returns it. The length of the read buffer is haphazardly set to 300 bytes.

Optional second and third arguments specify waiting times, i.e. how long the instrument needs to process the query and provide a result ($wait_query) and how long the instrument needs to react on a command at all and set the status line ($wait_status). Both parameters are set to 10us if not specified in the command line.

LongQuery

 $result=$instrument->LongQuery($command, $wait_query, $wait_status);

Same as Query, but with a read buffer size of 10240 bytes. If you need to read even more data, you will have to use separate Write and Read calls.

BrutalQuery

 $result=$instrument->BrutalQuery($command);

Same as Query (i.e. buffer size 300 bytes), but with a lot less finesse. :) Sends command, asks for a value and returns whatever is returned. All error conditions including timeouts are blatantly ignored.

Clear

 $instrument->Clear();

Sends a clear command to the instrument.

Handle

 $instr_handle=$instrument->Handle();

Returns the VISA handle. You can use this handle with the Lab::VISA module.

CAVEATS/BUGS ^

Probably many.

SEE ALSO ^

Lab::VISA
Lab::Instrument::HP34401A
Lab::Instrument::HP34970A
Lab::Instrument::Source
Lab::Instrument::KnickS252
Lab::Instrument::Yokogawa7651
Lab::Instrument::SR780
Lab::Instrument::ILM
and many more...

AUTHOR/COPYRIGHT ^

This is $Id: Instrument.pm 650 2010-04-22 19:09:27Z schroeer $

 Copyright 2004-2006 Daniel Schröer <schroeer@cpan.org>, 
           2009-2010 Daniel Schröer, Andreas K. Hüttel (L<http://www.akhuettel.de/>) and David Kalok

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: