How to continuously record data using data acquisition until programmatically told to stop.
Mostrar comentarios más antiguos
Hi all,
I have a feeling i am being stupid and missing something obvious but I cant quite get the code to work how I need it.
I am using the Data Aquisition toolbox, connecting to and reading anologue data from a NI device. I can connect fine and can record data okay but I can only seem to record data for a given amount of time or a given number of data points, both of which I don't know and changes from scan to scan. Ideally I would use something like the simplified code below were i start recording, I then carryout an other fucntion, which when finished stops the data recording before I read the data into the workspace :
dqlist = daqlist("ni");
dq = daq("ni");
dq.Rate=200000;
addinput(dq, dqlist.DeviceID, "ai0", "Voltage");
for i = 1:10000
start(dq,"continuous");
Some_other_function
stop(dq);
output{i} = read(dq); %%% read the data collected between the start and stop functions
end
Obviously I could just specify a record time/data aquire that is far bigger than needed but as this loop is happening thousands of times it isnt efficent or practical. I also need to record the data at the high inbuilt hardware speed of 200,000 samples a sec so I can't have a parrelel loop which records a single sample at a time.
Any help is much appricated, I am sure this is doable as there is a start and stop functions but I couldn't find an example which works exactly how it need.
Thanks
James
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Data Acquisition Toolbox Supported Hardware en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!