Acquire Data and Generate Signals at the Same Time for usb 6008

1 回表示 (過去 30 日間)
mado
mado 2014 年 3 月 11 日
編集済み: Walter Roberson 2014 年 3 月 24 日
i used this code to aquire and write signals in usb 6008 simultaneously but message error appeared . how to solve that?
% The hardware associated with this session is reserved. If you are using it in another
session use the release function to unreserve the hardware. If you are using it in an
external program exit that program. Then try this operation again.
% % Initialization
%%get connected devices d = daq.getDevices %create session s = daq.createSession('ni')
%add analog channel s.addAnalogInputChannel('ID',channel num, 'measurement type')
s.addAnalogInputChannel('Dev1','ai0', 'Voltage')%irradiance
s.addAnalogInputChannel('Dev1','ai1', 'Voltage')%Temperature
s.addAnalogOutputChannel('Dev1', 'ao0', 'Voltage')
% set rate of scan 1000 scans/second , run for 30 seconds
s.Rate=100;
duration = s.DurationInSeconds
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 = 3.5;
s.outputSingleScan(ao_value)
s.startBackground() s.wait()
delete (lh)
delete (h)

回答 (2 件)

Walter Roberson
Walter Roberson 2014 年 3 月 11 日
The device is already in use. If you are using it in another MATLAB session, then either use release() in that session or terminate the session. If the device is being used by another program outside of MATLAB, then end that program. If there is nothing you can find that is using the device then reboot your computer and try again.
  3 件のコメント
Walter Roberson
Walter Roberson 2014 年 3 月 11 日
編集済み: Walter Roberson 2014 年 3 月 11 日
I don't see any obvious problem with the code. I would not normally add two listeners for the same event but I guess you could.
When you post error messages please post the exact text including the traceback showing the sequence of calls and the relevant line of code -- everything generated by the error.
Why are you not queuing anything for output?
mado
mado 2014 年 3 月 12 日
編集済み: Walter Roberson 2014 年 3 月 24 日
ao_value = 3.5;
s.outputSingleScan(ao_value)%
this is my line to send output (3.5) is there any other method ?
i rebooted but another error came in " he session contains channels that do not support clocked operations using startForeground and startBackground." i created two sessions and it is working it can read and write .
%%Initialization
%
global Temperature
global Irradiance
global Vref
global data
%
%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','ai0', 'Voltage')%irradiance
s.addAnalogInputChannel('Dev1','ai2', 'Voltage')%Temperature
s1.addAnalogOutputChannel('Dev1', 'ao0', 'Voltage')
% set rate of scan 1000 scans/second , run for 30 seconds
s.Rate=100;
duration = s.DurationInSeconds
%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 = 4;
s1.outputSingleScan(ao_value)
s.startBackground()
s.wait()
delete (lh)
delete (h)

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


mado
mado 2014 年 3 月 15 日
when i used queue output data error come in "
% queueOutputData is disabled because the session contains channels that do not support
clocked operations

カテゴリ

Help Center および File ExchangeDigital Input and Output についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by