src.ni_board package

Submodules

src.ni_board.ni_synthetic module

class src.ni_board.ni_synthetic.Analog_Out(num_channels='all', rate=10000.0, verbose=True, daq_type='6733', line='Dev1/ao0', clock_name=None, minVol=0, maxVol=10)

Bases: object

Class to control a synthetic analog output board.

__init__(num_channels='all', rate=10000.0, verbose=True, daq_type='6733', line='Dev1/ao0', clock_name=None, minVol=0, maxVol=10)

Initialize synthetic analog output board.

Parameters:
  • num_channels – Number of channels.

  • rate – Rate of synthetic output board.

  • verbose – True/False for verbose statements.

  • daq_type – Determines synthetic channel type: ‘synthetic’ (analog), ‘synthetic_digital’ (digital), ‘synthetic_constant’ (constant)

  • line – Output line, e.g. “Dev1/ao30”

  • clock_name – Name of clock.

  • minVol – Minimal voltage allowed for constant voltage analog output.

  • maxVol – Maximal voltage allowed for constant voltage analog output.

close()

Close the synthetic analog output board.

Returns:

None

p2s(num_pixels)

Convert a duration in number of synthetic AO “pixels” to seconds.

Parameters:

num_pixels – Number of pixels for NI board.

Returns:

seconds. Time duration in seconds.

play_voltages(voltages=None, force_final_zeros=True, block=True)

Play voltages on the synthetic analog output board. By default, play_voltages() blocks until the voltages finish playing. If a previous voltage task is still playing, wait for it to finish before the next one is started.

Parameters:
  • voltages – Array of voltages. If None, play the previously set voltages.

  • force_final_zeros – Boolean True/False. If ‘force_final_zeros’, the last entry of each channel of ‘voltages’ is set to zero.

  • block – Boolean True/False. If ‘block’, this function will not return until the voltages are finished playing.

s2p(seconds)

Convert a duration in seconds to a number of synthetic AO “pixels.”

Parameters:

seconds – Time duration in seconds.

Returns:

num_pixels. Number of pixels for NI board.

s2s(seconds)

Calculate nearest duration the synthetic AO card can exactly deliver. This function rounds a time (in seconds) to the nearest time that the AO card can exactly deliver via an integer number of “pixels”.

Parameters:

seconds – Time to determine nearest duration of AO card can deliver.

Returns:

Seconds. Precise time that AO can deliver.

set_rate(rate)

Set up output rate of the synthetic analog output board.

Parameters:

rate – rate for output.

Returns:

None

set_verbose(verbosevalue=False)

Update verbose settings for debugging/trouble shooting.

Parameters:

verbosevalue – True/False for verbose output.

setconstantvoltage(voltage)

Synthetic function to set constant voltage.

Parameters:

voltage – Voltage to set.

write_voltages(voltages, force_final_zeros=True)

Write a voltage array to the synthetic analog card.

Parameters:
  • voltages – 2-d array with shape=(n, self.num_channels)

  • force_final_zeros – Boolean, if yes, voltages at the end are set to zero.

Returns:

None

src.ni_board.vni module

class src.ni_board.vni.Analog_Out(num_channels='all', rate=10000.0, verbose=True, daq_type='6733', line='Dev1/ao0', clock_name=None, minVol=0, maxVol=10)

Bases: object

Class to control the analog output of voltages on an NI board, such as NI PCIe 6733.

Class adapted from Andrew G York. Please check out: https://github.com/AndrewGYork/tools/blob/master/ni.py

__init__(num_channels='all', rate=10000.0, verbose=True, daq_type='6733', line='Dev1/ao0', clock_name=None, minVol=0, maxVol=10)

Set up analog, digital or constant voltage output channel via a National Instruments DAQ board.

Parameters:
  • num_channels – Number of channels.

  • rate – Rate of NI device.

  • verbose – True/False for verbose statements.

  • daq_type – Determines NI channel type: ‘6738’ (analog), ‘6738_digital’ (digital), ‘6738_constant’ (constant)

  • line – Output line, e.g. “Dev1/ao30”

  • clock_name – Name of clock.

  • minVol – Minimal voltage allowed for constant voltage analog output.

  • maxVol – Maximal voltage allowed for constant voltage analog output.

close()

Set voltages to zero and close NI board.

Returns:

None

p2s(num_pixels)

Convert a duration in number of AO “pixels” to seconds.

Parameters:

num_pixels – Number of pixels for NI board.

Returns:

seconds. Time duration in seconds.

play_voltages(voltages=None, force_final_zeros=True, block=True)

Play voltages on the NI board. By default, play_voltages() blocks until the voltages finish playing. If a previous voltage task is still playing, wait for it to finish before the next one is started.

Parameters:
  • voltages – Array of voltages. If None, play the previously set voltages.

  • force_final_zeros – Boolean True/False. If ‘force_final_zeros’, the last entry of each channel of ‘voltages’ is set to zero.

  • block – Boolean True/False. If ‘block’, this function will not return until the voltages are finished playing.

s2p(seconds)

Convert a duration in seconds to a number of AO “pixels.”

Parameters:

seconds – Time duration in seconds.

Returns:

num_pixels. Number of pixels for NI board.

s2s(seconds)

Calculate nearest duration the AO card can exactly deliver. This function rounds a time (in seconds) to the nearest time that the AO card can exactly deliver via an integer number of “pixels”.

Parameters:

seconds – Time to determine nearest duration of AO card can deliver.

Returns:

seconds. Precise time that AO can deliver.

set_rate(rate)

Set up output rate of DAQ card.

Parameters:

rate – Rate for output.

Returns:

None

set_verbose(verbosevalue=False)

Update verbose settings for debugging/trouble shooting.

Parameters:

verbosevalue – True/False for verbose output.

setconstantvoltage(voltage)

Set constant voltage to ‘6738_constant’ (constant) channel.

Parameters:

voltage – voltage to set.

write_voltages(voltages, force_final_zeros=True)

Write a voltage array to the NI board.

Parameters:
  • voltages – 2-d array with shape=(n, self.num_channels)

  • force_final_zeros – Boolean, if yes, voltages at the end are set to zero.

Returns:

None

src.ni_board.vni.check_error(error_code)

Print error code from NI DAQ board.

Parameters:

error_code – Error code.

Returns:

error_code.

Module contents