Claudia Haarman / Mbed 2 deprecated Opstellingbachelor_opdracht

Dependencies:   MODSERIAL SDFileSystemSeth mbed

Fork of Opstellingbachelor_opdracht by Seth Ruiter

Revision:
6:5951403edfd2
Parent:
5:f92906aaf1c2
Child:
7:9f9ea047975d
--- a/main.cpp	Fri Oct 07 15:02:56 2016 +0000
+++ b/main.cpp	Mon Oct 10 11:06:35 2016 +0000
@@ -11,10 +11,13 @@
 DigitalOut SCK_1(D0);       // sck pin of thermocouples
 DigitalOut CS_1(D1);        // chip select pin of thermocouples
 
-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[12]={D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13};        //thermocouples 1 - 12 select corresponding pin numbers mbed
+DigitalIn pins[1]={D2};        //thermocouple 1 select corresponding pin numbers mbed
+
 
 double d;
-unsigned int b[12] = { };
+//unsigned int b[12] = { };
+unsigned int b[1] = { };
 
 // Torque sensor
 AnalogIn fcs(PTB2);     // force sensor output connected to analog 0
@@ -34,7 +37,7 @@
 Ticker tick;
 
 const int baudrate = 115200;      // baud rate
-const float Ts = 0.01;            // sample time (sec)
+const float Ts = 0.1;            // sample time (sec)
 
 const int led_on = 0;
 const int led_off = 1;
@@ -83,10 +86,10 @@
 
     for (int i = 15; i >= 0; i--) {
         SCK_1 = 0;                      //set clock value to 0
-        wait_ms(0.1);                   //wait for 100ns
+//        wait_ms(0.1);                   //wait for 100ns
         SCK_1 = 1;                      //then set clock high again
-        wait_ms(0.1);                   //wait for 100ns
-        for (int j = 0; j <= 11; j++) { //read out bits for each thermocouple (0 to 11)
+//        wait_ms(0.1);                   //wait for 100ns
+        for (int j = 0; j < 0; j++) { //read out bits for each thermocouple (0 to 11)
             if (pins[j]) {
                 b[j] |= (1 << i);       //bitshift
             }
@@ -95,7 +98,7 @@
     
     CS_1 = 1;
     
-    for (int j = 0; j <= 11; j++) {     //for every thermocouple (starting from 0 to 11, so 12 in total)
+    for (int j = 0; j < 0; j++) {     //for every thermocouple (starting from 0 to 11, so 12 in total)
         if (b[j] & 0x1) {               //b[j] contains the bits that are received from every chip. if least significant bit is 1, then open circuit.
             b[j] = 20000;
         } else {
@@ -103,9 +106,10 @@
             d = b[j] / 16.0 * 100.0;
             b[j] = d;
         }
-        fprintf(fp, "%.3d\t", b[j]);
+        fprintf(fp, "%.3d \n\r", b[j]);
+        pc.printf("%.3d \n\r", b[j]);
     }
-    fprintf(fp, "\n\r");
+    //fprintf(fp, "\n\r");
     return;
 
 }
@@ -115,6 +119,7 @@
     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    
     }
     return;