• 1
rebekka

Save continous data to file in WaveForms

Question

I'm using WaveForms (and Javascript) for the first time. My problem is really simple; I measure a voltage signal with the Analog Discovery 2, and want to get a "long" file with data over several seconds. When using the record-function and exporting data, I only get 1000.000 data points with the frequency required, and I can't seem to figure out how to save the raw data in the script. 

If anyone can help this rookie, I'll be very grateful! 

I think I'll need a whole new script, but it looks like this right now:

ch = Scope.Channel1

var newfile = File("~/Desktop/scope/measure.csv")

if(!nyfil.exist()){

var AllData = Date()+","+ch.data+"

nyfil.appendLine(AllData)

Index++

 

Share this post


Link to post
Share on other sites

9 answers to this question

Recommended Posts

  • 1

Hi @alxcpa01101

You can use the WaveForms application Scope instrument to record up to 10M samples at rate up to about 1MHz.

image.png.92c157db73164c91e1f5141f66499fc8.png

 

The data can be exported with File/Export or View/Logging

In the Script tool you can use the Export function (since WF v3.7.22), like Scope1.Export("myfile.csv")
From the application Help:
Instrument#.Export(szFile, szView = "", fComments = true, fHeader = true, fLabel = true, fHeaderAsComment = false, szNotes = "")
exports a view or instrument data or screenshot to the given file. The file format is identified based on file name extension, like: csv, txt, tdms, bmp, png. For view name expects like: Acquisition, XY1, FFT; Wavegen: Channel1; without name the instrument is saved. The comment, header and labels boolean arguments enable or disable saving such information.

image.png.ae5ad0d5c63fa3a0e96841f0d32468a9.png

 

To capture more data you can use the WaveForms SDK. See example at:
C:\Program Files (x86)\Digilent\WaveFormsSDK\samples\py\ 
AnalogIn_Record.py 
AnalogIn_Record_int16.py 
AnalogIn_Record_Trigger.py 

Share this post


Link to post
Share on other sites
  • 0

Hi @rebekka

How many samples are you recording? The default setting is 1M.

The ch.data() returns the visible samples with the current time position and base options. Use ch.alldata() to get all the acquired samples.

Share this post


Link to post
Share on other sites
  • 0

I'm having the same issue and I'm not really seeing an answer here.  I would like to save the continuous scope data to a .csv file with a script.  I am currently just waiting the time of a full acquisition, but I am having issues where in between acquisitions there may be a small discontinuity.

while(1)

{

my_file.append(Scope1.Channel1.data);

wait(5);

}

Is there a better way to do this?

Share this post


Link to post
Share on other sites
  • 0

Not sure how I missed the 'record' functionality, that should do the trick, thanks!  I am little confused about the functionality of wait() in your sample code.  Is wait() returning a boolean in your for loop (i < 10 && wait())?  Also in the Scope1.wait() I thought this is blocking until you stop the acquisition or does it just block until each individual acquisition completes?

Edited by alxcpa01101

Share this post


Link to post
Share on other sites
  • 0

Hi @alxcpa01101

The wait(sec=0) function returns true when the specified time expires (default 0 seconds) and returns false when the Stop button was pressed.
Pressing Stop the wait() returns false and loop breaks. Otherwise continues for up to 10 records.

Yes. The Scope1.wait() blocks the script execution until the acquisition completes.

See the application Help for further information.

Share this post


Link to post
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