This document reads best when displayed in a mono-spaced font ¥-¥-¥-¥ STACK: NetCalc ¥-¥-¥-¥ ¥-¥-¥-¥ STACK SCRIPT: ¥-¥-¥-¥ °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° An RF Impedance Calculator Copyright © 2001-2002 by Harry Whitfield, G6AUC. All Rights Reserved. Broadly based on NETCALC - an RF Impedance Calculator by Ian White, G3SEK. The concepts and command names follow NETCALC, but the coding and design of this HyperCard stack are entirely new. This stack can also display impedances on a diagram similar to the well-known Smith Chart. AddColor XCMD ©1994-1998 Apple Computer, Inc. All Rights Reserved. The L-section code is based on a PERL program by Claude Frantz °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° -- -- Functions to perform complex arithmetic ---------------------------- -- -- -- A complex quantity z = r+jx is stored as a string "r,x" -- -- e.g. 50.23 + j5.04 is stored as "50.23,5.04" -- -- e.g. put "50.23,5.04" into z -- -- or put 50.23 into r -- put 5.04 into x -- put r & "," & x into z -- product of z1 and scalar s function smul s,z1 put item 1 of z1 into r1 put item 2 of z1 into x1 return (s*r1) & "," & (s*x1) end smul -- quotient of z1 and scalar s function sdiv s,z1 global INFINITY, UNDEFINED if (s = 0) then if modsqr(z1) = 0 then return UNDEFINED return INFINITY end if put item 1 of z1 into r1 put item 2 of z1 into x1 return (r1/s) & "," & (x1/s) end sdiv -- conjugate of z1 function conj z1 return (item 1 of z1) & "," & (-(item 2 of z1)) end conj -- square of the modulus of z1 function modsqr z1 put item 1 of z1 into r1 put item 2 of z1 into x1 return (r1*r1 + x1*x1) end modsqr -- modulus of z1 function modulus z1 put item 1 of z1 into r1 put item 2 of z1 into x1 return sqrt(r1*r1 + x1*x1) end modulus -- argument of z1 function arg z1 -- result in -¹ < arg <= ¹ global UNDEFINED put item 1 of z1 into r1 put item 2 of z1 into x1 if r1 = 0 then if x1 = 0 then return UNDEFINED if x1 > 0 then return pi/2 return -pi/2 end if if r1 > 0 then return atan(x1/r1) if x1 >= 0 then return atan(x1/r1) + pi return atan(x1/r1) - pi end arg -- sum of z1 and z2 function cadd z1,z2 return (item 1 of z1 + item 1 of z2) & "," & (item 2 of z1 + item 2 of z2) end cadd -- difference of z1 and z2 function csub z1,z2 return (item 1 of z1 - item 1 of z2) & "," & (item 2 of z1 - item 2 of z2) end csub -- product of z1 and z2 function cmul z1,z2 put item 1 of z1 into r1 put item 2 of z1 into x1 put item 1 of z2 into r2 put item 2 of z2 into x2 return (r1*r2 - x1*x2) & "," & (r1*x2 + r2*x1) end cmul -- quotient of z1 and z2 function cdiv z1,z2 global INFINITY, UNDEFINED put modsqr(z2) into ms if (ms = 0) then if modsqr(z1) = 0 then return UNDEFINED return INFINITY end if put conj(z2) into z return smul(1/ms,cmul(z1,z)) end cdiv -- -- Functions to perform electrical network calculations --------------- -- -- equivalent impedance of z1 in parallel with z2 function par z1,z2 global INFINITY if (modsqr(z1) = 0) or (modsqr(z2) = 0) then return "0,0" put cadd(z1,z2) into z if modsqr(z) = 0 then return INFINITY return cdiv(cmul(z1,z2),z) end par -- impedance z1 expressed in parallel form "R,X" such that z1 = "R,0" || "0,X" function Parform z1 put item 1 of z1 into r1 put item 2 of z1 into x1 put (r1*r1 + x1*x1) into ms if (ms = 0) then return "0,0" return ms/r1 & "," & ms/x1 end Parform -- impedance z1 expressed in parallel form "R || X" such that z1 = "R,0" || "0,X" function Pform z1 put item 1 of z1 into r1 put item 2 of z1 into x1 put (r1*r1 + x1*x1) into ms if (ms = 0) then return "0 || 0" return ms/r1 && "||" && ms/x1 end Pform -- -- Functions to perform transmission line calculations ---------------- -- -- Reflection Coefficient rho = ((Z1/Z0) - 1) / ((Z1/Z0) + 1) function rho Z1,Z0 put cdiv(Z1,Z0) into z put "1,0" into unity return cdiv(csub(z,unity),cadd(z,unity)) end rho -- Voltage Standing Wave Ratio VSWR = (1 + |rho|) / (1 - |rho|) function VSWR rho put modulus(rho) into r return (1+r)/(1-r) end VSWR -- Return Loss = -20*log(|rho|) dB = -10*log(|rho|^2) dB function ReturnLoss rho return -10*log(modsqr(rho)) end ReturnLoss -- log to the base 10 in terms of log to the base e function log x return ln(x)/ln(10) end log -- input impedance of a lossless transmission line of characteristic impedance Z0 -- and length x wavelengths which is terminated in a load impedance Z1 function Zin Z1,Z0,x put cos(2*pi*x) & ",0" into C put "0," & sin(2*pi*x) into S put cdiv(Z1,Z0) into Z return cmul(Z0,cdiv(cadd(cmul(Z,C),S),cadd(C,cmul(S,Z)))) end Zin -- length of transmission line of characteristic impedance Z0 having -- the same reactance at frequency f as the impedance Z1. -- v is the speed of transmission in the line = speed of light * velocity factor. function equivLength Z1,Z0,f,v put cdiv(Z1,Z0) into Z put atan(item 2 of Z) into x if x < 0 then add pi to x return x*v/(2*pi*f) end equivLength -- -- AddColor XCMD ©1994-1998 Apple Computer, Inc. All Rights Reserved. - -- on openCard Send colorMe to this card pass openCard end openCard on closeCard lock screen pass closeCard end closeCard on colorMe AddColor colorCard,stamp,0 end colorMe on openStack global INFINITY, UNDEFINED, OLDLEVEL AddColor install put the userlevel into OLDLEVEL set the userlevel to 5 put "1000000000000,1000000000000" into INFINITY put "NAN,NAN" into UNDEFINED put "About NetCalc..." into menuitem 1 of menu "Apple" pass openStack end openStack on closeStack global OLDLEVEL AddColor remove set the userlevel to OLDLEVEL put "About HyperCard..." into menuitem 1 of menu "Apple" pass closeStack end closeStack on resumeStack put "About NetCalc..." into menuitem 1 of menu "Apple" pass resumeStack end resumeStack on suspendStack put "About HyperCard..." into menuitem 1 of menu "Apple" pass suspendStack end suspendStack ----------------------------------------------------------------------- on toggleCardSize full -- toggle between a full and small view of the card window put the rect of the card window into windowRect if full then -- set width of card window to 544 put item 1 of windowRect + 544 into item 3 of windowRect -- set height of card window to 544 put item 2 of windowRect + 544 into item 4 of windowRect else -- set width of card window to 544 put item 1 of windowRect + 544 into item 3 of windowRect -- set height of card window to 342 put item 2 of windowRect + 342 into item 4 of windowRect end if set the rect of the card window to windowRect end toggleCardSize ----------------------------------------------------------------------- on doMenu menuItem if menuItem = "background" then --beep pass doMenu else pass doMenu end if end doMenu ----------------------------------------------------------------------- ¥-¥-¥-¥ BACKGROUND SCRIPT: NetCalc ¥-¥-¥-¥ on update global UNDEFINED put Pform(fld "X") into fld "P" put cdiv(fld "X",fld "Z0") into fld "N" get rho(fld "X",fld "Z0") put it into rh put modulus(it) into fld "R" put arg(it) into theta if theta <> UNDEFINED then put " @ " & 180*theta/pi & "¼" after fld "R" else put " @ UNDEFINED¼" after fld "R" end if put "VSWR=" & VSWR(rh) && "RL=" & ReturnLoss(rh) & "dB" into fld "Z" end update on copyToClip x lock screen show menubar put x into fld "CopyContents" show fld "CopyContents" select text of fld "CopyContents" doMenu "Copy Text" hide fld "CopyContents" play "Click" end copyToClip function Frequency return (value(fld "Freq")) * 10^(fld "FMultiplier") end frequency function Velocity return (value(fld "Velocity")) end Velocity function Resistance return (value(fld "Resistance")) * 10^(fld "RMultiplier") end Resistance function Inductance return (value(fld "Inductance")) * 10^(fld "LMultiplier") end Inductance function Reactance return (value(fld "Reactance")) * 10^(fld "XMultiplier") end Reactance function Capacitance return (value(fld "Capacitance")) * 10^(fld "CMultiplier") end Capacitance function prefix v put abs(v) into x if x >=1000000 then return "M" if x >=1000 then return "k" if x >= 1 then return empty if x >= 0.001 then return "m" if x >= 0.000001 then return "µ" if x >= 0.000000001 then return "n" return "p" end prefix function multiplier v put abs(v) into x if x >=1000000 then return 0.000001 if x >=1000 then return 0.001 if x >= 1 then return 1.0 if x >= 0.001 then return 1000 if x >= 0.000001 then return 1000000 if x >= 0.000000001 then return 1000000000 return 1000000000000 end multiplier on openCard toggleCardSize false if fld "Freq" is empty then put 1 into fld "Freq" put 0 into fld "FMultiplier" select line 1 of bg btn "FMenu" end if if fld "Z0" is empty then put "50,0" into fld "Z0" end if if fld "Velocity" is empty then put 1 into fld "Velocity" end if if fld "X" is empty then put "0,0" into fld "X" put "0,0" into fld "Y" update end if if fld "Factor" is empty then put 1 into fld "Factor" end if if fld "Length" is empty then put 0.5 into fld "Length" end if if fld "Resistance" is empty then put 0 into fld "Resistance" put 0 into fld "Rmultiplier" select line 1 of bg btn "Rmenu" end if if fld "Inductance" is empty then put 0 into fld "Inductance" put -6 into fld "Lmultiplier" select line 3 of bg btn "Lmenu" end if if fld "Reactance" is empty then put 0 into fld "Reactance" put 0 into fld "Xmultiplier" select line 1 of bg btn "Xmenu" end if if fld "Capacitance" is empty then put 0 into fld "Capacitance" put -12 into fld "Cmultiplier" select line 1 of bg btn "Cmenu" end if pass OpenCard end openCard ¥-¥-¥-¥ BACKGROUND BUTTON SCRIPTS ¥-¥-¥-¥ ¥-¥-¥-¥ BUTTON: bkgnd button "|X|" on mouseWithin Inflate "text", "|X| button" & return & return & Â "Puts the modulus of X into Z.","left bottom" end mouseWithin on mouseUp put modulus(fld "X") into fld "Z" end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "XL" on mouseWithin Inflate "text", "Series Inductance button" & return & return & Â "Pushes impedance of resistor R in series with inductor L onto the stack.","left bottom" end mouseWithin on mouseUp put fld "X" into fld "Y" put Resistance() & "," & 2*pi*Frequency()*Inductance() into fld "X" update end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "XX" on mouseWithin Inflate "text", "Series Reactance button" & return & return & Â "Pushes impedance of resistor R in series with reactance X (to the right) onto the stack.","left bottom" end mouseWithin on mouseUp put fld "X" into fld "Y" put Resistance() & "," & Reactance() into fld "X" update end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "XC" on mouseWithin Inflate "text", "Series Capacitance button" & return & return & Â "Pushes impedance of resistor R in series with capacitor C onto the stack.","left bottom" end mouseWithin on mouseUp put fld "X" into fld "Y" put Resistance() & "," & -1/(2*pi*Frequency()*Capacitance()) into fld "X" update end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "XLP" on mouseWithin Inflate "text", "Parallel Inductance button" & return & return & Â "Pushes impedance of resistor R in parallel with inductor L onto the stack.","left bottom" end mouseWithin on mouseUp put fld "X" into fld "Y" put Resistance() & ",0" into RR put "0," & 2*pi*Frequency()*Inductance() into XX put par(RR,XX) into fld "X" update end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "XXP" on mouseWithin Inflate "text", "Parallel Reactance button" & return & return & Â "Pushes impedance of resistor R in parallel with reactance X (to the right) onto the stack.","left bottom" end mouseWithin on mouseUp put fld "X" into fld "Y" put Resistance() & ",0" into RR put "0," & Reactance() into XX put par(RR,XX) into fld "X" update end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "XCP" on mouseWithin Inflate "text", "Parallel Capacitance button" & return & return & Â "Pushes impedance of resistor R in parallel with capacitor C onto the stack.","left bottom" end mouseWithin on mouseUp put fld "X" into fld "Y" put Resistance() & ",0" into RR put "0," & -1/(2*pi*Frequency()*Capacitance()) into XX put par(RR,XX) into fld "X" update end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "Parallel" on mouseWithin Inflate "text", "Parallel button" & return & return & Â "Puts the impedance of X in parallel with Y into X and clears Y.","left bottom" end mouseWithin on mouseUp put par(fld "X", fld "Y") into fld "X" put "0,0" into fld "Y" update end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "Series" on mouseWithin Inflate "text", "Series button" & return & return & Â "Puts the impedance of X in series with Y into X and clears Y.","left bottom" end mouseWithin on mouseUp put cadd(fld "X", fld "Y") into fld "X" put "0,0" into fld "Y" update end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "C" on mouseWithin Inflate "text", "Clear stack button" & return & return & Â "Pops one element off the stack. (Copies Y to X and clears Y.)","left bottom" end mouseWithin on mouseUp put fld "Y" into fld "X" put "0,0" into fld "Y" update end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "J" on mouseWithin Inflate "text", "Conjugate button" & return & return & Â "Puts the conjugate of X into X.","left bottom" end mouseWithin on mouseUp put conj(fld "X") into fld "X" update end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "Q" on mouseWithin Inflate "text", "Display Q Factor button" & return & return & Â "Displays Q(X) in Z.","left bottom" end mouseWithin on mouseUp put "Q=" & abs((item 2 of fld "X") / (item 1 of fld "X")) into fld "Z" end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "X" on mouseWithin Inflate "text", "Component Values button" & return & return & Â "Displays Inductor or Capacitor values corresponding to the reactances of X and P.","left bottom" end mouseWithin on mouseUp get item 2 of fld "X" if it >= 0 then get it/(2*pi*Frequency()) put "Lx=" & it*multiplier(it) & prefix(it) & "H" into fld "Z" else get -1/(2*pi*Frequency()*it) put "Cx=" & it*multiplier(it) & prefix(it) & "F" into fld "Z" end if get Parform(fld "X") get item 2 of it if it <> "INF" then if it >= 0 then get it/(2*pi*Frequency()) put " Lp=" & it*multiplier(it) & prefix(it) & "H" after fld "Z" else get -1/(2*pi*Frequency()*it) put " Cp=" & it*multiplier(it) & prefix(it) & "F" after fld "Z" end if else put " Xp=INF" after fld "Z" end if end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "L" on mouseWithin Inflate "text", "Equivalent Line button" & return & return & Â "Computes the length of a transmission line of characteristic impedance Z0 having" && Â "the same reactance at frequency F as the impedance X. Displays the result in Z.","left bottom" end mouseWithin on mouseUp put 299792458 into c -- speed of light in m/s put "Length=" & 1000*equivLength(fld "X",fld "Z0",Frequency(),c*Velocity()) & "mm" into fld "Z" end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "T" on mouseWithin Inflate "text", "Transmission Line button" & return & return & Â "Adds the impedance of a transmission line of length Tlength to the impedance X." && Â "If Tlength < 1, the length is taken to be a fraction of the wavelength." && Â "Otherwise, the length is taken to be in mm","left bottom" end mouseWithin on mouseUp put fld "Z0" into Z0 put fld "X" into Z1 put value(fld "Length") into x if x >= 1 then -- x in mm put 299792458 into c -- speed of light in m/s put Velocity() into v put 0.001*x*Frequency()/(c*v) into x end if put Zin(Z1,Z0,x) into fld "X" update end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "CS" on mouseWithin Inflate "text","Clear Chart button" & return & return & Â "Removes VSWR circles and (N) points from the impedance chart.","bottom left" end mouseWithin on mouseUp push this cd lock screen go to first card of bg "Smith Chart" set editBkgnd to false reset paint choose select tool doMenu "Select All" domenu "Clear Picture" choose browse tool put empty into fld "Plot Data" pop cd end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "Home" on mouseWithin Inflate "text", "Home button" & return & return & Â "Go to Home stack.","left bottom" end mouseWithin on mouseUp Inflate "remove" if the userlevel > 3 then go home else doMenu "Quit HyperCard" end if end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "/" on mouseWithin Inflate "text", "Scalar Divide button" & return & return & Â "Divides X by scalar Factor.","left bottom" end mouseWithin on mouseUp get value(fld "Factor") if (it is empty) or (it = 0) then beep exit mouseup end if put sdiv(it, fld "X") into fld "X" update end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "*" on mouseWithin Inflate "text", "Scalar Multiply button" & return & return & Â "Multiplies X by scalar Factor.","left bottom" end mouseWithin on mouseUp get value(fld "Factor") if it is empty then beep exit mouseup end if put smul(it, fld "X") into fld "X" update end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "Next" on mouseWithin Inflate "text", "Next button" & return & return & Â "Go to next card.","left bottom" end mouseWithin on mouseUp Inflate "remove" go to next cd of this bg end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "Prev" on mouseWithin Inflate "text", "Previous button" & return & return & Â "Go to previous card.","left bottom" end mouseWithin on mouseUp Inflate "remove" go to prev cd of this bg end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "Mn" on mouseWithin Inflate "text", "Write Memory button" & return & return & Â "Copies the X register to memory register n (1..9). Does not change X.","left bottom" end mouseWithin on mousedown Inflate "remove" wait 3 put "1,2,3,4,5,6,7,8,9" into MemoryList put 0 into MemoryNum put the rect of card window into cardPlace put item 1 of cardPlace into hOffset put item 2 of cardPlace into vOffset put the mouseloc into myPlace put (item 1 of myPlace) - 20 + hOffset into horiz put (item 2 of myPlace) - 10 + vOffset into vert get PopUpMenu(MemoryList, MemoryNum, vert, horiz) if it is not 0 then put fld "X" into fld ("M" & it) end if end mousedown ¥-¥-¥-¥ BUTTON: bkgnd button "Rn" on mouseWithin Inflate "text", "Read Memory button" & return & return & Â "Pushes the value of memory n (1..9) onto the stack (at X). Does not change memory n.","left bottom" end mouseWithin on mousedown Inflate "remove" wait 3 put "1,2,3,4,5,6,7,8,9" into MemoryList put 0 into MemoryNum put the rect of card window into cardPlace put item 1 of cardPlace into hOffset put item 2 of cardPlace into vOffset put the mouseloc into myPlace put (item 1 of myPlace) - 20 + hOffset into horiz put (item 2 of myPlace) - 10 + vOffset into vert get PopUpMenu(MemoryList, MemoryNum, vert, horiz) if it is not 0 then put fld "X" into fld "Y" put fld ("M" & it) into fld "X" update end if end mousedown ¥-¥-¥-¥ BUTTON: bkgnd button "?n" on mouseWithin Inflate "text", "Display Memory button" & return & return & Â "Displays the value of memory n (1..9) in Z. Does not change the stack or memory n.","left bottom" end mouseWithin on mousedown Inflate "remove" wait 3 put "1,2,3,4,5,6,7,8,9" into MemoryList put 0 into MemoryNum put the rect of card window into cardPlace put item 1 of cardPlace into hOffset put item 2 of cardPlace into vOffset put the mouseloc into myPlace put (item 1 of myPlace) - 20 + hOffset into horiz put (item 2 of myPlace) - 10 + vOffset into vert get PopUpMenu(MemoryList, MemoryNum, vert, horiz) if it is not 0 then put fld ("M" & it) into fld "Z" end if end mousedown ¥-¥-¥-¥ BUTTON: bkgnd button "LS" on mouseWithin Inflate "text", "L-sections button" & return & return & Â "Displays L-sections which match X to real part of Z0." & return & Â "(Use option key to display reactances in ohms)","left bottom" if the optionKey is down then set the name of me to "½" else set the name of me to "LS" end if end mouseWithin on mouseUp put item 1 of fld "Z0" into R0 put 2*pi*Frequency() into omega put item 1 of fld "X" into R put item 2 of fld "X" into X compute omega, R0, R, X lock screen show fld "Results" Send colorMe to this card end mouseUp on mouseLeave set the name of me to "LS" end mouseLeave on Say x, omega if the optionKey is down then get x put "reactance is " & it*multiplier(it) & prefix(it) & "½" & return after fld "Results" else if x < 0 then get -1/(x * omega) put "capacitance is " & it*multiplier(it) & prefix(it) & "F" & return after fld "Results" else get x/omega put "inductance is " & it*multiplier(it) & prefix(it) & "H" & return after fld "Results" end if end if end Say on compute omega, R0, R, X set the numberFormat to "0.###" put empty into fld "Results" put R*R + X*X into A put R/A into G put -X/A into B put "Shunt arm parallel to load" & return after fld "Results" put 1/(G*R0) into P if (P < 1) then put "No solution" & return after fld "Results" else put sqrt(P - 1) into A put R0*A into X1 put -A/(P*R0) into B2 put "First solution" & return & " Series arm " after fld "Results" Say (-X1), omega put " Shunt arm " after fld "Results" Say (-1/(B2 - B)), omega put "Second solution" & return & " Series arm " after fld "Results" Say (X1), omega put " Shunt arm " after fld "Results" Say (-1/(-B2 - B)), omega end if put return after fld "Results" put "Shunt arm parallel to generator" & return after fld "Results" put R0/R into P if (P < 1) then put "No solution" & return after fld "Results" else put sqrt(P - 1) into A put R*A into X1 put P*R/A into X2 put "First solution" & return & " Series arm " after fld "Results" Say (-X1 - X), omega put " Shunt arm " after fld "Results" Say X2, omega put "Second solution" & return & " Series arm " after fld "Results" Say (X1 - X), omega put " Shunt arm " after fld "Results" Say -X2, omega end if end compute ¥-¥-¥-¥ BUTTON: bkgnd button "E" on mouseWithin Inflate "text", "Exchange button" & return & return & Â "Exchanges the X and Y stack registers.","left bottom" end mouseWithin on mouseUp put fld "X" into XX put fld "Y" into fld "X" put XX into fld "Y" update end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "Z0" on mouseWithin Inflate "text", "Set Characteristic Impedance button" & return & return & Â "Copies the value of X into the Z0 register.","left bottom" end mouseWithin on mouseUp put fld "X" into fld "Z0" end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "|N|" on mouseWithin Inflate "text", "|N| button" & return & return & Â "Puts the modulus of N into Z.","left bottom" end mouseWithin on mouseUp put modulus(fld "N") into fld "Z" end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "VSWR Circle" on mouseWithin Inflate "text", "Plot VSWR Circle button" & return & return & Â "Plots the VSWR circle on the impedance chart.","left bottom" end mouseWithin on mouseUp get rho(fld "X",fld "Z0") push this cd lock screen go to first card of bg "Smith Chart" set editBkgnd to false drawCircle it pop cd end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "S" on mouseWithin if the optionKey is up then Inflate "Picture", "129","left bottom" else Inflate "text", "Show Chart button" & return & return & Â "Displays the impedance chart.","left bottom" end if end mouseWithin on mouseUp Inflate "remove" wait 6 push this cd toggleCardSize true go to first card of bg "Smith Chart" set editBkgnd to false end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "¥" on mouseWithin Inflate "text", "Plot Point button" & return & return & Â "Plots the current point (N = X/Z0) on the impedance chart.","left bottom" end mouseWithin on mouseUp get rho(fld "X",fld "Z0") push this cd lock screen go to first card of bg "Smith Chart" set editBkgnd to false placePoint it pop cd end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "W" on mouseWithin Inflate "text", "Display VSWR button" & return & return & Â "Displays the Voltage Standing Wave Ratio of X in Z.","left bottom" end mouseWithin on mouseUp get rho(fld "X",fld "Z0") put it into rh put "VSWR=" & VSWR(rh) && "RL=" & ReturnLoss(rh) & "dB" into fld "Z" end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "Help" on mouseWithin Inflate "text", "Help Information button" & return & return & Â "Displays information about this program.","left bottom" end mouseWithin on mouseUp Inflate "remove" wait 6 lock screen show bg fld "Help" show bg btn "Print Help Info" Send colorMe to this card end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "RMenu" on mouseWithin Inflate "text", "Resistance" & return & return & Â "Set resistance multiplier here.","left bottom" end mouseWithin on mouseUp --put "½,k½,M½,G½" into list put "0,3,6,9" into mlist get word 2 of the selectedLine of me put item it of mlist into fld "RMultiplier" end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "LMenu" on mouseWithin Inflate "text", "Inductance" & return & return & Â "Set inductance multiplier here.","left bottom" end mouseWithin on mouseUp --put "pH,nH,µH,mH,H,kH" into list -- omit MH,GH put "-12,-9,-6,-3,0,3,6,9" into mlist get word 2 of the selectedLine of me put item it of mlist into fld "LMultiplier" end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "XMenu" on mouseWithin Inflate "text", "Reactance" & return & return & Â "Set reactance multiplier here.","left bottom" end mouseWithin on mouseUp put "½,k½,M½,G½" into list put "0,3,6,9" into mlist get word 2 of the selectedLine of me put item it of mlist into fld "XMultiplier" end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "CMenu" on mouseWithin Inflate "text", "Capacitance" & return & return & Â "Set capacitance multiplier here.","left bottom" end mouseWithin on mouseUp put "pF,nF,µF,mF,F,kF" into list -- omit MF,GF put "-12,-9,-6,-3,0,3,6,9" into mlist get word 2 of the selectedLine of me put item it of mlist into fld "CMultiplier" end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "FMenu" on mouseWithin Inflate "text", "Frequency" & return & return & Â "Set frequency multiplier here.","left bottom" end mouseWithin on mouseUp --put "Hz,kHz,MHz,GHz,THz" into list put "0,3,6,9,12" into mlist get word 2 of the selectedLine of me put item it of mlist into fld "FMultiplier" end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "Print Help Info" on mouseEnter Inflate "remove" end mouseEnter on mouseWithin Inflate "text", "Print Help Information button" & return & return & Â "Prints this text.","top left" end mouseWithin on mouseUp Inflate "remove" wait 6 print bg fld "Help" close printing end mouseUp ¥-¥-¥-¥ BACKGROUND FIELD SCRIPTS ¥-¥-¥-¥ ¥-¥-¥-¥ FIELD: bkgnd field "Freq" on mouseWithin Inflate "text", "Frequency" & return & return & Â "Insert frequency value here.","left bottom" end mouseWithin ¥-¥-¥-¥ FIELD: bkgnd field "Z0" on mouseWithin Inflate "text", "Z0 value" & return & return & Â "Characteristic Impedance of the transmission line." & return & Â "(Set with Z0 button.)","left bottom" end mouseWithin on mouseUp copyToClip me end mouseUp ¥-¥-¥-¥ FIELD: bkgnd field "Velocity" on mouseWithin Inflate "text", "Velocity Factor" & return & return & Â "Insert velocity factor of the transmission line here.","left bottom" end mouseWithin ¥-¥-¥-¥ FIELD: bkgnd field "Resistance" on mouseWithin Inflate "text", "Resistance" & return & return & Â "Insert resistance value here.","left bottom" end mouseWithin ¥-¥-¥-¥ FIELD: bkgnd field "Inductance" on mouseWithin Inflate "text", "Inductance" & return & return & Â "Insert inductance value here.","left bottom" end mouseWithin ¥-¥-¥-¥ FIELD: bkgnd field "Reactance" on mouseWithin Inflate "text", "Reactance" & return & return & Â "Insert reactance value here.","left bottom" end mouseWithin ¥-¥-¥-¥ FIELD: bkgnd field "Capacitance" on mouseWithin Inflate "text", "Capacitance" & return & return & Â "Insert capacitance value here.","left bottom" end mouseWithin ¥-¥-¥-¥ FIELD: bkgnd field "Factor" on mouseWithin Inflate "text", "Factor" & return & return & Â "Insert factor for use with * and / buttons.","left bottom" end mouseWithin ¥-¥-¥-¥ FIELD: bkgnd field "Length" on mouseWithin Inflate "text", "Transmission line length" & return & return & Â "Insert transmission line length for use with T button." & return & Â "If < 1, it is regarded as a fraction of the wavelength" & return & Â "If >= 1, it is regarded as the length in mm.","left bottom" end mouseWithin on closeField get fld "Length" if word 1 of it is not empty then put value(fld "Length") into x if x < 0 then beep answer "Length must be non-negative!" put " " into fld "Length" select text of me exit closeField end if if x >= 1 then -- x in mm hide field "lamda" show field "mm" else show field "lamda" hide field "mm" end if end if end closeField ¥-¥-¥-¥ FIELD: bkgnd field "Y" on mouseWithin Inflate "text", "Y Register" & return & return & Â "Second stack register (in series form).","left bottom" end mouseWithin on mouseUp copyToClip me end mouseUp ¥-¥-¥-¥ FIELD: bkgnd field "X" on mouseWithin Inflate "text", "X Register" & return & return & Â "First stack register (in series form).","left bottom" end mouseWithin on mouseUp copyToClip me end mouseUp ¥-¥-¥-¥ FIELD: bkgnd field "P" on mouseWithin Inflate "text", "P Register" & return & return & Â "First stack register (in parallel form).","left bottom" end mouseWithin on mouseUp copyToClip me end mouseUp ¥-¥-¥-¥ FIELD: bkgnd field "N" on mouseWithin Inflate "text", "N value" & return & return & Â "Normalized impedance X/Z0.","left bottom" end mouseWithin on mouseUp copyToClip me end mouseUp ¥-¥-¥-¥ FIELD: bkgnd field "Z" on mouseWithin Inflate "text", "Z Register" & return & return & Â "General results register.","left bottom" end mouseWithin on mouseUp copyToClip me end mouseUp ¥-¥-¥-¥ FIELD: bkgnd field "M1" on mouseUp hide me end mouseUp ¥-¥-¥-¥ FIELD: bkgnd field "M2" on mouseUp hide me end mouseUp ¥-¥-¥-¥ FIELD: bkgnd field "M3" on mouseUp hide me end mouseUp ¥-¥-¥-¥ FIELD: bkgnd field "M4" on mouseUp hide me end mouseUp ¥-¥-¥-¥ FIELD: bkgnd field "M5" on mouseUp hide me end mouseUp ¥-¥-¥-¥ FIELD: bkgnd field "M6" on mouseUp hide me end mouseUp ¥-¥-¥-¥ FIELD: bkgnd field "M7" on mouseUp hide me end mouseUp ¥-¥-¥-¥ FIELD: bkgnd field "M8" on mouseUp hide me end mouseUp ¥-¥-¥-¥ FIELD: bkgnd field "M9" on mouseUp hide me end mouseUp ¥-¥-¥-¥ FIELD: bkgnd field "R" on mouseWithin Inflate "text", "rho value" & return & return & Â "Reflection coefficent in polar form.","left bottom" end mouseWithin on mouseUp copyToClip me end mouseUp ¥-¥-¥-¥ FIELD: bkgnd field "CopyContents" on mouseUp hide me end mouseUp ¥-¥-¥-¥ FIELD: bkgnd field "Results" on mouseWithin Inflate "text", "L-sections" & return & return & Â "Displays L-sections which match X to real part of Z0." && Â "Click anywhere in the text to dismiss this window.","left bottom" end mouseWithin on mouseUp Inflate "remove" wait 6 lock screen set scroll of me to 0 hide me Send colorMe to this card end mouseUp ¥-¥-¥-¥ FIELD: bkgnd field "Help" on mouseWithin Inflate "text", "Help Information" & return & return & Â "Click anywhere in the text to return to the main window.","top left" end mouseWithin on mouseUp Inflate "remove" wait 6 lock screen set scroll of me to 0 hide me hide bg btn "Print Help Info" Send colorMe to this card end mouseUp ¥-¥-¥-¥ BACKGROUND SCRIPT: Smith Chart ¥-¥-¥-¥ on drawCircle rho get modulus(rho) put "0,0," & it & return after fld "Plot Data" put round(225*it) into r reset paint choose oval tool set the centered to true set linesize to 2 drag from 272,272 to 272+r,272+r set centered to false choose browse tool end drawCircle on placePoint rho put item 1 of rho into r1 put item 2 of rho into x1 put r1 & "," & x1 & "," & "0.016" & return after fld "Plot Data" put 272+round(225*r1) into r put 272-round(225*x1) into x reset paint choose oval tool set the centered to true set linesize to 2 drag from r,x to r+4,x+4 set centered to false choose browse tool end placePoint function EPSdata put fld "ImpChart.ps" into ps put "lw3 setlinewidth" & return after ps put "newpath" & return after ps put 0 into n repeat add 1 to n get line n of fld "Plot Data" if it is empty then exit repeat put item 1 of it into r put item 2 of it into x put item 3 of it into rr put r && x && rr && "0 360 arc stroke" & return after ps end repeat put "grestore" & return after ps put "end" & return after ps put "showpage" & return after ps put "%%Trailer" & return after ps put "%%EOF" & return after ps return ps end EPSdata on openCard toggleCardSize true pass openCard end openCard on closeCard toggleCardSize false pass closeCard end closeCard ¥-¥-¥-¥ BACKGROUND BUTTON SCRIPTS ¥-¥-¥-¥ ¥-¥-¥-¥ BUTTON: bkgnd button "Hide me" on mouseWithin Inflate "text","Hides this window and returns to the main window.","bottom left" end mouseWithin on mouseUp Inflate "remove" wait 6 lock screen pop cd end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "CS" on mouseWithin Inflate "text","Clear Chart button" & return & return & Â "Removes VSWR circles and (N) points from this chart.","bottom left" end mouseWithin on mouseUp lock screen set editBkgnd to false reset paint choose select tool doMenu "Select All" domenu "Clear Picture" choose browse tool put empty into fld "Plot Data" end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "Save Screen" on mouseUp Inflate "remove" set the cursor to none wait 6 if the optionKey is down then get ScreenDump(4) else get ScreenDump(3) end if if it is not empty then answer it end if end mouseUp on mouseWithin Inflate "text","Saves the Screen." & return & return & Â "Saves a Screen Rectangle (use option key)." & return & return & Â "Saves a Window (use caps lock and option keys).","bottom right" if the optionKey is down then if capsLock() then set the name of me to "Save Window" else set the name of me to "Save Rectangle" end if else set the name of me to "Save Screen" end if end mouseWithin on mouseLeave set the name of me to "Save Screen" end mouseLeave function capsLock return char 58 of KeyMap() is "1" end capsLock ¥-¥-¥-¥ BUTTON: bkgnd button "Export EPS File..." on mouseWithin Inflate "text","Exports the Impedance Chart as an EPS file" && Â "which can be printed on a PostScriptª printer or" && Â "imported into other programs.","bottom left" end mouseWithin on mouseUp put NewFileName("Save EPS File as:","chart.eps") into it if it is empty then exit mouseUp put it into fileName open file fileName write EPSdata() to file fileName close file fileName get ChangeFileType(fileName, "EPSF", "vgrd") end mouseUp ¥-¥-¥-¥ BUTTON: bkgnd button "Print Chart..." on mouseWithin Inflate "text","Prints the Impedance Chart on a PostScriptª printer.","bottom left" end mouseWithin on mouseUp sendPS EPSdata() end mouseUp ¥-¥-¥-¥ BACKGROUND FIELD SCRIPTS ¥-¥-¥-¥ ¥-¥-¥-¥ FIELD: bkgnd field "Plot Data" on mouseUp hide me end mouseUp ¥-¥-¥-¥ FIELD: bkgnd field "ImpChart.ps" on mouseUp hide me end mouseUp