Jump to content
  • 0

Displaying and exporting scope measurements like Frequency in Scope


Sim_on112

Question

Hi,

I want to record some step responses of the RPM of an engine in WaveForms. The RPM sensor provides a sine signal, the frequency of this signal represents the RPM. So my intention was to visualize and record (around 5-10 minutes) this frequency and additionally my step signal, which is a 0-5V signal.

The second one is no problem, but I can't find a solution for displaying and exporting the frequency over time. I need the data in one file in CSV format, with a sampling rate of 1kHz or at least 100 Hz.

I am using the AD2.

I tried some ways so far, one was a custom script, but I had some issues with the sampling time, because it was not constant. I guess this is because of the "Scope.State.running()" method, but I'm not sure. Is there also another way for the time of the measurements? In this script I used Date(), but in fact, the sample time in ms would be enough.

It would be nice if someone has a solution about this topic!

grafik.png.929ce850dfed589b1981a9fb3eee1e0b.pnggrafik.png.929ce850dfed589b1981a9fb3eee1e0b.png

Edited by Sim_on112
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hi @Sim_on112

It can be done in multiple ways but the easier probably is to perform a record and process the capture.
The frequency measurement is relatively slow. Due to this processing larger number of samples (100M) could take hours.

Capture + Spectrogram and 3D to show alternative options:

image.png

image.png

var rga = [];
var rgf = [];
var step = 0.01; // sec
var start = Scope.Time.Position.real - Scope.Time.Base.real/2;
var stop = Scope.Time.Position.real + Scope.Time.Base.real/2;
Scope.Time.Base.value = step;
print(start,stop,step);
var file = File("~/Desktop/test.csv")
file.writeLine("Time,Amplitude,Frequency");
print("processing:", new Date())
for(var i = start; i < stop && wait(); i+=step){ // wait to be able to stop it
    Scope.Time.Position.value = i;
    var a = Scope.Channel1.measure("Peak2Peak");
    var f = Scope.Channel1.measure("Frequency");
    rga.push(a);
    rgf.push(f);
    file.appendLine([i,a,f]);
}
print("done:", new Date());
plot1.X.Offset.value = Scope.Time.Position.real; 
plot1.X.Range.value = Scope.Time.Base.real;
plot1.Y1.data = rga;
plot1.Y2.data = rgf;
// just to revert time settings
Scope.Time.Position.value = Scope.Time.Position.real; 
Scope.Time.Base.value = Scope.Time.Base.real;

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...