Documentation Center

  • Trial Software
  • Product Updates

Start Multiple Device Objects

With Data Acquisition Toolbox™ software, you can start multiple device objects. You might find this feature useful when simultaneously using your hardware's analog output (AO) and analog input (AI) subsystems. For example, suppose you create the analog input object ai and the analog output object ao for a sound card, and add one channel to each device object.

ai = analoginput('winsound');
ao = analogoutput('winsound');

You should use manual triggers when starting multiple device objects because this trigger type executes faster than other trigger types with the exception of hardware triggers. Additionally, to synchronize the input and output of data, you should configure the ManualTriggerHwOn property to Trigger for ai.

set([ai ao],'TriggerType','Manual')

Configure ai for continuous acquisition, call the callback function qmoredata whenever 1000 samples are output, and call daqcallback when ai and ao stop running.

set([ai ao],'StopFcn',@daqcallback)

As shown below, the callback function qmoredata extracts data from the engine and then queues it for output.

function qmoredata(obj,event,ai)
data = getdata(ai,1000);

Queue data in the engine, start the device objects, and execute the manual triggers.

data = zeros(4000,1);
start([ai ao])
trigger([ai ao])

    Note   You cannot trigger device objects simultaneously unless you use an external hardware trigger.

You can determine the starting time for each device object with the InitialTriggerTime property. The difference, in seconds, between the starting times for ai and ao is

aitime = ai.InitialTriggerTime
aotime = ao.InitialTriggerTime
delta = abs(aotime - aitime);
ans =

Note that this number depends on the specific platform you are using. To stop both device objects:

stop([ai ao])

The output from daqcallback is shown below.

Stop event occurred at 13:00:25 for the object: winsound0-AO.
Stop event occurred at 13:00:25 for the object: winsound0-AI.
Was this topic helpful?