Jump to content
  • 0

WaveForms 2015 - averaging using buffers


Piotr Rzeszut

Question

Hi,

I am using Waveforms 2015 with Analog Discovery 2.

I cannot locate a function to average waveforms form Scope collected after subsequent triggers. In normal scope we can display average of selected numbers of waveforms.

In WaveFroms2015 data is being stored in buffers, so is there any simple method using original software (or Math channel script) to display average of selected number of buffers?

Such function is available for example in Spectrum analyser

Kind regards

Peter

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

Hello,

The WaveForms application Scope does not offer buffer averaging (yet). For similar purpose you can use the Persistence view. Averaging is supported in Spectrum Analyzer interface and in Scope FFT.

You could use the Scope Logging tool to automate averaging, like this:
i6.png

// linear average
var rgr2 = Scope.Ref2.data;
if(Index==1){
   for(var i = 0; i < rgc1.length; i++){
      rgr2[i] /= Maximum;
   }
   Scope.Ref2.data = rgr2;
   Scope.Ref1.Clone(Scope.Ref2);
   Scope.Ref2.Clone(Scope.Channel1);
}else{
   var rgc1 = Scope.Channel1.data;
   for(var i = 0; i < rgc1.length; i++){
      rgr2[i] += rgc1[i];
   }
   Scope.Ref2.data = rgr2;
}
Index++;
if(Index>=Maximum) Index = 1;
// exponential average
if(Index==1){
   // after confguration change and acquisition
   // press Reset to apply timing to Reference1
   Scope.Ref1.Clone(Scope.Channel1);
   Index = 2;
}else{
   var b1 = 1.0/Maximum;
   var b2 = 1.0-b1;
   var rgc1 = Scope.Channel1.data;
   var rgr1 = Scope.Ref1.data;
   for(var i = 0; i < rgc1.length; i++){
      rgr1[i] = b2*rgr1[i] + b1*rgc1[i];
   }
   Scope.Ref1.data = rgr1;
}

 

Link to comment
Share on other sites

I have improved your code and corrected calculations. Now it works for 2 channels, uses Ref1 and Ref2 as outputs an Ref3 and Ref4 as buffers.

// linear average
var rgr2 = Scope.Ref3.data;
if(Index==1){
   for(var i = 0; i < rgc1.length; i++){
      rgr2[i] /= Maximum-1;
   }
   Scope.Ref3.data = rgr2;
   Scope.Ref1.Clone(Scope.Ref3);
   Scope.Ref3.Clone(Scope.Channel1);
}else{
   var rgc1 = Scope.Channel1.data;
   for(var i = 0; i < rgc1.length; i++){
      rgr2[i] += rgc1[i];
   }
   Scope.Ref3.data = rgr2;
}

var rgr4 = Scope.Ref4.data;
if(Index==1){
   for(var i = 0; i < rgc2.length; i++){
      rgr4[i] /= Maximum-1;
   }
   Scope.Ref4.data = rgr4;
   Scope.Ref2.Clone(Scope.Ref4);
   Scope.Ref4.Clone(Scope.Channel2);
}else{
   var rgc2 = Scope.Channel2.data;
   for(var i = 0; i < rgc2.length; i++){
      rgr4[i] += rgc2[i];
   }
   Scope.Ref4.data = rgr4;
}

Index++;
if(Index>=Maximum) Index = 1;

 

Link to comment
Share on other sites

Thank you for the correction.

You can also use the following where Maximum is the number of acquisitions to average:

// linear average
var rgr3 = Scope.Ref3.data;
if(Index==1){
   for(var i = 0; i < rgr3.length; i++){
      rgr3[i] /= Maximum;
   }
   Scope.Ref3.data = rgr3;
   Scope.Ref1.Clone(Scope.Ref3);
   Scope.Ref3.Clone(Scope.Channel1);
}else{
   var rgc1 = Scope.Channel1.data;
   for(var i = 0; i < rgc1.length; i++){
      rgr3[i] += rgc1[i];
   }
   Scope.Ref3.data = rgr3;
}

var rgr4 = Scope.Ref4.data;
if(Index==1){
   for(var i = 0; i < rgr4.length; i++){
      rgr4[i] /= Maximum;
   }
   Scope.Ref4.data = rgr4;
   Scope.Ref2.Clone(Scope.Ref4);
   Scope.Ref4.Clone(Scope.Channel2);
}else{
   var rgc2 = Scope.Channel2.data;
   for(var i = 0; i < rgc2.length; i++){
      rgr4[i] += rgc2[i];
   }
   Scope.Ref4.data = rgr4;
}

Index++;
if(Index>Maximum) Index = 1;

 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...