Prawnblaster puzzle

Visto 110 veces
Saltar al primer mensaje no leído

Karthik Chandrashekara

no leída,
20 abr 2022, 10:30:2220/4/22
a the labscript suite
Hello everyone, new user here!

I had a beginner question on setting up the Prawnblaster for a first run with the NI PXIe 6738 and PXIe 6535 cards. Following the very helpful documentation and the numerous previous discussions on this forum, we installed and configured the labscript-suite to launch and pick up the cards along with the Prawnblaster (See attached connection table file and a screenshot of BLACS). We were even able to successfully compile and run a test script meant to check the analog, digital outputs, and the clocking signal which, as per the runviewer, shows as expected (See attached test script and screenshot of runviewer).

We also, independently, using the provided BLACS GUI, verified that the connection with the hardware, PC, and labscript is in order. Toggling the digital outputs for instance shows on an oscilloscope and so does toggling the "GPIO 09" flag of the Prawnblaster at one of its clock outputs, "CLK0".

What is the issue however is when we run our test script, we are not able to see the output of the hardware as shown in runviewer - there is no clocking signal as expected from the "CLK0" output of the Prawnblaster and no output at the analog and digital outs of the NI cards. The connections were verified to be as specified in the connection table and the test script - "CLK0" goes to PFI2, digital output port "port0/line0" and analog output port "ao01" are monitored for the output.

Since the cards work as expected (also verified with NI software) and we are fairly confident we configured labscript correctly (there are no indications of errors), we believe the problem lies with or perhaps starts with Prawnblaster. There is no clocking signal as expected and so no subsequent execution of the instructions. What are we doing - or have done - wrong here? 
connection_table.py
BLACS.png
test.py
runmanager.png
runviewer.png

Zak V

no leída,
20 abr 2022, 23:10:5620/4/22
a the labscript suite
Hi Karthik,

First off, I'm happy to hear that you managed to get things set up just using the written resources!

Sorry if this is a dumb suggestion, but in the blacs screenshot I see that the shot execution queue is paused (see the button near the top left of the image). Does the sequence run if you un-pause the queue? Everything else looks to me like it should work.

Cheers,
Zak

Karthik Chandrashekara

no leída,
24 may 2022, 9:03:4824/5/22
a the labscript suite
Hi Zak, 

I want to first close the previous issue as resolved as I see that I sent a private email and perhaps there are others who will read this and would like to know if the suggested solution indeed was one -  unpausing the sequence worked. I was under the impression the pausing was happening because of some wrong configuration somewhere but that was not the case. Later, there were a few errors in the script with regard to the number of defined channels and their appropriate names but, after sweeping those away, the whole script executed like a charm.

I have now another issue with PrawnBlaster which also maybe is oversight on my part. We are writing a test sequence to load a MOT. I wrote a separate module with a method for loading a MOT and called it in a different script (as you would in an experimental sequence). To make life easier I used import_or_reload() to import the connection table each time but upon executing the sequence script, I obtain this error - 

Traceback (most recent call last):
  File "C:\Users\control\labscript-suite\userlib\labscriptlib\DyBEC\Sequences\MOT_3D_Loading.py", line 5, in <module>
    from labscriptlib.DyBEC.Subroutines.MOT import *
  File "C:\Users\control\labscript-suite\userlib\labscriptlib\DyBEC\Subroutines\MOT.py", line 4, in <module>
    import_or_reload('labscriptlib.DyBEC.connection_table')
  File "C:\Users\control\anaconda3\envs\py39\lib\site-packages\labscript_utils\__init__.py", line 44, in import_or_reload
    importlib.reload(sys.modules[modulename])
  File "C:\Users\control\anaconda3\envs\py39\lib\importlib\__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "C:\Users\control\labscript-suite\userlib\labscriptlib\DyBEC\connection_table.py", line 10, in <module>
    PrawnBlaster(name='prawn', com_port='COM5', num_pseudoclocks=2)
  File "C:\Users\control\anaconda3\envs\py39\lib\site-packages\labscript\labscript.py", line 192, in new_function
    return_value = func(inst, *args, **kwargs)
  File "C:\Users\control\anaconda3\envs\py39\lib\site-packages\labscript_devices\PrawnBlaster\labscript_devices.py", line 236, in __init__
    PseudoclockDevice.__init__(self, name, trigger_device, trigger_connection)
  File "C:\Users\control\anaconda3\envs\py39\lib\site-packages\labscript\labscript.py", line 192, in new_function
    return_value = func(inst, *args, **kwargs)
  File "C:\Users\control\anaconda3\envs\py39\lib\site-packages\labscript\labscript.py", line 1234, in __init__
    raise LabscriptError('There is already a master pseudoclock device: %s.'%device.name +
labscript.labscript.LabscriptError: There is already a master pseudoclock device: prawn.There cannot be multiple master pseudoclock devices - please provide a trigger_device for one of them.
Compilation aborted.

What could be the reason for this? 

I have attached the modified connection table and the sequence script here if that helps.
Load_MOT_3D.py
connection_table.py

Zak V

no leída,
24 may 2022, 22:20:2124/5/22
a the labscript suite
Hi Karthik,

I suspect the issue is that `import_or_reload('labscriptlib.DyBEC.connection_table')` is getting called more than once. That causes it to run `PrawnBlaster(name='prawn', ...)` twice, and the second time labscript raises an error indicating that you've already created a device called `'prawn'`. It looks to me like `import_or_reload()` is called both in `Load_MOT_3D.py` itself, and then again from `MOT.py` as it is imported during the `from labscriptlib.DyBEC.Subroutines.MOT import *` line in `Load_MOT_3D.py`.

I do like your approach of having functions defined for certain subsequences which then get imported into each experiment script that needs them. That makes it much easier when you need to e.g. change something about the MOT loading sequence as then you only need to modify the code in one place. Doing that is a real pain if the MOT subsequence has just been copy/pasted into each sequence that uses it.

You can implement your subsequence approach by defining the subsequences in their own `subsequences.py` module which doesn't call `import_or_reload()` itself. The functions there can use all of your globals and all of the devices defined in your connection table, just make sure that the experiment script which imports subsequences from `subsequences.py` calls `import_or_reload('labscriptlib.DyBEC.connection_table')`. This works because labscript injects the devices from your connection table as globals that even code imported from other modules can see. With this setup, `import_or_reload('labscriptlib.DyBEC.connection_table')` is only ever called once, so the error you see now is avoided.

To be more specific for your situation, I'd suggest defining a `subsequences.py` file and moving the code to execute your MOT subsequence there (but don't move the `import_or_reload('labscriptlib.DyBEC.connection_table')` call there). Then your `Load_MOT_3D.py` should call `import_or_reload()` and import the MOT subsequence code from `subsequences.py`. Next, when you define a new experiment sequence, you can create a new `my_sequence.py` file which also calls `import_or_reload()` and imports the MOT subsequences, and any other subsequences it needs, from `subsequences.py`.

Cheers,
Zak
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos