[time-nuts] Software for Prologix USB GPIB interface

Ulrich Bangert df6jb at ulrich-bangert.de
Tue Aug 1 07:05:31 EDT 2006


Hi Newsgroup,

just in case someone is interested: I have written a Windows based
utility for the Prologix USB GPIB interface that handles quite complex
data acquistion tasks using a easy to learn PASCAL style meta-language
with lots of predefined procedures and functions aiming at GPIB
communication.

For example:

function
ezgpib_BusWaitForData(Deviceaddress,DeviceData,Timeout):Boolean;

waits "Timeout" seconds to receive data from "Deviceaddress". If data is
available before the timeout the functions returns a "true" and delivers
the data in the string "Devicedata". Otherwise "DeviceData" is empty and
the function returns a "false".

A easy to understand script like the following 

------------------------------------------------------------------------
---------------------------
Program Test_9;                                            // Shows the
use of WaitSrq, SourceOfSrq
                                                           // and
WaitForData
const Keithley  = 1;                                       // Declare
some constants i.e. the device
      Racal1996 = 2;                                       // addresses
on the GPIB
      filename='C:\EZGPIBData\TestFile.Txt';

var ch:char;                                               // Declare a
variable of character type
    s:string;                                              // Declare
some variables of string type
    Temperature:string;
    RacalCount:string;
    TemperatureS:string;                                   // Declare
some strings to hold the 
    RacalCountS:string;                                    // stripped
down version of the instrument strings  
    srqdevice:integer;                                     // Declare a
variable of integer type
    srqtime:tdatetime;                                     // Declare a
variable of date/time type
    
procedure Init;
begin;                                    
  ezgpib_screenClear;                                      // Clear
output console screen
  ezgpib_screenwriteln('Checking for devices');            // Tell user
what we are doing...                       
  ezgpib_BusIFC;                                           // Send a IFC
to Prologix USB <-> GPIB converter
  ezgpib_BusFindAllDevices;                                // Find all
active GPIB devices
  ezgpib_screenwriteln('Initializing devices');            // Tell user
what we are doing...
  ezgpib_BusWriteData(Keithley,'F6X');                     // Set
multimeter to temperature measurement in degree Celsius  
  ezgpib_BusWriteData(Racal1996,'GA 100');                 // Set RACAL
DANA gate time to 100 s
end;

procedure DoScreenOutput;
begin;
  s:='At ';
  ezgpib_ConvertAddToString(s,srqtime);
  ezgpib_ConvertAddToString(s,' device # ');
  ezgpib_ConvertAddToString(s,srqdevice);  
  ezgpib_ConvertAddToString(s,' requested service with status byte '); 
  ezgpib_ConvertAddToString(s,ezgpib_bussrqstatus);     
  ezgpib_screenwriteln(s);
  s:='Raw data: ';
  ezgpib_ConvertAddToString(s,Temperature);
  ezgpib_ConvertAddToString(s,' '); 
  ezgpib_ConvertAddToString(s,RacalCount);
  ezgpib_screenwriteln(s);   
  s:='Stripped: ';
  ezgpib_ConvertAddToString(s,TemperatureS);
  ezgpib_ConvertAddToString(s,' '); 
  ezgpib_ConvertAddToString(s,RacalCountS);
  ezgpib_screenwriteln(s); 
  ezgpib_screenwriteln('');            
end;

procedure writefileheader;
begin;
  ezgpib_filedelete(filename);                             // If the
file exists, delete it
  ezgpib_fileclearbuffer;                                  // Clear the
file's Dataline
  ezgpib_fileaddtobuffer('Date&Time / MJD');               // Add the
first header
  ezgpib_fileaddtobuffer('Temperature / Deg C');           // Add the
second header
  ezgpib_fileaddtobuffer('Frequency / Hz');                // Add the
third header  
  ezgpib_filewrite(filename);                              // Write
Dataline to file
end;

procedure writefiledata;
begin;
  ezgpib_fileclearbuffer;
  ezgpib_fileaddtobuffer(ezgpib_convertToMJD(ezgpib_timenow));// Convert
data&time into 'Modified Julian Date' 
  ezgpib_fileaddtobuffer(TemperatureS);  
  ezgpib_fileaddtobuffer(RacalCountS);                               
  ezgpib_filewrite(filename);
end;

procedure GetData;
begin;
  srqtime:=ezgpib_timeNow;                                 // Store
current time in date/time variable
  srqdevice:=ezgpib_BusSourceOfSrq;                        // Find out
which device requests service
  ezgpib_BusWaitForData(Keithley,Temperature,2);           // Read
temperature frm KEITHLEY multimeter, wait max 2 s
  ezgpib_BusWaitForData(Racal1996,RacalCount,2);           // Read RACAL
DANA counter value
  TemperatureS:=ezgpib_ConvertStripToNumber(Temperature);  // Strip down
the instrument strings to pure numbers
  RacalCountS:=ezgpib_ConvertStripToNumber(RacalCount);  
end;

begin  
  WriteFileHeader;                                         // Notice how
easy the body of the program is to be read
  Init;                                                    // with some
procedures and functions defined.
  repeat
    if ezgpib_BusWaitForSrq(5) then                        // Wait until
a device requests service (or maximal 5 s)
    begin;                                                 // If a
device requests service
      GetData;                                             // Perform
GPIB communication
      DoScreenOutput;
      WriteFileData;                                       // Output
data to screen
    end;
  until ezgpib_kbdKeyPressed;
  ch:=ezgpib_kbdReadKey;
end.  
------------------------------------------------------------------------
--------------------------------------------
produces a screen output as to be seen in the jpg

and produces a file output of:

Date&Time / MJD	Temperature / Deg C	Frequency / Hz
53947.745442175772	+0025.52E+0	+1.0000000000084E+07
53947.746608032379	+0025.52E+0	+1.0000000000045E+07
53947.747769004665	+0025.47E+0	+1.0000000000063E+07
53947.748937349767	+0025.47E+0	+1.0000000000047E+07
53947.750102997758	+0025.50E+0	+1.0000000000057E+07
53947.751264375169	+0025.52E+0	+1.0000000000065E+07
53947.752432140987	+0025.57E+0	+1.0000000000051E+07
53947.753598206211	+0025.57E+0	+1.0000000000092E+07
53947.754759895615	+0025.55E+0	+1.0000000000053E+07
.....
.....
.....

Please note that you need at least firmware version 3.12c of the
Prologix interface to make full use of the utility. If you have an older
firmware please contact Prologix for an update. The utility can be
downloaded from 

http://www.ulrich-bangert.de/html/downloads.html  

At this point of time no documentation is available. Just load the
example files and read the comments to get an idea what it all is about.
Data files produced with EZGPIB may be directly read and processed with
my PLOTTER utility available from the same url. 

Enjoy!

Ulrich Bangert
df6jb at ulrich-bangert.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot.jpg
Type: image/jpeg
Size: 48231 bytes
Desc: not available
Url : http://www.febo.com/pipermail/time-nuts/attachments/20060801/f5068c56/attachment-0001.jpg 


More information about the time-nuts mailing list