Where To Find This Script
AWR Version 12
For version 12.00, Download
Starting in version 12.01, you can run this script by clicking on Scripts->Data->Generate_IVD from AWRDE menu.
AWR Version 11
Description
The AWRDE does not currenlty have an output file type for IV curve data. This script will convert simulated IV data into an IV curve data file (IVD format) and load the file into the project. After you run the script you will pick which IVCurve measurement on a graph that you want to convert:
And it will create an IVD data file and load the data into the project with the name "IVD_Data" as shown below.
Scripting Information
Scripts included in the install are configured to run directly from the NI AWR Design Environment from the Scripts menu.
Scripts that you download must be imported into a project or placed in your global scripts folder to use them. See Working with VB Scripts for information on how to use these scripts.
You can also customize the AWRDE to run scripts from hotkeys, menus, or toolbar buttons. See Working with VB Scripts for more information.
For complete information about the AWRDE API, see the AWRDE API Programming Guide Help in the AWRDE installation. You can also view our Scripting Website for more scripting examples.
Code
' Code Module Sub Main Dim data() As Double Dim Stepv() As Double Dim sweepv() As Double Dim grp As Graph Dim meas As Measurement Dim sch As Schematic Dim ele As Element Dim grpnames() As String cnt = 0 ReDim grpnames(cnt) For Each grp In Project.Graphs For Each meas In grp.Measurements 'Debug.Print meas.Name tks = Split(meas.Name,":") If tks(1) = "IVCurve()" Then grpnames(cnt) = meas.Name cnt = cnt +1 ReDim Preserve grpnames(cnt) End If Next meas Next grp Begin Dialog UserDialog 400,161,"Select IV Measurement to choose from" ' %GRID:10,7,1,1 ListBox 40,35,310,63,grpnames(),.lstdataBox,1 Text 40,21,160,14,"Select Measurement File",.Text1 OKButton 150,119,100,28 End Dialog Dim dlg5 As UserDialog Dialog dlg5 e=0 For Each grp In Project.Graphs For Each meas In grp.Measurements If meas.Name = grpnames(dlg5.lstdataBox) Then e = 1 Exit For End If Next meas If e = 1 Then Exit For End If Next grp 'Set grp = Project.Graphs("IV Curves_IVMeter") 'Set meas = grp.Measurements(1) 'fill in sweep variables num_sweep = meas.XPointCount ReDim sweepv(num_sweep) For i = 1 To num_sweep sweepv(i) = meas.XValue(i) Next i 'sweepv = meas.XValues num_step = meas.YDataDim ReDim Stepv(num_step) 'Stepv = meas.YValue 'don't know how to get the step parameters from graph, get from schematic. nm = meas.Name nm2 = Split(nm,":") nm = nm2(0) Set sch = Project.Schematics(nm) Set ele = sch.Elements("IVCURVEI.IV1") 'here have to type in name of meter. may have to search for it. For i = 1 To num_step Stepv(i) = ele.Parameters(5).ValueAsDouble+(i-1)*ele.Parameters(7).ValueAsDouble Next i 'now get data ReDim data(UBound(Stepv),UBound(sweepv)) For i = 1 To UBound(Stepv) For j = 1 To UBound(sweepv) data(i,j) = meas.YValue(j,i) Next j Next i 'writes out IVD file and loads into the project. tmpname$=Project.Path + "__awr_interp.txt" Open tmpname$ For Output As #2 Print #2,UBound(sweepv) Print #2,UBound(Stepv) For i = 1 To UBound(Stepv) Print #2, Stepv(i);" "; Next i Print #2 For i = 1 To UBound(sweepv) Print #2,sweepv(i);" "; For j=1 To UBound(Stepv) If data(j,i) <> -1000 Then Print #2,Format(data(j,i),"0.0000e+00");" ";'scale to amps End If Next j Print #2 Next i Close #2 Dim df As DataFile 'new_name = Join(Array(fname$,"interp"),"_") Set df = Project.DataFiles.Add("IVD_DATA",tmpname$,True,mwDFT_IV) Kill tmpname$ ' End Sub