Data Acquisition Toolbox    

Creating and Executing Action Functions

When using action functions, you should be aware of these execution rules:

You can specify the action function to be executed when a specific event type occurs by including the name of the M-file as the value for the associated action property. For example, to execute the action function myaction for the analog input object ai every time 1000 samples are acquired

M-file action functions require at least two input arguments. The first argument is the device object. The second argument is a variable that captures the event information given in Table 5-12, Analog Input Event Information Stored in EventLog,. This event information pertains only to the event that caused the action function to execute. The function header for myaction is shown below.

You can pass additional parameters to the action function by including them as elements of a cell array. For example, to pass the MATLAB variable time to myaction

The corresponding function header is

If you pass additional parameters to the action function, then they must be included in the function header after the two required arguments.

Specifying a Toolbox Function as an Action

In addition to specifying your own action function, you can specify the start, stop, or trigger toolbox functions as actions. For example, to configure ai to stop running when an overrange condition occurs


 Recording and Retrieving Event Information Examples: Using Action Properties and Functions