mbed code Inductive_Sensor_Jasper for Bsc paper

Dependencies:   Bob DS1825 LDC1101 SDFileSystem mbed

Fork of Inductive_Sensor by Bob Giesberts

Revision:
13:62442b016e9f
Parent:
12:cceece4f3afb
--- a/main.cpp	Tue Apr 12 14:42:52 2016 +0000
+++ b/main.cpp	Thu Jun 23 08:49:11 2016 +0000
@@ -24,9 +24,9 @@
 using namespace std;
 
 // SETTINGS
-bool DEBUG              = false;
+bool DEBUG              = true;
 float C                 = 120E-12;      // Capacitor in F
-uint16_t INTERVAL_FIRST = 600;          // First sampling time in seconds.  60:00 minutes = 600 sec
+uint16_t INTERVAL_FIRST = 600;          // First sampling time in seconds.  10:00 minutes = 600 sec
 uint16_t INTERVAL_OFF   = 870;          // Waiting interval in seconds.     14:30 minutes = 870 sec (14*60+30)
 uint16_t INTERVAL_ON    = 30;           // Sampling interval in seconds.     0:30 minutes =  30 sec
 
@@ -44,7 +44,7 @@
             PTC2, // battery
             PTE30 // 3V3_DET        TODO: can we use this to detect if we're charging the battery? If so, how should we respond?
             );
-// Serial pc(USBTX, USBRX);
+Serial pc(USBTX, USBRX);
 
 // timer variables
 uint32_t now = 0, next = 0, prev = 0;
@@ -65,7 +65,7 @@
 float T;
 
 // temporal storage for data samples
-const uint8_t package_size = 60;    // ±12-13 Hz, so 60 would take about 5 sec.
+const uint8_t package_size = 18;    // ±12-13 Hz, so 60 would take about 5 sec.
 struct mydata {
     uint32_t    t[package_size];    // time (s)
     uint32_t    L[package_size];    // LHR_DATA
@@ -83,7 +83,7 @@
     fclose( fp );               // close file
     bob.ledoff();
                  
-    // pc.printf( "%d points: %.2f;%d;%.4f;%.4f\r\n", counter, (float) collected.t[0]/100.0, collected.L[0], bob.battery(), T );
+    //pc.printf( "%d points: %.2f;%d;%.4f;%.4f\r\n", counter, (float) collected.t[0]/100.0, collected.L[0], bob.battery(), T );
                     
     // Reset data
     memset(collected.t, 0, counter);
@@ -91,8 +91,45 @@
     counter = 0;    
 }
 
+
 int main(void)
 {
+    if(DEBUG)  
+    {
+        // load libraries to take control over the communication        
+        LDC1101 *ldc = new LDC1101( PTC6,   // mosi
+                                    PTC7,   // miso
+                                    PTC5,   // sck
+                                    PTC4,   // cs
+                                    C,      // capacitor
+                                    16E6    // f_CLKIN
+                                    );      // load sensor (LDC1101) library (this takes 0.81 s)
+        DS1825 *thermometer = new DS1825( _Tpin );                          // load thermometer (DS1825) library
+        
+        while(1)
+        {
+            // wait for new data to be ready
+            while( !ldc->is_New_LHR_data() ) { }
+            
+            pc.printf("%.3f\n", ldc->get_fsensor());
+            
+            //wait(0.1);
+            
+           
+        }
+        
+        
+    }
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
     // Load SD File system
     // - the Raspberry Pie SD cards give a warning here that might just be ignored:
     //      "Not in idle state after sending CMD8 (not an SD card?)
@@ -183,6 +220,11 @@
             // wait for new data to be ready
             while( !ldc->is_New_LHR_data() ) { }
 
+            
+            pc.printf("%d\n", ldc->get_LHR_Data());
+
+
+
             // what time is it now?
             prev = now;
             now = (uint32_t) clock();