' Poles and Zeroes OpenW # 1 FullW # 1 AutoRedraw = 1 PrintScroll = 1 '##E# FontSize = 12 Global a0 As Double Global dd As Int, yd As Int, dmp As Double, dn As Double Global dq As Double, f As Double, flog As Double Global fnorm As Double, freq As Double, ymax As Double Global g As Double, hz$, i As Int, n As Int, n0 As Int Global n1 As Int, n2 As Int, ok$, om As Double, per As Double Global sq As Double, sta$, outfile$, sw As Double, trans As Double Global pi2 As Double, twopi As Double, y As Double Global z0 As Double, st As Double, xx As Int, yy As Int Global s(6) As Double, sre(12) As Double, sim(12) As Double z0 = 1 Repeat Input " station code or title ";sta$ outfile$ = sta$ + ".txt" Open outfile$ for Output As # 7 Print # 7, "Program POL_ZERO Station "; sta$ Repeat Input " are the poles given in Hz [h] or in rad/sec [r] ";hz$ Until hz$ = "h" Or hz$ = "r" pi2 = 2 * PI If hz$ = "r" twopi = pi2 Else twopi = 1 EndIf Input " normalization factor A0 ";a0 Input " normalization frequency [Hz] ";fnorm Input " number of zeroes at s=0 ";n0 Input " number of single (real) poles ";n1 Input " number of (complex) pole pairs ";n2 Input " gain factor ";g Print Print " You typed: "; sta$; " "; hz$; " "; a0; " "; fnorm; Print " "; n0; " "; n1; " "; n2; " "; g Print Print # 7 Print # 7, " You typed: "; sta$; " "; hz$; " "; a0; " "; fnorm; Print # 7, " "; n0; " "; n1; " "; n2; " "; g Print # 7 Input " ok? type n for no ", ok$ Until ok$ <> "n" Cls If n1 > 0 Repeat Print Print " Enter single poles (absolute real part only):" For n = 1 To n1 Print Print " Pole "; n; ": "; Print # 7 Print # 7, " Pole "; n; ": " Input " Re s ";s(n) s(n) = -Abs(s(n)) Exit If s(n) = 0 freq = -s(n) / twopi per = 1 / freq Print "s1", "freq", "per" Print s(n), Round(freq), Round(per, 3) Print # 7, "s1", "freq", "per" Print # 7, s(n), Round(freq), Round(per, 3) Next n Input " ok? type n for no ", ok$ Until ok$ <> "n" Cls EndIf If n2 > 0 Repeat Print " Enter pole pairs (absolute real and imag. parts)" For n = 1 To n2 Print Print " Pair "; n; ": "; Print # 7 Print # 7, " Pair "; n; ": " Input " Re s ";sre(n) sre(n) = -Abs(sre(n)) Print " Pair "; n; ": "; Input " Im s "; sim(n) sq = sre(n) ^ 2 + sim(n) ^ 2 sw = Sqr(sq) freq = sw / twopi per = 1 / freq dmp = -sre(n) / sw Print " sre", "sim", "freq", "per", "dmp" Print sre(n), sim(n), Round(freq, 3), Round(per, 3), Round(dmp, 4) Print # 7, " sre", "sim", "freq", "per", "dmp" Print # 7, sre(n), sim(n), Round(freq, 3), Round(per, 3), Round(dmp, 4) Next n Print Input " ok? type n for no ", ok$ Until ok$ <> "n" Cls EndIf om = twopi * fnorm trans = a0 * om ^ n0 dq = 1 For n = 1 To n1 dq = dq * (s(n) ^ 2 + om ^ 2) Next n For n = 1 To n2 dq = dq * (sre(n) ^ 2 + (om + sim(n)) ^ 2) dq = dq * (sre(n) ^ 2 + (om - sim(n)) ^ 2) Next n trans = trans / Sqr(dq) Print Print " Normalized response at ", fnorm; " Hz is "; Round(trans, 6) Print Print " if this is not very close to 1 then your entries were wrong or inaccurate" Print Print # 7 Print # 7, " Normalized response at ", fnorm; " Hz is "; Round(trans, 6) Print # 7 Input " ok? ", ok$ dn = 0 Repeat Cls ymax = -77777 Text 146, 660, "log f" Text 90, 385, "log" Text 90, 405, " R" Text 925, 385, "log" Text 925, 405, " R" For i = 20 To 820 Step 100 Line i + 100, 55, i + 100, 655 Text i + 94, 660, Str$((i - 420) / 100) Next i For i = 10 To 610 Step 100 Line 120, i + 45, 920, i + 45 Text 100, i + 36, Str$(Round((610 - i) / 100 - dn)) Text 925, i + 36, Str$(Round((610 - i) / 100 - dn)) Next i st = 1 / 256 For flog = -4 To 4 Step st f = 10. ^ flog om = twopi * f trans = a0 * g * om ^ n0 dq = 1 For n = 1 To n1 dq = dq * (s(n) ^ 2 + om ^ 2) Next n For n = 1 To n2 dq = dq * (sre(n) ^ 2 + (om + sim(n)) ^ 2) dq = dq * (sre(n) ^ 2 + (om - sim(n)) ^ 2) Next n trans = trans / Sqr(dq) y = Log10(trans) + dn ymax = Max(ymax, y) If y >= 0 And y <= 6 xx = Round(520 + 100 * flog) yy = Round(655 - 100 * y) ' Line xx - 1, yy, xx + 1, yy ' Line xx, yy - 1, xx, yy + 1 PCircle xx, yy, 2 EndIf Next flog Print AT(16, 2); "Station: " + sta$ Print AT(34, 2); "Scroll up by d decades ("; Round(5.45 - ymax); Input ") or exit with d=0: d = ";dd dn = dn + dd Until dd = 0 $DatFile $ExeName = C:\Dokumente und Einstellungen\Erhard\STRATO Webhosting\private\software\polzero\pol_zero.Exe $FileDescription = -<({[]})>- $Comments = Autor: E. Wielandt $CompanyName = Uni Stuttgart $LegalCopyright = © 2000 Uni Stuttgart $LanguageId = 0407 $FileVersion = %d.%d.%d.%d $ProductVersion = %d.%d.%d.%d $DatFile