Log Test Code

Dependencies:   C12832 mbed

Fork of VoltageThreshold by A Clark

Revision:
1:2178a66e1223
Parent:
0:e99407475b62
Child:
2:d5b23f4e6884
--- a/main.cpp	Tue Mar 18 15:15:47 2014 +0000
+++ b/main.cpp	Fri Mar 28 01:42:38 2014 +0000
@@ -1,34 +1,38 @@
 #include "mbed.h"
+#define PI 3.1415926
 
-AnalogIn   ain_v1(p20);
-AnalogIn   ain_v2(p19);
+AnalogIn   ain_v1(p20); // 
+//AnalogIn   ain_v2(p19);
 
 int main()
 {
-    float v1, v2;
-    int value1, value2; 
-    
-    v1 = ain_v1;
-    v2 = ain_v2;
-    
-    // Thresholded voltages as found in testing
+    float v1, m, b, p_in, c, r, f
+    int value1
     
-    if(v1 >= 2.345 & v1 <= 2.310)   // 824 MHz to 896 MHz
-    {
-        value1 = 1;
-    }
+    // Voltage to Power calculations
+    v1      = ain_v1;   // Comes from mBed (Can adjust manually for now)
+    b       = 2.095;    // (volts) Direct function generator measurement
+    m       = .0316;    // volts/dBm (Calculated at 2000 MHz and 0 and -40 dBm)
+    p_in    = (v1-b)/m; // Derived from v = m*p+b (linear relationship of voltage and power)
+                    // m = slope , v1 = vin, b = y-intercept
+   
+    // Range equation Terms
+    Pt      = .001;  //(mW or 0 dBm) Power Transmitted. This should be constant for a phone I think... it just changes with the function generator
+    Gt      = 1;     // Unitless (1 for FG)
+    Gr      = ??;    // How do we get this? Should be on datasheet... but calc required? 
+    Pr      = p_in;
     
-    if(v1 >= 2.120 & v1 <= 2.095)   // 1855 MHz to 1910 MHz
-    {
-        value1 = 1;
-    }
+    // Free Space Loss Terms
+    f       = 2000    // (MHz) This will be constant for a phone... but what to put for the FG
+    c       = 2.99792458*10^8;
     
-    else
-    {
-        value1 = 0;
-    }
+    r       = [c*(sqrt(Pt*Gt*Gr)/Pr)]/(4*PI*f);
+    
+    
     
 }
 
 
 
+
+