bachelor project code temperature not writing to file 22/05

Dependencies:   MODSERIAL SDFileSystemSeth mbed

Fork of reamer_experiments by Claudia Haarman

Files at this revision

API Documentation at this revision

Comitter:
sdruiter
Date:
Tue May 22 10:33:05 2018 +0000
Parent:
8:1326141017ea
Commit message:
temperature not writing to file 22/05;

Changed in this revision

SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/SDFileSystem.lib	Tue Oct 11 14:07:58 2016 +0000
+++ b/SDFileSystem.lib	Tue May 22 10:33:05 2018 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/SDFileSystem/#7b35d1709458
+https://os.mbed.com/users/sdruiter/code/SDFileSystemSeth/#7a6704fa37dd
--- a/main.cpp	Tue Oct 11 14:07:58 2016 +0000
+++ b/main.cpp	Tue May 22 10:33:05 2018 +0000
@@ -13,7 +13,7 @@
 
 
 //DigitalIn pins[12]={D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13};        //thermocouples 1 - 12 select corresponding pin numbers mbed
-DigitalIn pins[3]={D2, D3, D4};        //thermocouple select corresponding pin numbers mbed
+DigitalIn pins[7]={D2, D3, D4, D5, D6, D7, D10};        //thermocouple select corresponding pin numbers mbed
 
 
 // Torque sensor
@@ -44,6 +44,7 @@
 volatile bool meas = 0;
 
 float fcs_read;
+float read_TC;
 
 int trial_numb = 0;
 int cal_numb = 1;
@@ -106,11 +107,11 @@
             b[j] &= 0xfffc;             //if no fault then select 14 bit thermocouple data from bitstring
             d = b[j] / 16.0;
         }
-        //fprintf(fp, "%.3f \n\r", d);
+        fprintf(fp, "%.3f \n\r", d);
         pc.printf("%.3f\t", d);
     }
-    pc.printf("\n\r");
-    //fprintf(fp, "\n\r");
+   // pc.printf("\n\r");
+    fprintf(fp, "\n\r");
     return;
 
 }
@@ -119,9 +120,10 @@
 {
     if(meas){                                   // alleen data uitlezen en opslaan als meas = 1
         fcs_read = fcs.read();                  // capture torque sensor data   
-        //fprintf(fp, "%.3f\t", fcs_read);        // output data to file
-        pc.printf("%.3f\t", fcs_read);          // output data to screen
-        readTC();                               // call function to read thermocouple data    
+        fprintf(fp, "%.3f\t", fcs_read);        // output data to file
+       // pc.printf("%.3f\t", fcs_read);          // output data to screen
+        read_TC = readTC();                               // call function to read thermocouple data 
+        fprintf(fp,"%.3f\t", read_TC);   
     }
     return;
 }
@@ -148,6 +150,7 @@
                 case 'c':
                     led_control(led_on,led_on,led_off);                         //orange LED during calibration
                     sprintf(filename_cal, "/sd/cal_torque_%d.txt", cal_numb);   //construct new textfile
+                    sprintf(filename_cal, "/sd/cal_temp_%d.txt", cal_numb);
                     fp = fopen(filename_cal, "w");
                     if(fp == NULL) {
                         error("Could not open file for write\n");
@@ -161,6 +164,7 @@
                         }
                     }
                     fclose(fp);                                             //close file
+                   
                     cal_numb++;                                             //increment calibration number
                     pc.printf("File saved as %s\n\r", filename_cal);        //print name of calibration file to screen
                     pc.printf("Press 'c' to record new calibration or 't' to start new trial\n\r");    // print message to screen
@@ -175,7 +179,10 @@
                     if (start) {
                         led_control(led_off,led_on,led_off);                        //green LED during measurement
                         sprintf(filename_torque, "/sd/trial%d.txt", trial_numb);    //construct new textfile to store data from torque sensor
+                        sprintf(filename_temp, "/sd/temp%d.txt", trial_numb);
                         fp = fopen(filename_torque, "w");
+                        fp = fopen(filename_temp, "w");
+                        
                         if(fp == NULL) {
                             error("Could not open file for write\n\r");
                         } else {
@@ -188,6 +195,7 @@
                         led_control(led_on,led_off,led_off);                                  // RED LED when ready to stopped measuring
                         meas = 0;                                                   // hiermee stop je de output naar het .txt file
                         fclose(fp);
+                        
                         pc.printf("File saved as %s\n\r", filename_torque);                                // print filename to screen
                         pc.printf("Press 'c' to perform new calibration or 't' to start new trial\n\r");    // print message to screen