Transmission Line Topology Calculation (TransNetCalc)

Description

Transmission Line Topology Calculation

 

Documentation

User Guide

Integration with TCL

FAQ

Getting Started

Source Forge Download


CCDSP

CCDSP Tech Blog

Radio Calc Site


IIPPlot Java Plotting

 

Introduction

The TCL interpreter has been integrated into TransNetCalc providing for very powerful capabilities in the design and tuning of transmission line networks. Iterations can be setup to optimize designs or optimization algorithms can be run in TCL scripts that manipulate the transmission line network parameters such as lengths, transmission line type parameters and topology.

Example Double Stub Tuner

Network Topology

n1 n2 n3
n3 n4 n5
n2
n4
n5
end
n1 coax1 30
n2 coax1 1.76 0 0
n3 coax1 2.5
n4 coax1 6.6 0 0
n5 R100_L0.0000015915 0 open

The coaxial transmission line coax1 has characteristic impeance of 50 Ohms.

VSWR Results

 

 

 

In addition to the TCL commands that directly interact with the transmission line topology and nodes, vector commands for both real and complex vectors and complex scalar commands have been added to TCL. These are documented below.

Two sample scripts are provided. The first script calculates the variation of VSWR versus the length of a stub in a double stub tuner. The second example script calculates the variation of VSW with frequency around the tuned frequency.

TCL Scripts
VSWR vs Length of Stub VSWR vs Frequency

TCL Commands
Vector Commands Transmission Line Network Commands Complex Scalar Commands

TCL Commands for Vector Operations

Command Syntax Description
vec ?vector? [list ...] Create a real vector with the TCL List command. Example, vec [list 11 22 33 44 55]
cxvec ?vector? [list a+bi c+di ...] Create a complex vector with the TCL list command. Example, cxvec [list 1+2i 3+4i 5+6i]
vpr format [filename] [-nolen or -twocol] Print vector (complex or Real) or complex scalar to terminal or store in file. Format must be specified. As simple e or f or like 14.2f just as in C formatting. For real vector can specify if vector length stored (to avoid use -nolen at end of command). For complex vectors specify -twocol at end of command to store as two columns with no length. Otherwise store as complex a+bi.
vrd ?vector? fileName Read an ASCII real vector from a file given by fileName. The first line in the file must be the vector length.
vcxrd ?vector? fileName Read an ASCII complex vector from a file given by fileName. The first line in the file must be the vector length. The complex values are in the format: a+bi
vset $Vector $value $index Set the element index within the Vector to value
vget $Vector $index ?value? Get the value at index from the Vector . Store in value
vcr ?vector? $length [$std $seed] Create a real vector of length,$ length. If std and seed provided populate with Normal distribution. Otherwise fill with zeroes.
vcxcr ?vector? $length [$std $seed] Create a complex vector of length,$ length. If std and seed provided populate with Normal distribution. Otherwise fill with zeroes.
vdot $x $y ?z? Calculate the dot product of two vectors. Both vectors must be real or complex but not mixed.
vcxset $Vector $value $index Set the element index within the Vector to complex scalar value
vcxget $Vector $i ?value? Get the value at index from the Vector . Store in complex scalar value
vfft $Vector ?complexVector? Compute forward FFT of real vector. Store in complex vector.
vifft $Vector ?resultReal? Compute inverse FFT of complex vector. Result is real FFT. Complex vector must be symmetric with imaginary of Nyquist term zero.
saxpy $y $x $alpha # y= alpha x + y , alpha scalar Compute y=alpha*x+y where alpha is a scalar. Both complex and real supported but not mixed. y is replaced.
vconv $x $f $y # vectors either all complex or all real Compute y= convolution of x with f. Note vectors must exist before hand. Result is stored in y. Both Real and Complex supported.
   

 

Complex Scalar Commands
Command Syntax Description
cx $re $im ?z? Create complex scalar from double real and imaginary parts.
cxpolar $m $angle ?z? Create complex scalar from double magnitude and angle(degrees)
cxmult $x $y ?z? Multiply two complex scalars
cxadd $x $y ?z? Add two complex scalars
cxsub $x $y ?z? Subtract two complex scalars
cxdiv $x $y ?z? # z=x/y Divide two complex scalars
cxexp $x ?z? Exponentiate complex scalar
cxtanh $x ?z? (exp(x) - exp(-x))/(exp(x) + exp(-x))
cxsqrt $x ?z? Convert to polar, take the square root of the magnitude and halve theta, then convert back to rectangular and store in complex scalar
cxgetpolar $x ?mag? ?angle? Convert complex scalar to polar. Angle in degrees.
cxget $x ?re? ?im? Get the double real and imaginary parts from complex scalar
cxconj $x Conjugate complex scalar and replace
cxcopy $x ?z? Create a duplicate of complex scalar
cxinv $x ?z? Compute inverse of complex scalar. z=1/x
   



