labscript-suite-temp-2 / labscript

The labscript Python library provides a translation from simple Python code to complex hardware instructions. The library is used to construct a "connection table" containing information about what hardware is being used and how it is interconnected. Devices described in this connection table can then have their outputs set by using a range of functions, including arbitrary ramps.
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

While setting values for the NI PCI 6733 DAQ... #17

Closed philipstarkey closed 8 years ago

philipstarkey commented 8 years ago

Original report (archived issue) by Jesse Evans (Bitbucket: jcevans).

The original report had attachments: errormessage.txt


I got this strange error raised in blacs when I tried to run my script. The script had a bunch of commands like these:

Li72DP_amp.constant(Li72DP_amp.t0, 0.5)

which compiled ok, but once I tried to run in blacs gave rise to the attached error. No idea what the root cause is. I tried to use the same syntax as in the example python file. The blacs gui can still be used to set values on the daq, but whenever I try to use a script it runs into trouble.

Regards

Jesse Evans

philipstarkey commented 8 years ago

Original comment by Jesse Evans (Bitbucket: jcevans).


philipstarkey commented 8 years ago

Original comment by Philip Starkey (Bitbucket: pstarkey, GitHub: philipstarkey).


Hi Jesse,

This error happens when there are not enough instructions for the device in the compiled HDF5 file. The NI PCI 6733 requires a minimum of 2 instructions. If you add an additional instruction at a later time, this error should go away. For example, in your labscript (experiment logic) file:

#!python

t = Li72DP_amp.t0
Li72DP_amp.constant(t, 0.5)
t += 1
Li72DP_amp.constant(t, 0.5)
t += 1
stop(t)

Note that in this example, the experiment will last for 2 seconds. You can adjust the times as you like, as long as there are at least two commands to channels on the NI PCI 6733 at different times, the error should not exist.

We should however, put a check in the labscript_devices.NI_PCI_6733 code to display an error at compilation time, rather than the obtuse error you have seen in BLACS. I've logged it as a bug here (labscript-suite-temp-2/labscript_devices#14).

Let me know if this doesn't solve the issue :)

philipstarkey commented 8 years ago

Original comment by Jesse Evans (Bitbucket: jcevans).


Thanks for the help, Philip. I tried what you suggested, and got a different (but also indecipherable) error.

Traceback (most recent call last):

File "C:\labscript_suite\labscript_devices\NI_PCI_6733.py", line 233, in transition_to_manual

self.ao_task.StopTask()

File "", line 3, in StopTask

File "", line 2, in function

File "C:\Anaconda\lib\site-packages\PyDAQmx\DAQmxFunctions.py", line 33, in mafunction

raise DAQError(error,errBuff.value.decode("utf-8"), f.name)

DAQError: Finite acquisition or generation has been stopped before the requested number of samples were acquired or generated.

in function DAQmxStopTask

Fatal exception in main process - Tue Jan 12, 12:53:30 :

Traceback (most recent call last):

File "C:\labscript_suite\blacs\tab_base_classes.py", line 670, in mainloop

next_yield = inmain(generator.send,results)

File "C:\Anaconda\lib\site-packages\qtutils\invoke_in_main.py", line 68, in inmain

return get_inmain_result(in_main_later(fn,False,*args,**kwargs))

File "C:\Anaconda\lib\site-packages\qtutils\invoke_in_main.py", line 47, in event

result = event.fn(*event.args, **event.kwargs)

File "C:\labscript_suite\blacs\device_base_class.py", line 627, in transition_to_manual

raise Exception('Could not transition to manual. You must restart this device to continue')

Exception: Could not transition to manual. You must restart this device to continue

I think the key complaint here is the transition to manual part, but I don't know what that means.

Regards

Jesse Evans

philipstarkey commented 8 years ago

Original comment by Jesse Evans (Bitbucket: jcevans).


Nevermind, our clock was connected. We're all good here. Thanks for your help!

philipstarkey commented 8 years ago

Original comment by Philip Starkey (Bitbucket: pstarkey, GitHub: philipstarkey).


Hi Jesse,

Glad it is fixed!

For future reference on decoding the BLACS exceptions: In the error above there are two exceptions raised. The first was from PyDAQmx:

DAQError: Finite acquisition or generation has been stopped before the requested number of samples were acquired or generated.

This then causes the second exception:

Exception: Could not transition to manual. You must restart this device to continue

What this tells us is that PyDAQmx had an exception during the BLACS mode of "transition_to_manual". BLACS has 4 modes; manual, transition_to_buffered, buffered and transition_to_manual. BLACS moves each device tab through these modes as it prepares and finishes running an experiment. Tabs are in manual mode when you are not running a shot, buffered mode when they are in the middle of a shot and the transition modes to prepare and finalise the shot.

In this case, the NI card reported that it had not generated all of it's programmed samples by the time the experiment shot was finished. As you found out, that was because the clock line was not connected!

Let us know if you have any further issues!

philipstarkey commented 8 years ago

Original comment by Philip Starkey (Bitbucket: pstarkey, GitHub: philipstarkey).