Generate Continuous Analog Output Using NI Card
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Eddy H
am 15 Jan. 2016
Kommentiert: Walter Roberson
am 15 Jan. 2016
Hello,
I am trying to generate continuous analog output using an NI card (NI USB-6343). The frequency of the analog output will be updated based on an algorithm and other input data. However, I am struggling with a more basic step and for now, I would just like to generate a continuous voltage signal using data called from a function (queueMoreData.m). My code:
daq.reset
daq.HardwareInfo.getInstance('DisableReferenceClockSynchronization',true); % This is to overcome a different issue
d = daq.getDevices;
s = daq.createSession('ni');
ch = addAnalogOutputChannel(s,'Dev1','ao0','Voltage');
lh = addlistener(s, 'DataRequired', @queueMoreData);
s.IsContinuous = true;
queueOutputData(s,linspace(-1, 1, 1000)');
startBackground(s);
Which calls the function queueMoreData.m
function queueMoreData(src,event)
queueOutputData(s, linspace(-1, 1, 1000)');
end
This is based on this tutorial: http://uk.mathworks.com/help/daq/generate-analog-output-signals.html#btxscoj-1
But I get the following error:
_Warning: Error occurred while executing callback: Undefined function or variable 's'.
Error in queueMoreData (line 3) queueOutputData(s,linspace(-1, 1, 1000)');
Error in daq.internal.BaseClass/notify (line 91) obj.notify@handle(varargin{:});_
Etc Etc Etc
Any help would be very much appreciated!
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 15 Jan. 2016
In your callback change the reference from s to src
2 Kommentare
Walter Roberson
am 15 Jan. 2016
If you go to the bottom right of the documentation page and click on the button to say that it did not help you then you can describe the mistake and the report will be sent to an appropriate person.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu National Instruments Frame Grabbers finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!