This is an old revision of the document!
Python IVI Readme
Python IVI is a Python-based interpretation of the Interchangeable Virtual Instrument standard from the IVI foundation.
Included drivers
- DC Power Supplies (dcpwr)
- Tektronix PS2520G/PS2521G
- Function Generators (fgen)
- Tektronix AWG2000 series
- RF Signal Generators (rfsiggen)
- Agilent 8642 A/B
- Oscilloscopes (scope)
- Agilent InfiniiVision 7000A series
Instrument communication
Python IVI can use linux-gpib and Python VXI11 to connect to instruments. The implementation of the initialize method takes a VISA resource string and attempts to connect to an instrument. If the resource string starts with TCPIP, then Python IVI will attempt to use Python VXI11. If it starts with GPIB, it will attempt to use linux-gpib's python interface. Integration with PyVISA is planned, but not currently supported.
A note on standards compliance
As the IVI standard only specifies the API for C, COM, and .NET, a Python implementation is inherently not compliant and hence this is not an implementation of the standard, but an interpretation that tries to remain as faithful as possibe while presenting a uniform, easy-to-use, sensible, python-style interface.
The Python IVI library is a Pythonized version of the .NET and COM IVI API specifications, with the CamelCase for everything but the class names replaced with lowercase_with_underscores. The library most closely follows the .NET standard, with the calls that would require the .NET helper classes follwing the corresponding COM specifications. There are some major deviations from the specification in order to be consistent with the spirit of the other IVI specifications. The fgen class is the most obvious example of this, using properties instead of the getters and setters as required by the IVI specification.
Usage example
This sample Python code will use Python IVI connect to an Agilent MSO7104A over LXI (VXI11), configure the timebase, trigger, and channel 1, capture a waveform, and read it out of the instrument.
# import Python IVI import ivi # connect to MSO7104A via LXI mso = ivi.agilent.agilentMSO7104A("TCPIP0::192.168.1.104::INSTR") # configure timebase mso.acquisition.time_per_record = 1e-3 # configure triggering mso.trigger.type = 'edge' mso.trigger.source = 'channel1' mso.trigger.coupling = 'dc' mso.trigger.edge.slope = 'positive' mso.trigger.level = 0 # configure channel mso.channels['channel1'].enabled = True mso.channels['channel1'].offset = 0 mso.channels['channel1'].range = 4 mso.channels['channel1'].coupling = 'dc' # initiate measurement mso.measurement.initiate() # read out channel 1 waveform data waveform = mso.channels[0].measurement.fetch_waveform()
This sample Python code will use Python IVI to connect to a Tektronix AWG2021 through a GPIB to VXI11 bridge or serial (pySerial), generate a sinewave with numpy, and transfer it to channel 1.
# import Python IVI import ivi # import numpy from numpy import * # connect to AWG2021 via E2050A GPIB to VXI11 bridge awg = ivi.tektronix.tektronixAWG2021("TCPIP0::192.168.1.104::gpib,10::INSTR") # connect to AWG2021 via serial #awg = ivi.tektronix.tektronixAWG2021("ASRL::/dev/ttyUSB0,9600::INSTR") # create a waveform n = 128 f = 1 a = 1 wfm = a*sin(2*pi/n*f*arange(0,n)) # transfer to AWG2021 awg.outputs[0].arbitrary.create_waveform(wfm) # 2 volts peak to peak awg.outputs[0].arbitrary.gain = 2.0 # zero offset awg.outputs[0].arbitrary.gain = 0.0 # sample rate 128 MHz arb.arbitrary.sample_rate = 128e6 # enable ouput awg.outputs[0].enabled = True