Analog Discovery

See the Digilent Constants.

class experimentor.drivers.digilent.AnalogDiscovery[source]

Bases: object

analog_in_acquisition_mode_get()[source]
Returns:Current mode
Return type:AcquisitionMode
analog_in_acquisition_mode_info()[source]

Returns the supported AnalogIn acquisition modes. They are returned (by reference) as a bit field. This bit field can be parsed using the IsBitSet Macro. Individual bits are defined using the ACQMODE constants in dwf.h. The acquisition mode selects one of the following modes, ACQMODE:

Returns:Bitfield of modes, needs to be parsed
Return type:int
analog_in_bits_info()[source]
analog_in_buffer_size_get()[source]
analog_in_buffer_size_info()[source]
analog_in_buffer_size_set(buffer_size)[source]
analog_in_channel_attenuation_get(channel)[source]
analog_in_channel_attenuation_set(channel, attenuation)[source]

Configures the attenuation for each channel. When channel index is specified as -1, each enabled AnalogIn channel attenuation will be configured to the same level. The attenuation does not change the attenuation on the device, just informs the library about the externally applied attenuation. :param channel: :type channel: int :param attenuation: :type attenuation: float

analog_in_channel_count()[source]
analog_in_channel_disable(channel)[source]

Disables the specified channel. See analog_in_channel_enable()

Parameters:channel (int) –
analog_in_channel_enable(channel)[source]

Enables the specified channel. See analog_in_channel_disable()

Parameters:channel (int) –
analog_in_channel_enable_get(channel)[source]
analog_in_channel_filter_get(channel)[source]
analog_in_channel_filter_info()[source]
analog_in_channel_filter_set(channel, filter)[source]
analog_in_channel_offset_get(channel)[source]
analog_in_channel_offset_info()[source]
analog_in_channel_offset_set(channel, offset)[source]
analog_in_channel_range_get(channel)[source]
analog_in_channel_range_info()[source]
Returns:
  • volts_min (float)
  • volts_max (float)
  • volts_steps (float)
analog_in_channel_range_set(channel, channel_range)[source]
analog_in_configure(reconfigure=1, start=1)[source]
analog_in_frequency_get()[source]
analog_in_frequency_info()[source]

Retrieves the minimum and maximum (ADC frequency) settable sample frequency.

Returns:
  • min_freq (float) – Minimum allowed frequency
  • max_freq (float) – Maximum allowed frequency
analog_in_frequency_set(frequency)[source]
analog_in_noise_size_info()[source]
analog_in_record_length_get()[source]
analog_in_record_length_set(length)[source]
analog_in_reset()[source]
analog_in_samples_left()[source]
Retrieves the number of samples left in the acquisition.
Returns:Number of samples remaining
Return type:int
analog_in_samples_valid()[source]
analog_in_sampling_delay_get()[source]
analog_in_sampling_delay_set(delay)[source]
analog_in_sampling_slope_get()[source]
analog_in_sampling_slope_set(slope)[source]
Parameters:slope (TriggerSlope) –
analog_in_sampling_source_get()[source]
analog_in_sampling_source_set(source)[source]
Parameters:source (TriggerSource) –
analog_in_status(read_data=0)[source]

Checks the status of the acquisition

Parameters:read_data (int) – 0 or 1, to indicate whether data should be read from the device
Returns:The instrument state
Return type:InstrumentState
analog_in_status_auto_trigger()[source]
Verifies if the acquisition is auto triggered.
Returns:I guess it returns 1 if the acquisition was auto triggered
Return type:int
analog_in_status_data(channel, samples, buffer=None)[source]
Retrieves the acquired data samples from the specified idxChannel on the AnalogIn instrument. It copies the
data samples to the provided buffer.
Parameters:
  • channel (int) –
  • samples (int) –
  • buffer (c_double array, optional) –
Returns:

Array with the data

Return type:

np.array

