Ophir USBI ActiveX Support - ophirUSBI

Python module for accessing Ophir’s USB power meters through the OphirUSBI ActiveX interface.

Note

Requires pywin32 and Ophir’s USBI ActiveX component (status 2010). Ophir has since released new versions of the ActiveX components and also a newer COM object, neither of which is supported currently. The ActiveX control is included by early-binding. It is necessary to run the Com - Makepy Utility found in the PythonWinIDE - Tools - Menu in order to make it accessible to python.

Short example:

import ophirUSBI

# create class instance and connect to ActiveX component
dev = ophirUSBI.OphirUSBI()     

# connect to first OphirUSBI device
dev.connect(0)                  

# set measurement mode
dev.set_default_mode()          

# record 10 data points
t, y = dev.read_data(10)        

dev.disconnect()
class ophirUSBI.OphirUSBI

Python interface to the Ophir USBI device.

MM_Modes = None

List of available measurement modes as returned by connect().

MM_PulseLengths = None

List of available pulse lengths as returned by connect().

MM_Ranges = None

List of available measurement ranges as returned by connect().

MM_Wavelengths = None

List of available wavelength settings as returned by connect().

USBI_channel = None

Channel number for readout.

ask(cmd)

Function for direct legacy access to the Ophir power meter used for querying some value.

For a list of commands see the OphirUSBI ActiveX manual.

If reading of query result fails, an error message is printed to stdout.

Parameters:cmd (str) – Query command.
Returns:Query result (str).
connect(devID=0)

Establish a connection to an Ophir USB power meter.

The function acquires a list of connected Ophir devices and connects to the one found at position devID. After connecting, the current settings are loaded and a list of permitted values for the measurement parameters is generated.

Parameters:devID (int) – Index of device to connect to. In order to connect to the first one, set this to 0 (default).
Returns:None
Raises:IndexError – If devID does not point to a valid Ophir device.
disconnect()

Close connection to current device.

get_data()

Read the result from an asynchronous data acquisition start().

Warning

Be careful with this function as it blocks the application if no data can be read from the sensor.

Returns:
  • Time of acquisition (sequence).
  • Actual power meter reading (sequence).
  • Status of each sample (sequence).
get_measurement_mode()

Returns the current measurement mode index.

get_pulse_length()

Returns current pulse length setting index.

get_range()

Returns current power/energy range index.

get_wavelength()

Returns index of current wavelength setting.

read_data(num_samples)

Read data synchronously from power meter using the selected readout mode.

This function blocks execution of the program until the desired number of samples has been read.

Parameters:num_samples (int) – Number of data points to be read from the sensor.
Returns:
  • Time of acquisition (sequence).
  • Actual power meter reading (sequence).
reset()

Reset device.

Important

The device must not be in streaming mode!

scanUSBI()

Scan for supported / connected power meters.

Returns:List of attached USBI devices.
set_default_mode()

Set power meter to default readout mode.

set_immediate_mode()

Set power meter to immediate readout.

set_measurement_mode(newmode)

Set new measurement mode.

Parameters:newmode (int) – Index of new measurement mode (0 to # of modes).
Returns:None.
set_pulse_length(newlength)

Set new pulse length setting.

Parameters:newlength (int) – Index of new pulse length setting (0 to # of pulse lengths).
Returns:None.
set_range(newrange)

Set new power/energy range setting.

Parameters:newrange (int) – Index of new range setting (0 to # of ranges).
Returns:None.
set_turbo_mode(freq)

Set power meter to turbo mode. Only available if turbo mode is supported by hardware.

Parameters:freq (float) – Frequency for acquisition in Hz.
Returns:None.
set_wavelength(newwl)

Set new wavelength setting.

Parameters:newwl (int) – Index of new wavelength setting (0 to # of wavelengths).
Returns:None.
start()

Starts an asynchronous acquisition of data from power meter using the selected measurement mode and returns immediately.

Use stop() to stop acquisition and get_data() to read the data.

stop()

Stops an asynchronous acquisition of data from power meter that has been started with start().

Use get_data() to read the data.

timeout = None

Timeout for data acquisition using read_data() in seconds.

write(cmd)

Function for direct legacy access to the Ophir power meter.

For a list of commands see the OphirUSBI ActiveX manual.

Parameters:cmd (str) – Query command.
Returns:None.