home *** CD-ROM | disk | FTP | other *** search
GW-BASIC | 1985-07-14 | 3.8 KB | 97 lines |
- 10 ' ****************************************************************
- 20 ' *
- 30 ' Chebychev Filter Element Values *
- 40 ' *
- 50 ' This program calculates Chebychev Filter element values *
- 60 ' for a normalized filter with a cutoff of one radian per second *
- 70 ' and terminations of one ohm. The calculated prototype may be *
- 80 ' impedance scaled and frequency scaled to the desired frequency *
- 90 ' of operation. The prototype, as per convention, is a low *
- 100 ' pass type with series inductors and shunt capacitors. Various*
- 110 ' techniques are used to convert the low pass prototype to other*
- 120 ' topologies, such as highpass or bandpass. The user who is *
- 130 ' unfamiliar with these techniques is encouraged to refer to one*
- 140 ' of the standard texts on the subject, such as Zverev. *
- 150 ' Output units are in Farads and Henries. It does not *
- 160 ' matter whether the shunt or series element comes first in the *
- 170 ' filter as long as one remembers that the shunt element will *
- 180 ' always be a cap and the series element a coil for a low pass *
- 190 ' filter. In the case of an even order filter, an impedance *
- 200 ' transformation will always take place -- the program outputs *
- 210 ' the new scaled value of load resistance. *
- 220 ' *
- 230 ' This program may be freely distributed, as long as this *
- 240 ' banner remains intact. If you like this program, do not send *
- 250 ' money! Instead, take the time to write and upload something *
- 260 ' ORIGINAL to your local BBS. I like many other users, would *
- 270 ' like to see some new "stuff". If you do not like this program,*
- 280 ' do it anyway! *
- 290 ' Donald J. Miller *
- 300 ' *
- 310 '****************************************************************
- 320 DIM X#(50) 'ELEMENT ARRAY
- 330 LET PI#=3.14159
- 340 LET RL#=1 'TERMINATION
- 350 CLS
- 360 LOCATE 10,1
- 370 '
- 380 '***************************************************************
- 390 PRINT TAB(30) "CHEBYSHEV ELEMENT VALUES" ' *
- 400 PRINT ' *
- 410 PRINT TAB(30) " By Donald J. Miller" ' *
- 420 '**************************************************************
- 430 '
- 440 FOR I=1 TO 1000:NEXT I
- 450 CLS
- 460 '
- 470 '
- 480 '***** PROMPT FOR DEGREE AND RIPPLE INPUT*****
- 490 '
- 500 INPUT "ENTER RIPPLE IN DB: ";RIPPLE#
- 510 PRINT
- 520 PRINT
- 530 INPUT "ENTER FILTER DEGREE: ";N%
- 540 '
- 550 '
- 560 '***** INITIALIZE ITERATION VARIABLES *****
- 570 '
- 580 LET E#=SQR(10^(RIPPLE#/10)-1)
- 590 LET BETA#=(1/N%)*LOG(1/E#+SQR(1/E#^2+1))
- 600 LET S#=(EXP(BETA#)-EXP(-1*BETA#))/2
- 610 LET A#=1
- 620 LET B#=S#
- 630 LET XI#=2
- 640 LET T#=(-1*PI#)/(2*N%)
- 650 LET D#=PI#/N%
- 660 LET DI#=D#/2
- 670 '
- 680 '
- 690 '***** ITERATE TO FIND ELEMENT VALUES *****
- 700 '
- 710 FOR K%=1 TO N%
- 720 T#=T#+D#
- 730 F#=T#+DI#
- 740 AI#=SIN(T#)
- 750 X#(K%)=(4*AI#*A#)/(XI#*B#)
- 760 XI#=X#(K%)
- 770 A#=AI#
- 780 B#=S#^2+(SIN(F#))^2
- 790 NEXT K%
- 800 '
- 810 '
- 820 '***** TEST FOR EVEN ORDER FILTERS *****
- 830 '(LOAD TERMINATION WILL HAVE TO BE ADJUSTED IN THIS CASE)
- 840 '
- 850 K%=N%/2
- 860 K%=K%*2
- 870 IF K%<>N% THEN 900
- 880 H#=SQR(E#^2+1)
- 890 RL#=1/(2*H#^2-2*H#*SQR(H#^2-1)-1)
- 900 FOR K%=1 TO N%
- 910 PRINT "X (";K%;") = ";X#(K%)
- 920 NEXT K%
- 930 PRINT
- 940 PRINT
- 950 PRINT "RL = ";RL#
- 960 END
-