Transmission Line and Topology Commands
Command Syntax Description
tload $fileName ?top? Load the transmission line topology from ASCII file and store in TCL variable "top"
tcalc $root $frequency $gen $genImp [?totalImpedance? ?totalCurrent?] Calculate the current, impedances, characteristic impedance, propagation constant and loads for all nodes in the topology for the given frequency with source voltage and impedance specified. Optionally store the total current and impedance as seen from the source into TCL variables as complex scalars.
tpr $root [$fileName] Display the loaded topology or store in a file.
ninfo $root $nodeName Display the calculated values and info at a given node for topology $root previously loaded.
nz0gamma $root $nodeName ?z0? ?gamma? Store characteristic impedance and propagation constant as complex scalars for nodeName in topology $root.
nvalues $root $nodeName /variables automatically generated/ Get all the variables for a node and automatically store in TCL variables. The node name is prepended to all variable. So the left impedance is nodeName_zl etc. The node type, Unary, Binary, Leaf is stored in nodeName_type. The left and right currents are il and ir. zo and gamma are also returned. For Unary zl and il are returned.
ngetlength $root $nodeName ?length? Get the length of a node
ngetrlcg $root $nodeName ?r? ?l? ?c? ?g? Get the rlcg parameters for a node
ngettypeprm $root $nodeName ?p1? ?p2? ?p3? ?p4? Get the parameters for the transmission line type for a node p1,p2,p3,p4 (same as rlcg)
nsetlength $root $nodeName $length Set the length of a node .
nsetrlcg $root $nodeName $r $l $c $g Set the rlcg parameters for a node
nsettypeprm $root $nodeName $p1 $p2 $p3 $p4 Set the transmission line parameters for a node (p1,p2,p3,p4)
rflc $z $z0 ?rc? Compute the complex scalar reflection coefficient given the impedance z and characteristic impedance z0.
vswr $rflc ?vswr? Compute double VSWR from complex scalar reflection coefficient.
zpar $x $y ?z? Compute impedance of two parallel impedances
nimp $topologyFileName $nodeName $zs $fmin $fmax $points ?imResp? [ ?zinput? ?fresp? ] Compute impulse response of transmission line network from topology file. Can compute over a frequency band. Points is better to be power of two (it will be truncated to power of two). Frequency response and input impedance optionally returned as complex vectors. Impulse response returned in real vector.
ncurrlength $topology $nodeName $points ?voltage? For the loaded topology (from previous tload command) compute the voltage distribution along a segment of transmission line for nodeName. Specify the number of points. Use tcalc command before this command.
   
   

 

 

TransmissionLineTopCalc TCL Code for Varying Length of Stub n2 in Double Stub Tuner

TCL Script Links
Double Stub Tuner VSWR Results

 

TCL Script VSWR vs Length

# Transmission Line Topology Calculation and Analysis (TransmissionLineTopCalc)
# Command Tool Scripts
# Copyright (C) 2006 Sasan H Ardalan
#
# This script is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# http://www.ccdsp.org
#
#

#
# This is a double stub tuner. At node n1 we have a match.
# node n2 is the second stub near the generator
# At 10MHz the network is matched.
#
# in the following script we change the length of the stub n2
# by +- 10% around the length where a match is achieved.
# 100 points are calculated.
# results are stored as follows.
# The complex input impedance is stored in a complex vector
# It is stored in a filex as complex numbers (a+bi)
# The VSWR and Length are stored in a list.
# This list is later stored in a file as two columns
#

#
# load the transmission line topology file "t.top"
#

