AllenNeuralDynamics / exa-spim-control

Acquisition control for the exaSPIM microscope system
MIT License
2 stars 1 forks source link

NI counter output task fails #15

Closed adamkglaser closed 1 year ago

adamkglaser commented 1 year ago

Bug encountered today which took all day to trace. For unknown reasons... no update via pip or to code, it looks like the command which sets the output PFI line for the counter task is no longer doing anything.

https://github.com/AllenNeuralDynamics/exa-spim-control/blob/a2700218b41776b36ef244088e45b13d1b7a206f/exaspim/devices/WaveformGenerator.py#L33

As a result, when the counter task is setup, the PFI line defaults(and stays set) to something for the specified counter (i.e. ctr0, ctr1, ...).

https://github.com/AllenNeuralDynamics/exa-spim-control/blob/a2700218b41776b36ef244088e45b13d1b7a206f/exaspim/devices/WaveformGenerator.py#L26

For example, through experimental measurement, it looks like ctr0 defaults to PFI7, and ctr1 defaults to PFI2.

TODOs. See if this behavior is mirrored on other systems (meso/diSPIM). If so, there must be a bug in nidaqmx (?) If not, that is good, but something strange has now happened on the exaSPIM workstation.

adamkglaser commented 1 year ago

Solution is to set things at the co_channel level instead of task. Still not sure why the behavior changed, but problem solved.

Example:

import nidaqmx

co_task = nidaqmx.Task('counter_output_task')
co_channel = co_task.co_channels.add_co_pulse_chan_freq('/Dev1/ctr0', ...)
co_channel.co_pulse_term = '/Dev1/PFI1'