Acquiring Thermocouple Data Real-Time
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello,
I am trying to acquire thermocouple data (temperature), and save it to a text file while seeing the data in present time and manually stop it whenever I feel like it. I started the code, but have failed and need help.
s = daq.createSession('ni');
addAnalogInputChannel(s,'Dev2',0, 'Thermocouple');
s.Rate = 4;
tc = s.Channels(1);
set(tc);
tc.ThermocoupleType = 'K';
tc.Units = 'Kelvin';
value = input('Press 1 To Start: ');
if value == 1
s.IsContinuous = true;
else
error('Try Again')
end
lh= s.addlistener('DataAvailable',@plotData);
startBackground(s);
value = input('Press 0 To End: ');
if value == 0
stop(s);
delete(lh)
end
function plotData(src,event)
hold on
plot(event.TimeStamps, event.Data)
end
Notice that for the plotData function I placed a "hold on" in order to see the entire data for the span of time of acquisition.
Thank You!
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Data Acquisition Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!