ECG_ADS1198

Dependencies:   ADSlib mbed SDFileSystem

This was created for an internship project at IIT hyderabad.

Files at this revision

API Documentation at this revision

Comitter:
joelbandi
Date:
Fri May 01 20:26:20 2015 +0000
Parent:
4:dee470044b03
Commit message:
1

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r dee470044b03 -r 4bcb26d018f8 main.cpp
--- a/main.cpp	Thu Apr 09 21:07:59 2015 +0000
+++ b/main.cpp	Fri May 01 20:26:20 2015 +0000
@@ -6,7 +6,7 @@
 DigitalOut CLKSEL(p8);
 DigitalOut ADS1CS(p16);
 DigitalOut ADS2CS(p17);
-DigitalOut MULT_ADS(p18);
+DigitalIn MULT_ADS(p18);
 DigitalOut PWDN(p10);
 DigitalOut RESETpin(p9);
 DigitalOut STARTpin(p19);
@@ -14,8 +14,8 @@
 DigitalIn DRDY(p15);
 SPI spi(p5,p6,p7);
 SDFileSystem sd(p11,p12,p13,p14,"sd");
-signed char Input_Data_Stream[19];
-int16_t Input_modified[12];
+signed char Input_Data_Stream[];
+uint16_t Input_modified[];
 LocalFileSystem local("local");
 /********************************************************************/
 
@@ -69,50 +69,157 @@
     //write main superloop and rdatac mode and enable dout conversion AND SETUP FILESTORAFGE
     Timer tensec;
     tensec.start();
-    while(tensec.read()<=10) {
-        spi.write(RDATAC);
-        wait_ms(10);
-        while(DRDY) {}
-        ADS1CS= 0;
-        for (int i=0; i<=18; i++) {
-            Input_Data_Stream[i] = spi.write(0x00);
-        }
-        for(int i=3; i<=17; i++) {
+    
+    
+    
+    
+    if (MULT_ADS = 0) {
+        while(tensec.read()<=10) {
+            spi.write(RDATAC);
+            wait_ms(10);
+            while(DRDY) {}
+            ADS1CS= 0;
+            for (int i=0; i<=18; i++) {
+                Input_Data_Stream[i] = spi.write(0x00);
+            }
             int k= 0;
             int j= 4;
-            Input_modified[k]=Input_Data_Stream[i]<<8 + Input_Data_Stream[j];
-            j++;
-            k++;
-        }
-        Input_modified[8]=Input_modified[7]-Input_modified[6];
-        Input_modified[9]=-(Input_modified[7]+Input_modified[6]/2);
-        Input_modified[10]=((2*Input_modified[6])-Input_modified[7])/2;
-        Input_modified[11]=((2*Input_modified[7])-Input_modified[6])/2;
-        spi.write(SDATAC);
+            for(int i=3; i<=17; i++) {
+                Input_modified[k]=Input_Data_Stream[i]<<8 + Input_Data_Stream[j];
+                j++;
+                k++;
+            }
+            Input_modified[8]=Input_modified[7]-Input_modified[6];
+            Input_modified[9]=-(Input_modified[7]+Input_modified[6]/2);
+            Input_modified[10]=((2*Input_modified[6])-Input_modified[7])/2;
+            Input_modified[11]=((2*Input_modified[7])-Input_modified[6])/2;
+            spi.write(SDATAC);
 
-        /***********************FILE IO PROCEDURE ON LOCAL STORAGE******************/
-        FILE* file = fopen("local/logfile.txt","w");
-        for (int k =0; k<12; k++) {
-            fputc(Input_modified[k],file);
-        }
-        //dont forget to 
-        //fclose(file);
-        /***************************************************************************/
+            /***********************FILE IO PROCEDURE ON LOCAL STORAGE******************/
+            FILE* file = fopen("local/logfile.txt","w");
+            for (int k =0; k<12; k++) {
+                fputc(Input_modified[k],file);
+            }
+            //dont forget to
+            //fclose(file);
+            /***************************************************************************/
 
 
 ///////////////////////////OR///////////////////////////////////////////////////////////////////////
 
 
-        /****************************SD I/O OPERATIONS *****************************/
-        mkdir("sd/logfiledir",0777);
-        FILE* file1 = fopen("sd/logfiledir/logfile.txt","w");
-        for (int k =0; k<12; k++) {
-            fputc(Input_modified[k],file1);
+            /****************************SD I/O OPERATIONS *****************************/
+            mkdir("sd/logfiledir",0777);
+            FILE* file1 = fopen("sd/logfiledir/logfile.txt","w");
+            for (int k =0; k<12; k++) {
+                fputc(Input_modified[k],file1);
+            }
+            //dont forget to
+            //fclose(file1);
+            /***************************************************************************/
         }
-        //dont forget to 
-        //fclose(file1);
-        /***************************************************************************/
+    }
+    
+    
+     if (MULT_ADS = 0) {
+        while(tensec.read()<=10) {
+            spi.write(RDATAC);
+            wait_ms(10);
+            while(DRDY) {}
+            ADS1CS= 0;
+            for (int i=0; i<=18; i++) {
+                Input_Data_Stream[i] = spi.write(0x00);
+            }
+            int k= 0;
+            int j= 4;
+            for(int i=3; i<=17; i++) {
+                Input_modified[k]=Input_Data_Stream[i]<<8 + Input_Data_Stream[j];
+                j++;
+                k++;
+            }
+            Input_modified[8]=Input_modified[7]-Input_modified[6];
+            Input_modified[9]=-(Input_modified[7]+Input_modified[6]/2);
+            Input_modified[10]=((2*Input_modified[6])-Input_modified[7])/2;
+            Input_modified[11]=((2*Input_modified[7])-Input_modified[6])/2;
+            spi.write(SDATAC);
+
+            /***********************FILE IO PROCEDURE ON LOCAL STORAGE******************/
+            FILE* file = fopen("local/logfile.txt","w");
+            for (int k =0; k<12; k++) {
+                fputc(Input_modified[k],file);
+            }
+            //dont forget to
+            //fclose(file);
+            /***************************************************************************/
+
+
+///////////////////////////OR///////////////////////////////////////////////////////////////////////
+
+
+            /****************************SD I/O OPERATIONS *****************************/
+            mkdir("sd/logfiledir",0777);
+            FILE* file1 = fopen("sd/logfiledir/logfile.txt","w");
+            for (int k =0; k<12; k++) {
+                fputc(Input_modified[k],file1);
+            }
+            //dont forget to
+            //fclose(file1);
+            /***************************************************************************/
+        }
     }
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
     tensec.stop();
     waitled =0;
 }