Online documentation - GPIBGPIB messages can be sent and received through channel functions or the gpib() terminal function (version 0.81+). The former method works best when the purpose of the communication is to get or set an instrument parameter which can be stored locally as a floating-point value. The latter method can be used for any purpose because it is up to the user to format the message and interpret the reply. Channel functionsInstrument parameters can be accessed via GPIB by placing a call to a pre-defined channel function in a virtual channel definition. During the parsing phase a gpib slot is created for each board/address combination mentioned in the channel definitions. The resulting set of gpib slots is read continuously in panel mode, assuming GPIB is not paused. GPIB channel functions are defined using the following function: GPIB_Device (read_str, read_period, dummy_value, reply_fmt, write_fmt)
Since version 0.81, users can create new their own functions by placing calls to GPIB_Device() in ~/.config/mezurit2/compute.py (see Installed files). Example: SRS lock-in amplifier
Technical detail: When read_period is much slower than the DAQ rate (which is usually the case), a gpib slot will return the value obtained by the last read operation rather than waiting for a "fresh" value. When a slot has been written more recently than it has been read, it will return the last written value, in effect assuming that the write operation succeeded. This behavior allows smooth high-speed sweeps over GPIB with out bogging down the system (and the instrument) with unnecessary reads during idle periods. Functions created with GPIB_Device have several additional default parameters which can be modified if necessary: self.eos to set the end-of-string byte (default: 0x0), self.intro to set the identification query (default: "*IDN?"), and self.inverse_fn and self.noninverse_fn to provide an additional layer of abstraction, explained below. Example: Oxford temperature controller
Members self.inverse_fn and self.noninverse_fn are useful when a GPIB command expects values in undesirable units. Function self.noninverse_fn is applied to the value read via GPIB and self.inverse_fn is applied to a value to be sent over GPIB. The default for both is to do nothing, i.e. the unity function lambda x : x. Example: Agilent signal generator
These functions are also useful for implementing lookup tables, especially when combined with the nearest_index() function (version 0.81+) detailed below. For an example, see the definition of SR830_Tau() in compute_example.py (for version 0.74, see script_example.py). nearest_index (list, target)
Important: The syntax used to define GPIB channel functions in version 0.74 is slightly different from that described above, and self.inverse_fn and self.noninverse_fn are not available. More information is available here. Terminal function (ver. 0.81+)Plain text GPIB commands can be sent directly from the terminal using the gpib() function. This function also accepts two optional arguments eos and expect_reply which are described in its documentation. Example: Agilent signal generator
|
GPIB |