def run_example():
    board_num = 0

    if use_device_detection:
        ul.ignore_instacal()
        if not util.config_first_detected_device(board_num):
            print("Could not find device.")
            return

    channel = 0

    ao_props = AnalogOutputProps(board_num)
    if ao_props.num_chans < 1:
        util.print_unsupported_example(board_num)
        return

    ao_range = ao_props.available_ranges[0]

    data_value = ao_range.range_max / 2

    try:
        print("Outputting " + str(data_value) + " Volts to channel " +
              str(channel) + ".")
        # Send the value to the device (optional parameter omitted)
        ul.v_out(board_num, channel, ao_range, data_value)
    except ULError as e:
        util.print_ul_error(e)
    finally:
        if use_device_detection:
            ul.release_daq_device(board_num)
Exemple #2
0
 def _get_supports_v_out(self, available_ranges):
     if len(available_ranges) == 0:
         return False
     try:
         ul.v_out(self._board_num, 0, available_ranges[0], 0)
     except ULError:
         return False
     return True
Exemple #3
0
    def update_value(self):
        channel = self.get_channel_num()
        ao_range = self.ao_info.supported_ranges[0]
        data_value = self.get_data_value()

        try:
            # Send the value to the device (optional parameter omitted)
            ul.v_out(self.board_num, channel, ao_range, data_value)
        except ULError as e:
            show_ul_error(e)
Exemple #4
0
 def supports_v_out(self):
     ranges_supported = self.supported_ranges
     v_out_supported = False
     if ranges_supported:
         try:
             ul.v_out(self._board_num, 0, ranges_supported[0], 0)
             v_out_supported = True
         except ULError:
             v_out_supported = False
     return v_out_supported
Exemple #5
0
def run_example():
    # By default, the example detects and displays all available devices and
    # selects the first device listed. Use the dev_id_list variable to filter
    # detected devices by device ID (see UL documentation for device IDs).
    # If use_device_detection is set to False, the board_num variable needs to
    # match the desired board number configured with Instacal.
    use_device_detection = True
    dev_id_list = []
    board_num = 0

    try:
        if use_device_detection:
            config_first_detected_device(board_num, dev_id_list)

        daq_dev_info = DaqDeviceInfo(board_num)
        if not daq_dev_info.supports_analog_output:
            raise Exception('Error: The DAQ device does not support '
                            'analog output')

        print('\nActive DAQ device: ',
              daq_dev_info.product_name,
              ' (',
              daq_dev_info.unique_id,
              ')\n',
              sep='')

        ao_info = daq_dev_info.get_ao_info()
        ao_range = ao_info.supported_ranges[0]
        channel = 0

        data_value = ao_range.range_max / 2

        print('Outputting', data_value, 'Volts to channel', channel)
        # Send the value to the device (optional parameter omitted)
        ul.v_out(board_num, channel, ao_range, data_value)
    except Exception as e:
        print('\n', e)
    finally:
        if use_device_detection:
            ul.release_daq_device(board_num)