analog_in_status_data_16(channel, first, samples, buffer=None)[source]

Retrieves the acquired raw data samples from the specified idxChannel on the AnalogIn instrument. It copies the data samples to the provided buffer or creates a new one. This is the raw data, as opposed to what analog_in_status_data() returns.

Parameters:
  • channel (int) –
  • first (int) –
  • samples (int) –
  • buffer (c_double array, optional) –
Returns:

Array with the data

Return type:

numpy.array

analog_in_status_data_2(channel, first, samples, buffer=None)[source]
Retrieves the acquired data samples from the specified idxChannel on the AnalogIn instrument. It copies the data samples to the provided buffer or creates a new buffer. This method allows to specify which data will be copied. To retrieve all data see analog_in_status_data().
Parameters:
  • channel (int) –
  • first (int) –
  • samples (int) –
  • buffer (c_double array, optional) –
Returns:

Array with the data

Return type:

numpy.array

analog_in_status_index()[source]

Retrieves the buffer write pointer which is needed in ScanScreen acquisition mode to display the scan bar. :returns: Variable to receive the position of the acquisition. :rtype: int

analog_in_status_noise(channel, samples)[source]

Retrieves the acquired noise samples from the specified idxChannel on the AnalogIn instrument.

Parameters:
  • channel (int) –
  • samples (int) –
Returns:

minimum noise data, maximum noise data

Return type:

2-colum numpy.array

analog_in_status_record()[source]

Retrieves information about the recording process. The data loss occurs when the device acquisition is faster than the read process to PC. In this case, the device recording buffer is filled and data samples are overwritten. Corrupt samples indicate that the samples have been overwritten by the acquisition process during the previous read. In this case, try optimizing the loop process for faster execution or reduce the acquisition frequency or record length to be less than or equal to the device buffer size (record length <= buffer size/frequency).

Returns:
  • data_available (int) – Available number of samples
  • data_lost (int) – Lost samples after the last check
  • data_corrupt (int) – Number of samples that can be corrupt
analog_in_status_sample(channel)[source]

Gets the last ADC conversion sample from the specified idxChannel on the AnalogIn instrument.

Parameters:channel (int) –
Returns:Sample value
Return type:float
analog_in_trigger_auto_timeout_get()[source]
analog_in_trigger_auto_timeout_info()[source]
analog_in_trigger_auto_timeout_set(timeout=0)[source]
analog_in_trigger_channel_get()[source]
analog_in_trigger_channel_info()[source]
analog_in_trigger_channel_set(channel)[source]

Sets the trigger channel.

analog_in_trigger_condition_get()[source]
analog_in_trigger_condition_info()[source]

Returns the supported trigger type options for the instrument. They are returned (by reference) as a bit field. This bit field can be parsed using the IsBitSet Macro. Individual bits are defined using the DwfTriggerSlope constants in dwf.h. These trigger condition options are:

  • DwfTriggerSlopeRise (This is the default setting):
    • For edge and transition trigger on rising edge.
    • For pulse trigger on positive pulse; For window exiting.
  • DwfTriggerSlopeFall
    • For edge and transition trigger on falling edge.
    • For pulse trigger on negative pulse; For window entering.
  • DwfTriggerSlopeEither
    • For edge and transition trigger on either edge.
    • For pulse trigger on either positive or negative pulse.
Returns:info
Return type:int
analog_in_trigger_condition_set(condition)[source]
analog_in_trigger_filter_get()[source]
analog_in_trigger_filter_info()[source]

Returns the supported trigger filters. They are returned (by reference) as a bit field which can be parsed using the IsBitSet Macro. Individual bits are defined using the FILTER constants in DWF.h. Select trigger detector sample source, FILTER:

  • filterDecimate: Looks for trigger in each ADC conversion, can detect glitches.
  • filterAverage: Looks for trigger only in average of N samples, given by analog_in_frequency_set().
