Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Minor corrections


The NI AWR Design Environment comes with a complete COM Application Program Interface (API) that can be accessed programmatically through any language or system that can use COM APIs.   The AWRDE also contains a Scripting Development Environment to allow you to develop your automation tasks.  The application engineers at AWR frequency frequently use the SDE to build custom solutions to customer problems.  Many such solutions have wide-spread applications.  The NI AWRDE software includes these scripts, and they are available from the Scripts menu in software.  This guide will walk you through the basics of the API and the SDE. The guide includes:


Creating a Filter Simulation

The This section will cover coding a script to create the same circuit as in the linear chapter of the Microwave Office getting started guide. In general, this will work through the various steps of generating the filter.   Each step will be a function or subroutine in the Sub Main.  The guide will show you how to change the Sub Main and then just the code to implement that function or subroutine.   This organization will make showing the code changes at each step simpler.   


Now, if you run this code, a new schematic is added. 

The code adds anew a new schematic and opens a new blank schematic window.    


Next, we need to build the schematics schematic by adding elements, wires, ports and ground nodes.  


Code Block
Option Explicit
' Code Module
Sub Main
	Dim sch As Schematic


	Set sch = CreateSchematic



End Sub

Then type or add the frequency changing code for setting element parameter values after the sub main subroutine.  A few things to notice.   

  1. We reference the elements by the element name, a dot, and then the element ID.   
  2. We set the values in base units, such as Hz, Henry'sHenrys, Farads, etc. because each project could have different project units, but the code will still work just fine.  The schematic display converts to the proper units.  

Code Block
Sub SetValues(s As Schematic)
	'sets the parameter values of the elements to be non-default
	'values as double will always be in base units (Farads, Henries, etc)
	s.Elements("IND.L1").Parameters("L").ValueAsDouble = 15e-9
	s.Elements("IND.L2").Parameters("L").ValueAsDouble = 30e-9
	s.Elements("IND.L3").Parameters("L").ValueAsDouble = 30e-9
	s.Elements("IND.L4").Parameters("L").ValueAsDouble = 15e-9
	s.Elements("CAP.C1").Parameters("C").ValueAsDouble = 8e-12
	s.Elements("CAP.C2").Parameters("C").ValueAsDouble = 10e-12
	s.Elements("CAP.C3").Parameters("C").ValueAsDouble = 8e-12

End Sub

After When you run the script after this point, you will see this schematic in a window that is maximized and centered around the elements with new parameter values.   


Code Block
Sub SetFrequencies
	Dim freqs() As Double
	Dim fstart,fstop,fstep As Double
	Dim num,cnt,i As Integer

	fstart = 100
	fstop = 1000
	fstep = 10
	num = (fstop-fstart)/fstep
	ReDim freqs(num)
	cnt = 0
	For i = 100fstart To 1000fstop Step 10fstep
		freqs(cnt) = i * 1e6 'enter in base units, Hz.
		cnt = cnt + 1
	Next i
End Sub


  1. The auto-complete will help you get the right setting for the graph type.   
  2. We pass in the schematic so we can get the schematic name as the first argument (i.e. the SourceDoc) for the measurement.   
  3. The measurements have a specific syntax.  An easy way to get this is to add the measurement to a project and then use a script to retrieve the measurement syntax.