• Content Count

  • Joined

  • Last visited

About Andras

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Andras

    Math on FFT traces

    Szia @attila, Thanks again for the excellent script, it works nearly perfectly. I noticed that when I run the script you recommended for the exponential average of difference and I keep the source Trace1 and Trace2 visible the Spectrum Analyzer, they both are shown as if they had a "Sample" type, and it make no difference if I choose any other type for them. Is this the intended behavior?
  2. Andras

    Math on FFT traces

    Hi @attila I'm playing around with the new Spectrum1.Trace3.setMagnitude(d); command and I'd need some help. I used your script and made some changes to it to generate the 3rd trace signal in the Spectrum Analyzer: plot1.X.Units.text = "Hz" = Spectrum1.Trace1.frequency plot1.Y1.Units.text = "dB" plot1.Y1.AutoScale.checked = false; plot1.Y1.Range.value = 40; plot1.Y1.Offset.value = 100; //while (true) { var t1 = Spectrum1.Trace1.magnitude var t2 = Spectrum1.Trace2.magnitude var c = t1.length var d = [] for(var i = 0; i < c; i++){ d.push(t1[i]-t2[i]-100) } = d Spectrum1.Trace3.setMagnitude(d); // Spectrum1.wait(); } I have 3 traces in the Spectrum Analyzer: Trace1 (C1, Exponential dB Average, 10) Trace2 (C2, Exponential dB Average, 100) Trace3 (Hold, Sample) The first strange thing is that when I run the Spectrum Analyzer and then I click on the Play sign next the the "Script" label at the tab's top, the script runs, but both averaging functions reset for Trace1 and Trace2. Is that the intended behavior? Also, I would like to make the script above a continuously running one (that's why I used the "do (while)" and ".wait()" methods), but I wasn't successful. Could you help me out with this? The third thing I wonder: will it be possible to run an averaging function on Trace3 (like the Exponential dB Average) if it's values are set by the Spectrum1.Trace3.setMagnitude() method? Thanks!
  3. Andras

    Logger RMS averaging with script

    @attila, that's fantastic, thank you, I really appreciate your quick work!
  4. Szia @attila! I'm using WaveForms 3.8.18 on Windows 10. I would like to chart the difference between the currently measured AC RMS compared to the average of the past x values. Is it possible to do with a script? Theoretically, if I could access the past values of the C1ACRMS from script it would be possible to calculate the average and the difference from that average. Or as another approach, can I access the current value of the "Average" column in the script? Let's say I name this script-based signal C1ACRMSDelta. I created another one for C2, and name it C2ACRMSDelta. Will I be able to create a third one using C1ACRMSDelta, C2ACRMSDelta are they accessible from script somehow? The other thing is that the "Maximum" column displays the minimum value, not the maximum. I think that's a small bug
  5. Szia @Attila! I'm trying to make the Network Analyzer and the Waveform Generator work at the same time, because I would need to generate a sine wave at a frequency and then check if that frequency is detectable by the Network Analyzer. When I start my test by first running the Waveform Generator and then I start the Network Analyzer, the Generator stops automatically. Is it intentional, is there a reason why they can't run at the same time? I use WaveForms version 3.8.15 beta. Btw, thank you for showing me the min and max functions, I didn't know they exists. I have just found them listed in the 5.6. section of the help (Help/Browse menu) and you also mention the following: "The specific objects and variables available in each of these can be found under the Insert menu Locals group." Could you help me get to the Insert/Locals menu item, I can't seem to find it anywhere Thanks!
  6. Awesome, thanks Attila!
  7. Hi, I'm working on a WaveForms script which would be able to generate chart with the frequency profile of a liquid. For this, I need to use a Wavegen and a Scope: first I need to set the generator to a certain frequency and then I'd like to check the power of that signal on the scope. Between the probes of the generator and the scope there will be the liquid I would like to test. I created a basic script to step from 1 Hz to 150 Hz, check that signal with the scope, repeat this loop 5 times, and calculate the min, max and average values at each frequency. Although the script works, I have a few questions: * I couldn't find any documentation about the Scope.Channelx.fftmagnitude and fftfrequency arrays. Where should I look for them? Are there any other properties related to the FFT configuration? * Is there a way to set the number of BINs and samples of the scope's FFT? * Can I somehow use the Goertzel algorithm instead of FFT? (The Görtzel algorithm is designed to tell us the power of a signal at one predefined frequency. I would need this to get the power for the exact Hz value I define, and not the closest one I have from the FFT like I do it now. * Is there a way to change the color/style of the charts? Here is the script itself, but bear in mind that it is just the very first version const hzmax = 150; // the maximum frequency to measure const csamples = 5; // the number of samples to measure for each frequency const cdatapoints = 150; // chart X-axis resolution (currently: 1 datapoint / 1 Hz) var datapoints = new Array(4); // datapoint array datapoints[0] = new Array(cdatapoints); // max datapoints[1] = new Array(cdatapoints); // avg datapoints[2] = new Array(cdatapoints); // min datapoints[3] = new Array(cdatapoints * csamples); // raw data // clear the raw data array for(var j = 0; j < cdatapoints * csamples; j++) { datapoints[3][j] = 0; } // generate the freqeuncies to measure var frequencies = new Array(cdatapoints); for(var j = 0; j < cdatapoints; j++) { frequencies[j] = j+1; } { // configure plot plot1.X.Units.text = "Hz"; plot1.X.Offset.value = -hzmax/2 plot1.X.Range.value = hzmax; plot1.Y1.AutoScale.checked = false; plot1.Y2.AutoScale.checked = false; plot1.Y3.AutoScale.checked = false; plot1.Y4.AutoScale.checked = false; const vmax = 1.00; const vmin = 0.98; var offset = -(vmin + (vmax - vmin)/2); var range = (vmax - vmin); plot1.Y1.Offset.value = offset; plot1.Y2.Offset.value = offset; plot1.Y3.Offset.value = offset; plot1.Y4.Offset.value = offset; plot1.Y1.Range.value = range; plot1.Y2.Range.value = range; plot1.Y3.Range.value = range; plot1.Y4.Range.value = range; } { // configure wavegen Wavegen1.Channel1.Mode.text = "Simple"; Wavegen1.Channel1.Simple.Type.text = "Sine"; } { // configure scope Scope1.BufferSize.value = 1; Scope1.Buffer.value = 1; Scope1.Time.Mode.text = "Shift"; Scope1.Channel1.checked = true; Scope1.Channel2.checked = false; }; for (var n=0; n<csamples; n++) { Scope1.Time.Samples.value = 1024; for (var i=0; i<hzmax; i++) { // change the frequency to the next one var frequency = frequencies[i]; Wavegen1.Channel1.Simple.Frequency.text = frequency; Scope1.Time.Rate.value = frequency * 256; print("Frequency: ",frequency," Hz | Running @ ",Scope1.Time.Rate.value," Hz | ", Scope1.Time.Samples.value," samples"); // take a single sample Scope1.single(); Scope1.wait(); // check out the FFT values var rgmag = Scope1.Channel1.fftmagnitude; var rghz = Scope1.Channel1.fftfrequency; var c = rgmag.length; var minHzDistance = frequency; // check all the FFT values, and get the one closest to our inspected frequency for(var j = 0; j < c; j++) { var hz = rghz[j] var hzDistance = frequency - hz; if (hzDistance < 0) { hzDistance = -hzDistance; } if (hzDistance <= minHzDistance) { minHzDistance = hzDistance; datapoints[3][i*csamples + n] = rgmag[j]; } } // calculate the min, max, avg values var rgmin = 1000.0; var rgavg = 0.0; var rgmax = 0.0; var validsamples = 0; for(var j = 0; j < csamples; j++) { currentsample = datapoints[3][i*csamples + j]; if (currentsample != 0) { if (currentsample < rgmin) { rgmin = currentsample; } if (currentsample > rgmax) { rgmax = currentsample; } rgavg += currentsample; validsamples++; } } rgavg /= validsamples; print("Min:",rgmin," V | Avg:",rgavg," V | Max:",rgmax," V | error: +/-",minHzDistance," Hz"); print(); // save the calculated data into their arrays datapoints[0][i] = rgmax; datapoints[1][i] = rgavg; datapoints[2][i] = rgmin; // check if the error if too high if (minHzDistance > 0.5) { Scope1.Time.Samples.value *= 2; i--; } // plot the most recent values on the chart = datapoints[0]; // max = datapoints[1]; // avg = datapoints[2]; // min } }
  8. Szia Attila! Perfect, thanks a lot for the quick and wonderful reply!
  9. Hi, I'm an absolute beginner with WaveForms, I've just started to play around with it last week. I think it's brilliant, there are only a few questions I'd like to ask. 1, When I use the Spectrum's FFT or CZT and I set the stop frequency to something low (like 200 Hz) and the sample to something high (like 8.192k) the response rate of the chart will get very slow (it takes 20 seconds to refresh). My guess is that Analog Discovery 2 has to fill its buffer fully before sending it for the FFT/CZT and since the sample rate is 400 Hz only it takes a lot of time. If I understand it correctly I would need a big buffer if I wanted to measure the very low frequency regions (at least 400 samples for 1 Hz, 800 samples for 0.5 Hz, etc.) so I would prefer to not lower the sample count. On the other hand a higher refresh rate would be nice. Could you add the option to use a FIFO buffer for FFT/CZT, where a small number of samples of the recently captured values would be frequently added to the buffer that is used for the FFT/CZT, so the FFT/CZT would be always highly responsive independently from the buffer size/score rate? 2, I'm trying to visually show the changes of a signal using the Spectrum with 3 different exponential dB average traces on the same channel with 5, 100 and 1000 weights. It looks alright, but since I can't set the opacity level of the different trances they overlap each other. As a small feature request, could you add opacity option to the color setting dialog? 3, Do I understand it correctly that if I wanted to measure the cumulative power of a certain frequency region (like the theta, alpha, beta, gamma brainwaves) I need to write a script to do the math and plot the values? Is it possible to create a continuously updating chart which shows the different measurements over time this way? Thank you, Andras