Hi,
I am using DaqAInScanBegin, Continue and End to get analog input from a force sensor (FSR406) through USB-1208FS. The versions of PsychToolbox and MALTAB are 3.0.17 and 9.5.0.1586782 (R2018b) Update 8. I use Windows10.
The problem I would like to ask for your help is the latency of DaqAInScanContinue.
When I set options and ran the functions as below, DaqAInScanContinue takes about 0.03 sec or more and gets multiples of 31 samples. This number 31 should be the number of samples per block from the DAQ device according to the user’s guide of USB-1208FS.
My goal is to record the input from the sensor during presenting a visual motion stimulus. Is it somehow possible to reduce the delay or keep measuring background so that I can use this function with the loop of updating the screen?
Sorry, I solved the issue. I had mistaken the usage of the functions. Now I use them like this and it works very well:
daqIndex = DaqDeviceIndex();
DaqAInScanBegin(daqIndex, options);
while true
% Stimulus presentation using Screen function
if starttiming + presentationtime < GetSecs
DaqAInScanContinue(daqIndex, options);
[data, params] = DaqAInScanEnd(daqIndex, options);
break;
end
end
Almost. DaqAInScanContinue(daqIndex, options); must be always executed in your stimulus drawing loop, to keep data acquisition going over longer periods of time. Otherwise you’ll lose data, depending on operating system. "help DaqAInScanBegin`` demonstrates this.
There is one setting options.secs that allows to specify a timeout for how long one DaqAInScanContinue(daqIndex, options); should roughly take (in reality it may take a bit longer, depending on operating system, machine speed etc.), e.g., options.secs=0.002 for 2 msecs. Default is at least 10 msecs per call.
Thank you mario!
I had given up to use DaqAInScanContinues in drawing loops because of the latency when I uploaded the cord. I tried the option you suggested and DaqAInScanContinues gets 20000 samples in 10 seconds in a loop now .
I got these output when I ran the cord above on my average laptop.
daici: 914
n samples read: 20000
n blocks read: 646
starttime: 4301.689783
DAQ 1st block time: 4301.705430
DAQ 2nd block time: 4301.720357
DAQ lastblock time: 4311.689358
I checked the option in my drawing loop to get satisfiable result. Thanks a lot!
My next question is the timing of samplings. Are data sampled during the time range from the timing DaqAInBegin was run (approximately starttime in the cord) to the timing DaqAInEnd was run? Or are they sampled during the time range returned from DaqAInEnd (i.e., from eparams.times(1) to eparams.times(end) in the cord)?