Jump to content
  • 0

Analog Discovery 2 || Java Script


RajatDas

Question

Hi,

Is there any java script commands/program to access the network analyzer of AD2, where I can sweep the frequency and save the Magnitude and phase response of the DUT ? This sweep should run in a continuous mode. I want to plot them and save them as a csv file. Kindly help.

Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0

Hi I have written the sudo code as well as the corresponding Java script, kindly guide me.

###  FOR LOOP 100 times

#To start Network Analyzer
#Start Freqeucy = 100KHz
#Stop Frequency = 1MHz
#Steps = 1k
#Source = Wavegen Ch1
#Voltage = 2V
#Offset = 0V
#Scale = Linear
#Wavegen Settle value = 200ms
#Reference Channel 1 (gain X)
#Get Channel1 attenuation value
#Get Channel2 attenuation value
# Get Channel2 Magnitude responce in gain(x)
# Get Channel2 phase response
# save the data

### END
#Stop Network Analyzer

 


for (var i = 0; i < 1000 ; i ++){
Network.Frequency.Start.value=100e100
Network.Frequency.Samples.value=1k
Network.Wavegen.Channel.text=1
Network.Wavegen.Amplitude.value=2
Network.Wavegen.Offset.value=2
Network.Wavegen.Settle.value=200 (in ms)
Network.Channel1.Range.values = 1
Ch1Att = Network.Channel1.Attenuation.value
Ch1Att = Network.Channel2.Attenuation.value
Ch2Mag = Network.Channel2.magnitude
Ch2Phase = Network.Channel2.phase
}

Link to comment
Share on other sites

  • 0

clear()
if(!('Network' in this)) throw "Open the Network Analyzer instrument";

var nScan = 10
var Mag = []
var Phase = []
Network.run()
Network.Frequency.Start.value = 100000
Network.Frequency.Stop.value = 1000000
Network.Frequency.Samples.value = 500
Network.Wavegen.Amplitude.value = 1
Network.Wavegen.Channel.text = "WaveGen1"
Network.Wavegen.Settle.value = 0.04
Network.Channel1.Range.values = 3
Network.Channel1.SampleMode.text = "Constant"

for(var iScan = 0; iScan < nScan; iScan++){
    print(iScan+1)
    if(!Network.wait()) throw "Stopped";
    Mag = Network.Channel2.magnitude
    Phase = Network.Channel2.phase
}

Network.stop()

Not able to control the source, Mode, Scale ?

With respect to the GUI there is a checkbox called Magnitude, how to get control on that ? I want to check the "Relative to Ref" and Units in gain (X).

image.thumb.png.b413a4ab347fc7e83d6b6cb472b9fc0b.png

Screenshot from 2023-06-06 12-50-44.png

Link to comment
Share on other sites

  • 0

Ok. Thanks @attila. So when I am saving Java script project, it is generating a .dwf3script file. Is it possible somehow I can run this script from the Ubuntu terminal so that the script input parameters can be directly fetched by the GUI and the output is saved as csv or text file ?

Edited by RajatDas
explanation
Link to comment
Share on other sites

  • 0

Really thanks a lot @attila for your prompt support and help. Just on more question, I have a Java script file which simple set some parameters of the Network analyser and collect magnitude response data and save it to a CSV file. It does not do any further calculation. This javascript file is saved. So when I want to run this javascript file to collect the Network analyser data is it mandatory that Network GUI window needs to be opened for visualization? Or simple by running the javascript I can collect the data ?

 

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...