Acquiring Thermocouple Data Real-Time
Afficher commentaires plus anciens
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 commentaire
Walter Roberson
le 27 Juin 2019
Try adding a marker to the plot
Réponses (0)
Catégories
En savoir plus sur Counter and Timer Input and Output dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!