kazu Posted September 25, 2020 Share Posted September 25, 2020 Hi, I need help to use the script in "WaveForms". I don't know much about Javascript, but I need to measure the time from the change point on channel 1 to the change point on channel 2. Please let me know if anyone has a reference script. Link to comment Share on other sites More sharing options...
attila Posted September 25, 2020 Share Posted September 25, 2020 Hi @kazu You could use Phase measurement or FFT phase for sine/periodic signals. The following script looks for value on channel 2 which at least as high as the value in the middle of channel 1 var rg2 = Scope.Channel2.data var c = rg2.length var c2 = c/2 var v1 = Scope.Channel1.data[c2] print("Voltage:", v1) for(var i = c2; i < c; i++){ if(rg2[i]<v1) continue print("Time:",(i-c2)/Scope.Time.Rate.value) break } Link to comment Share on other sites More sharing options...
kazu Posted September 28, 2020 Author Share Posted September 28, 2020 On 9/25/2020 at 6:43 PM, attila said: Hi @kazu You could use Phase measurement or FFT phase for sine/periodic signals. The following script looks for value on channel 2 which at least as high as the value in the middle of channel 1 var rg2 = Scope.Channel2.data var c = rg2.length var c2 = c/2 var v1 = Scope.Channel1.data[c2] print("Voltage:", v1) for(var i = c2; i < c; i++){ if(rg2[i]<v1) continue print("Time:",(i-c2)/Scope.Time.Rate.value) break } Thank you for the sample script. Sorry for the lack of explanation. The waveform I'm assuming will look like an attachment. With my knowledge of Java script, I can't get the Ch1-Ch2 time from the sample you taught me. Please let me know if you have a good sample. Thank you Regards. Link to comment Share on other sites More sharing options...
attila Posted September 28, 2020 Share Posted September 28, 2020 Hi @kazu function dt(){ var rg1 = Scope.Channel1.visibledata var rg2 = Scope.Channel2.visibledata var c = rg1.length var i1 = 0 for(var i = 0; i < c; i++){ if(i1==0){ // Ch1 below 1.5V if(rg1[i]<1.5) i1 = i }else if(rg2[i]>1.5){ // Ch2 above 1.5V return (i-i1)/Scope.Time.Rate.value } } return -1 } const ctest = 300 var nssum = 0, nsmin = 1e9, nsmax = 0 Scope.run() for(var i = 0; i < ctest && Scope.wait(); i++) { var ns = dt()*1e9 if(ns<0) throw "Error" nssum += ns nsmin = min(nsmin, ns) nsmax = max(nsmax, ns) } Scope.stop() print("Average:", nssum/ctest, "ns") print("Min:", nsmin, "ns") print("Max:", nsmax, "ns") Link to comment Share on other sites More sharing options...
Question
kazu
Hi, I need help to use the script in "WaveForms".
I don't know much about Javascript, but I need to measure the time from the change point on channel 1 to the change point on channel 2.
Please let me know if anyone has a reference script.
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.