I just signed up, so first let me say hello. I've been using the Analog Discovery 2 for a while now and I must say, this is one of the best values available in its category. I seldom power up my Tektronix now. I turn to that only when I need more than two analog channels and/or faster sampling and higher bandwidth. What a great product!
Okay, now to the question:
I want to create a custom math channel that will climb a waveform looking for the highest sample value, (the peak). The output of this should hold each highest value encountered in C1 until a higher value is encountered.
I tried:
var yy = 0;
if(C1>yy) {
yy = C1 }
return yy
Seems reasonable, but when run I see the entire script is evaluated for every sample. Therefore yy is set to zero every time. The resulting math channel simply tracks the positive half of each waveform.
I'd like to declare the variable yy and zero it at the start of each sweep of C1 data collection, not at every point of C1.
The result of the above script is the same as simply writing "max(C1,Time )", which is the first thing I tried. What use is a "max" function that doesn't return the maximum of an array passed to it in the argument? I must be missing something. Maybe there is a way to cause a function to evaluate across the time argument rather than at each point?
Please set me straight here. How does one accomplish this simple thing in this environment?
Also, the commonly used functions you can click on to copy into the script editor: Is there a description somewhere of the arguments these functions require in the parenthesis? For example, the max( , ) function, what are the arguments? In Javascript there is a max method, which isn't the same thing.
Question
P. Fiery
Hello,
I just signed up, so first let me say hello. I've been using the Analog Discovery 2 for a while now and I must say, this is one of the best values available in its category. I seldom power up my Tektronix now. I turn to that only when I need more than two analog channels and/or faster sampling and higher bandwidth. What a great product!
Okay, now to the question:
I want to create a custom math channel that will climb a waveform looking for the highest sample value, (the peak). The output of this should hold each highest value encountered in C1 until a higher value is encountered.
I tried:
var yy = 0;
if(C1>yy) {
yy = C1 }
return yy
Seems reasonable, but when run I see the entire script is evaluated for every sample. Therefore yy is set to zero every time. The resulting math channel simply tracks the positive half of each waveform.
I'd like to declare the variable yy and zero it at the start of each sweep of C1 data collection, not at every point of C1.
The result of the above script is the same as simply writing "max(C1,Time )", which is the first thing I tried. What use is a "max" function that doesn't return the maximum of an array passed to it in the argument? I must be missing something. Maybe there is a way to cause a function to evaluate across the time argument rather than at each point?
Please set me straight here. How does one accomplish this simple thing in this environment?
Also, the commonly used functions you can click on to copy into the script editor: Is there a description somewhere of the arguments these functions require in the parenthesis? For example, the max( , ) function, what are the arguments? In Javascript there is a max method, which isn't the same thing.
P. Fiery
Link to comment
Share on other sites
6 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.