07-26-2011 06:22 PM
I am receiving DataMissed event(s) in matlab when acquiring waveform data (2 channels) and an analog input trigger (set up in pretrigger mode - negative delay value).
sampleRate =500000;
pretrigger =8;
trigger_value =0.6;
ai = analoginput('nidaq','Dev1');
ch = addchannel(ai,0:channels);
set(ai,'SampleRate',sampleRate);
requiredSamples = floor(pretrigger*sampleRate);
set(ai,'SamplesPerTrigger',requiredSamples);
%triggering
set(ai,'TriggerChannel',ch(channels+1));
set(ai,'TriggerType','Software');
set(ai,'TriggerCondition','Rising');
set(ai,'TriggerConditionValue',trigger_value);
set(ai,'TriggerDelay',-pretrigger);
set(ai,'TriggerRepeat',0);
set(ai,'LoggingMode','Disk');
set(ai,'LogToDiskMode','Index');
set(ai,'LogFileName',[filename '_01']);
waitTime = pretrigger *1.1+0.5;
for k =1:100
start(ai);
CurrentFile=get(ai,'LogFileName');
disp(['Acquiring for 'CurrentFile]);
while strcmp((get(ai,'Running')),'On')
pause(1);
end
wait(ai,waitTime);
showdaqevents(ai)
disp(['Triggered 'CurrentFile]);
while strcmp((get(ai,'Logging')),'On');end;
disp(['Saved 'CurrentFile]);
end
stop(ai);
delete(ai);
clear ai;
When running this, I get Data Missed Events after the trigger event is received (using the showdaqevents(ai)). However, the Data Missed Events have a sample number of NaN, so I'm not completely certain that they are coming after the trigger.
Looking into Data Missed Events in the matlab documentation, there are two explanations given:
I've attempted to increase the memory available with the daqmem command, but I haven't found that to work. 500000 samples/second, 3 channels is about 90 MB total per trigger, and daqmem reports having over 360MB free (though the buffermode is set to Auto). I am wondering if I need to periodically call getdata(ai) in the while loop to clear the memory. The other possibility is that I am running at too high of a sample rate for the system?
I should mention that the likelihood of getting a DataMissed event goes up the longer (in time) I let the system acquire before pressing the trigger.
Is there a problem with my data acquisition code (I'm most uncertain about having the pause in there in the middle of the acquisition)? The hardware? Is it something not to worry about? Is Visual Studio better for acquiring with NI boards?
07-28-2011
10:39 PM
- last edited on
01-30-2025
09:59 PM
by
Content Cleaner
Hi Ben,
Unfortunately we don't support MATLAB toolboxes (nor do we at NI have access to them), so it will be difficult to support you with this specific code. That said, I can definitely try to help on the hardware side. First off, what DAQ board are you using? Also, what version of the DAQmx driver do you have? If you could go into a bit more detail on your system/application, that could be quite helpful too.
It's entirely possible that you're overflowing the onboard FIFO, given the speed you're running at, but that's very dependent on your hardware setup.
Vis-a-vis what software would be best for acquiring from NI boards, I don't think it's much of a stretch to say that our software works best - our DAQ boards, drivers and software are all designed specifically to go hand-in-hand. Labview (www.ni.com/labview/) is definitely the easiest and most robust way to perform DAQ tasks, but if you prefer working in text based environments, we also offer CVI (www.ni.com/lwcvi/), a C-based measurement environment, and Measurement Studio (www.ni.com/mstudio/), a Visual Studio-based environment.
Let me know the specifics of your DAQ setup, and I'll do my best to see that we can get your application working.
James M.
Applications Engineer
National Instruments
07-29-2011
07:42 AM
- last edited on
01-30-2025
09:58 PM
by
Content Cleaner
The board is the PCI-6122
I am recording on 2 channels, with the third analog channel being used for a digital trigger. I would have rather used the digital inputs on the card for the digital trigger, but I was unable to setup a pretrigger with the digital inputs.
I believe the DAQmx driver is the most recent version.
The reason for using MATLAB instead of Signal Express was that I could not figure out to get Signal Express to automatically re-arm the device for another trigger/trial after the previous trigger (with an incrementing trial number in the file name).
I mentioned in my original post the basic hardware specs on the computer. By hardware setup, is that what you meant?
08-01-2011 12:15 PM
Hey Ben,
I'm trying to get an understanding of your DAQ task, and how it corresponds to specific calls to the DAQmx driver (into which Matlab would be calling). It looks like you're trying to capture analog input data using 100 separate reference trigger events, each with 8 seconds worth of pre-trigger data. This is physically possible on the 6122, though it would be better practice to write that data to disk in multiple chunks for each trigger event, rather than all at once.
With regards to the hardware, your 6122 is able to use reference triggers on the digital lines in the same manner as the analog lines. Signal express does not have a way to automatically create multiple files from multiple triggering events; each event needs to be triggered manually. Labview or Measurement Studio are much more suited to these kind of tasks than Signal Express (which is intended only for simple applications). Also, Signal Express reads data all at once, which isn't feasible with the size of the acquisition task you're performing.
If you perform the same task with a much smaller pre-trigger, do you still see errors? It would be worth establishing that your error is definitely from buffer overflow, rather than some other source.
James M.
Applications Engineer
National Instruments