How can I send a predefined wave to my analog data acquisition output based on a trigger with the Data Acquisition Toolbox 2.0 (R12) and later versions?

1 view (last 30 days)
I am using a data acquisition board and want to be able to send a predefined wave to my analog output every time a trigger is issued.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
To send a predefined wave to the analog output based on a trigger, use the SamplesOutputFcn property. This property associates a callback function with the object. This callback function will be executed after the last N samples were sent out to the analog output (where N is determined by the SamplesOutputFcnCount property). In the callback function, a new set of data will be loaded in the buffer, and in the next trigger it will be sent to the analog output.
An example of code showing how to work with triggers using the winsound (sound card) object is attached in the file outputPredefinedWave.m. In this example, a manual trigger is used, but it can be modified for hardware trigger as well. For more information regarding the available trigger types, type the following at your MATLAB command prompt:
web([docroot,'/toolbox/daq/c4_gsai8.html'])
You can call this demo from MATLAB as follows:
ao = outputPredefinedWave
trigger(ao)
stop(ao)
delete(ao)
clear ao
You should note the following in the example:
The SamplesOutputFcn property specifies the callback function to be called after the output of N samples to the channels. For more information regarding the SamplesOutputFcn property, type the following at your MATLAB command prompt:
doc SamplesOutputFcn
The SamplesOutputFcnCount property specifies the number of samples to output for each channel before the next call to the callback function. For more information regarding the SamplesOutputFcnCount property, type the following at your MATLAB command prompt:
doc SamplesOutputFcnCount
The function LOADWAVES is the callback function specified by the SamplesOutputFcn property. For more information on creating and executing callback functions, type the following at your MATLAB command prompt:
web([docroot,'/techdoc/matlab_external/ch_ser30.html'])
For general information regarding analog output events and callbacks, you can refer to the documentation by typing the following at your MATLAB command prompt:
web([docroot,'/toolbox/daq/c5_dma18.html'])

More Answers (0)

Categories

Find more on Simultaneous and Synchronized Operations in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!