Data acquisition during a period with triggers
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I programm the following code:
duradaTotal = 10 %ara poso 10 segons
durationTrigger = 0.5 %durada de cada trigger (temps d'aquisició).
ai = analoginput('winsound',0);
chan1 = addchannel(ai,1); %esquerra
chan2 = addchannel(ai,2); %dret
Fs = 44100;
set(ai,'SampleRate',Fs) %Defineixo el Rang de Mostreig el valor d'Fs.
ActualRate = get(ai, 'SampleRate'); %llegeixo quin Freqüència de mostreig tinc
set(ai, 'Timeout', 15 )
set(ai,'SamplesPerTrigger',ActualRate*durationTrigger);
set(ai,'TriggerChannel', chan1);
set(ai,'TriggerType', 'Immediate');
set(ai, 'TriggerConditionValue', 0.2);
set(ai, 'TriggerRepeat', inf);
tic;
tStop = 0
%començo la lectura
start(ai)
while tStop < duradaTotal
tStop=toc
wait (ai,duradaTotal+1 )
end
[data, time] = getdata(ai); %agafo totes les dades que tinc del tots els triggers
if tStop > duradaTotal
stop (ai);
end
remsamp = num2str(ai.SamplesAvailable); %num2str converteix els números en string
ai.TriggersExecuted %pinta tots els triggers que han saltata i quan
showdaqevents(ai) %pinta tots els triggers que han saltata i quan
%pinta per la Command Window el contingut de remsamp
disp(['Number of samples remaining in engine: ', remsamp])
%time=[0:tStop];
subplot 211;
plot(time,data);
drawnow
xlabel ('Time (s)')
ylabel ('Signal Level (volts)')
title ('Signal')
zoom
datacursormode on
hold on
I want to listen my analog channel during period of time (for initialize I put 10 seconds), and I want that when a trigger ocurrs, the system save this data during 0.5sec. Therefore I put the TriggerType as 'Immediate' and the TriggerRepeat as Inf.
How much time have I wait?
Other problem I have, is the data saved, because I program:
[data, time] = getdata(ai);
But only shows on plot the first period of data, and I want all the period.. (with all the triggers if there are more than one trigger occurred)
Thanks,
Roser
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Data Acquisition Toolbox Supported Hardware en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!