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

10 ビュー (過去 30 日間)
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!

回答 (4 件)

Hooman Sedghamiz
Hooman Sedghamiz 2019 年 8 月 24 日
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 件のコメント
Walter Roberson
Walter Roberson 2019 年 9 月 19 日
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.
Hooman Sedghamiz
Hooman Sedghamiz 2019 年 9 月 20 日
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...

サインインしてコメントする。


Ryan
Ryan 2019 年 9 月 19 日
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.

Anthony Le
Anthony Le 2020 年 6 月 14 日
I also had the same issue when doing continuous analogue inputs and output to monitor a solar cell charging a lipo battery. Matlab always stop at sample 8002. I suspect this is caused by the buffer being flooded with data and matlab does not know when to queue more data leading to the buffer being overflow and the code subsequently stops. To solve this, I added a second listener to handle the date generation and tell matlab to queue more data when the scan queue fall bellow a certain value. The code runs continously for 160 hours without any issue (see bellow for the code). I also attached my battery charging result for your information.
I am using matlab 2018a and NI USB-6351.
% setting up the DAQ
d = daq.getDevices;
d(1)
s = daq.createSession('ni');
s.IsContinuous = true;
s.NotifyWhenScansQueuedBelow = 100;
% Set up input channels
ch1 = addAnalogInputChannel(s,'Dev2', 1, 'Voltage'); % scan signal from channel 1 (battery voltage)
ch1.TerminalConfig = 'SingleEnded';
ch2 = addAnalogInputChannel(s,'Dev2', 2, 'Voltage'); % scan signal from channel 2 (relay)
ch2.TerminalConfig = 'SingleEnded';
ch3 = addAnalogInputChannel(s,'Dev2', 3, 'Voltage'); % scan signal from channel 3 (fuel cell voltage)
ch3.TerminalConfig = 'SingleEnded';
% Set up output channels
ch4 = addAnalogOutputChannel(s,'Dev2', 0, 'Voltage'); % signal to control relays
% running for 60 hours
% run Fuel cell for 9 mins
% charge battery for 6 hours
fs = 1;
t = 0:1/fs:21600;
x = 5 * rectpuls(t - 270,540)';
s.Rate = 1; % scan X time/s must be the same as the frequency of the output signal
lh = addlistener(s,'DataAvailable',@plotData);
lh2 = addlistener(s,'DataRequired', @(src,event) src.queueOutputData(x));
global time;
global data;
queueOutputData(s,x);
s.startBackground();
% pause (10);
%%
fig = figure (1);
plot(time/3600,data(:,1)); %Plotting battery votage
xlabel('Time (hours)');
ylabel('Voltage (V)');
hold on;
plot(time/3600,data(:,2)); %Plotting relay
plot(time/3600,data(:,3)); %Plotting Fuel cell voltage
hold off;
%% Stop
% stop(s);
%% save data
save('Lipo_battery_charging_data_withFuelcell_final.mat', 'data');
save('Lipo_battery_charging_time_withFuelcell_final.mat', 'time');
%% Function
function plotData(src,event)
persistent tempData;
persistent tempTime;
global time;
global data;
if(isempty(tempData))
tempData = [];
end
plot(event.TimeStamps,event.Data);
tempData = [tempData;event.Data];
tempTime = [tempTime;event.TimeStamps];
time = tempTime;
data = tempData;
end

哲史 伊藤
哲史 伊藤 2023 年 2 月 20 日
I am also facing exactly same problem using NI USB-6343 and MATLAB 2017b. I am playing sound data at 300kHz sampling rate, and the device stopped after 12 hours (about 2,884,890,000 samples). I monitored the amount of queued data and there was no problem of shortage of queued data.
  4 件のコメント
哲史 伊藤
哲史 伊藤 2023 年 2 月 22 日
Thanks. What type of log data would it be useful?
The error reported by addlistener is
Analog Output underflow event: Last vaild output was scan number 12884897924.
log2(12884897924)=33.5850
it is slightly higher than 2^32.
Walter Roberson
Walter Roberson 2023 年 2 月 22 日
If you are getting that many successful outputs then I do not know what the problem might be -- not unless you are logging to file and running out of disk space.

サインインしてコメントする。

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by