当前位置: 首页>>代码示例>>Python>>正文


Python PyDAQmx.bool32方法代码示例

本文整理汇总了Python中PyDAQmx.bool32方法的典型用法代码示例。如果您正苦于以下问题:Python PyDAQmx.bool32方法的具体用法?Python PyDAQmx.bool32怎么用?Python PyDAQmx.bool32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyDAQmx的用法示例。


在下文中一共展示了PyDAQmx.bool32方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: wait_and_clean

# 需要导入模块: import PyDAQmx [as 别名]
# 或者: from PyDAQmx import bool32 [as 别名]
    def wait_and_clean(self):
        """
        This should be called after start().

        Waits for the task to finish and then cleans up.
        """

        #Wait for the task to finish
        complete = _mx.bool32()
        while not (complete): _mx.DAQmxGetTaskComplete(self._handle, _mx.byref(complete))
        self.clean()
开发者ID:julian-wolf,项目名称:spinmob,代码行数:13,代码来源:__init__.py

示例2: isDone

# 需要导入模块: import PyDAQmx [as 别名]
# 或者: from PyDAQmx import bool32 [as 别名]
 def isDone(self):
     """Returns true if task is done."""
     done = pydaq.bool32()
     self.IsTaskDone(ctypes.byref(done))
     return done.value
开发者ID:shreyaspotnis,项目名称:rampage,代码行数:7,代码来源:daq.py

示例3: Scan

