MATLAB Answers

Timothée
2

DAQ analog output stops after a fixed number of samples during long continuous signal generation

Asked by Timothée
on 23 May 2018
Latest activity Commented on by Hooman Sedghamiz on 20 Sep 2019
Hello,
I am using the following example code to continuously output analog signals on channels 0 and 1 of a National Instruments USB-6251 Device. I am using Matlab R2018a.
Every 10 seconds, the queue is filled with 10 seconds of data at 0.5 or 1MHz. The problem is that after an almost fixed number of samples sent (12,884,890,000 +/- 10,000, i.e. after a bit more than 3.5 or 7 hours depending on the sampling frequency), the device stops requiring and outputing data continuously. No error message is displayed, and the porperties of the device after stopping are: ScansQueued: 0, ScansOutputByHardware: 12884899987 (for example) and IsDone: 'true'.
devices = daq.getDevices;
s = daq.createSession('ni');
s.Rate = 1000000;
s.IsContinuous = true;
s.NotifyWhenScansQueuedBelow = 10*s.Rate;
addAnalogOutputChannel(s,'Dev1',0,'Voltage');
addAnalogOutputChannel(s,'Dev1',1,'Voltage');
outputSignal = ones(10*s.Rate,2);
queueOutputData(s, outputSignal);
lh = addlistener(s, 'DataRequired', @(src,event) src.queueOutputData(outputSignal));
startBackground(s);
Notice that I tried to manually queue data by calling s.queueOutData every 10 s instead of using addlistener. In this case, there is no error, but no signal can be seen from the analog output ports.
Does anybody has an idea of what is going on?
Thanks!

  0 Comments

Sign in to comment.

2 Answers

Answer by Hooman Sedghamiz on 24 Aug 2019

I have seen many questions in regards to DAQ session issues, some even dating back to 2016 but no answer so far. I am having the same issue and the output generation stops everytime at sample number 8196, even when I change the signal which is being outputed... The device i use is a NI-USB-6211 which is supposed to be SUPPORTED!
Is this a bug? Please be kind and advice!

  4 Comments

Show 1 older comment
In general, DAQ object and its modules seem to be pretty buggy. For instance, in this case, I had to add a listener and reduce the buffer size to inject the signal in buffers of 8000 samples to avoid this issue. But, ideally would like to be able to avoid this and be able to inject all of my samples all at once without the delay being introduced due to the listener calling the function that queues more samples. Is there any known limitations with the buffer size?
Other issue that there is no instructions neither explanations is that being able to output one analog signal and input one analog input simultanously in the BACKGROUND. It is not clear how the listerner shoudlbe triggered 'DataAvailable' or 'DataRequired'. DataRequired would not work and flushes the queue, so one has to use 'DataAvailable'. In that case also, the listener only is called once and if one tries to queue data to inject the process is intrupted. One way would be to queue a bigger buffer size and then only aquire data without queueing more samples but as I mentioned earlier queuing more samples is not possible at least in my USB-6211 case and therefore I need to queue samples iteratively by trigerring a listener... The DAQ card works like a charm in C#. Any ideas how to resolve this?
In general, DAQ session is very badly documented and many online questions remain unaswered. Please help improve this toolbox documentation and examples...
Thank you
I have not formed a good impression of the NI USB-62xx series; they are the low-end USB series and NI seems to have cut some corners on them. The NI USB-65xx series look comparatively more stable... or perhaps just less has been posted about those.
Thanks for your answer Walter, but these issues do not seem to be related to the device. Since, I can inject and aquire the same signal in C# using the same device. It rather seems to be something faulty within the Matlab wrapper. I needed to do this because all of my other routines are written in C and Matlab and did not want to completely move to C# or bother with interfacing it with Matlab...

Sign in to comment.


Answer by Ryan
on 19 Sep 2019

I had a similar issue with creating a continuous Analog Output Signal in MATLAB through an NI-DAQ (PCIe-6361). I kept getting an "Analog Output Underflow Error" when I added an 'ErrorOccurred' listener:
addlistener(s, 'ErrorOccurred', @(src,event) disp(getReport(event.Error))).
This would happen intermittently after the signal would run for a few seconds to a few minutes. After much tinkering, I found that in order to overcome this issue, I increased the CPU priority for the program MATLAB.exe in the Task Manager in Windows to "Above Normal." See the following link:
This seems to have fixed my issue. Hope it helps everyone else.

  0 Comments

Sign in to comment.