Nanodrop.OOI (nanodrop v0.3.1)

Copy Markdown

Ocean Optics Interface (OOI) protocol implementation.

This module implements the USB2000 command protocol for communicating with NanoDrop spectrophotometers and defines the raw spectrum data structure.

Command Reference

CommandHexDescription
Initialize0x01Initialize spectrometer
Set Integration Time0x02Set integration time in µs
Set Strobe Enable0x03Enable/disable strobe
Set Shutdown Mode0x04Enter low-power mode
Query Information0x05Query device info/calibration
Write Information0x06Write configuration
Request Spectra0x09Trigger spectrum acquisition
Set Trigger Mode0x0ASet triggering mode

Raw Spectrum Data

The USB2000 returns 2048 pixel values representing light intensity across the detector. The wavelength for each pixel is calculated using calibration coefficients stored on the device:

λ(N) = C0 + C1*N + C2*N² + C3*N³

Pixels 2-24 are "dark pixels" - optically masked for dark current subtraction.

Summary

Functions

Calculates the average dark pixel value.

Returns the dark pixel values (pixels 2-24).

Creates an OOI struct from raw binary data.

Acquires a dark spectrum (no lamp/strobe). Use this for dark calibration to measure detector baseline.

Acquires a spectrum from the device with the lamp/strobe firing. Use this for blank and sample measurements.

Initializes the spectrometer.

Returns the maximum pixel intensity.

Queries device information.

Sets the integration time in microseconds.

Enables or disables the strobe.

Sets the trigger mode.

Types

t()

@type t() :: %Nanodrop.OOI{raw_pixels: [non_neg_integer()], timestamp: DateTime.t()}

Functions

dark_average(ooi)

@spec dark_average(t()) :: float()

Calculates the average dark pixel value.

dark_pixels(ooi)

@spec dark_pixels(t()) :: [non_neg_integer()]

Returns the dark pixel values (pixels 2-24).

from_raw(data)

@spec from_raw(binary()) :: t()

Creates an OOI struct from raw binary data.

The data should be 4096 bytes (2048 x 16-bit little-endian values).

get_dark_spectrum(device)

@spec get_dark_spectrum(Nanodrop.Device.t()) :: {:ok, t()} | {:error, term()}

Acquires a dark spectrum (no lamp/strobe). Use this for dark calibration to measure detector baseline.

get_spectrum(device)

@spec get_spectrum(Nanodrop.Device.t()) :: {:ok, t()} | {:error, term()}

Acquires a spectrum from the device with the lamp/strobe firing. Use this for blank and sample measurements.

initialize(device)

@spec initialize(Nanodrop.Device.t()) :: :ok | {:error, term()}

Initializes the spectrometer.

max_intensity(ooi)

@spec max_intensity(t()) :: non_neg_integer()

Returns the maximum pixel intensity.

query_info(device, query_type)

@spec query_info(Nanodrop.Device.t(), atom()) :: {:ok, term()} | {:error, term()}

Queries device information.

set_integration_time(device, microseconds)

@spec set_integration_time(Nanodrop.Device.t(), pos_integer()) ::
  :ok | {:error, term()}

Sets the integration time in microseconds.

Valid range: 3,000 - 655,350,000 µs

set_strobe_enable(device, enabled)

@spec set_strobe_enable(Nanodrop.Device.t(), boolean()) :: :ok | {:error, term()}

Enables or disables the strobe.

set_trigger_mode(device, mode)

@spec set_trigger_mode(Nanodrop.Device.t(), 0..3) :: :ok | {:error, term()}

Sets the trigger mode.

Modes:

  • 0: Normal (free running)
  • 1: Software trigger
  • 2: External hardware level trigger
  • 3: External synchronization trigger