# 需要导入模块: import PyDAQmx [as 别名]
# 或者: from PyDAQmx import bool32 [as 别名]
def Scan(focus, offset, images, exposure, readout=10., focusChannel="Dev1/ao0", scanChannel="Dev1/ao1"):
	"""Function to scan galvo mirror across field of view, centered on offset voltage and with the focus set by the perpendicular galvo. This function is specific to a National Instruments DAQ card, used to send signals to the mirror galvonometers. A trigger (e.g. from the camera) is currently necessary on PFI0, if undesirable, change CfgDigEdgeStartTrig.
	
	***To Do:
	    - add error handling with Try/Except
	    - add scan signal bounds as an input. Not only does this vary a little with alignment, but needs to be different
	      for the visible laser galvos and enables an ROI.

	    Done - add a digital I/O channel to accept a trigger from the camera.
	    Done - figure out how to wait until sweep is done before exiting function (something better than timed delay?)

	Inputs:
	    focus - float, Voltage (in V) used by the off-axis galvo to bring the laser into focus.
	    offset - float, Voltage (in V) that steers the laser through the center of the scan range.
	    images - int, number of images in the scan
	    exposure - float/int, exposure time in milliseconds. The laser should take this long to cover the field of view.
	               *** In light sheet readout mode, the exposure time given to the camera refers to each 4 row block exposed in succession
		       So the number here should be equal to Vn/4 * Exp1 (total number of rows and camera's exposure time)
	    readout - float, readout time in milliseconds of the camera
	    
	    focusChannel - string, Hardware device and channel that controls the focus galvo, e.g. "Dev1/ao0"
	    scanChannel - string, Hardware device and channel that controls the scan galvo, e.g. "Dev1/ao1"
	"""
	print('Make sure that camera trigger is positive and set to Exposure\n otherwise behavior is unpredictable.')

	focus = float(focus)
	offset = float(offset)
	exposure = exposure/1000.
	readout = readout/1000.

	analog_output = pydaq.Task()
	analog_output.CreateAOVoltageChan(focusChannel, "", -5.0, 5.0, pydaq.DAQmx_Val_Volts, None)
	analog_output.CreateAOVoltageChan(scanChannel, "", -5.0, 5.0, pydaq.DAQmx_Val_Volts, None)

	"""Create a timer that can be used to trigger the camera in light sheet readout mode (Hamamatus Orca Flash).
	There is a delay in the camera (see manual) of 1H*9, where 1H = HLN/(26600000) (HLN 2592 to 266*10^6 - refer to section 10-3-2 of the manual).
	The frame rate is calculated as 1/(Exp1 + (Vn+10)*1H), where Vn is the number of vertical lines and Exp1 can be varied from 9.7us to 10s
	"""
	HLN = 2592
	H1 = HLN/266000000.
	readout = 2048*H1
	#print(readout)
	timer = pydaq.Task()
	timer.CreateCOPulseChanTime("Dev1/Ctr0", "timer", pydaq.DAQmx_Val_Seconds, pydaq.DAQmx_Val_Low, 0.01, readout, exposure)
	timer.CfgImplicitTiming(pydaq.DAQmx_Val_FiniteSamps, images)
	
	"""For the time being, I am assuming that the field of view is (over)filled by sweeping through 600 milliVolts.
	At 40x with the Hamamatsu sCMOS, this should be about 333 microns, so there is a rough correspondence of 1.8mV to 
	1um. Since the NIR (bessel) beam has a FWHM of about 3um, I will move in 1mV (0.55um) steps, which should appear
	continuos. This means that the sampling rate should be set to samples/duration (where samples is 600)."""
	samples = 10000 + 1
	samplingRate = float(samples)/exposure
	analog_output.CfgSampClkTiming(None, samplingRate, pydaq.DAQmx_Val_Rising, pydaq.DAQmx_Val_FiniteSamps, samples)

	scan = np.linspace(-0.250, 0.250, samples) + offset
	#go back to starting value:
	scan = np.append(scan, scan[0])
	#print(str(scan[0]) + str(scan[-1]))
	focus = focus*np.ones(samples)
	#for debugging, go back to 0:
	#focus = np.append(focus, 0.0)
	#To minimize unnessecary sample exposure, move focus far away:
	#This is unnecessary if the AOTF is used as a shutter
	#focus = np.append(focus, -3.0 )
	focus = np.append(focus, focus[0])
	samples = samples + 1

	"""Since the analog out write function has an ouput that is the actual number of samples per channel successfully
	written to the buffer, create a variable to store those values: """
	temp = (pydaq.c_byte*4)()
	actualWritten = pydaq.cast(temp, pydaq.POINTER(pydaq.c_long))

	analog_output.CfgDigEdgeStartTrig("PFI0", pydaq.DAQmx_Val_Rising)


	if (focusChannel == "Dev1/ao0"):
		writeData = np.concatenate((focus, scan),1)
	else:
		writeData = np.concatenate((scan, focus),1)

	analog_output.WriteAnalogF64(samples, False, -1, pydaq.DAQmx_Val_GroupByChannel, writeData, actualWritten, None)
	
	timer.StartTask()

	for image in np.arange(0,images):
		analog_output.StartTask()

		done = pydaq.bool32()
		analog_output.IsTaskDone(pydaq.byref(done))
	
	#	while (done.value != 1):
	#		analog_output.IsTaskDone(pydaq.byref(done))
		
		analog_output.WaitUntilTaskDone(images*(exposure+readout))
		analog_output.StopTask()

	timer.WaitUntilTaskDone(-1)
	timer.StopTask()


#.........这里部分代码省略.........
开发者ID:miketaormina,项目名称:SPIMcode,代码行数:103,代码来源:spimLibrary.py

示例4: init_constraints

