Jump to content
  • 0

Scope custom math channel limitations?


P. Fiery

Question

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

Hi Attila,

Well I'm relieved to know I wasn't just confused. I have version 3.7.5 64 bit. I see the current version is 3.10.9. I'll install this.

On a wider subject but still about the AD2: It's just right to form the hardware and software base upon which to construct a demonstration of a novel device for a client. The application consists of the following steps:

0) Generate a particular pulse signal using Wavegen, and synchronized with the completion of this pulse, do the following:

1) acquire a full buffer, (16K) of 14 bit samples. (sample rate about 15 MHz).

2) read this into an array.

3) upsample the array contents using a suitable order of FIR interpolation. (custom DSP unless it's a stock function)

4) perform a custom heuristic analysis of the larger array.  (dump outliers, perform some array operations, etc. Probably all custom code.) 

5) repeat steps 0 to 4 and average the results to hone resolution and accuracy. 

6) Be able to "probe" intermediate results at least during development by displaying them in a waveform window.

7) The whole thing ends up producing two simple numbers that tell a particular truth about the object of the process. Display those numbers using a large font.

My question is, what documents would you direct me to reference to be able to modify the waveforms app - or build a smaller custom GUI to do only what I want - using the AD2? Can I do all this with the Waveforms SDK?  I had a look at your labview stuff. It seems too big and complex a hammer for this task. 

 

Link to comment
Share on other sites

Hi @P. Fiery

You could use the View/Logging/Script to create an up-sampled reference channel like this:
image.thumb.png.eee073982b9e14fd49e52c09521e1511.png

var rg = []
var v2 = 0
Scope.Channel1.data.forEach(function(v1){
    rg.push((v1+v2)/2)
    rg.push(v1)
    v2 = v1
})
// upsampling by 2 doubles the sample rate
Scope.Ref1.setData(rg, 2*Scope.Time.Rate.value)

 

Link to comment
Share on other sites

Thank you very much. Great stuff, so many ways to do things with this tool. I think the logger is limited to a top sample rate of 1 MHz. My signal is ~ 2MHz, and I need to get some sub-nyquist detail so the results aren't mathematical fiction. But I get the idea. It looks like I can do the job entirely with scripting - except perhaps for the very last step.

So, last 2 questions before I dive in:

1) the oversampling feature of the scope: Oversampling can mean different things. It should mean that when the sample rate is lower than the maximum sample rate several samples are taken in real time and averaged to produce the sample that is sent to the buffer. This can increase the effective precision beyond the 14 bits of each individual sample.  However, it seems that with the scope I can set the sample rate to say 50 MHz and yet oversample by a factor of 16. With a max sample rate of 100MHz, this shouldn't be possible. So, exactly what does your scope oversampling actually do?

2) Everything I want to do appears to be possible with only scripting within ghe WaveForms app - except presenting the output. It's just a couple of numbers, but I'd like them to be seen across a room. Seems like this qualifies as a "custom gui" and would therefore require I use the SDK. Or can I send a couple of numbers to a file, (that could be read and displayed as I want by another process)?

image.png.edd99a9fac07f1a59d74fa83d20a989d.png

Link to comment
Share on other sites

Hi @P. Fiery

1. The oversampling (equivalent time sampling) makes sens to use with 100MHz. I have enabled it for lower frequencies for testing, to be able to veify the upsampling method.

2. WaveForms SDK give more freedom but requires more work. In the application it is easier to test such algorithms.
You could use the Tool.getNumber/Integer/Text... functions for input in the Script interface. See the Help tab in the application for more info.

image.thumb.png.c6b886a257e080d863208704e678290d.png

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...