Temp

Dependencies:   mbed

Committer:
ajclark2
Date:
Fri Mar 28 01:42:38 2014 +0000
Revision:
1:2178a66e1223
Parent:
0:e99407475b62
Child:
2:d5b23f4e6884
REV2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ajclark2 0:e99407475b62 1 #include "mbed.h"
ajclark2 1:2178a66e1223 2 #define PI 3.1415926
ajclark2 0:e99407475b62 3
ajclark2 1:2178a66e1223 4 AnalogIn ain_v1(p20); //
ajclark2 1:2178a66e1223 5 //AnalogIn ain_v2(p19);
ajclark2 0:e99407475b62 6
ajclark2 0:e99407475b62 7 int main()
ajclark2 0:e99407475b62 8 {
ajclark2 1:2178a66e1223 9 float v1, m, b, p_in, c, r, f
ajclark2 1:2178a66e1223 10 int value1
ajclark2 0:e99407475b62 11
ajclark2 1:2178a66e1223 12 // Voltage to Power calculations
ajclark2 1:2178a66e1223 13 v1 = ain_v1; // Comes from mBed (Can adjust manually for now)
ajclark2 1:2178a66e1223 14 b = 2.095; // (volts) Direct function generator measurement
ajclark2 1:2178a66e1223 15 m = .0316; // volts/dBm (Calculated at 2000 MHz and 0 and -40 dBm)
ajclark2 1:2178a66e1223 16 p_in = (v1-b)/m; // Derived from v = m*p+b (linear relationship of voltage and power)
ajclark2 1:2178a66e1223 17 // m = slope , v1 = vin, b = y-intercept
ajclark2 1:2178a66e1223 18
ajclark2 1:2178a66e1223 19 // Range equation Terms
ajclark2 1:2178a66e1223 20 Pt = .001; //(mW or 0 dBm) Power Transmitted. This should be constant for a phone I think... it just changes with the function generator
ajclark2 1:2178a66e1223 21 Gt = 1; // Unitless (1 for FG)
ajclark2 1:2178a66e1223 22 Gr = ??; // How do we get this? Should be on datasheet... but calc required?
ajclark2 1:2178a66e1223 23 Pr = p_in;
ajclark2 0:e99407475b62 24
ajclark2 1:2178a66e1223 25 // Free Space Loss Terms
ajclark2 1:2178a66e1223 26 f = 2000 // (MHz) This will be constant for a phone... but what to put for the FG
ajclark2 1:2178a66e1223 27 c = 2.99792458*10^8;
ajclark2 0:e99407475b62 28
ajclark2 1:2178a66e1223 29 r = [c*(sqrt(Pt*Gt*Gr)/Pr)]/(4*PI*f);
ajclark2 1:2178a66e1223 30
ajclark2 1:2178a66e1223 31
ajclark2 0:e99407475b62 32
ajclark2 0:e99407475b62 33 }
ajclark2 0:e99407475b62 34
ajclark2 0:e99407475b62 35
ajclark2 0:e99407475b62 36
ajclark2 1:2178a66e1223 37
ajclark2 1:2178a66e1223 38