5
/* This program, called 'input' asks the user for information about the
6
yagi. This includes the number of elements, design frequency, dimension and
7
locations of elements. It also asks for a range of frequencies to plot
8
the antenna details over (eg 144-146MHz) and an angular step size (eg 5deg)
9
over which the antenna pattern is plotted in both theta and phi (in this case
10
0deg, 5deg, 10deg, 15 deg ... 180deg). This program just writes all this
11
information into a file, which can be read by 'yagi'. The file created by
12
this program has the extension .out and is a text file, so it can be editied
13
manually if required. Be warned though, 'yagi' may not report errors in the
14
.out file, so extreme care is necessary if the .out file file is edited
24
extern int optind, opterr;
26
int main(int argc, char **argv)
28
double frequency, diameter, **d, **p;
29
double min_f, max_f, step_f, angular_step;
30
int elements, driven, i, fixed_diameter, boom, parasitic, c, hflg=0, errflg=0;
32
char response, *filename, *notes, *type, data_entry;
35
filename = string(0L, 1000L);
36
notes = string(0L, 1000L);
37
type = string(0L, 1000L);
39
while ((c = getoptions(argc,argv,"h")) != -1)
54
printf("Yagi-Uda antenna analysis programs, version %.2f\n", version());
55
printf("Written by Dr. David Kirkby Ph.D. (G8WRB, email:david.kirkby@onetel.net)\n");
56
printf("\nThis program asks for length, diameter and position of antenna elements then\n");
57
printf("writes them to a file you specify. Data is written in m (metres)\n \n");
58
printf("Enter any notes on this design (up to 400 characters): ");
60
printf("Enter a filename to write data to ");
62
printf("Enter the centre frequency in MHz ");
63
scanf("%lf", &frequency);
64
printf("Enter the minimum frequency in MHz ");
66
printf("Enter the maximum frequency in MHz ");
68
printf("Enter the frequency steps in MHz ");
69
scanf("%lf", &step_f);
71
nrerror("The minimum frequency has been set higher than the centre frequency");
73
nrerror("The maximum frequency has been set lower than the centre frequency");
74
printf("\nData can be entered in imperial (inches) metric (mm) or wavelengths (lambda)\n");
75
printf("Please enter i (for imperial), m (for metric) or w (for wavelengths). ");
76
scanf("%c", &data_entry);
77
scanf("%c", &data_entry);
78
/* The file produced by this is always written in metres. */
79
if(data_entry=='i' || data_entry=='I')
81
scale_factor=39.37; /* inches in 1m */
84
else if(data_entry=='m' || data_entry=='m')
86
scale_factor=1000.0; /* mm in 1m */
89
else if(data_entry=='w' || data_entry=='w')
91
scale_factor=frequency/300; /* wavelegths in 1m */
96
printf("Enter the number of elements for the antenna ");
97
scanf("%d",&elements);
98
/* printf("Enter the number of driven elements ");
99
scanf("%d", &driven); */
101
parasitic=elements-driven;
102
d=dmatrix(1L, (long) driven, 1L, 6L);
103
p=dmatrix(1L, (long) parasitic , 1L, 4L);
104
printf("Enter the angular step size in degrees for the gain to be plotted ");
105
scanf("%lf",&angular_step);
106
/* printf("Are any of the elements tappered? ");
107
scanf("%c", &response);
108
scanf("%c", &response);
109
if(response =='y' || response == 'Y')
112
printf("\nSorry: this program as yet can't handle tapered elements.\n");
116
printf("Are all the elements of the same diameter ? ");
117
scanf("%c",&response);
118
scanf("%c",&response);
119
if(response=='Y' || response =='y')
121
printf("Enter the diameter of the elements (in %s) ", type);
122
scanf("%lf", &diameter);
126
fixed_diameter=FALSE;
128
for(i=1;i<=driven;++i)
130
printf("\n\nEnter location of the driven element in %s (wrt. reflector at x=0) ", type);
131
scanf("%lf", &d[i][X]);
135
printf("Enter the y position of the driven element (in %s) ", type);
136
scanf("%lf", &d[i][Y]);
140
printf("Enter length of the driven element (in %s) ", type);
141
scanf("%lf", &d[i][LENGTH]);
142
if(fixed_diameter == TRUE)
143
d[i][DIAMETER]=diameter;
146
printf("Enter the diameter of the driven element (in %s) ", type);
147
scanf("%lf", &d[i][DIAMETER]);
150
printf("Enter the voltage driving this element ");
151
scanf("%lf", &d[i][VOLTAGE_R]);
152
printf("Enter the phase driving this element ");
153
scanf("%lf", &d[i][VOLTAGE_I]);
158
for(i=1;i<=elements-driven;++i)
160
if(i==1) /* The reflector */
162
printf("\nEnter length of the reflector (in %s) ", type);
163
scanf("%lf", &p[1][LENGTH]);
166
printf("\nEnter the y position of the reflector (in %s) ", type);
167
scanf("%lf", &p[i][Y]);
169
if(fixed_diameter == TRUE)
170
p[i][DIAMETER]=diameter;
173
printf("Enter the diameter of the reflector (in %s) ", type);
174
scanf("%lf", &p[i][DIAMETER]);
177
else /* a director */
179
printf("\n\nEnter location of director %d in %s (wrt. reflector at x=0.0) ", i-1, type);
180
scanf("%lf", &p[i][X]);
183
printf("Enter the y position of director %d (in %s) ", i-1, type);
184
scanf("%lf", &p[i][Y]);
188
printf("Enter the length of director %d (in %s) ", i-1,type);
189
scanf("%lf", &p[i][LENGTH]);
190
if(fixed_diameter == TRUE)
191
p[i][DIAMETER]=diameter;
194
printf("Enter the diameter of director %d (in %s) ", i-1, type);
195
scanf("%lf", &p[i][DIAMETER]);
199
/* Now write data to disk */
200
fp=fopen(filename,"wt");
201
write_input_data_to_disk(fp, notes, frequency, min_f, max_f, step_f, elements , driven, parasitic, angular_step, d, p, scale_factor);
203
free_string(filename,0L, 1000L);
204
free_string(notes,0L, 1000L);
205
free_string(type,0L, 1000L);
206
free_dmatrix(d, 1L, (long) driven, 1L, 6L);
207
free_dmatrix(p, 1L, (long) parasitic , 1L, 4L);