Externally Triggerable Scripts

Externally Triggerable Scripts is a ScanImage “device” developed to use DAQ digital input ports to trigger execution of MATLAB scripts when a change in voltage from 0V to 5V or 5V to 0V has been detected. Each device can support execution of up to 5 scripts, and several of these devices can be added for even more.

Device Compatibility

The externally triggerable scripts device can use any DAQ digital input port that has not already been reserved by another resource/device.

The external signal must be able to generate a voltage that passes the threshold for logical high and low values according to the DAQ. For the vDAQ, this TTL threshold is greater than 2V for high and less than 0.8V for low. Also of particular note is that the polling rate of the DAQ digital input ports for this device is 1 Hz. This means a pulsed TTL signal must have a pulse width equal to or greater than 1 second in order to detect the change in voltage.

Note, scripts should not take longer than 300 ms to complete, as it will be competing with other ScanImage processes which all occur in the singular MATLAB execution thread.

vDAQ Datasheet

Hardware Config

Connect the source of a TTL signal via BNC cable to a digital input port of the DAQ.

Software Config

From the Resource Configuration window, under the Devices tab click the add device “+” button.

../_images/config+devices.png

Select Miscellaneous from the sidebar and then Externally Triggerable Scripts and click “Add”. Assign it a name and click OK.

../_images/DeviceSelection.png

In the resource configuration page, configure the device according to your needs given the definitions provided below for each script that is defined.

../_images/ResourceConfigPage.png

Definitions

Script to Trigger

The script that will be executed. Click the Browse button to select it.

Note

The script can be a script or function on or off the MATLAB path. If it is a function, it needs to take no input arguments, or only varargin as an input argument. if it is off the MATLAB path, then it will take an additional ~50 ms to execute the script.

Terminal

Port used to trigger execution

Note

The port is actually optional, in which case the device behaves just like the user buttons device.

Edge

If a port is selected, then this decides whether a rising edge (0V -> 5V) or falling edge (5V -> 0V) initiates the execution of the script.

Enable

If the checkbox is checked, then TTL pulses arriving on the ports will execute the script

Widget

../_images/Widget.png

The scripts can be enabled/disabled and executed by clicking their respective buttons. The text box besides the buttons tells the amount of time taken to execute the script.