home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / hamradio / noise.zip / NOISE.C < prev    next >
Text File  |  1993-08-24  |  5KB  |  157 lines

  1. /* noise.c - calculates noise figure for deviation of Gamma optimum.
  2.  *
  3.  * 1-jun-1993
  4.  * Peter Beyer -PA3AEF-
  5.  * beyer@athena.uto.dec.com
  6.  *
  7.  * Evironment variables:
  8.  *      NOISE_RN - Normalized noise resistance of two port
  9.  *      NOISE_GO - Gamma optimum of two port
  10.  *      NOISE_F  - Noise figure (dB) at Gamma optimum
  11.  *
  12.  *
  13.  * Some brain massage:
  14.  *
  15.  * In general the noise temperature for a lineair two-port is defined as:
  16.  *                                                   2
  17.  *                                          |Gs - Go|
  18.  *            T = Tmin + To * 4 * rn * -------------------------
  19.  *                                               2            2
  20.  *                                      (1 - |Gs| ) * |1 + Go| 
  21.  *
  22.  * Where: Tmin is the two-port minimum noise temperature,
  23.  *        To is room temperature (293K),
  24.  *        rn is normalized noise resistance,
  25.  *        Gs is Gamma source and,
  26.  *        Go is Gamma optimum
  27.  *
  28.  * This will calculate the expected noise figure when the two port is NOT
  29.  * properly matched to Gamma optimum. Gamma optimum is the impedance the 
  30.  * two-port wants to see for minimum noise temperature (Tmin). 
  31.  * 
  32.  * The equation actually has the form of a circle. i.e. for a lot of
  33.  * combinations of Gs the same noise temperature can be reached. These 
  34.  * circles are refered to as Constant Noise Circles and can be used together 
  35.  * with Constant Gain Circles to find the best compromis between unilateral
  36.  * transducer gain and minimum noise figure.
  37.  *
  38.  * The equations for the Noise circles can be found given the parameters
  39.  * Gamma optimum, Tmin and rn. To determine a family of noise figure circles
  40.  * a noise figure parameter Ni is defined:
  41.  *
  42.  *               Ti - Tmin          |        | 2
  43.  *        Ni = ------------------- * | 1 + Go |
  44.  *                        4 * rn           |        |
  45.  *
  46.  * where Ti is the value of the desired noise temperature circle.
  47.  *
  48.  * Now the center and the radius of the circle in the smithchart can be
  49.  * calculated:
  50.  *                  Go
  51.  *    Center = --------
  52.  *                1 + Ni
  53.  *
  54.  *                  1              2                 2
  55.  *     Radius = -------- * sqrt(Ni  + Ni * (1 - |Go| ))
  56.  *                1 + Ni
  57.  *
  58.  * Where Radius and Center lie along the Gamma optimum vector.
  59.  * 
  60.  * In these calculations, the losses in the input and output matching 
  61.  * networks are not incorporated. They have to be added to the resulting noise
  62.  * temperature: 
  63.  *                                     Toutput
  64.  *      Ttot = Tinput + Ttwo-port + -------------
  65.  *                                  Gain two-port
  66.  *
  67.  * 
  68.  */
  69. #include <math.h>
  70. #include <stdio.h>
  71. #include <stdlib.h>
  72. #define _PROTO_
  73. #include "complex.c"
  74.  
  75. #define To 293                              /* Room temperature */
  76. main()
  77. {
  78.     struct polair Gs, Go, pt1;
  79.     struct complex ct1, ct2, ct3, ct4;
  80.     double rn, F, Fmin, T, Tmin, tmp1, tmp2, tmp3, i;
  81.     char *env;
  82.  
  83.     printf("NOISE - Calculate NF for deviation of Gamma optimum (c) PA3AEF\n");
  84.  
  85.     /* Get Gamma optimum */
  86.     if ((env = getenv("NOISE_GO")) != NULL) {
  87.     sscanf(env, "%le,%le", &Go.m, &Go.a);
  88.     printf("Enter Gamma optimum (Mag, Angle) : %0.2f,%0.2f\n", Go.m, Go.a);
  89.     } else {
  90.         printf("Enter Gamma optimum (Mag, Angle) : ");
  91.     scanf("%le,%le",&Go.m, &Go.a);
  92.     }
  93.  
  94.     /* We want to know the complex conjugate of Gamma optimum as well */
  95.     pol2c(&Go, &ct1);
  96.     ct2.x = 1; ct2.y = 0;
  97.     cadd(&ct2, &ct1, &ct3);
  98.     csub(&ct2, &ct1, &ct4);
  99.     cdiv(&ct3, &ct4, &ct1);
  100.     printf("Complex conjugate for Zo=50: %0.2f j%0.2f ohms\n",
  101.         50 * ct1.x, -50 * ct1.y);
  102.  
  103.     /* Get normalized noise resistance */
  104.     if ((env = getenv("NOISE_RN")) != NULL) {
  105.     sscanf(env, "%le", &rn);
  106.     printf("Enter Rn/50 : %0.2f\n", rn);
  107.     } else {
  108.     printf("Enter Rn/50 : ");
  109.     scanf("%le", &rn);
  110.     }
  111.  
  112.     /* Get minimum noise figure and convert to temperature */
  113.     if ((env = getenv("NOISE_F")) != NULL) {
  114.     sscanf(env, "%le", &Fmin);
  115.     printf("Enter Fmin (dB) at Gamma optimum : %0.2f\n", Fmin);
  116.     } else {
  117.         printf("Enter Fmin (dB) at Gamma optimum :");
  118.         scanf("%le", &Fmin);
  119.     }
  120.     Tmin = To * (pow(10, Fmin/10) -1);
  121.  
  122.     /* Get Gamma source */
  123.     printf("Enter Gamma source (Mag, Angle) : ");
  124.     scanf("%le,%le",&Gs.m, &Gs.a);
  125.  
  126.     /* Now calculate the noise figure for this mismatch */
  127.     polsub(&Gs, &Go, &pt1);
  128.     tmp1 = pt1.m * pt1.m;
  129.     tmp2 = 1 - Gs.m * Gs.m;
  130.     pol2c(&Go, &ct1);
  131.     ct2.x = 1; ct2.y = 0;
  132.     cadd(&ct1, &ct2, &ct3);
  133.     tmp3 = cabs(ct3) * cabs(ct3);
  134.     T = Tmin + 4 * rn * To * (tmp1 / (tmp2 * tmp3));
  135.     F = 10 * log10(1+(T/To));
  136.     printf("Noise Figure: %0.2fdB (%3.0fK)\n", F, T);
  137.  
  138.     /* Calculate the noise figure circles */
  139.     printf("Constant Noise Circles in Smithchart:\n");
  140.     pol2c(&Go, &ct1);
  141.     ct1.x++;
  142.     tmp1 = cabs(ct1) * cabs(ct1);
  143.     for (i=0.2; i<Fmin+3; i=i+0.2) {
  144.     double Ni, Cfi, Rfi, Ti;
  145.  
  146.     if (i < Fmin)
  147.         continue;
  148.     Ti = To * (pow(10, i/10) - 1);
  149.     Ni = ((Ti - Tmin) / (4 * rn * To)) * tmp1;
  150.     Cfi = Go.m / (1 + Ni);
  151.     Rfi = (1 / (1 + Ni)) * sqrt(Ni*Ni + Ni * (1 - Go.m * Go.m));
  152.     printf("\tNF: %0.2fdB  (%3.0fK)  C: %0.3f, %0.1fdeg  R: %0.3f\n",
  153.         i, Ti, Cfi, Go.a, Rfi,Ni);
  154.     }
  155. }
  156.  
  157.