Jump to content
  • 0

USB-1608GX connection issues after using a_in_scan


Seweee

Question

Hey,

I have a rather interesting problem when trying to use a_in_scan with my USB-1608GX-2AO device. I am using the python uldaq library and have written a small script to test the a_in_scan function as I need it for a larger application:

import numpy as np
from icecream import ic

from uldaq import (get_daq_device_inventory, DaqDevice, InterfaceType,
                   AiInputMode, Range, AInFlag, AInScanFlag,
                   create_float_buffer,
                   ScanOption)

# Get a list of available DAQ devices
ic("Start")
devices = get_daq_device_inventory(InterfaceType.USB)
# Create a DaqDevice Object and connect to the device
daq_device = DaqDevice(devices[0])
daq_device.connect()
ic("Connected")

# Get AiDevice and AiInfo objects for the analog input subsystem
ai_device = daq_device.get_ai_device()

# Sample acquisition rate in Hz
rate = 200

# Number samples per channel.
samples_per_channel = 200

# Number of channels, must agree with specification of low_channel and
# high_channel below
num_channels = 1
low_channel = 0
high_channel = 0


buffer = create_float_buffer(num_channels, samples_per_channel)


actual_scan_rate = ai_device.a_in_scan(
    low_channel=low_channel,
    high_channel=high_channel,
    input_mode=AiInputMode.DIFFERENTIAL,
    analog_range=Range.BIP5VOLTS,
    samples_per_channel=samples_per_channel,
    rate=rate,
    options=ScanOption.DEFAULTIO,
    flags=AInScanFlag.DEFAULT,
    data=buffer)

data = np.array(buffer[:]).reshape(
    (samples_per_channel, num_channels)).transpose()


ic(data)

ai_device.scan_stop()
daq_device.disconnect()
daq_device.release()

The first time I run the script after physically connecting the device, it runs fine and returns the expected input value. However, when I try to run the script multiple times, it either immediately fails to connect to the device and returns the following error:
uldaq.ul_exception.ULException: 8: Device no longer responding
during the daq_device.connect() command in line 8. Or it returns an input value of 0 and the same error occurs in one of the following executions. After the error occurs, I have to physically reconnect the device. When trying other functions such as a_in() with this device, they work as intended, so I don't think my device itself is broken.

I have also tried running the AInScan.c example provided by libuldaq, where the device shows exactly the same behaviour. The first time I run the example script everything is fine until I terminate the process and try to run it again where it gives the same error code I get with my own script. 

I have another MCC device, USB-2408-2AO, and have tried both my script and the AInScan.c example on this device. Both worked fine, so I am not really sure how to solve this problem. Is this a specific problem with the USB-1608GX device or am I missing something really basic here?

Thanks in advance.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
Posted (edited)

Hey @Fausto,

I am using Ubuntu 22.04 LTS and libuldaq-1.2.1. However, my Ubuntu OS is running as a VirtualBox VM, which has not caused any problems with my other MCC devices..

Edited by Seweee
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...