Jump to content
  • 0

Invalid board number error while outputting voltages 2nd time


Sid_1

Question

Hi there, I am using the Python library mcculw on a Windows 10 mcahine. I am using the USB 231 DAQ.

When I send voltages for the first time (using a_out_scan() method) everything works fine. When I send it for the second time, I get this error:

daq_device_info.py, line 37, in __init__
    raise ULError(ErrorCode.BADBOARD)
mcculw.ul.ULError: Error ErrorCode.BADBOARD: Invalid board number.

Notes:

  1. I have stored the board number in a variable board_num=0. I am not changing it at all during program execution. So, I don't know how it changes and how I get the error.
  2. I initialize the device using the following code each time I try to send voltage. The following is an excerpt from my code:
    class DaqLogic:
        '''
        This class has various methods to interact with the DAQ
        '''
        def __init__(self):
            self.board_num = 0
            self.daq_info = DaqDeviceInfo(self.board_num)
            self.ao_info = self.daq_info.get_ao_info()
    
            #Useful constants for the DAQ
            self.low_chan = 0
            self.high_chan = 1
            self.num_chans = self.high_chan - self.low_chan + 1
            self.ao_range = ULRange.BIP10VOLTS
            self.use_device_detection = True
            self.dev_id_list = []
            self.calibrationFactor = 1
            self.lcdFreq = 200 # in Hz
    
        def configure_first_detected_device(self):
            '''
            Configures the first detected device. Ingores Instacl config.
            '''
            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='')
    
            # Add the first DAQ device to the UL with the specified board number
            ul.create_daq_device(self.board_num, devices[0])
    
        def intialize_daq(self):
            '''
            Initializes the DAQ
            '''
            try:
                self.configure_first_detected_device()
                daq_dev_info = DaqDeviceInfo(self.board_num)
                if not daq_dev_info.supports_analog_output:
                    raise Exception('Error: The DAQ device does not support '
                                    'analog output')
            except ULError as e:
                # Todo: Create alert window
                print("Error: ", e)

     

Is it that I should not initialize the device each time I wish to send voltage ?
I guess, I must initialize only once and then store some reference to the device for further use, like sending voltages for 2nd time.

Edited by Sid_1
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hello Jeffery. Thanks a lot for the solution. Thanks for the fast reply.

I would just like to restate the solution for anyone reading this page:

Don't use ul.release_daq_device(board_num) if you are planning to send more voltages.

Edited by Sid_1
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...