Jump to content
  • 0

AD2 & Waveforms Script Question


PBritten

Question

Hi Guys,

I'm new to the AD2 & Waveforms, and in the need of some help. I'm trying to import a csv file into a custom wavegen and then output it.

 

Here is my code:

if(!('Wavegen1' in this)||!('Scope1' in this))throw"Please open a Scope and a Wavegen instrument";

var filename = "/Users/PaulBritten/Documents/AFWorkMain/AFWork/Waveform/single_qrst_improved_twave_1khz.csv";
var file = File(filename);
print("exists? " + file.exists());
var arr = file.readArray();
print(arr);

Wavegen1.Channel1.Mode.text = "Custom";
Wavegen1.Channel1.Custom.Type.set("MyWave", arr);
Wavegen1.Channel1.Custom.Type.add(arr);
Wavegen1.Channel1.Custom.Offset.value = 0;
Wavegen1.Channel1.Custom.Frequency.value = 1;
Wavegen1.Channel1.Custom.Amplitude.value = 1;
Scope1.Trigger.Trigger.text = "Repeated";
Wavegen1.run();
Scope1.run();

Can anyone explain to me why I'm getting this error:

Quote

TypeError: Result of expression 'Wavegen1.Channel1.Custom.Type.set' [undefined] is not a function.

 

Thanks for any help in advance.

 

Best wishes

Paul

Edited by PBritten
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hi @PBritten

The custom waveforms in Wavegen are stored in a the .Custom container to be able to reuse them in multiple Channels and different modes.

Wavegen1.Custom.set("MyWave", arr)
Wavegen1.Channel1.Custom.Type.text = "MyWave"

Related posts:
https://forum.digilentinc.com/search/?q=wavegen custom script&type=forums_topic&nodes=8

 

image.png.acb1da799feaff4482f494070f69df5f.png

image.thumb.png.a6ddc2c48f5904ab62ccaf0d84c079d6.png

 

Link to comment
Share on other sites

  • 0

I guess that corresponding part of example should be corrected in Waveforms Help, because now it looks like ravings of a madman🙂

Quote

The following code creates a custom waveform and sets it to be further used.

wave = Array()
for(var i = 0; i   wave.push(0)
  wave.push(i/10)
}

And on this page also:

https://digilent.com/reference/software/waveforms/waveforms-3/reference-manual?redirect=1#code

Edited by Kabron
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...