Jump to content
  • 0

A quick question about running scripts in WaveForm3.0


Charlie

Question

Hello,

I am new to the Analog Discovery and WaveForm software, so this might be a "silly" question. I did try to run some scripts in WaveForm3,0 (The latest version). Right now, I am just running the example code coming with the tool. It is shown in the following, it gave errors, like Can't find variable: Wavegen1, etc. I believe I have to add a library which includes all the definitions of this variables, but I didn't find them. Can anyone help with me and show me how to get codes like this to run successfully? Thanks so much!

function main(){

if(!('Wavegen1' in this) || !('Scope1' in this)) {

throw("Please open a Scope and a Wavegen instrument");

}

Wavegen1.run();

for(var idx = 0; wait(1) && idx < 10; idx++){

Scope1.single();

if(!Scope1.wait()){

return;

}

var average = 0;

var data = Scope1.Channel1.data;

data.forEach(function(sample){average += sample;})

average /= data.length;

print(idx+" Average: "+average+" V");

}

}

main();

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Hello,

The Scripting tool allows automating/ customizing the other instruments by providing access to adjust the configuration of these, control them and acquire data.

The default examples needs a Scope and a Wavegen instrument.
This starts the Wavegen, performs 10 Scope acquisitions, calculates and prints the average of channel 1. 

You can also perform further data processing, data logging, adjusting the Wavegen offset based on some Scope measurements...

You might find some earlier posts in this topic, like:

 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...