Claudia Haarman / Mbed 2 deprecated Opstellingbachelor_opdracht

Dependencies:   MODSERIAL SDFileSystemSeth mbed

Fork of Opstellingbachelor_opdracht by Seth Ruiter

Revision:
7:9f9ea047975d
Parent:
6:5951403edfd2
Child:
8:1326141017ea
--- a/main.cpp	Mon Oct 10 11:06:35 2016 +0000
+++ b/main.cpp	Mon Oct 10 14:25:22 2016 +0000
@@ -11,13 +11,14 @@
 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[1]={D2};        //thermocouple 1 select corresponding pin numbers mbed
 
 
-double d;
-//unsigned int b[12] = { };
-unsigned int b[1] = { };
+float d;
+//int16_t b[12] = { };
+int16_t b[1];
 
 // Torque sensor
 AnalogIn fcs(PTB2);     // force sensor output connected to analog 0
@@ -86,10 +87,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 < 0; j++) { //read out bits for each thermocouple (0 to 11)
+        wait_ms(0.1);                   //wait for 100ns
+        for (int j = 0; j < 1; j++) { //read out bits for each thermocouple (0 to 11)
             if (pins[j]) {
                 b[j] |= (1 << i);       //bitshift
             }
@@ -98,16 +99,15 @@
     
     CS_1 = 1;
     
-    for (int j = 0; j < 0; j++) {     //for every thermocouple (starting from 0 to 11, so 12 in total)
+    for (int j = 0; j < 1; 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 {
             b[j] &= 0xfffc;             //if no fault then select 14 bit thermocouple data from bitstring
-            d = b[j] / 16.0 * 100.0;
-            b[j] = d;
+            d = b[j] / 16.0;
         }
-        fprintf(fp, "%.3d \n\r", b[j]);
-        pc.printf("%.3d \n\r", b[j]);
+        fprintf(fp, "%.3f \n\r", d);
+        pc.printf("%.3f \n\r", d);
     }
     //fprintf(fp, "\n\r");
     return;