Jump to content

Julien S

Members
  • Posts

    1
  • Joined

  • Last visited

Julien S's Achievements

Newbie

Newbie (1/4)

0

Reputation

  1. Hi everyone, I'm trying to write a simple piece of python code using github examples but i'm facing some issues while i try to stop an acquisition with ul.daq_in_scan() function. My goal is fairly simple (i guess): i want to scan the 8 analog channel at maximal rate (one point each 5┬Ás) and stop the acquisition either by using a TTL signal, a HIGH to LOW hardware transition (using arduino for instance) or even after the completion of 500 measurements for each channel. Here the code i use (i volontary skip the displaying value part). from __future__ import absolute_import, division, print_function from builtins import * # @UnusedWildImport from ctypes import cast, POINTER, c_ushort import time from mcculw import ul from mcculw.enums import (ScanOptions, Status, FunctionType, ChannelType, ULRange, DigitalPortType, TriggerSensitivity, TriggerEvent, TriggerSource, InterfaceType) from mcculw.ul import ULError from mcculw.device_info import DaqDeviceInfo try: from ui_examples_util import UIExample, show_ul_error except ImportError: from .ui_examples_util import UIExample, show_ul_error def ADCScanFunction(): use_device_detection = True board_num = 0 chan_list = [] chan_type_list = [] gain_list = [] num_chans = 8 try: if use_device_detection: ul.ignore_instacal() devices = ul.get_daq_device_inventory(InterfaceType.ANY) ul.create_daq_device(board_num, devices[0]) device_info = DaqDeviceInfo(board_num) if device_info.supports_daq_input: for i in range(0,8): chan_list.append(i) chan_type_list.append(ChannelType.ANALOG_SE) gain_list.append(ULRange.UNI5VOLTS) chan_list.append(0) chan_type_list.append(ChannelType.CTR16) gain_list.append(ULRange.NOTUSED) except: print('ok') rate = 200000 points_per_channel = 500 total_count = points_per_channel * (num_chans) scan_options = (ScanOptions.FOREGROUND | ScanOptions.EXTTRIGGER) # scan_options = (ScanOptions.BACKGROUND | # ScanOptions.CONTINUOUS | ScanOptions.EXTTRIGGER) # Allocate a buffer for the scan memhandle = ul.win_buf_alloc_32(total_count) #Set the start trigger settings ul.daq_set_trigger(board_num, TriggerSource.EXTTTL, TriggerSensitivity.RISING_EDGE, chan_list[-1], chan_type_list[-1], gain_list[-1], 5, 0, TriggerEvent.START) ul.daq_set_trigger(board_num, TriggerSource.EXTTTL, TriggerSensitivity.ABOVE_LEVEL, chan_list[-1], chan_type_list[-1], gain_list[-1], 5, 0, TriggerEvent.STOP) c = chan_list[0:8] # Run the scan ul.daq_in_scan(board_num, chan_list[0:8], chan_type_list[0:8], gain_list[0:8], num_chans, rate, 0, total_count, memhandle, scan_options) When i use this, i have the following error: I'm kind of lost and i'm affraid i don't understand how the TriggerEvent.STOP would work (and github examples are not very detailled in term of stopping an acquisition). if someone could guide me on how to stop an acquisition with my previous condition (TTL, 5V to 0V, or after 500 points) that would be great ! Thank you to all those who will take the time to help me !
×
×
  • Create New...