tload t.top T
#print the topology
tpr $T
# set the complex generator and generator source impedance
cx 1.0 0.0 g
cx 50.0 0. zs
#calculate all nodes at 10MHz and store the impedances, z0, gamma,
# and current for each node
tcalc $T 1e7 $g $zs timp tcur
#print total input impedance and current (complex scalars)
vpr $timp
vpr $tcur
# get the length of the stub n2
ngetlength $T n2 n4len
#calculate +-10% and dlength
set lenBegin [ expr $n4len -0.1*$n4len]
set lenEnd [ expr $n4len + 0.1*$n4len ]
set dlen [expr ($lenEnd-$lenBegin)/100.0 ]
#create complex and real vectors to store results (much more efficient than lists)
vcxcr zvlen 100
vcr zmag 100
# get z0 and gamma (propagation constant) to use in VSWR calculation
nz0gamma $T n1 z0 gamma
# initialize list to store results (in addition to storing in vectors)
set results [list {}]

puts "Iterating over length"

for { set i 0 } { $i<100 } {incr i} {


set len [expr $lenBegin +$i*$dlen ]
#change the length of the stub
nsetlength $T n2 $len
#recalculate the network for new length
tcalc $T 1e7 $g $zs
# store all the computed values for node n1 (left right impedance, current )
# the variables are automatically created
nvalues $T n1
# compute total inpedance at node n1 (variables $n1_zl and
# $n1_zr were automatically created in the previous command)
zpar $n1_zl $n1_zr zt
vpr $zt
#store the input impedance at n1 in the complex vector $zvlen (z versus length)
vcxset $zvlen $zt $i
#get the magnitude of the impedance
cxgetpolar $zt zmagval theta

#compute reflection coefficient
rflc $zt $z0 rflc_n1
#compute vswr
vswr $rflc_n1 vswr_n1
#store in real vector
vset $zmag $zmagval $i


#store vswr in list with length
lappend results [list $len $vswr_n1 ]


}

#print resulst of input impedance
vpr $zvlen 14.6f zin_vs_len.dat -twocol

#
# create a file to store the vswr vs length
#
puts "Storing results in vswr.dat"
set out [ open vswr.dat w ]

# puts $out [ llength $results ]
#puts -nonewline $out "#Length"
#puts -nonewline $out "\t"
#puts $out "MagZin"

foreach value $results {


puts -nonewline $out [lindex $value 0]
puts -nonewline $out "\t"
puts $out [lindex $value 1]


}
close $out

VSWR versus Frequency TCL Script

# Transmission Line Topology Calculation and Analysis (TransmissionLineTopCalc) Command Tool Scripts
# Copyright (C) 2006 Sasan H Ardalan
#
# This script is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# http://www.ccdsp.org
#
#
#

#
# This is a double stub tuner. At node n1 we have a match.
# node n2 is the second stub near the generator
# At 10MHz the network is matched.
#
# in the following script we change the frequency of the stub n2
# by +- 10% around the frequency where a match is achieved.
# 100 points are calculated.
# results are stored as follows.
# The VSWR and freq are stored in a list.
# This list is later stored in a file as two columns
#

#
# load the transmission line topology file "t.top"
#

tload t.top T
#print the topology
tpr $T
# set the complex generator and generator source impedance
cx 1.0 0.0 g
cx 50.0 0. zs
set freq 1e7
#calculate +-10% of tuned frequency 10MHz
set fBegin [ expr $freq -0.1*$freq]
set fEnd [ expr $freq + 0.1*$freq ]
set df [expr ($fEnd-$fBegin)/100.0 ]

# initialize list to store results (in addition to storing in vectors)
set results [list {}]

puts "Iterating over length"


for { set i 0 } { $i<100 } {incr i} {


set f [expr $fBegin +$i*$df ]
#recalculate the network for new frequency
tcalc $T $f $g $zs
# get z0 and gamma (propagation constant) to use in VSWR calculation
nz0gamma $T n1 z0 gamma

# store all the computed values for node n1 (left right impedance, current )
# the variables are automatically created
nvalues $T n1
# compute total inpedance at node n1 (variables $n1_zl and $n1_zr were automatically created in the previous command)
zpar $n1_zl $n1_zr zt

#compute reflection coefficient
rflc $zt $z0 rflc_n1
#compute vswr
vswr $rflc_n1 vswr_n1

#store vswr in list with freq
set fMHz [expr $f*1e-6]
lappend results [list $fMHz $vswr_n1 ]


}

#
# create a file to store the vswr vs length
#
puts "Storing results in vswr_tune.dat"
set out [ open vswr_tune.dat w ]


foreach value $results {


puts -nonewline $out [lindex $value 0]
puts -nonewline $out "\t"
puts $out [lindex $value 1]

}

close $out

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


© 2007-2017 Silicon DSP Corporation