home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1 / HamRadio.cdr / math / cheb / cheb.bas (.txt)
Encoding:
GW-BASIC  |  1985-07-14  |  3.8 KB  |  97 lines

  1. 10  ' ****************************************************************
  2. 20  '                                                                *
  3. 30  '                Chebychev Filter Element Values                 *
  4. 40  '                                                                *
  5. 50  '     This program calculates Chebychev Filter element values    *
  6. 60  ' for a normalized filter with a cutoff of one radian per second *
  7. 70  ' and terminations of one ohm.  The calculated prototype may be  *
  8. 80  ' impedance scaled and frequency scaled to the desired frequency *
  9. 90  ' of operation.  The prototype, as per convention, is a low      *
  10. 100  ' pass type with series inductors and shunt capacitors.  Various*
  11. 110  ' techniques are used to convert the low pass prototype to other*
  12. 120  ' topologies, such as highpass or bandpass.  The user who is    *
  13. 130  ' unfamiliar with these techniques is encouraged to refer to one*
  14. 140  ' of the standard texts on the subject, such as Zverev.         *
  15. 150  '    Output units are in Farads and Henries.  It does not       *
  16. 160  ' matter whether the shunt or series element comes first in the *
  17. 170  ' filter as long as one remembers that the shunt element will   *
  18. 180  ' always be a cap and the series element a coil for a low pass  *
  19. 190  ' filter.  In the case of an even order filter, an impedance    *
  20. 200  ' transformation will always take place -- the program outputs  *
  21. 210  ' the new scaled value of load resistance.                      *
  22. 220  '                                                               *
  23. 230  '    This program may be freely distributed, as long as this    *
  24. 240  ' banner remains intact.  If you like this program, do not send *
  25. 250  ' money!  Instead, take the time to write and upload something  *
  26. 260  ' ORIGINAL to your local BBS.  I like many other users, would   *
  27. 270  ' like to see some new "stuff". If you do not like this program,*
  28. 280  ' do it anyway!                                                 *
  29. 290  '                                  Donald J. Miller             *
  30. 300  '                                                               *
  31. 310  '****************************************************************
  32. 320  DIM X#(50)                                         'ELEMENT ARRAY
  33. 330  LET PI#=3.14159
  34. 340  LET RL#=1                                          'TERMINATION
  35. 350  CLS
  36. 360  LOCATE 10,1
  37. 370  '
  38. 380  '***************************************************************
  39. 390  PRINT TAB(30) "CHEBYSHEV ELEMENT VALUES"            '          *
  40. 400  PRINT                                               '          *
  41. 410  PRINT TAB(30) "   By Donald J. Miller"             '          *
  42. 420  '**************************************************************
  43. 430  '
  44. 440  FOR I=1 TO 1000:NEXT I
  45. 450  CLS
  46. 460  '
  47. 470  '
  48. 480  '***** PROMPT FOR DEGREE AND RIPPLE INPUT*****
  49. 490  '
  50. 500  INPUT "ENTER RIPPLE IN DB: ";RIPPLE#
  51. 510  PRINT
  52. 520  PRINT
  53. 530  INPUT "ENTER FILTER DEGREE: ";N%
  54. 540  '
  55. 550  '
  56. 560  '***** INITIALIZE ITERATION VARIABLES *****
  57. 570  '
  58. 580  LET E#=SQR(10^(RIPPLE#/10)-1)
  59. 590  LET BETA#=(1/N%)*LOG(1/E#+SQR(1/E#^2+1))
  60. 600  LET S#=(EXP(BETA#)-EXP(-1*BETA#))/2
  61. 610  LET A#=1
  62. 620  LET B#=S#
  63. 630  LET XI#=2
  64. 640  LET T#=(-1*PI#)/(2*N%)
  65. 650  LET D#=PI#/N%
  66. 660  LET DI#=D#/2
  67. 670  '
  68. 680  '
  69. 690  '***** ITERATE TO FIND ELEMENT VALUES *****
  70. 700  '
  71. 710  FOR K%=1 TO N%
  72. 720  T#=T#+D#
  73. 730  F#=T#+DI#
  74. 740  AI#=SIN(T#)
  75. 750  X#(K%)=(4*AI#*A#)/(XI#*B#)
  76. 760  XI#=X#(K%)
  77. 770  A#=AI#
  78. 780  B#=S#^2+(SIN(F#))^2
  79. 790  NEXT K%
  80. 800  '
  81. 810  '
  82. 820  '***** TEST FOR EVEN ORDER FILTERS *****
  83. 830  '(LOAD TERMINATION WILL HAVE TO BE ADJUSTED IN THIS CASE)
  84. 840  '
  85. 850  K%=N%/2
  86. 860  K%=K%*2
  87. 870  IF K%<>N% THEN 900
  88. 880  H#=SQR(E#^2+1)
  89. 890  RL#=1/(2*H#^2-2*H#*SQR(H#^2-1)-1)
  90. 900  FOR K%=1 TO N%
  91. 910  PRINT "X (";K%;")  =  ";X#(K%)
  92. 920  NEXT K%
  93. 930  PRINT
  94. 940  PRINT
  95. 950  PRINT "RL  =  ";RL#
  96. 960  END
  97.