Acquire and generate data simultaneously with NiDAQ USB 6211

2 views (last 30 days)
I'm trying to generate and acquire data with this device but at the moment I've only achieved to generate and acquire in separated functions following the toolbox examples. I did this with the "startForeground" function. I thought that if I did this with "startBackground" instead it will be really easy but again I only managed to get background data in separated functions.
My goal it's to acquire data in the background for a long time while I generate data in the foreground with some loops and such. Is this possible?
If not I think I could manage acquiring and generating data in several sessions and after that sum all acquired data but I don't know how to do this. Could you help please?
Here's the code I have so far that doesn't work:
sIn = daq.createSession('ni');
sIn.Rate = samplesPerSec ;
sIn.DurationInSeconds = timeLenght;
ch1 = addCounterInputChannel(sIn,'Dev1', 'ctr0', 'Position');
ch1.TerminalA; ch1.TerminalB; ch1.TerminalZ;
ch1.EncoderType = 'X2';encoderCPR = 8192/4;
addAnalogInputChannel(sIn,'Dev1','ai1','Voltage');
addAnalogInputChannel(sIn,'Dev1','ai5','Voltage');
addAnalogInputChannel(sIn,'Dev1','ai6','Voltage');
addAnalogInputChannel(sIn,'Dev1','ai2','Voltage');
addAnalogInputChannel(sIn,'Dev1','ai4','Voltage');
addAnalogOutputChannel(sIn,'Dev1','ao1','Voltage');
Vout = linspace(outputValue,outputValue,samplesPerSec*timeLenght);
sIn.queueOutputData(transpose(Vout));
[data,timestamps] = startForeground(sIn);
I don't get any error but either get any output values

Answers (0)

Categories

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

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!