# 需要导入模块: import PyDAQmx [as 别名]
# 或者: from PyDAQmx import bool32 [as 别名]
    def init_constraints(self):
        """ Build a pulser constraints dictionary with information from the NI card.
        """
        device = self.device
        constraints = {}
        ch_map = OrderedDict()

        n = 2048
        ao_max_freq = daq.float64()
        ao_min_freq = daq.float64()
        ao_physical_chans = ctypes.create_string_buffer(n)
        ao_voltage_ranges = np.zeros(16, dtype=np.float64)
        ao_clock_support = daq.bool32()
        do_max_freq = daq.float64()
        do_lines = ctypes.create_string_buffer(n)
        do_ports = ctypes.create_string_buffer(n)
        product_dev_type = ctypes.create_string_buffer(n)
        product_cat = daq.int32()
        serial_num = daq.uInt32()
        product_num = daq.uInt32()

        daq.DAQmxGetDevAOMinRate(device, daq.byref(ao_min_freq))
        self.log.debug('Analog min freq: {0}'.format(ao_min_freq.value))
        daq.DAQmxGetDevAOMaxRate(device, daq.byref(ao_max_freq))
        self.log.debug('Analog max freq: {0}'.format(ao_max_freq.value))
        daq.DAQmxGetDevAOSampClkSupported(device, daq.byref(ao_clock_support))
        self.log.debug('Analog supports clock: {0}'.format(ao_clock_support.value))
        daq.DAQmxGetDevAOPhysicalChans(device, ao_physical_chans, n)
        analog_channels = str(ao_physical_chans.value, encoding='utf-8').split(', ')
        self.log.debug('Analog channels: {0}'.format(analog_channels))
        daq.DAQmxGetDevAOVoltageRngs(
            device,
            ao_voltage_ranges.ctypes.data_as(ctypes.POINTER(ctypes.c_double)),
            len(ao_voltage_ranges))
        self.log.debug('Analog voltage range: {0}'.format(ao_voltage_ranges[0:2]))

        daq.DAQmxGetDevDOMaxRate(self.device, daq.byref(do_max_freq))
        self.log.debug('Digital max freq: {0}'.format(do_max_freq.value))
        daq.DAQmxGetDevDOLines(device, do_lines, n)
        digital_channels = str(do_lines.value, encoding='utf-8').split(', ')
        self.log.debug('Digital channels: {0}'.format(digital_channels))
        daq.DAQmxGetDevDOPorts(device, do_ports, n)
        digital_bundles = str(do_ports.value, encoding='utf-8').split(', ')
        self.log.debug('Digital ports: {0}'.format(digital_bundles))

        daq.DAQmxGetDevSerialNum(device, daq.byref(serial_num))
        self.log.debug('Card serial number: {0}'.format(serial_num.value))
        daq.DAQmxGetDevProductNum(device, daq.byref(product_num))
        self.log.debug('Product number: {0}'.format(product_num.value))
        daq.DAQmxGetDevProductType(device, product_dev_type, n)
        product = str(product_dev_type.value, encoding='utf-8')
        self.log.debug('Product name: {0}'.format(product))
        daq.DAQmxGetDevProductCategory(device, daq.byref(product_cat))
        self.log.debug(product_cat.value)

        for n, ch in enumerate(analog_channels):
            ch_map['a_ch{0:d}'.format(n+1)] = ch

        for n, ch in enumerate(digital_channels):
            ch_map['d_ch{0:d}'.format(n+1)] = ch

        constraints['sample_rate'] = {
            'min': ao_min_freq.value,
            'max': ao_max_freq.value,
            'step': 0.0,
            'unit': 'Samples/s'}

        # The file formats are hardware specific. The sequence_generator_logic will need this
        # information to choose the proper output format for waveform and sequence files.
        constraints['waveform_format'] = 'ndarray'
        constraints['sequence_format'] = None

        # the stepsize will be determined by the DAC in combination with the
        # maximal output amplitude (in Vpp):
        constraints['a_ch_amplitude'] = {
            'min': 0,
            'max': ao_voltage_ranges[1],
            'step': 0.0,
            'unit': 'Vpp'}
        constraints['a_ch_offset'] = {
            'min': ao_voltage_ranges[0],
            'max': ao_voltage_ranges[1],
            'step': 0.0,
            'unit': 'V'}
        constraints['d_ch_low'] = {
            'min': 0.0,
            'max': 0.0,
            'step': 0.0,
            'unit': 'V'}
        constraints['d_ch_high'] = {
            'min': 5.0,
            'max': 5.0,
            'step': 0.0,
            'unit': 'V'}
        constraints['sampled_file_length'] = {
            'min': 2,
            'max': 1e12,
            'step': 0,
            'unit': 'Samples'}
        constraints['digital_bin_num'] = {
#.........这里部分代码省略.........
开发者ID:a-stark,项目名称:qudi,代码行数:103,代码来源:national_instruments_pulser.py


注:本文中的PyDAQmx.bool32方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。