Jump to content
  • 0

SDK to measure time between 2 edge events on 2 different channels


Nicolas Deup

Question

Hi,

I would like to use the SDK (python) to compute in real time the time elapsed between 2 edges events measured on 2 differents channels (eg A & B) .

If I assume that one of this event is used as a trigg for the scope/logic analyser on channel A, I would like like to get absolute time when edge occurs on channel B.

As instance, on attached file, the Channel 2 (in blue) is used as trigger.

I want to get the time elapsed from trigg to falling edge on channel A (in orange), that is 4.99 us is this exemple, but measured manually with markers.

One solution may be to perform a BIT operation in logic analyser between BUS signal0 and BUS signal1 and perform a pulse width, but I think that there's a better solution.

 

image.thumb.png.94e65ee01b086051e370a01eade81293.png

 

Thanks.

Nicolas

Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0

Hi @Nicolas Deup

You could use a global custom measurement like this to be very precise:

const thr = Scope.Trigger.Level.value;
var ch1 = Scope.Channel1;
var ch2 = Scope.Channel2;
var data1 = ch1.visibledata;
var data2 = ch2.visibledata;
var cnt = data1.length;
var i1 = 0;
for(; i1 < cnt; i1++){
    if(data1[i1]>thr) continue;
    i1 = i1-(data1[i1]-thr)/(data1[i1]-data1[i1-1]);
    break;
}
var i2 = 0;
for(; i2 < cnt; i2++){
    if(data2[i2]>thr) continue;
    i2 = i2-(data2[i2]-thr)/(data2[i2]-data2[i2-1]);
    break;
}
(i2-i1)/Scope.Time.Rate.real;

image.png

 

Other similar posts with digital data.

 

Link to comment
Share on other sites

  • 0

Hi,

Thanks a lot, it worked perfectly.

In the end, I have to store all of these computed values into a file. 

My First idea is to use the SDK and interface with Python to get theses computed values : I have no idea about the way to perform this and some support is appreciate.

My Second idea is to use the native Logging feature from WaveForms, and including the Script to execute or proposed code and get the computed values to be store into the csv: I have no idea about the way to perform this and some support is appreciate...

Thanks a lot for you support,

Nicolas

Link to comment
Share on other sites

  • 0

Thanks a lot for this answer.😀

I stil need to provide an Automated test script for this measurments (basically, start/stop).

With this solution, I can get the computed values written on the file system as expected, but I still need to

  1. open workspace (where Channels, Trigger and Measurment and Logging are configured)
  2. "click" on Run 
  3. "wait" to get N acquisition (or at last "wait" for T secondes)
  4. "click" on Stop

I am quite sure that the Python SDK is able to perform these 4 actions, but I would like to have some support.

I have been able to run and change some of the Python samples SDK. My concern are :

  • Does the SDK is able to load a workspace in order not to have to reconfigure Channels, Trigger, ... (This is something quite simple to do with the SDK, but If I can avoid this ...)
  • Does the SDK is able to lauchn the logging feature associated with the measurment script in order not to have to rewrite the JS scrip in Python

Once more, thanks for your support,

Nicolas

 

Link to comment
Share on other sites

  • 0

Hi,

Still one more requirement, how can I add in the outputs a new column which contains the aboslute time of trigger ?

If it is not possible, I want to get/provide hardware scope time elapsed between consecutive trigg/acquisition/lines. (OS time provided by JavaScript new Date may not be enough accurate).

Thanks

Link to comment
Share on other sites

  • 0

Great,

I am still facing a problem !

When trying to launch consecutive starts from the commande line with -runscript , if the previous script is not finished (still waiting in the for loop because of Scope.wait() a cap < 100 in this example, on the next call from a new command line with -runscript, the previous loop will continue...

Because of the Scope.wait() I can't set a time out, and from the help, 

image.png.d75e9d32818a26c3005189c8bf1f2bdb.png

I can cleary see a -runscript but I can't see a stop/cancel function.

Trying to kill and restart the waveforms is not the best option.

Can you please help me regarding this ?

Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...