how to output multiple scan in usb6008 with matlab

2 visualizzazioni (ultimi 30 giorni)
mado
mado il 23 Mar 2014
Risposto: Walter Roberson il 24 Mar 2014
hi
i need your help to use ni usb6008 to output analog signal , the analog signal is the control signal from PID controller i used this code
% Initialization
global Temperature
global Irradiance
global current
global Vref
global data
global u
%%get connected devices
d = daq.getDevices
%create session
s = daq.createSession('ni')
s1= daq.createSession('ni')
%add analog channel s.addAnalogInputChannel('ID',channel num, 'measurement type')
% s.addAnalogInputChannel('Dev1',0:3, 'Voltage')%irradiance
s.addAnalogInputChannel('Dev1','ai0', 'Voltage')%irradiance
s.addAnalogInputChannel('Dev1','ai1', 'Voltage')%Temperature
% s.addAnalogInputChannel('Dev1','ai3', 'Voltage')%Temperature
s1.addAnalogOutputChannel('Dev1', 'ao0', 'Voltage')
% set rate of scan 1000 scans/second , run for 30 seconds
s.Rate=1000;
s.DurationInSeconds =10
v.TerminalConfig = ' Differential';
%v.TerminalConfig = ' SingleEnded';
%_____________________________
%aquire data and process
lh = s.addlistener('DataAvailable', @plotData);
%store data
%h = s.addlistener('DataAvailable', @storedata)% Analog Output
ao_value = u % duty cycle control signal
s1.outputSingleScan(ao_value)
s.startBackground()
s.wait()
delete (lh)
delete (h)
s.release()
but an error message appeared "The data argument must contain one column for each output channel in the session.
i also can't use queue output data
ao_value = u % duty cycle control signal
s.queueOutputData (( ao_value)');
it gives me error that "There must be at least one analog output channel in the session before outputSingleScan or queueOutputData can be used.

Risposte (1)

Walter Roberson
Walter Roberson il 24 Mar 2014
When you use
global u
then "u" is initialized to [] unless you have already initialized it. The empty array [] does not contain at least one column and so cannot be used as a value for outputSingleScan

Categorie

Scopri di più su Analog Input and Output in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by