Device::GPIB::Prologix - Interface to Prologix GPIB-USB Controller
use Device::GPIB::Prologix; my $d = Device::GPIB::Prologix->new('/dev/ttyUSB0'); my $pad = 17; $d->sendTo('id?', $pad); my $id = $d->read();
This module provides an OO interface to the Prologix GPIB-USB Controller http://prologix.biz/downloads/PrologixGpibUsbManual-6.0.pdf
It allows you to issue commands and read and write data to and from GPIB devices. The Prologix controller can also act as a device and Device::GPIB::Prologix supports this.
Requires Device::SerialPort.
None by default.
$d->sendControllerCommand($command);
Sends the unescaped $command to the Prologix controller. This is for internal use only, and not for sending commands to GPIB devices, for which you should instead use send() or sendTo()
$d->send($command);
Sends the $command to the currently addressed device.
$d->sendTo($command, $pad);
Sets the current address if necessary, sends the $command to the specified device.
Reads data until a timeout. No interpretation of incoming characters is done.
Reads data until and EOL character (newline, "\n") is read.
Closes the serial port device.
my $d = Device::GPIB::Prologix->new($port);
Creates a new device instance, connected to the Prologix GPIB-USB Controller via the serial-USB port specified by $port (default '/dev/ttyUSB0').
The Device::GPIB::Prologix object will be automatically destroyed and the serial port closed when the reference goes out of scope.
$data = $d->read();
Read data from the addressed instrument until a timeout.
$data = $d->read(1);
Read data from the addressed instrument until EOI or timeout.
Reads binary data from the addressed instrument until a timeout expires. The binary data s delivered verbatim, adn can enclude the EOL character.
Returns the version string from the Prologix GPIB-USB controller.
Issues the '++auto' command to the PRologix controller, which is not very useful with this package.
Configure or query the current GPIB address of the GPIB controllerusing the '++addr' command.
$ver = $d->addr();
Returns the currently selected GPIB device address.
$d->addr($pad);
Sets the GPIB address of the instrument to be controlled. $pad is an integer between 0 and 30.
$d->addr($pad, $sad);
Sets both the Primary and secondary address of the instrument to be controlled. $pad is an integer between 0 and 30. $sad is an ineger between 96 and 126.
Sends the Selected Device Clear (SDC) message to the currently specified GPIB address.
$d->eoi($bool);
Enables or disables the assertion of the EOI signal with the last character.
$set = $d->eoi();
Queries whether EOI is enabled or disabled.
$d->eos($val);
Specifies the GPIB termination character, where $val is:
0 Append CR+LF to instrument commands 1 Append CR to instrument commands 2 Append LF to instrument commands 3 Do not append anything to instrument commands
$val = $d->eos();
Queries the current setting of eoi.
$d->eot_enable($bool) Enables or disables the appending of a user specified character (see eot_char) to USB output whenever EOI is detected while reading a character from the GPIB port.
$val = $d->eot_enable();
Queries the current state of eot_enable.
$d->eot_char($char);
Specifies the character to be appended to USB output when eot_enable is set to 1 and EOI is detected.
$char = $d->eot_char();
Queries the value of the currently set eot_char.
$d->ifc();
Asserts GPIB IFC signal for 150 microseconds making Prologix GPIB-USB controller the Controller-In-Charge on the GPIB bus.
$d->llo();
Disables front panel operation of the currently addressed instrument.
$d->loc();
Enables front panel operation of the currently addressed instrument.
$d->lon($bool)
Enables or disables the GPIB-USB controller to listen to all traffic on the GPIB bus, irrespective of the currently specified address (listen-only mode).
$val = $d->lon();
Queries the state of the lon.
$d->mode($val);
Configures the Prologix GPIB-USB controller to be a CONTROLLER or DEVICE, where $val = 1 is CONTROLLER and $val = 2 is DEVICE
$val = $d->mode();
Queries the current value of the mode setting.
$d->read_tmo_ms($val);
specifies the timeout value, in milliseconds, to be used in the read command and spoll command. Timeout may be set to any value between 1 and 3000 milliseconds
$d->rst();
Performs a power-on reset of the controller. The process takes about 5 seconds. All input received over USB during this time are ignored.
$d->savecfg($val);
Enables, or disables, automatic saving of configuration parameters in EPROM.
$val = $d->savecfg();
performs a serial poll of the instrument at the specified address. If no address is specified then this command serial polls the currently addressed instrument.
$d->spoll($pad);
Serial poll instrument at primary address.
$d->spoll($pad, $sad);
Serial poll instrument at primary address and secondary address.
$d->spoll();
Serial poll the currently addressed instrument.
$val= $d->srq();
Returns the current state of the GPIB SRQ signal.
$d->status($val);
Specify the device status byte to be returned when serial polled by a GPIB controller.
$d->trg($pad1, $sad1, ......);
issues Group Execute Trigger GPIB command to devices at the specified addresses. Up to 15 addresses maybe specified.
$d->id()
Queries the device for its ID and retuens it. If there is no device at the assigned address, returns empty string
A number ofsample programs are provided in bin which may be useful in their own right. They will be installed into your perl script diorectory if you 'make install'.
Make a screendump from a Tek TDS-220 or similar scope tekscreendump.pl -address 1 >/tmp/x.bmp
Read values continuously from a Tektronix DM5110. dm5110.pl -address 22
Mike McCauley, <mikem@airspayce.com>
Copyright (C) 2015 by Mike McCauley
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.18.1 or, at your option, any later version of Perl 5 you may have available.
To install Device::GPIB, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Device::GPIB
CPAN shell
perl -MCPAN -e shell install Device::GPIB
For more information on module installation, please visit the detailed CPAN module installation guide.