Acquiring Thermocouple Data Real-Time
Show older comments
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!
1 Comment
Walter Roberson
on 27 Jun 2019
Try adding a marker to the plot
Answers (0)
Categories
Find more on Counter and Timer Input and Output in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!