Error: Analog Output underflow event

조회 수: 15 (최근 30일)
Daniel
Daniel 2016년 11월 18일
댓글: cecile conrad 2022년 5월 2일
I am trying to simultaneously record two analog inputs and create a digital output using a National Instruments DAQ. I cannot get around this error, however, and I have not found any posts that specifically address it. The most confusing part is that I am not actually using any analog outputs! The last valid output is always a little less than half of what it should be. For example, if the output signal is 1e6x1, then the last valid output scan number is 498552. Here is the code:
s = daq.createSession('ni');
Dch = addDigitalChannel(s,'Dev1','Port0/Line0','OutputOnly');
Ach = addAnalogInputChannel(s,'Dev1',0:1,'Voltage');
Ach(2).TerminalConfig = 'SingleEnded';
Ach(2).Range = [-5 5];
s.Rate = 250000/length(Ach);
ActualRate = get(s,'Rate');
L = 2; % number of seconds of each voltage pulse
TotalTime = 8; % total output signal length in seconds
n = TotalTime/L/2; % number of times to repeat a pair of pulses
tempOutputSignal = [5*ones(1,L*ActualRate) zeros(1,L*ActualRate)];
OutputSignal = repmat(tempOutputSignal,1,n)';
OTime = linspace(0,TotalTime,length(OutputSignal));
figure, plot(OTime,OutputSignal);
s.queueOutputData(OutputSignal);
duration = s.DurationInSeconds;
[data,time] = s.startForeground;
Update: I have worked on this issue through the National Instruments forum and can say with some certainty now that it is not a hardware issue, but is, in fact, an issue with the code. Please help!
  댓글 수: 2
Sarah Miller
Sarah Miller 2018년 3월 6일
Any update on this, I am getting an identical issue without and analog output. The underflow event always happen in the last second when there is just under half number of samples as the s.Rate.
cecile conrad
cecile conrad 2022년 5월 2일
@Sarah Miller / @Daniel did you figure out what the problem was? I have the same error and am not able to figure it out with the example listed below.

댓글을 달려면 로그인하십시오.

답변 (1개)

Daniel
Daniel 2018년 3월 7일
I don't remember at this point how I fixed this, but here is the code I use now that works. The only relevant difference I see is in the amplitude of the DO signal. I originally thought I needed to send a 0 to 5 V signal for what I was doing, but all the DO signal can produce is one or zero. My recollection is vague now, but this binary signal corresponds to on and off and the voltage is set by other equipment for what I'm doing at least. Hope that helps.
s = daq.createSession('ni');
AIch = addAnalogInputChannel(s,'Dev1',0:1,'Voltage');
AIch(2).TerminalConfig = 'SingleEnded';
AIch(2).Range = [-5 5];
DOch = addDigitalChannel(s,'Dev1','Port0/Line0','OutputOnly');
s.Rate = 250000/length(AIch);
ActualRate = get(s,'Rate');
L1 = 30; % number of seconds of first voltage pulse -- 51 ohms
L2 = 0; % number of seconds of second voltage pulse -- 12 ohms
TotalTime = 30; % total output signal length in seconds
n = TotalTime/(L1+L2); % number of times to repeat one period (one on/off cycle)
tempOutputSignal = [ones(1,L1*ActualRate) zeros(1,L2*ActualRate)];
OutputSignal = repmat(tempOutputSignal,1,n)';
OTime = linspace(0,TotalTime,length(OutputSignal));
figure, plot(OTime,OutputSignal);
queueOutputData(s,OutputSignal);
duration = s.DurationInSeconds;
[data,time] = s.startForeground();

카테고리

Help CenterFile Exchange에서 Periodic Waveform Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by