Data Acquisition Toolbox | ![]() ![]() |
Starting Multiple Device Objects
With the Data Acquisition Toolbox, 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.
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
.
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,'SamplesPerTrigger',inf) set(ao,'SamplesOutputFcn',{'qmoredata',ai}) set(ao,'SamplesOutputFcnCount',1000) set([ai ao],'StopFcn',@daqcallback)
As shown below, the callback function qmoredata
extracts data from the engine and then queues it for output.
Queue data in the engine, start the device objects, and execute the manual triggers.
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); sprintf('%d',delta(6)) ans = 2.288818e-005
Note that this number depends on the specific platform you are using. To stop both device objects:
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.
![]() | Example: Performing a Linear Conversion | Digital Input/Output | ![]() |