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 ctr_props = CounterProps(board_num) if ctr_props.num_chans < 1: util.print_unsupported_example(board_num) return # Use the first counter channel on the board (some boards start channel # numbering at 1 instead of 0, CounterProps are used here to find the # first one). counter_num = ctr_props.counter_info[0].channel_num try: # Get a value from the device value = ul.c_in_32(board_num, counter_num) # Display the value print("Counter Value: " + str(value)) except ULError as e: util.print_ul_error(e) finally: if use_device_detection: ul.release_daq_device(board_num)
def __init__(self, master=None): super(ULCT07, self).__init__(master) self.running = False self.board_num = 0 self.ctr_props = CounterProps(self.board_num) self.create_widgets()
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()
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()
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 ctr_props = CounterProps(board_num) # Find a pulse timer channel on the board first_chan = next( (channel for channel in ctr_props.counter_info if channel.type == CounterChannelType.CTRPULSE), None) if first_chan == None: util.print_unsupported_example(board_num) return timer_num = first_chan.channel_num frequency = 100 duty_cycle = 0.5 try: # Start the pulse timer output (optional parameters omitted) actual_frequency, actual_duty_cycle, _ = ul.pulse_out_start( board_num, timer_num, frequency, duty_cycle) # Print information about the output print( "Outputting " + str(actual_frequency) + " Hz with a duty cycle of " + str(actual_duty_cycle) + " to pulse timer channel " + str(timer_num) + ".") # Wait for 5 seconds time.sleep(5) # Stop the pulse timer output ul.pulse_out_stop(board_num, timer_num) print("Timer output stopped.") except ULError as e: util.print_ul_error(e) finally: if use_device_detection: ul.release_daq_device(board_num)
def __init__(self, master=None): super(CInScan02, self).__init__(master) self.board_num = 0 self.ctr_props = CounterProps(self.board_num) chan = next((channel for channel in self.ctr_props.counter_info if channel.type == CounterChannelType.CTRSCAN), None) if chan != None: self.chan_num = chan.channel_num else: self.chan_num = -1 # Initialize tkinter self.grid(sticky=tk.NSEW) self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure(0, weight=1) self.create_widgets()
def __init__(self, master=None): super(CInScan03, self).__init__(master) self.board_num = 0 self.ctr_props = CounterProps(self.board_num) chan = next((channel for channel in self.ctr_props.counter_info if channel.type == CounterChannelType.CTRQUAD), None) if chan == None: # Check for scan counters, which may (or may not) support # encoder modes chan = next((channel for channel in self.ctr_props.counter_info if channel.type == CounterChannelType.CTRSCAN), None) if chan != None: self.chan_num = chan.channel_num else: self.chan_num = -1 self.create_widgets()
def __init__(self, master=None): super(TimerOutStart01, self).__init__(master) master.protocol("WM_DELETE_WINDOW", self.exit) self.board_num = 0 self.ctr_props = CounterProps(self.board_num) # Find the first pulse counter first_chan = next((channel for channel in self.ctr_props.counter_info if channel.type == CounterChannelType.CTRTMR), None) if first_chan != None: last_chan = next( (channel for channel in reversed(self.ctr_props.counter_info) if channel.type == CounterChannelType.CTRTMR), None) self.first_chan_num = first_chan.channel_num self.last_chan_num = last_chan.channel_num else: self.first_chan_num = -1 self.last_chan_num = -1 self.create_widgets()
def __init__(self, master=None): super(CInScan01, self).__init__(master) self.board_num = 0 self.ctr_props = CounterProps(self.board_num) min_chan = next((channel for channel in self.ctr_props.counter_info if channel.type == CounterChannelType.CTRSCAN or channel.type == CounterChannelType.CTRQUAD), None) if min_chan is not None: self.min_chan_num = min_chan.channel_num else: self.min_chan_num = -1 max_chan = next((channel for channel in reversed(self.ctr_props.counter_info) if channel.type == CounterChannelType.CTRSCAN or channel.type == CounterChannelType.CTRQUAD), None) if max_chan is not None: self.max_chan_num = max_chan.channel_num else: self.max_chan_num = -1 self.create_widgets()