This repository was archived by the owner on Dec 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathim.pas
More file actions
414 lines (357 loc) · 13.7 KB
/
im.pas
File metadata and controls
414 lines (357 loc) · 13.7 KB
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
{ intermod program by j0e Stevens }
const
max_no_of_freqs = 100;
format_list = ' ####.#### ######### ####.#### #########';
format_list_short = ' ####.#### #########';
title_2f_result = ' Freq A Freq B A B diff IM prod Recv Freq Difference';
format_2f_result = ' ####.#### ####.#### ####.#### ####.#### ####.#### ####.###';
format_2f_comment = ' ######### ######### ######### ';
title_3f_result = ' Freq A Freq B Freq C IM prod Recv Freq Difference';
format_3f_result = ' ####.#### ####.#### ####.#### ####.#### ####.#### ####.###';
format_3f_comment = ' ######### ######### ######### #########';
title_harmonic_result = ' Freq A Harmonic Recv Freq Difference';
format_harmonic_result = ' ####.#### ####.#### ####.#### #.####';
format_harmonic_comment= ' ######### #########';
format_summary = '####.#### ########### ### ### ####.#### @@@@@@@@### ### ###';
format_comment = '########';
var
tx_file, rx_file, output_file : text;
tx_freq, rx_freq : array[1..max_no_of_freqs] of real;
tx_comment, rx_comment : array[1..max_no_of_freqs] of string[9];
a_index, b_index, c_index, d_index, no_rx_freqs, no_tx_freqs,
times_a, times_b, title : integer;
result_tf_2, result_rf_2,
result_tf_3, result_rf_3,
result_tf_5, result_rf_5 : array[1..max_no_of_freqs] of integer;
print_2_3_decision, print_2_5_decision, print_3_3_decision,
print_details, print_title : boolean;
tally, a, df, max_apart : real;
answer : char;
{=============================================================================}
procedure list_a_line_of_tx_rx_frequencies;
begin
if rx_freq[a_index] = 0. then
writeln (output_file,
tx_freq[a_index]:9:4,
tx_comment[a_index]:11
)
else
writeln (output_file,
tx_freq[a_index]:9:4,
tx_comment[a_index]:11,
rx_freq[a_index]:17:4,
rx_comment[a_index]:11
);
end;
{=============================================================================}
procedure two_freq;
begin {1}
title := 0;
for a_index := 1 to no_tx_freqs do
begin {2}
for b_index := 1 to no_tx_freqs do
begin {3}
if ( ( tx_comment[a_index] = tx_comment[b_index] )
or ( a_index = b_index ) { dont compare a frequency to itself }
)
then
else
begin {4}
{ calculate the intermod product }
a := abs((times_a * tx_freq [a_index]) - (times_b * tx_freq [b_index]));
{ then compare it to the list of receive frequencies }
for c_index := 1 to no_rx_freqs do
begin {5}
tally:=tally+1;
if (abs(a-rx_freq[c_index]) > df) { df specified by user }
{ dont compare if the comments are the same }
or (tx_comment[b_index] = rx_comment[c_index])
or (tx_comment[a_index] = rx_comment[c_index])
or (abs(tx_freq[a_index]) - abs(rx_freq[c_index]) < 0.001)
or (abs(tx_freq[b_index]) - abs(rx_freq[c_index]) < 0.001)
then
else
begin {6}
if title = 0 then
writeln(output_file,title_2f_result);
title := 1;
writeln(output_file,
tx_freq[a_index]:9:4,
tx_freq[b_index]:11:4,
abs(tx_freq[a_index]-tx_freq[b_index]):11:4,
a:11:4,
rx_freq[c_index]:11:4,
abs(a-rx_freq[c_index]):11:4);
writeln(output_file,
tx_comment[a_index]:9,
tx_comment[b_index]:11,
rx_comment[c_index]:33);
writeln(output_file,'');
end; {6}
end; {5}
end; {4}
end; {3}
end; {2}
if title = 0 then writeln(output_file,'-none');
end; {1}
{=============================================================================}
procedure harmonics;
begin {1}
title := 0;
for a_index := 1 to no_tx_freqs do
begin {2}
{ calculate the harmonic }
a := (tx_freq [a_index]) * times_a;
{ then compare it to the list of receive frequencies }
for c_index := 1 to no_rx_freqs do
begin {5}
tally:=tally+1;
if (abs(a-rx_freq[c_index]) < df) { df specified by user }
then
begin {6}
if title = 0 then
writeln(output_file,title_harmonic_result);
title := 1;
writeln(output_file,
tx_freq[a_index]:9:4,
a:11:4,
rx_freq[c_index]:11:4,
abs(a-rx_freq[c_index]):6:4);
writeln(output_file,
tx_comment[a_index]:9,
rx_comment[c_index]:24);
writeln(output_file,'');
end; {6}
end; {5}
end; {2}
if title = 0 then writeln(output_file,'-none');
end; {1}
{=============================================================================}
procedure three_freq;
begin {1}
title := 0;
for a_index := 1 to no_tx_freqs-1 do
begin {2}
for b_index := a_index+1 to no_tx_freqs do
begin {3}
if (
( tx_comment[a_index] = tx_comment[b_index] )
or ( a_index = b_index ) { dont compare a frequency to itself }
{ don't do frequencies more than 50 MHz apart }
or ( abs(tx_freq[a_index] - tx_freq[b_index]) > max_apart )
)
then
else
begin {4}
for c_index := 1 to no_tx_freqs do
if (
( tx_comment[a_index] = tx_comment[c_index] )
or ( tx_comment[b_index] = tx_comment[c_index] )
or ( a_index = c_index )
or ( b_index = c_index )
{ don't do frequencies more than 50 MHz apart }
or ( abs(tx_freq[a_index] - tx_freq[b_index]) > max_apart )
)
then
else
begin {5}
{ calculate the intermod product }
a := abs((1 * tx_freq [a_index]) +
(1 * tx_freq [b_index]) -
(1 * tx_freq [c_index]));
{ then compare it to the list of receive frequencies }
for d_index := 1 to no_rx_freqs do
begin {6}
tally:=tally+1;
if (abs(a-rx_freq[d_index]) > df) { df specified by user }
{ dont compare if the comments are the same }
or (tx_comment[a_index] = rx_comment[d_index])
or (tx_comment[b_index] = rx_comment[d_index])
or (tx_comment[c_index] = rx_comment[d_index])
{ dont compare if the Frequencies are the same }
or (abs(tx_freq[a_index]) - abs(rx_freq[d_index]) < 0.001)
or (abs(tx_freq[b_index]) - abs(rx_freq[d_index]) < 0.001)
or (abs(tx_freq[c_index]) - abs(rx_freq[d_index]) < 0.001)
then
else
begin {7}
if title = 0 then
writeln(output_file,title_3f_result);
title := 1;
writeln(output_file,
tx_freq[a_index]:9:4,
tx_freq[b_index]:11:4,
tx_freq[c_index]:11:4,
a:11:4,
rx_freq[d_index]:11:4,
abs(a-rx_freq[d_index]):11:4);
writeln(output_file,
tx_comment[a_index]:9,
tx_comment[b_index]:11,
tx_comment[c_index]:11,
rx_comment[d_index]:11);
writeln(output_file,'');
end; {7}
end; {6}
end; {5}
end; {4}
end; {3}
end; {2}
if title = 0 then writeln(output_file,'-none');
end; {1}
{=============================================================================}
begin {1} { begin main program }
{ writeln('All output from this version will go to a file named ',output_file);}
{ set matrices to zero }
begin
for a_index := 1 to max_no_of_freqs do
begin
tx_freq[a_index] := 0;
rx_freq[a_index] := 0;
tx_comment[a_index] := '';
rx_comment[a_index] := '';
end;
end;
{ set all decisions to false }
print_2_3_decision := false;
print_2_5_decision := false;
print_3_3_decision := false;
print_details := false;
print_title := false;
{ fill transmit frequency matrices }
assign(tx_file, 'tfreqs');
{$I-}
reset(tx_file);
{$I+}
if IOresult <> 0 then
begin
writeln(' Cannot find input file "tfreqs"');
halt;
end
else
begin
a_index := 1;
while (not eof(tx_file)) do begin
read(tx_file, tx_freq[a_index], tx_comment[a_index]);
a_index := a_index + 1;
end;
close(tx_file);
no_tx_freqs := a_index - 2;
end;
{ fill receive frequency matrices }
assign(rx_file, 'rfreqs');
{$I-}
reset(rx_file);
{$I+}
a_index := 1;
if IOresult <> 0 then
begin
writeln(' Cannot find input file RFREQS');
halt;
end
else
begin
while (not eof(rx_file)) do begin
read(rx_file, rx_freq[a_index], rx_comment[a_index]);
a_index := a_index + 1;
end;
close(rx_file);
no_rx_freqs := a_index - 2;
end;
{ setup where the output goes }
if paramstr(1) = '' then
assign (output_file, 'con:')
else
begin
assign (output_file, paramstr(1));
rewrite (output_file);
end;
{ get operating variables }
df := 0;
max_apart := 0;
write ('Enter max difference MHz for a hit to count [.049] - '); readln(df);
if df = 0 then df := 0.049;
write ('Enter max apart in MHz for a comparison [50] - '); readln(max_apart);
if max_apart = 0 then max_apart := 50;
{ write ('Do you want detailed results? (Y/N) '); readln(answer);
if upcase(answer) = 'Y' then
begin
write (' of 2 signal, 3rd order? (Y/N) '); readln(answer);
if upcase(answer) = 'Y' then print_2_3_decision := true;
write (' of 2 signal, 5th order? (Y/N) '); readln(answer);
if upcase(answer) = 'Y' then print_2_5_decision := true;
write (' of 3 signal, 3rd order? (Y/N) '); readln(answer);
if upcase(answer) = 'Y' then print_3_3_decision := true;
end;
}
{ print report heading }
writeln(output_file,'=========================================================');
writeln(output_file,' Intermod Study program (c) 1996 Aksala Electronics ');
writeln(output_file,' Difference for hit = ',df:5:3,' MHz');
writeln(output_file,' Frequencies more than ',max_apart:3,' MHz apart not compared.');
writeln(output_file,'');
writeln(output_file,' This is the list of frequencies for the study:');
writeln(output_file,'');
begin
for a_index := 1 to no_tx_freqs do
list_a_line_of_tx_rx_frequencies
end;
writeln(output_file,'');
writeln(output_file,' Transmitters ',no_tx_freqs, ' Receivers ',no_rx_freqs);
writeln(output_file,'');
writeln(output_file,'==========================================================');
writeln(output_file,'');
writeln(output_file,'');
writeln(output_file,'===== Two Frequency, third-order tests:');
writeln(output_file,'');
times_a := 1;
times_b := 2;
tally := 0;
two_freq;
{writeln(output_file,form(' Loops: ###,###.',tally));}
writeln(output_file,'');
writeln(output_file,'===== Two Frequency, fifth-order tests:');
writeln(output_file,'');
times_a := 2;
times_b := 3;
tally := 0;
two_freq;
{writeln(output_file,form(' Loops: ###,###.',tally));}
writeln(output_file,'');
writeln(output_file,'===== Three Frequency, third-order tests:');
writeln(output_file,'');
tally := 0;
three_freq;
if title = 0 then
writeln(output_file,'-none');
{writeln(output_file,form(' Loops: ###,###,###.',tally));}
writeln(output_file,'');
writeln(output_file,'===== Second Harmonic Tests:');
writeln(output_file,'');
times_a := 2;
tally := 0;
harmonics;
{writeln(output_file,form(' Loops: ###,###,###.',tally));}
writeln(output_file,'');
writeln(output_file,'===== Third Harmonic Tests:');
writeln(output_file,'');
times_a := 3;
tally := 0;
harmonics;
{writeln(output_file,form(' Loops: ###,###,###.',tally));}
writeln(output_file,'');
writeln(output_file,'===== Fourth Harmonic Tests:');
writeln(output_file,'');
times_a := 4;
tally := 0;
harmonics;
{writeln(output_file,form(' Loops: ###,###,###.',tally));}
writeln(output_file,'');
writeln(output_file,'===== Fifth Harmonic Tests:');
writeln(output_file,'');
times_a := 5;
tally := 0;
harmonics;
{writeln(output_file,form(' Loops: ###,###,###.',tally));}
close(output_file);
end. {1}