/* The following program has been useful for generating possible intermod interference reports. Tools such as this are primarily for repeater owners wishing to examine the impact of a new machine at a given site, but may have other applications as well. As you can see, the program has been around for a while. I waited until now to post it in order to catch as many bugs as possible. I hope I have got most of them. ;-) I also have a version of this program (mmix.c) specially designed for the Sequent Balance 8000 (makes use of some curde parallel processing). If you want this version, mail me a request. I would appreciate hearing any comments on the program, and of course, bug reports! Ed Morin - Teltone Corporation ...uw-beaver_____!tikal!edm 10801 - 120th Ave. N.E. .......fluke___/ Kirkland, WA 98033 (206) 827-9626 P.S. Parts of the code are a bit complex due to performance considerations. */ /******************************************************************** * * * PROGRAM: mix.c Rev 1.0 * * * * Compile: cc -O mix.c -o mix (4.2BSD) * * * * Written by: Ed Morin (WB7UBD) * * Date: 9-15-84 (Copyright 1984 Morin) * * * * Description: * * * * This program takes bandwidth, maximum number * * of harmonics, maximum order of mixes, maximum * * number of transmitters to mix at a time along * * with a list of transmitter and receiver freq- * * uencies and then lists all possible receiver * * interferences as a result of unwanted mixes. * * * * Copies of this program may be made as long as * * this header is retained with the source. * * * * (Program was based on Supermix by Mike Boyd.) * * * * Ver 1.1 Added signon and tiny help messages and formatted * * 14 MAR 87 output routines so AWK not needed for reports, * * altered to compile under Aztec-C V106D (CP/M-80) * * Dick Mead WB6NGC Pasadena Z-Node 36 (818)799-1632 * * * ********************************************************************/ #include "stdio.h" #define FALSE 0 #define TRUE ~FALSE /* Status byte identifiers... */ #define BANDWIDTH 1 #define HARMONICS 2 #define MAXMIX 4 #define ORDER 8 #define RX 16 #define TX 32 /* Array size limitations... */ #define MAXTRANS 100 #define MAXHARM 50 /* These are global since they are used everywhere... */ long rx[MAXTRANS], /* Receiver frequencies... */ tx[MAXTRANS], /* Transmitter frequencies... */ tx_mix[MAXTRANS], /* Current transmitters being mixed... */ combination[MAXTRANS], /* Current combination being used... */ harmonic[MAXTRANS]; /* Harmonic multiplier table... */ long lower_bound, /* Lowest frequency to examine... */ upper_bound, /* Highest frequency to examine... */ *last_harmonic, /* Address of last harmonic entry... */ max_mix, /* Maximum number of transmitters to mix... */ max_rx, /* Number of receivers in table... */ max_tx, /* Number of transmitters in table... */ max_harmonic, /* Maximum number of harmonics to examine... */ max_order, /* Maximum order to examine... */ bandwidth; /* Maximum bandwidth to be concerned with... */ /* Meat and Potatoes (as Mike would say)... */ long get_int(); long read_params(); long atol(); main() { long param_status, comb_inc, harm_inc; long *h; /* Pointer into harmonic array... */ long *t; /* Pointer into transmitter array... */ long mix; /* Sum of frequencies... */ long order; /* Order of mix... */ long i; /* Fast general purpose index... */ long j; /* Slow general purpose index... */ long r; /* Current r for combination... */ printf("MIX 1.1 : Enter parameters or ? for help.\n"); /* Read our parameters and make sure we got everything... */ if ((param_status = read_params()) == (BANDWIDTH | HARMONICS | MAXMIX | ORDER | RX | TX)) { /* Make sure we do not have some rediculous specs... */ if (max_order < max_harmonic) { printf("mix: Order specification (O) is less than Harmonic specification (H).\n"); exit(1); } if (max_mix > max_tx) { printf("mix: Maximum number of transmitters to mix at a time (M) is greater than\n"); printf(" the number of transmitters specified (T)\n"); exit(1); } /* Print out what we are analyzing... */ printf("\nInterModulation Analysis Parameters\n"); printf("Max. bandwidth = +/- %ld kHz\n",bandwidth); printf("Max. Tx to mix = %ld\n",max_mix); printf("Max. Harmonic = %ld\n",max_harmonic); printf("Max. Order = %ld\n",max_order); printf("\nTransmitters Mixed\n"); for(i=0;i= lower_bound) && (mix <= upper_bound)) { /* Check it against all receivers within bandwidth... */ for(i=0;i= rx[i] - bandwidth) && (mix <= rx[i] + bandwidth)) { /* Print #:rx:order:distance: */ printf("\nRx: %8.3f MHz\n",(float)( rx[i]/1000.0)); printf("Order = %ld\n",order); printf("Distance = %ld kHz",mix-rx[i]); /* Print out all transmitters involved... */ for(j=0;j= 0) && (! comb_inc)) { if (combination[i] < max_tx-(r-i)) { combination[i]++; while (++i < r) combination[i] = combination[i-1]+1; comb_inc = TRUE; } i--; } } while (comb_inc == TRUE); } printf("\n******************************\n"); exit(0); } else { /* Figure out what is wrong... */ if ((param_status & BANDWIDTH) == 0) printf("mix: Bandwidth specification (B) is missing.\n"); if ((param_status & HARMONICS) == 0) printf("mix: Harmonics specification (H) is missing or too large.\n"); if ((param_status & MAXMIX) == 0) printf("mix: Maximum number of transmitters to mix at a time (M) is missing.\n"); if ((param_status & ORDER) == 0) printf("mix: Order specification (O) is missing.\n"); if ((param_status & RX) == 0) printf("mix: Too many or no receiver frequencies (R) specified.\n"); if ((param_status & TX) == 0) printf("mix: Too many or no transmitter frequencies (T) specified.\n"); exit(1); } } /* Read in our parameters... */ long read_params() { int c; /* Input character buffer... */ long status; /* Status byte... */ status = 0; max_rx = 0; max_tx = 0; while ((c = getchar()) != EOF) /* Parse the input line... */ switch (c) { case '?': printf("mix: Enter parameters one per line. Control-Z to end.\n"); printf("mix: B=Bandwidth,H=Harmonic,M=Max Tx,O=Order,R=Rx kHz,T=Tx kHz.\n\n"); break; /* We got the bandwidth parameter... */ case 'B': case 'b': bandwidth = get_int(); status |= BANDWIDTH; break; /* We got the number of harmonics to calculate... */ case 'H': case 'h': max_harmonic = get_int(); if (max_harmonic <= MAXHARM) status |= HARMONICS; else status &= ~HARMONICS; break; /* We got maximum number of transmitters to mix... */ case 'M': case 'm': max_mix = get_int(); status |= MAXMIX; break; /* We got the maximum order to calculate... */ case 'O': case 'o': max_order = get_int(); status |= ORDER; break; /* We got a receiver frequency... */ case 'R': case 'r': rx[max_rx++] = get_int(); if (max_rx <= (MAXTRANS+1)) status |= RX; /* Turn on RX bit... */ else status &= ~RX; /* Turn off RX bit... */ break; /* We got a transmitter frequency... */ case 'T': case 't': tx[max_tx++] = get_int(); if (max_tx <= (MAXTRANS+1)) status |= TX; /* Turn on TX bit... */ else status &= ~TX; /* Turn off TX bit... */ break; } /* Return our status... */ return(status); } /* Read in characters until newline... */ long get_int() { long c; /* Input character buffer... */ char *p, /* Pointer to array elements... */ inbuf[BUFSIZ]; /* Input string buffer... */ p = &inbuf[0]; /* Start out pointer at first position in array... */ c = getchar(); /* Priming read... */ *p = (char) c; /* Put the char in the array... */ /* While we are not at EOF and not at the end of the line... */ while ((c != EOF) && (c != '\n')) { c = getchar(); *++p = (char) c; /* Fill up the buffer... */ } /* If we got EOF, push it back so it will get caught later... */ if (c == EOF) ungetc(c, stdin); return(atol(inbuf)); /* Return its integer equivalent... */ } /* Initialize all that we need... */ init_bounds() { long index; /* Insure that these will get set appropriately... */ lower_bound = 999999999; upper_bound = 0; /* Find our bounds of interest... */ for(index=0;index upper_bound) upper_bound = rx[index]; } /* Adjust bounds for bandwidth... */ lower_bound -= bandwidth; upper_bound += bandwidth; }