'General Space Communication Program [COMMPARS.BAS]
'define some constants
kB = 1.38E-23
pi = 3.14159
'input data - CR for the parameter you want calculated
CLS
INPUT "Transmitter power or EIRP (watts)"; Pt
INPUT "Transmit antenna gain [=1 if EIRP above] (number)"; Tgain
INPUT "Transmit antenna gain (dB)"; TgaindB
INPUT "Receive system noise temperature (K)"; Ts
INPUT "Receive antenna dish diameter (metres)"; Rd
INPUT "Receive antenna efficiency (%)"; Reff
INPUT "Receive antenna gain (number)"; Rgain
INPUT "Receive antenna gain (dB)"; RgaindB
INPUT "Communication range (km)"; range
INPUT "Signal to noise ratio (dB)"; SNRdB
INPUT "System bandwidth (Hz)"; bw
INPUT "System frequency [required input] (MHz)"; freq
'now compute alternative variables
wavel = 300 / freq 'wavelength in metres
IF SNRdB <> 0 THEN SNR = 10 ^ (SNRdB / 10)
IF TgaindB <> 0 THEN Tgain = 10 ^ (TgaindB / 10)
IF Pt <> 0 THEN
IF Tgain <> 0 THEN
Peff = Pt * Tgain
ELSE
Peff = Pt
END IF
END IF
IF Rd <> 0 THEN
IF Reff <> 0 THEN
Ae = Reff * pi * Rd * Rd / 4 'antenna affective area
ELSE
Ae = .7 * pi * Rd * Rd / 4 'assume 70% efficient
END IF
END IF
IF RgaindB <> 0 THEN Rgain = 10 ^ (RgaindB / 10)
IF Rgain <> 0 THEN Ae = wavel ^ 2 * Rgain / 4 / pi
IF range <> 0 THEN rangem = range * 1000
IF Ae <> 0 AND RgaindB = 0 THEN RgaindB = 10 * LOG(4 * pi * Ae / wavel ^ 2) / 2.303
'now compute unknown parameter - if more than one bad luck, try again
IF Peff = 0 THEN Peff = 4 * pi * rangem ^ 2 * kB * bw * Ts * SNR / Ae
IF SNR = 0 THEN SNR = Ae * Peff / (4 * pi * rangem ^ 2 * kB * bw * Ts)
IF Ae = 0 THEN Ae = 4 * pi * rangem ^ 2 * kB * bw * Tz * SNR / Peff
IF range = 0 THEN range = SQR(Ae * Peff / (4 * pi * kB * bw * Ts * SNR)) / 1000
IF bw = 0 THEN bw = Ae * Peff / (4 * pi * rangem ^ 2 * kB * Ts)
IF Ts = 0 THEN Ts = Ae * Peff / (4 * pi * rangem ^ 2 * kB * bw)
SNRdB = 10 * LOG(SNR) / 2.303
'print parameters
PRINT
PRINT "SPACE COMMUNICATION PARAMETERS"
PRINT
PRINT USING "Effective transmitted power = #######.# W"; Peff
PRINT USING "Receive antenna collecting area = #######.# square metres"; Ae
PRINT USING " [Receive antenna gain = ###.# dB]"; RgaindB
PRINT USING "Communication range = ######### km"; range
PRINT USING "System noise temp = ###### K"; Ts
PRINT USING "Bandwith = #####.### kHz"; bw / 1000
PRINT USING "Signal to noise ratio = ###.# dB"; SNRdB
END