1 /* atlc - arbitrary transmission line calculator, for the analysis of
2 transmission lines are directional couplers.
4 Copyright (C) 2002. Dr. David Kirkby, PhD (G8WRB).
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either package_version 2
9 of the License, or (at your option) any later package_version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 Dr. David Kirkby, e-mail drkirkby at ntlworld.com
25 /* The following calculates the odd and even mode impedances between two
26 zero thickness strips of width w, spaced a distance s between two
27 groundplanes of spacing h. */
32 #include "definitions.h"
33 #include "exit_codes.h"
43 double WW, HH, ww, Er1, Er2;
45 int W, H, s, w, verbose=FALSE;
47 int main(int argc, char **argv)
49 double er, return_error;
50 double Zodd, Zeven, Zo;
51 int bmp_size=DEFAULT_COUPLER_BMP_SIZE, q;
53 struct transmission_line_properties optimise;
54 struct transmission_line_properties not_used;
56 not_used.W=1; /* keep MipsPro compiler happy on IRIX */
58 while((q=get_options(argc,argv,"Cb:v")) != -1)
62 print_copyright((char *) "2002");
63 exit_with_msg_and_exit_code("",OKAY);
66 bmp_size=atol(my_optarg);
72 if( bmp_size < 6 || (argc-my_optind != 5) || bmp_size>28)
74 usage_create_bmp_for_stripline_coupler();
75 exit_with_msg_and_exit_code("",PROGRAM_CALLED_WITH_WRONG_NUMBER_OF_ARGUMENTS);
77 HH=atof(argv[my_optind]);
78 ww=atof(argv[my_optind+1]);
79 ss=atof(argv[my_optind+2]);
80 if(HH<0 || ww <0 || ss<0)
82 fprintf(stderr,"Sorry, W, H and s must all be greater than 0\n");
83 exit_with_msg_and_exit_code("",DIMENSION_LESS_THAN_ZERO);
85 er=atof(argv[my_optind+3]);
90 fprintf(stderr,"Sorry, you can't have a dielectric constand Er of less than 1.0\n");
91 exit_with_msg_and_exit_code("Sorry, you can't have a dielectric constand Er of less than 1.0",PERMITTIVITY_LESS_THAN_1);
93 if( (image_data_fp=fopen(argv[my_optind+4],"wb")) ==NULL)
94 exit_with_msg_and_exit_code("Can't open binary file for writing",CANT_OPEN_FOR_WRITING);
95 WW=2.0*ww+ss+RATIO*HH;
96 optimise.float_values[0]=WW ; /* minimum width as a float*/
97 optimise.float_values[1]=HH; /* height in floats */
98 optimise.float_values[2]=ww; /* stripline width */
99 optimise.float_values[3]=ss; /* spacing between the strips */
101 optimise.importance[0]=NOT_IMPORTANT; /* W is non critical */
102 optimise.importance[1]=MOST_IMPORTANT; /* H is critical */
103 optimise.importance[2]=IMPORTANT; /* w is critical */
104 optimise.importance[3]=IMPORTANT; /* s is most critical */
106 optimise.odd_or_even[0]=DONT_CARE; /* W can be odd or even */
107 optimise.odd_or_even[1]=ODD; /* H must be even */
108 optimise.odd_or_even[2]=DONT_CARE; /* w can be odd or even */
109 optimise.odd_or_even[3]=DONT_CARE; /* s can be odd or even */
111 /* We will now optimise for the 4 parameters W, H, w and s, forcing H
112 to be odd, and not bothering what the width is, as long as its about
115 return_error=calculate_integer_values(&optimise, 4, bmp_size);
117 printf("error returned from calculate_integer_values=%g\n", return_error);
122 write_bitmap(image_data_fp, not_used);
125 calculate_Zodd_and_Zeven(&Zodd, &Zeven, &Zo, ww, HH, ss, er);
126 printf("The actual dimensions you gave have theoretical imedances of:\n");
127 printf(" Zodd= %f Zeven= %f Zo= %f (Ohms) ww=%f HH=%f ss=%f er=%f\n\n", Zodd, Zeven, Zo,ww,HH,ss,er);
128 calculate_Zodd_and_Zeven(&Zodd, &Zeven, &Zo, (double) w, (double) H-10, (double) s, er);
129 printf("The bitmap produced (which approximates what you want) should have:\n");
130 printf(" Zodd= %f Zeven= %f Zo= %f (Ohms)\n", Zodd, Zeven, Zo);