ECG_ADS1198
Dependencies: ADSlib mbed SDFileSystem
This was created for an internship project at IIT hyderabad.
Revision 2:86845af4bcac, committed 2015-04-05
- Comitter:
- joelbandi
- Date:
- Sun Apr 05 20:34:03 2015 +0000
- Parent:
- 1:65a219536d66
- Child:
- 3:86eef673aec5
- Commit message:
- SUPERFIX;
Changed in this revision
| ADSlib.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/ADSlib.lib Thu Apr 02 13:27:43 2015 +0000 +++ b/ADSlib.lib Sun Apr 05 20:34:03 2015 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/users/joelbandi/code/ADSlib/#e3a7ca6b9405 +http://developer.mbed.org/users/joelbandi/code/ADSlib/#8c8ce127f100
--- a/main.cpp Thu Apr 02 13:27:43 2015 +0000
+++ b/main.cpp Sun Apr 05 20:34:03 2015 +0000
@@ -1,15 +1,97 @@
#include "mbed.h"
#include "ADSlib.h"
+/***********************PROTOTYPING**********************************/
+DigitalOut CLKSEL(p8);
+DigitalOut ADS1CS(p11);
+DigitalOut ADS2CS(p12);
+DigitalOut MULT_ADS(p13);
+DigitalOut PWDN(p10);
+DigitalOut RESETpin(p9);
+DigitalOut STARTpin(p14);
+DigitalIn DRDY(p15);
+SPI spi(p5,p6,p7);
+/********************************************************************/
+signed char Input_Data_Stream[19];
+int16_t Input_modified[12];
+
+int main() // main call
+{
+ /********************POWER ON SEQUENCING *****************************/
+ wait_ms(500); // boot up time
+
+ ADS1CS=1; // deselect ADS1
+ spi.format(8,3); //spi setttings
+ spi.frequency(1000000); //spi settings
+
+ CLKSEL = 1; //clock signal (internal) setup Frequency = 2.048 MHz
+ ADS1CS= 0;
+ spi.write(W_CONFIG1);
+ spi.write(0x00);
+ spi.write(0x64);
+ ADS1CS =1;
+
+ PWDN = 1;
+ RESETpin = 1;
+ wait(1); //Delay for Power-On Reset and Oscillator Start-Up
+
+ ADS1CS= 0; // intial reset command for device reset and register setting clean up
+ spi.write(RESET);
+ pause_clk(18);
+
+
+ spi.write(SDATAC); // device boots up in RDATAC mode set it in SDATAC mode
+ pause_clk(4);
+
+
+ spi.write(W_CONFIG3); // internal reference stup and enable
+ spi.write(0x00);
+ spi.write(0xC0);
+
+ /***************POWER ON SEQUENCING COMPLETE**************************/
+
+
+ /**************CHANNEL SETTINGS***************************************/
+ spi.write(W_CHnSET);
+ spi.write(0x07);
+ spi.write((int)ADS_Default_Channel_Settings);
+ ADS1CS = 1;
+ /*********************************************************************/
+
+ /*****************************CONVERSION BEGINS**********************/
+ STARTpin= 1;
+
+ //write main superloop and rdatac mode and enable dout conversion AND SETUP FILESTORAFGE
+
+ 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++) {
+ 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);
+
-int main(){
- while(true){
-
-
- }
-
- }
-
-
+
+
+
+
+
+}
+
+
+