analog_in_trigger_filter_set(trig_filter)[source]
analog_in_trigger_holdoff_get()[source]
analog_in_trigger_holdoff_info()[source]

Returns the supported range of the trigger Hold-Off time in Seconds. The trigger hold-off is an adjustable period of time during which the acquisition will not trigger. This feature is used when you are triggering on burst waveform shapes, so the oscilloscope triggers only on the first eligible trigger point.

Returns:
  • min_holdoff (float)
  • max_holdoff (float)
  • steps (float)
analog_in_trigger_holdoff_set(holdoff)[source]
analog_in_trigger_hysteresis_get()[source]
analog_in_trigger_hysteresis_info()[source]

Retrieves the range of valid trigger hysteresis voltage levels for the AnalogIn instrument in Volts. The trigger detector uses two levels: low level (TriggerLevel - Hysteresis) and high level (TriggerLevel + Hysteresis). Trigger hysteresis can be used to filter noise for Edge or Pulse trigger. The low and high levels are used in transition time triggering.

analog_in_trigger_hysteresis_set(level)[source]
analog_in_trigger_length_condition_get()[source]
analog_in_trigger_length_condition_hysteresis_get()[source]
analog_in_trigger_length_condition_info()[source]

Returns the supported trigger length condition options for the AnalogIn instrument. They are returned (by reference) as a bit field. This bit field can be parsed using the IsBitSet Macro. Individual bits are defined using the TRIGLEN constants in DWF.h. These trigger length condition options are:

  • triglenLess: Trigger immediately when a shorter pulse or transition time is detected.
  • triglenTimeout: Trigger immediately as the pulse length or transition time is reached.
  • triglenMore: Trigger when the length/time is reached, and pulse or transition has ended.
Returns:
Return type:supported trigger length conditions
analog_in_trigger_length_condition_set(length)[source]
analog_in_trigger_length_info()[source]

Returns the supported range of trigger length for the instrument in Seconds. The trigger length specifies the minimal or maximal pulse length or transition time.

analog_in_trigger_length_set(length)[source]
analog_in_trigger_level_get()[source]
analog_in_trigger_level_info()[source]
analog_in_trigger_level_set(level)[source]
analog_in_trigger_position_get()[source]
analog_in_trigger_position_info()[source]

Returns the minimum and maximum values of the trigger position in seconds. For Single/Repeated acquisition mode the horizontal trigger position is used is relative to the buffer middle point. For Record mode the position is relative to the start of the capture.

Todo

The documentation specifies steps as double, but it makes more sense for it to be an integer. Other methods like analog_in_trigger_auto_timeout_info() use an integer

Returns:
  • min_trigger (float)
  • max_trigger (float)
  • steps (float)
analog_in_trigger_position_set(position)[source]
analog_in_trigger_source_get()[source]
analog_in_trigger_source_set(source)[source]
analog_in_trigger_type_get()[source]
analog_in_trigger_type_set(trig_type)[source]
analog_out_count()[source]

The number of analog output channels available on this board.

Returns:The number of analog channels available
Return type:int
analogin_noise_size_get()[source]

Returns the used AnalogIn instrument noise buffer size. This is automatically adjusted according to the sample buffer size. For instance, having maximum buffer size of 8192 and noise buffer size of 512, setting the sample buffer size to 4096 the noise buffer size will be 256.

Returns:Current noise buffer size
Return type:int
analong_in_acquisition_mode_set(mode)[source]
Parameters:mode (AcquisitionMode) –
digital_out_configure(status)[source]
digital_out_count()[source]

Returns the number of Digital Out channels by the device specified by hdwf.

digital_out_counter_get(channel)[source]
digital_out_counter_info(channel)[source]
digital_out_counter_init_get(channel)[source]
digital_out_counter_init_set(channel, start_high, divider)[source]

Sets the initial state and counter value of the specified channel.

digital_out_counter_set(channel, low, high)[source]

