Error after adding NI-DAQmx card

46 views
Skip to first unread message

Tomáš Lamich

unread,
Mar 31, 2022, 10:33:06 AM3/31/22
to the labscript suite
Hi everyone,

I'm trying to see if an NI-PCI-6132 card that we have in lab is working or not and if we can use it to control our single atom experiment.
I added it as simulated device using NI MAX and I went through the adding process as specified in the documentation. After running  get_capabilities.py and generate_subclasses.py scripts I can see the file for the card and everything looks fine. However, when I try to run Blacs I got a prompt to recompile my connection table. The compilation fails showing me this error:
Recompiling connection table
PCI-6132
Traceback (most recent call last):
  ...
  File "C:\Users\tlamich\Anaconda3\envs\py38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'labscript_devices.NI_DAQmx.models.NI_PCI_6132'
Compilation failed. Please fix the errors in the connection table (python file) and try again

While my connection table looks like this:
from labscript import *
from labscript_devices.PrawnBlaster.labscript_devices import PrawnBlaster
from labscript_devices.NI_DAQmx.labscript_devices import NI_PCI_DIO_32HS
from labscript_devices.NI_DAQmx.labscript_devices import NI_PCI_6713


PrawnBlaster(name='prawn', com_port='COM4', num_pseudoclocks=1,use_wait_monitor=False)
#find the COM port and include it here
NI_PCI_6713(name='ni_card_1',parent_device=prawn.clocklines[0],
                        clock_terminal='PFI0', MAX_name='Dev1')
NI_PCI_DIO_32HS(name='DIO_card',parent_device=prawn.clocklines[0],
                        clock_terminal='PFI2', MAX_name='Dev2',
                        start_order=-1, stop_order=1)

DigitalOut('dig0', DIO_card, 'port0/line0')
DigitalOut('dig1', DIO_card, 'port0/line1')


if __name__ == '__main__':

   start()

   stop(1)

As you can see, I'm not even using the card at the moment while getting the error.
I am on the latest release of labscript using standard conda distribution running on windows. Before I tried to add the card, everything was running without problems.
Thanks for you help.

Have a great day
Tomas

dihm....@gmail.com

unread,
Apr 1, 2022, 12:14:06 PM4/1/22
to the labscript suite
Hello again Tomas!

I can at least tell which piece of the code is the offending part. It is in labscript_devices/NI_DAQmx/models/__init__.py. What is happening is if the labscript_devices/NI_DAQmx/models is imported (which it will be when any model is imported), all of the generated subclasses are automatically added to the global namespace by importing them.

The error you are seeing is fairly straightforward in that the model subclass python file (NI_PCI_6132) is not being found in the models subfolder (labscript_devices/NI_DAQmx/models/) as expected. Are you using an editable installation of labscript_devices, or a normal installation? If the latter, adding a new device is going to be tricky to do right, and likely to be unstable after updates (as new pip installation would overwrite files you had added). To add new devices, you'll want to use an editable install so that the code is loaded directly from your working directory instead of the environment's site-packages.

-David

Tomáš Lamich

unread,
Apr 4, 2022, 8:52:30 AM4/4/22
to the labscript suite
Hi David!

Thanks a lot for the explanation. 
I was using the standard installation. I reinstalled the labscript using the editable installation and everything runs fine for now.

Tomas

Reply all
Reply to author
Forward
0 new messages