how to detect egde on trigger signal
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to get waveform data by connecting Tektronix Oscilloscope with PC. So far I can read the waveform data points. Problem is I want to collect data points at right time (when trigger signal goes low). Is there some MATLAB function that monitors the trigger signal and detects when it is high/low so that I can do the following
while i< N if Trigger_signal_is_low w1=getwaveform(myscope); end
end
I can get data points for one time trigger signal and perform required action but I have to capture 2000 signals (each time when trigger occurs). I believe interrupt handling will achieve the purpose but how to link an interrupt to trigger signal?
1 comentario
Melwin Thomas
el 8 de Ag. de 2018
Hi Ayle,
Did you find a solution for this. If so, can you please let me know?
Thank you.
Respuestas (1)
Chaitral Date
el 9 de Mayo de 2017
Editada: Chaitral Date
el 9 de Mayo de 2017
Interrupt handling can be done in MATLAB using events and listeners. Refer to the few links given below for the reference,
https://www.mathworks.com/help/matlab/matlab_oop/learning-to-use-events-and-listeners.html
https://www.mathworks.com/help/matlab/matlab_oop/events-and-listeners--concepts.html
Also, please refer to the below simple example which can give you an idea about how you can implement events and listeners,
classdef Test < handle
properties
prop = 0;
end
events
overflow;
end
methods
function setprop(obj,value)
obj.prop = value;
if (obj.prop>5)
notify(obj,'overflow');
end
end
end
end
function testD(eventsrc,eventdata)
disp('The value of prop is overflowing');
end
The class 'Test' has an event 'overflow' which gets triggered when 'obj.prop>5'. Function "notify" is used to trigger the event. Function 'testD' is used to print the given message. Next, we will add a listener to the above event so that whenever the prop is greater than 5, it will print the message from function "testD". Here is the way how you can trigger the listener function,
>> A=Test;
>> addlistener(A,'overflow',@testD);
>> A.setprop(20);
As you can see, function "addlistener" is used to create an event listener.Whenever prop is greater than 5, the callback function 'testD' will get executed.
You can implement your code using similar manner. Please make a note that only handle classes can define events and listeners.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!