Using Data Acquisition Toolbox™ software, you can simultaneously
start analog input and analog output. For example, you can create
an analog input object
ai and an analog output
ao for a sound card, and add one channel
to each device object.
ai = analoginput('winsound'); addchannel(ai,1); ao = analogoutput('winsound'); addchannel(ao,1);
Queue data in the engine and start the device objects. By default
this allows the trigger to execute immediately after
start command will configure the objects
and execute the trigger sequentially, leading to a delay between the
start of the two operations:
data = zeros(4000,1); putdata(ao,data) start([ai ao])
When you pass
start as an array, the first object in the array is configured and
triggered, then the second object is configured and triggered. This
is done serially, and therefore there is a certain amount of latency
between the actual triggers of the objects.
In order to reduce this latency, you should use manual triggers. A manual trigger executes faster than all other trigger types (except hardware triggers).
[ai ao].TriggerType = Manual data = zeros(4000,1); putdata(ao,data) start([ai ao]) trigger([ai ao])
Note: Device objects cannot be triggered simultaneously unless you use an external hardware trigger.
The analog output object does not start outputting data until
you trigger it. The analog input object will start acquiring data
start is executed, but will discard the data
until you trigger it. In order to achieve the lowest possible latency,
you should configure the analog input object's
ManualTriggerHwOn property to
ai.ManualTriggerHwOn = Trigger data = zeros(4000,1); putdata(ao,data) start([ai ao]) trigger([ai ao])
You can determine the time the analog input and analog output
objects triggered with the
Calculate the time in seconds, between
aitime = ai.InitialTriggerTime; aotime = ao.InitialTriggerTime; delta = abs(aotime - aitime); sprintf('%d',delta(6))
ans = 2.288818e-005
Note: You can also use this feature to simultaneously start any number of analog input and analog output objects.