1 #ifdef HAVE_STDLIB_H
2 #include <stdlib.h>
3 #endif
4 #include <stdio.h>
5 #include <math.h>
6 #include <string.h>
7 #include "yagi.h"
8 
9 /* This program 'first' has a go at a first attempt of a yagi. It uses
10 as a basis, the DL6WU Yagis, which are strictly only  okay for 10 or more
11 elements, but this program takes liberties and calculates for any size of
12 dipole.
13 
14 The program 'first' disscussed in an article sent to RadCom, used a much
15 worst method, by trying to extend a 33 ele beam form the ARRL handbook in
16 both directions. I've abandoned this algorithm (if you could call it an
17 algorithm) in faviour of the DL6WU designs.
18 
19 */
20 
21 extern int optind, opterr;
22 extern char *optarg;
23 
24 /* space between the eleemnts */
25 double space[]={0.000,0.200,0.075,0.180,0.215,0.250,0.280,0.300,0.315,0.330,0.345,0.360,0.375,0.390,0.400,0.400,0.400,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4};
26 /* elements length. These values are for a diamter of 0.01 lambda */
27 double length[]={0.480,0.456,0.425,0.42,0.414,0.408,0.404,0.399,0.396,0.392,0.390,0.388,0.385,0.383,0.381,0.379,0.377,0.376,0.375,0.374,0.372,0.371,0.370,0.369,0.368,0.367,0.366,0.365,0.364,0.363};
28 
29 /* We now compute the element lengths. The program computes the self reactance
30 of eleemnts assuming a diamter of 0.01 lambda, then adjest the length for the
31 array 'length' so they have the same reactance. The resistance will change
32 somewhat, so you cant expect the performance  to be identical with different
33 element lengths */
34 
main(int argc,char ** argv)35 int main(int argc, char **argv)
36 {
37 	double min_f, f, max_f, step_f, angular_step=180, diameter, lambda;
38 	double **d, **p,scale_factor=1.0;
39 	int elements, driven, parasitic, i,c;
40 	FILE *fp;
41 	char *output_filename, *notes="Automatically produced by first";
42 
43 
44    while ((c =  getoptions(argc,argv,"m")) != -1)
45    switch       (c)
46    {
47 	}
48 	if((argc-optind!=7))
49 	{
50 		usage_first(argv[0]);
51 		exit(1);
52 	}
53 	elements=atoi(argv[optind+1]);
54 	if(elements <10)
55 	{
56 		printf("DL6WU antennas are only valid for 10 or more elements, but I'll do it!\n");
57 	}
58 	min_f=atof(argv[optind+2]);
59 	f=atof(argv[optind+3]);
60 	max_f=atof(argv[optind+4]);
61 	step_f=atof(argv[optind+5]);
62 	diameter=1e-3*atof(argv[optind+6]);
63 	driven=1;
64 	parasitic=elements-1;
65 	output_filename=string(0L,100L);
66 	d=dmatrix(1L,(long) driven,1L, 6L);
67 	p=dmatrix(1L,(long) parasitic,1L, 4L);
68 	lambda=300/f;
69 	fp=fopen(*(argv+1),"wt");
70 	d[1][X]=space[1]*lambda;
71 	d[1][DIAMETER]=diameter;
72 	d[1][LENGTH]=new_length(lambda*length[1],0.01*lambda,lambda,diameter);
73 	d[1][VOLTAGE_R]=1.0;
74 	d[1][VOLTAGE_I]=0.0;
75 	/* now all the directors */
76 	for(i=1;i<=parasitic;++i)
77 	{
78 		if(i==1)
79 		{
80 			p[1][X]=space[0]; /* position of reflector */
81 			p[1][DIAMETER]=diameter; /* length of reflector */
82 			p[1][LENGTH]=new_length(lambda*length[0],0.01*lambda,lambda,diameter);
83 		}
84 		else if (i==2)
85 		{
86 			p[i][X]=space[i]*lambda+d[1][X];
87 			p[i][DIAMETER]=diameter; /* length of first director */
88 			p[i][LENGTH]=new_length(lambda*length[2],0.01*lambda,lambda,diameter);
89 		}
90 		else if ((i>2) && (i < 26))
91 		{
92 			p[i][X]=space[i]*lambda+p[i-1][X];
93 			p[i][DIAMETER]=diameter; /* length of subsequent directors */
94 			p[i][LENGTH]=new_length(lambda*length[i],0.01*lambda,lambda,diameter);
95 		}
96 		else if(i>=26)
97 		{
98 			p[i][X]=0.400*lambda+p[i-1][X];
99 			p[i][LENGTH]=0.997*p[i-1][LENGTH]; /* Log taper, eancjh element constant fraction of the length od the last one */
100 			p[i][DIAMETER]=diameter; /* length of these, assume constant frac of previous */
101 		}
102 	}
103 	write_input_data_to_disk(fp, notes, f, min_f, max_f, step_f, elements   , driven, parasitic, angular_step, d, p, scale_factor);
104 	fclose(fp);
105 	free_string(output_filename,0L,100L);
106 	exit(0);
107 }
108