PBritten Posted September 26, 2019 Share Posted September 26, 2019 (edited) 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 September 26, 2019 by PBritten Link to comment Share on other sites More sharing options...
0 attila Posted September 26, 2019 Share Posted September 26, 2019 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 Link to comment Share on other sites More sharing options...
0 PBritten Posted September 27, 2019 Author Share Posted September 27, 2019 Hi @attila Thanks for this, worked a treat! Best wishes Paul Link to comment Share on other sites More sharing options...
0 Kabron Posted September 15, 2022 Share Posted September 15, 2022 (edited) 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 September 15, 2022 by Kabron Link to comment Share on other sites More sharing options...
0 attila Posted September 15, 2022 Share Posted September 15, 2022 Hi @Kabron I've corrected the html special chars. Thank you for the observation. Link to comment Share on other sites More sharing options...
0 Kabron Posted September 16, 2022 Share Posted September 16, 2022 (edited) No, you did not: Quote Wavegen1.Channel1.Custom.Type.set("MyWave", wave) Edited September 16, 2022 by Kabron Link to comment Share on other sites More sharing options...
Question
PBritten
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:
Thanks for any help in advance.
Best wishes
Paul
Edited by PBrittenLink to comment
Share on other sites
5 answers to this question
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now