示例#1
0
def mc_digital_out(board_num, bit_num, bit_value):
    digital_props = DigitalProps(board_num)

    port = next(
        (port for port in digital_props.port_info if port.supports_output),
        None)
    if port == None:
        util.print_unsupported_example(board_num)

    # If the port is configurable, configure it for output.
    if port.is_port_configurable:
        ul.d_config_port(board_num, port.type, DigitalIODirection.OUT)

    port_value = 0xFF

    print("Setting " + port.type.name + " to " + str(port_value) + ".")

    # Output the value to the port
    ul.d_out(board_num, port.type, port_value)

    # bit_num = 0 #CH0 --> normally high
    # bit_value = 1 ##set 5V to HIGH, power the sensor
    print("Setting " + port.type.name + " bit " + str(bit_num) + " to " +
          str(bit_value) + ".")

    # Output the value to the bit
    ul.d_bit_out(board_num, port.type, bit_num, bit_value)
示例#2
0
    def __init__(self, master=None):
        super(ULDO01, self).__init__(master)
        master.protocol("WM_DELETE_WINDOW", self.exit)

        self.board_num = 0
        self.digital_props = DigitalProps(self.board_num)

        # Find the first port that supports output, defaulting to None
        # if one is not found.
        self.port = next(
            (port
             for port in self.digital_props.port_info if port.supports_output),
            None)

        # If the port is configurable, configure it for output
        if self.port != None and self.port.is_port_configurable:
            try:
                ul.d_config_port(self.board_num, self.port.type,
                                 DigitalIODirection.OUT)
            except ULError as e:
                self.show_ul_error(e)

        self.running = False

        self.create_widgets()
示例#3
0
    def __init__(self, master=None):
        super(ULDI03, self).__init__(master)

        self.board_num = 0
        self.digital_props = DigitalProps(self.board_num)
        # Find the first port that supports input, defaulting to None
        # if one is not found.
        self.port = next((port for port in self.digital_props.port_info
                          if port.supports_input_scan), None)

        self.create_widgets()
示例#4
0
    def __init__(self, master=None):
        super(DaqOutScan01, self).__init__(master)

        self.board_num = 0
        self.daqo_props = DaqOutputProps(self.board_num)
        if self.daqo_props.is_supported:
            self.ao_props = AnalogOutputProps(self.board_num)
            self.digital_props = DigitalProps(self.board_num)
            self.init_scan_channel_info()

        self.create_widgets()
示例#5
0
    def __init__(self, master=None):
        super(DaqInScan01, self).__init__(master)

        self.board_num = 0
        self.daqi_props = DaqInputProps(self.board_num)
        self.ai_props = AnalogInputProps(self.board_num)
        self.digital_props = DigitalProps(self.board_num)
        self.counter_props = CounterProps(self.board_num)
        self.init_scan_channel_info()

        self.create_widgets()
示例#6
0
    def __init__(self, master=None):
        super(ULDI06, self).__init__(master)

        self.board_num = 0
        self.digital_props = DigitalProps(self.board_num)

        # Find the first port that supports input, defaulting to None
        # if one is not found.
        self.port = next(
            (port for port in self.digital_props.port_info
             if (port.supports_input and port.is_bit_configurable)), None)
        self.running = False

        self.create_widgets()
示例#7
0
    def __init__(self, master=None):
        super(DaqSetSetpoints01, self).__init__(master)

        self.board_num = 0
        self.daqi_props = DaqInputProps(self.board_num)

        example_supported = (self.daqi_props.is_supported
                             and self.daqi_props.supports_setpoints)
        if example_supported:
            self.ai_props = AnalogInputProps(self.board_num)
            self.digital_props = DigitalProps(self.board_num)
            self.counter_props = CounterProps(self.board_num)
            self.init_scan_channel_info()
            self.init_setpoints()

        self.create_widgets()
示例#8
0
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

    digital_props = DigitalProps(board_num)

    # Find the first port that supports input, defaulting to None
    # if one is not found.
    port = next(
        (port for port in digital_props.port_info
         if port.supports_output), None)
    if port == None:
        util.print_unsupported_example(board_num)
        return

    try:
        # If the port is configurable, configure it for output.
        if port.is_port_configurable:
            ul.d_config_port(board_num, port.type, DigitalIODirection.OUT)

        port_value = 0xFF

        print(
            "Setting " + port.type.name + " to " + str(port_value) + ".")

        # Output the value to the port
        ul.d_out(board_num, port.type, port_value)

        bit_num = 0
        bit_value = 0
        print(
            "Setting " + port.type.name + " bit " + str(bit_num) + " to "
            + str(bit_value) + ".")

        # Output the value to the bit
        ul.d_bit_out(board_num, port.type, bit_num, bit_value)

    except ULError as e:
        util.print_ul_error(e)
    finally:
        if use_device_detection:
            ul.release_daq_device(board_num)
示例#9
0
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

    digital_props = DigitalProps(board_num)

    # Find the first port that supports input, defaulting to None
    # if one is not found.
    port = next(
        (port for port in digital_props.port_info if port.supports_input),
        None)
    if port == None:
        util.print_unsupported_example(board_num)
        return

    try:
        # If the port is configurable, configure it for input.
        if port.is_port_configurable:
            ul.d_config_port(board_num, port.type, DigitalIODirection.IN)

        # Get a value from the digital port
        port_value = ul.d_in(board_num, port.type)

        # Get a value from the first digital bit
        bit_num = 0
        bit_value = ul.d_bit_in(board_num, port.type, bit_num)

        # Display the port value
        print(port.type.name + " Value: " + str(port_value))
        # Display the bit value
        print("Bit " + str(bit_num) + " Value: " + str(bit_value))
    except ULError as e:
        util.print_ul_error(e)
    finally:
        if use_device_detection:
            ul.release_daq_device(board_num)