Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

how to output multiple scan in usb6008 with matlab

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.

 

0 Kudos
Message 1 of 6
(5,353 Views)
Please note that matlab programming is not supported here. The place you want to use is the matlab forum.
0 Kudos
Message 2 of 6
(5,342 Views)

ok, i just want to know if that is avaiable to send multiple output values in this daq?

0 Kudos
Message 3 of 6
(5,337 Views)
I don't know what 'that' is. As you can see from the specs, the analog output is software timed and you have to write one point at a time in a loop and cannot specify timing.
0 Kudos
Message 4 of 6
(5,335 Views)

what do you mean by "the analog output is software timed and you have to write one point at a time in a loop and cannot specify timing."  i tried to output single value and it works but when i tried to put a variable it gives error however the variable have different value every scan .

also i found this link  http://forums.ni.com/t5/Multifunction-DAQ/How-to-output-a-sine-with-usb-6008-on-MATLAB/m-p/1510508#M...and i think it is close to my question but i don't understand it and how to make use of

0 Kudos
Message 5 of 6
(5,331 Views)

Hey sfhj,

 

Dennis is referring to the device only supporting software timed inputs/outputs and not hardware timed. This is listed in the NI USB-6008 specs here. With regards to the errors you're receiving, unfortunately they are specific to The MathWorks, Inc. MATLAB ® software and the Data Acquisition Toolbox, not the NI USB-6008. Therefore, you'll need to troubleshoot this from the MATLAB side and your best bet for assistance will be on the MATLAB forums. It looks like others on those forums have seen this error before, this for example, but I'd recommend posting a new thread to those forums to seek assistance.

 

Hope this helps!

 

--Ryan_S

 

MATLAB is a Registered Trademark of The MathWorks, Inc.

0 Kudos
Message 6 of 6
(5,286 Views)