TheDeanLab / navigate

navigate - open source light-sheet microscope controls
https://thedeanlab.github.io/navigate/
Other
31 stars 6 forks source link

PXI-6723 Timing Error #1007

Open AdvancedImagingUTSW opened 3 weeks ago

AdvancedImagingUTSW commented 3 weeks ago

@EvoleneP

The NI-based galvo that performs the z-stack is failing when the triggered sine-wave generation on the shadow reduction galvo is enabled.

Error thrown is NI status code -200963. Timing type of the galvo is incompatible.

image
EvoleneP commented 3 weeks ago
2024-10-02 10:21:56,313 - model - INFO - common_features: ZStackAcquisition. Positions [[4600.9, -3520.6, 150.0, 0.0, 1907.1]], Starting Focus 0.0, Starting Z-Position -100.0
2024-10-02 10:21:56,344 - model - INFO - model: Stage moved to:, {'x_abs': 4600.9, 'y_abs': -3520.6, 'theta_abs': 0.0}, Wait until done: True
2024-10-02 10:21:56,380 - model - DEBUG - ni: Error moving z to 50.0 volts: 1.3157894736842106
2024-10-02 10:21:56,380 - model - ERROR - ni: Requested Sample Timing Type is not allowed, because there is already another task with analog output channels from the same device configured for a different Sample Timing Type. This is not supported on this device.
Change your application so that all the channels from this device are used in one task, set Sample Timing Type to On Demand for all tasks, or consider using two devices for the two tasks.
Task Name: _unnamedTask<0>

Status Code: -200963
Traceback (most recent call last):
  File "C:\Users\Nikon\Documents\GitHub\navigate\src\navigate\model\devices\stages\ni.py", line 245, in move_axis_absolute
    self.ao_task.write(volts, auto_start=True)
  File "C:\Users\Nikon\miniconda3\envs\navigate\lib\site-packages\nidaqmx\task.py", line 1233, in write
    return _write_analog_f_64(
  File "C:\Users\Nikon\miniconda3\envs\navigate\lib\site-packages\nidaqmx\_task_modules\write_functions.py", line 32, in _write_analog_f_64
    check_for_error(error_code)
  File "C:\Users\Nikon\miniconda3\envs\navigate\lib\site-packages\nidaqmx\errors.py", line 127, in check_for_error
    raise DaqError(error_buffer.value.decode("utf-8"), error_code)
nidaqmx.errors.DaqError: Requested Sample Timing Type is not allowed, because there is already another task with analog output channels from the same device configured for a different Sample Timing Type. This is not supported on this device.
Change your application so that all the channels from this device are used in one task, set Sample Timing Type to On Demand for all tasks, or consider using two devices for the two tasks.
Task Name: _unnamedTask<0>

Status Code: -200963
AdvancedImagingUTSW commented 2 weeks ago

The error arises because the galvo used for shadow reduction operates in a triggered mode (like the camera external trigger), whereas the galvo ni-based stage operates on-demand.

This is intentional, since we want the stage to move as soon as we deliver the command, and not at the same time that the camera is triggered.

The timing for the analog outputs is set as follows:

self.analog_output_tasks[board] = nidaqmx.Task()
self.analog_output_tasks[board].ao_channels.add_ao_voltage_chan(channel)
self.analog_output_tasks[board].timing.cfg_samp_clk_timing(
                rate=self.sample_rate,
sample_mode=nidaqmx.constants.AcquisitionType.FINITE,
                samps_per_chan=max_sample * self.waveform_repeat_num,
            )