I am bringing some old test fixtures back to life which were based on the OM-USB-1208FS. We are using the python implementation of mcculw. The DAQ I am using for development works fine in all cases when I test it using Instacal but I am having a hard time getting my python script to run as reliably. I noticed that when i plug the DAQ in the indication LED blinks briefly, stays lit for 6 seconds or so then turns off completely. If I plug in the daq and start my script at the right time (while the LED is constant lit), everything runs perfectly. If I wait until the LED turns OFF, then run my script, the DAQ LED will start blinking and can handle any calls to digital IO but any calls to any DAQ analog inputs will hang the application (DAQ will stay blinking forever) and it seems an unplug/replug will be required.
I need this test tool to be reliable enough for someone who cant see the LED to use. Can anyone offer any advice? Code which works depending on LED status when starting shown below:
# START CODE HERE #
from __future__ import absolute_import, division, print_function
from builtins import * # @UnusedWildImport
from mcculw import ul
from mcculw.enums import DigitalIODirection
from mcculw.device_info import DaqDeviceInfo
from mcculw.enums import InterfaceType
from mcculw import enums
#Copied from console examples folder
def config_first_detected_device(board_num, dev_id_list=None):
"""Adds the first available device to the UL. If a types_list is specified,
the first available device in the types list will be add to the UL.
Parameters
----------
board_num : int
The board number to assign to the board when configuring the device.
dev_id_list : list[int], optional
A list of product IDs used to filter the results. Default is None.
See UL documentation for device IDs.
"""
ul.ignore_instacal()
devices = ul.get_daq_device_inventory(InterfaceType.ANY)
if not devices:
raise Exception('Error: No DAQ devices found')
print('Found', len(devices), 'DAQ device(s):')
for device in devices:
print(' ', device.product_name, ' (', device.unique_id, ') - ',
'Device ID = ', device.product_id, sep='')
device = devices[0]
if dev_id_list:
device = next((device for device in devices
if device.product_id in dev_id_list), None)
if not device:
err_str = 'Error: No DAQ device found in device ID list: '
err_str += ','.join(str(dev_id) for dev_id in dev_id_list)
raise Exception(err_str)
# Add the first DAQ device to the UL with the specified board number
ul.create_daq_device(board_num, device)
def get_inputs():
global board_num
global ai_range
input_buffer = []
for i in range(5):
#value = ul.a_in(board_num, i, ai_range)
value = ul.v_in(board_num, i, ai_range)
# Convert the raw value to engineering units
#input_buffer.append(ul.to_eng_units(board_num, ai_range, value))
print("DEBUG: input "+str(i)+" = "+str(value))
input_buffer.append(value)
print("DEBUG: inputs = "+str(input_buffer))
return input_buffer
if not daq_dev_info.supports_analog_input:
raise Exception('Error: The DAQ device does not support '
'analog input')
########################
# HANGS ON LINE BELOW IF LED NOT LIT <--------
########################
ai_info = daq_dev_info.get_ai_info()
print(str(ai_info.supported_ranges))
#ensure in single ended mode:
ul.a_input_mode(board_num, enums.AnalogInputMode.SINGLE_ENDED)
get_inputs()
except Exception as e:
print('\n', e)
finally:
if use_device_detection:
ul.release_daq_device(board_num)
print("released")
Question
Pizzaguy
I am bringing some old test fixtures back to life which were based on the OM-USB-1208FS. We are using the python implementation of mcculw. The DAQ I am using for development works fine in all cases when I test it using Instacal but I am having a hard time getting my python script to run as reliably. I noticed that when i plug the DAQ in the indication LED blinks briefly, stays lit for 6 seconds or so then turns off completely. If I plug in the daq and start my script at the right time (while the LED is constant lit), everything runs perfectly. If I wait until the LED turns OFF, then run my script, the DAQ LED will start blinking and can handle any calls to digital IO but any calls to any DAQ analog inputs will hang the application (DAQ will stay blinking forever) and it seems an unplug/replug will be required.
I need this test tool to be reliable enough for someone who cant see the LED to use. Can anyone offer any advice? Code which works depending on LED status when starting shown below:
# START CODE HERE #
from __future__ import absolute_import, division, print_function
from builtins import * # @UnusedWildImport
from mcculw import ul
from mcculw.enums import DigitalIODirection
from mcculw.device_info import DaqDeviceInfo
from mcculw.enums import InterfaceType
from mcculw import enums
use_device_detection = True
dev_id_list = [130]
board_num = 0
ai_range = enums.ULRange.BIP10VOLTS
#Copied from console examples folder
def config_first_detected_device(board_num, dev_id_list=None):
"""Adds the first available device to the UL. If a types_list is specified,
the first available device in the types list will be add to the UL.
Parameters
----------
board_num : int
The board number to assign to the board when configuring the device.
dev_id_list : list[int], optional
A list of product IDs used to filter the results. Default is None.
See UL documentation for device IDs.
"""
ul.ignore_instacal()
devices = ul.get_daq_device_inventory(InterfaceType.ANY)
if not devices:
raise Exception('Error: No DAQ devices found')
print('Found', len(devices), 'DAQ device(s):')
for device in devices:
print(' ', device.product_name, ' (', device.unique_id, ') - ',
'Device ID = ', device.product_id, sep='')
device = devices[0]
if dev_id_list:
device = next((device for device in devices
if device.product_id in dev_id_list), None)
if not device:
err_str = 'Error: No DAQ device found in device ID list: '
err_str += ','.join(str(dev_id) for dev_id in dev_id_list)
raise Exception(err_str)
# Add the first DAQ device to the UL with the specified board number
ul.create_daq_device(board_num, device)
def get_inputs():
global board_num
global ai_range
input_buffer = []
for i in range(5):
#value = ul.a_in(board_num, i, ai_range)
value = ul.v_in(board_num, i, ai_range)
# Convert the raw value to engineering units
#input_buffer.append(ul.to_eng_units(board_num, ai_range, value))
print("DEBUG: input "+str(i)+" = "+str(value))
input_buffer.append(value)
print("DEBUG: inputs = "+str(input_buffer))
return input_buffer
try:
if use_device_detection:
config_first_detected_device(board_num, dev_id_list)
daq_dev_info = DaqDeviceInfo(board_num)
dio_info = daq_dev_info.get_dio_info()
print('\nActive DAQ device: ', daq_dev_info.product_name, ' (', daq_dev_info.unique_id, ')\n', sep='')
if not daq_dev_info.supports_analog_input:
raise Exception('Error: The DAQ device does not support '
'analog input')
########################
# HANGS ON LINE BELOW IF LED NOT LIT <--------
########################
ai_info = daq_dev_info.get_ai_info()
print(str(ai_info.supported_ranges))
#ensure in single ended mode:
ul.a_input_mode(board_num, enums.AnalogInputMode.SINGLE_ENDED)
get_inputs()
except Exception as e:
print('\n', e)
finally:
if use_device_detection:
ul.release_daq_device(board_num)
print("released")
# END CODE HERE #
Edited by PizzaguyLink to comment
Share on other sites
4 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now