Sets the counter low and high values for the specified channel..

digital_out_data_info(channel)[source]

Returns the maximum buffers size, the number of custom data bits.

digital_out_data_set(channel, data_array, num_bits)[source]
digital_out_divider_get(channel)[source]
digital_out_divider_info(channel)[source]
digital_out_divider_init_get(channel)[source]
digital_out_divider_init_set(channel, divider)[source]
digital_out_divider_set(channel, divider)[source]
digital_out_enable_get(channel)[source]
digital_out_enable_set(channel, enable)[source]
digital_out_idle_get(channel)[source]
digital_out_idle_info(channel)[source]

Returns the supported idle output types of the channel. They are returned (by reference) as a bit field. This bit field can be parsed using the IsBitSet Macro. Individual bits are defined using DigitalOutIdle :

  • DwfDigitalOutIdleInit: Output initial value.
  • DwfDigitalOutIdleLow: Low level.
  • DwfDigitalOutIdleHigh: High level.
  • DwfDigitalOutIdleZet: Three state.
digital_out_idle_set(channel, idle)[source]
digital_out_internal_clock_info()[source]
digital_out_output_get(channel)[source]
digital_out_output_info(channel)[source]

Returns the supported output modes of the channel. They are returned (by reference) as a bit field. This bit field can be parsed using the IsBitSet Macro. Individual bits are defined using the DigitalOutOutput:

  • DwfDigitalOutOutputPushPull: Default setting.
  • DwfDigitalOutOutputOpenDrain: External pull needed.
  • DwfDigitalOutOutputOpenSource: External pull needed.
  • DwfDigitalOutOutputThreeState: Available with custom and random types.
digital_out_output_set(channel, output)[source]
digital_out_play_data_set(bits, bits_per_sample, count)[source]
digital_out_play_rate_set(rate)[source]
digital_out_repeat_get()[source]
digital_out_repeat_info()[source]
digital_out_repeat_set(repeat)[source]
digital_out_repeat_status()[source]
digital_out_repeat_trigger_get()[source]
digital_out_repeat_trigger_set(trigger)[source]

Sets the repeat trigger option. To include the trigger in wait-run repeat cycles, set fRepeatTrigger to TRUE. It is disabled by default.

digital_out_reset()[source]
digital_out_run_get()[source]
digital_out_run_info()[source]
digital_out_run_set(run_len)[source]
digital_out_run_status()[source]

Reads the remaining run length. It returns data from the last digital_out_status() call.

digital_out_status()[source]
digital_out_trigger_slope_get()[source]
digital_out_trigger_slope_set(slope)[source]
digital_out_trigger_source_get()[source]
digital_out_trigger_source_set(source)[source]
digital_out_type_get(channel)[source]
digital_out_type_info(channel)[source]

Returns the supported types of the channel. They are returned (by reference) as a bit field. This bit field can be parsed using the IsBitSet Macro. Individual bits are defined using DigitalOutType:

  • DwfDigitalOutTypePulse: Frequency = internal frequency/divider/(low + high counter).
  • DwfDigitalOutTypeCustom: Sample rate = internal frequency / divider.
  • DwfDigitalOutTypeRandom: Random update rate = internal frequency/divider/counter alternating between

low and high values. - DwfDigitalOutTypeROM: ROM logic, the DIO input value is used as address for output value - DwfDigitalOutTypePlay: Supported with Digital Discovery.

digital_out_type_set(channel, out_type)[source]
digital_out_wait_get()[source]
digital_out_wait_info()[source]

Returns the supported wait length range in seconds. The wait length is how long the instrument waits after being triggered to generate the signal. Default value is zero.

digital_out_wait_set(wait)[source]
initialize(dev_num=-1)[source]

Initialize the communication with a device identified by its order

Parameters:dev_num (int) – The device number to open, by default it opens the last device
Raises:DriverException – If the device can’t be opened