-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilter
256 lines (256 loc) · 5.87 KB
/
filter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
PROGRAM FILTER CARD RESISTOR CALCULATIONS
COMMON R(5,3),AV(5,2),FP(5),DP(5),FZ(5)DZ(5),NTY(5)
LOGICAL*1 ANS,YES,NO
DATA YES/1HY/,NO/1HN/
TWOPI=6.2831853
TYPE 10
10 FORMAT (' SDAS SIGNAL CONDITIONING CARD DESIGN PROGRAM')
NST=0
C
C Adapted from Air Force Geophysics Laboratory
C Standalone Data Acquisition System (Functional Design)
C PG VON GLAHN, CPT_USAF, AUTHOR
C Restart point for board redesign
GOTO 11000
10000 NST=1
C Clear COMMON for initial use
11000 DO 900 N=1,5
DO 800 M=1,8
R(N,M)=0.
800 CONTINUE
CAP(N,1)=0.
CAP(N,2)=0.
CAP(N,3)=0.
AV(N,1)=0.
AV(N,2)=0.
FP(N)=0.
DP(N)=0.
FZ(N)=0.
DZ(N)=0.
900 CONTINUE
C
C Begin by asking for design stage and jump to
C that stage.
C
IF(NST.EQ.1) GOTO 1000
TYPE 40
40 FORMAT ('0 STAGE TO BE DESIGNED (0=ENTIRE BOARD) = ? ',$)
ACCEPT 50,NST
50 FORMAT (I1)
NST=NST+1
20000 GOTO (1000,1000,2000,3000,4000,5000) NST
C
C Stage one. Only used for gain. Stage gain and gain-setting resistor
C values retrieved to calculate value of other resistor. The program
C allows resistor values to be entered to recalculate gain. Pole frequency
C accepted by program to set stage, determined by values of frequency-
C limiting components used on board and is input. The program stores
C component and parameters in COMMON locations. If entire board
C is not being designed, program jumps to closeout; else, next stage.
C
1000 TYPE 110
110 FORMAT (' STAGE 1:')
TYPE 120
120 FORMAT ('$DC GAIN (V/V) = ?')
ACCEPT 130,GAIN
130 FORMAT (E12.5)
IF (GAIN.EQ.0.) GOTO 1100
TYPE 140
140 FORMAT ('$R102 (OPTIMUM = 100) (K OHMS) = ?')
ACCEPT 130,RS
RG=RS/GAIN
TYPE 150,RG
150 FORMAT (' R101 = ',G11.4,' KOHMS')
TYPE 160
160 FORMAT ('0 CHECK ACTUAL COMPONENTS (Y/n) ?',$)
ACCEPT 170,ANS
170 FORMAT (A1)
IF (ANS.NE.YES) GOTO 1900
1100 TYPE 180
180 FORMAT ('$R101 (KOHMS) = ? ')
ACCEPT 130,RG
TYPE 140
ACCEPT 130,RS
GAIN=RS/RG
DBG=20.*(ALOG10(GAIN))
TYPE 190,GAIN,DBG
190 FORMAT (' DC GAIN = ',G11.4,' (V/V) [',G10.3,' (DB)]')
TYPE 195
195 FORMAT ('0CHECK AGAIN (Y/n) ? '$)
ACCEPT 170,ANS
IF (ANS.EQ.YES) GOTO 1100
1900 TYPE 198
198 FORMAT ('$POLE FREQ (HZ) = ? ')
ACCEPT 130,FREQ
R(1,1)=RG
R(1,2)=RS
FP(1)=FREQ
AV(1,1)=GAIN
AV(1,2)=20.*(ALOG10(GAIN))
NTY(1)=2
IF (NST.NE.1) GOTO 6000
C
C Stage 2. Can be used for any type of filter. Program will accept
C type and call appropriate routine to perform actual calculations
C and jumps to closeout unless entire board is being designed.
C
2000 TYPE 200
200 FORMAT (' STAGE 2:')
2100 TYPE 210
210 FORMAT ('$FILTER TYPE (NONE=0, LP=1, HP=2, BP=3, BR=4)= ? ')
ACCEPT 220,NTYP
220 FORMAT (I1)
NTYP=NTYP+1
GOTO (2200,2300,2400,2500,2600) NTYP
GOTO 2100 !|REPEAT ABOVE IF GOTO OUT OF RANGE
2200 CALL DC(2)
GOTO 2900
2300 CALL LP(2)
GOTO 2900
2400 CALL HP(2)
GOTO 2900
2500 CALL BP(2)
GOTO 2900
2600 CALL BR(2)
GOTO 2900
2900 IF (NST.NE.1) GOTO 6000
C
C STAGE 3 LOWPASS ONLY FILTER
C
3000 TYPE 300
300 FORMAT (' STAGE 3:')
TYPE 310
310 FORMAT (' GAIN CAPABILITY 1 OF 2 OTHER STAGES')
CALL LP(3)
IF (NST.NE.1) GOTO 6000
C
C STAGE 4 USED FOR GAIN OR GAIN PLUS SINGLE LOWPASS POLE ONLY.
C PROGRAM ACCEPTS VALUES FOR STAGE GAIN AND ONE GAIN SETTING
C RESISTOR. THE PROGRAM CALCULATES AND DISPLAYS VALUE OF OTHER
C RESISTOR. AFTER LOWPASS FREQUENCY VALUE ACCEPTED (0 = NO FILTER)
C PROGRAM CHECKS FOR NONZERO FREQUENCY. IF FOUND, PROGRAM WILL
C CALCULATE AND DISPLAY APPROPRIATE CAPACITOR SIZE. PROGRAM WILL
C STORE COMPONENT PARAMETERS IN COMMON LOCATIONS AFTER ALLOW
C OF ITERATIVE COMPONENT ENTRIES AND PARAMETER CALCULATIONS.
C Program then jumps to closeout if next stage is not being designed.
C
4000 TYPE 400
400 FORMAT (' FOURTH STAGE:')
TYPE 410
410 FORMAT (' GAIN AND/OR SINGLE LP POLE ONLY')
TYPE 120
ACCEPT 130,GAIN
C
C Component calculation:
C
TYPE 420
420 FORMAT ('$R309 (KOHMS) = ?')
ACCEPT 130,RF
R1=RF/GAIN
TYPE 430,R1
430 FORMAT (' R306 = ',G11.4,' KOHMS')
TYPE 435
435 FORMAT ('0 NOTE: STAGE INVERTS SIGNAL')
TYPE 440
440 FORMAT ('0 FILTER FREQ (ENTER 0.0 FOR GAIN ONLY) (HZ) = ? ',$)
ACCEPT 130,FREQ
C=0.0
IF (FREQ.EQ.0.) GOTO 4100
C=1/(TWOPI*1000.*RF*FREQ)
C=C*1.E+06
TYPE 450,C
450 FORMAT (' C301 (UFD) = ',G12.5)
4100 TYPE 160
ACCEPT 170,ANS
IF (ANS.NE.YES) GOTO 4900
C
C PARAMETER CALCULATION:
C
4200 IF (FREQ.NE.0.) GOTO 4300
TYPE 460
460 FORMAT ('$R306 (KOHMS) = ? ')
ACCEPT 130,R1
TYPE 420
ACCEPT 130,RF
TYPE 480
480 FORMAT ('$C301 (UFD) = ? ')
ACCEPT 130,RF
TYPE 480
480 FORMAT ('$C301 (UFD) = ? ')
ACCEPT 130,C
490 FORMAT (3E12.5)
GAIN=RF/R1
DBG=20.*(ALOG10(GAIN))
TYPE 190,GAIN,DBG
IF (C.EQ.0.0) GOTO 4800
TYPE 435
FREQ=1000./(TWOPI*C*RF)
TYPE 495,FREQ
495 FORMAT (' POLE FREQ = ',G11.4,' HZ')
4800 TYPE 195
ACCEPT 170,ANS
IF (ANS.EQ.YES) GOTO 4200
4900 R(4,1)=R1
R(4,2)=RF
CAP(4,1)=C
AV(4,1)=-GAIN
AV(4,2)=20.*(ALOG10(GAIN))
FP(4)=FREQ
DP(4)=0.
NTY(4)=1
IF (FREQ.NE.0.) NTY(4)=2
IF (NST.NE.1) GOTO 6000
C
C STAGE 5 ANY FILTER TYPE, program will accept input: type
C of filter and call appropriate subroutine to perform calculation.
C
5000 TYPE 500
500 FORMAT (' STAGE 5:')
5100 TYPE 210
ACCEPT 220,NTYP
NTYP=NTYP+1
GOTO (5200,5300,5400,5500,5600) NTYP
GOTO 5100 !| REPEAT ABOVE IF GOTO OUT OF RANGE
5200 CALL DC(5)
GOTO 6000
5300 CALL LP(5)
GOTO 6000
5400 CALL HP(5)
GOTO 6000
5500 CALL BP(5)
GOTO 6000
5600 CALL BR(5)
C
C CLOSEOUT SECTION FOLLOWS
C User may correct errors, affecting only stage selected.
C All other values stored in COMMON will stay as-is.
C User is presented with print option (table) and option
C to re-run the program.
C
6000 TYPE 600
600 FORMAT ('0 ANY CHANGES (Y/n) ? ',$)
ACCEPT 170,ANS
IF (ANS.NE.YES) GOTO 7000
TYPE 610
610 FORMAT ('$STAGE TO BE CHANGED (1-5) = ? ')
ACCEPT 50.NST
NST=NST+1
GOTO 20000
7000 TYPE 620
620 FORMAT ('WOULD YOU LIKE RESISTOR AND PARAMETER PRINTOUT (Y/n) ? ')
ACCEPT 170,ANS
IF (ANS.EQ.YES) CALL PRINT
7100 TYPE 630
630 FORMAT ('$STORE PARAMETERS ON DRIVE (Y/n) ? ')
ACCEPT 170,ANS
IF (ANS.NE.YES) GOTO 7200
CALL STORE
GOTO 7100
7200 PRINT 640
640 FORMAT ('1')
CALL CLOSE (6)
TYPE 650
650 FORMAT ('$RESTART PROGRAM (Y/n) ? ')
ACCEPT 170,ANS
IF(ANS.EQ.YES) GOTO 10000
END