Interfacing ADAS1000 ECG device by Arduino Uno

Hello Everyone,

I am trying to do SPI communication for receiving ECG data in serial monitor by Arduino IDE.
My ECG circuit is ADAS1000 (see the attachment) and using Arduino Uno.

If you look the datasheet page number 50-52 you can see serial interface descriptions.
Table 23 is describing several register information which are difficult to place in code and it said
Packet data/frame rates should be programmed.

I cant understand how to handle such large number of resisters, how to set up and read the data, including how to configure the register?

Can you help me please.

My ECG circuit is ADAS1000 (see the attachment)

There was nothing attached.

I am trying to do SPI communication for receiving ECG data in serial monitor by Arduino IDE.

If you look the datasheet page number 50-52 you can see serial interface descriptions.

Serial and SPI are quite different.

Dear Sir,

Thank you a lot! I am really disappointing to write SPI code. I am a new arduino user.
Sorry for not able to attach big file. This is the datasheet link.

http://www.analog.com/media/en/technical-documentation/data-sheets/ADAS1000_1000-1_1000-2.pdf

It looks related register configuration is tough. One reference could give an idea,
http://www.mit.edu/~gari/CODE/ECG_lab/ecg_ads1292.ino

  1. What would be the buffer writing ?
    2.How to configure DRDY?
    3.It needs interrupt?

Kindly look at this code,
Circuit:
ADAS1000 ecg board attached to pins 6, 7, 10 - 13:
DRDY: pin 6
CSB: pin 7
MOSI: pin 11
MISO: pin 12
SCK: pin 13

// SPI
#define DOUT 11 //MOSI
#define DIN 12 //MISO
#define SPICK 13 //SCK

// pins
#define PIN_CS 10
#define PIN_DRDY 6

#include <SPI.h>

//ADAS1000's memory register addresses:
const int LEADONE_LA = 0x11; //3 most significant bits of left arm ECG
const int LEADTWO_LL = 0x12; //16 least significant bits of left leg ECG
const byte READ = 0x40 ; // ADAS1000's read command
const byte WRITE =0x81F804AE; // ADAS1000's write command

// pins used for the connection with ecg device
// initialization the data ready and chip select pins:

pinMode(SPICK, OUTPUT);
pinMode(DIN, INPUT);
pinMode(DOUT, OUTPUT);
pinMode(PIN_LED, OUTPUT);
pinMode(PIN_CS, OUTPUT);
pinMode(PIN_RESET, OUTPUT);
pinMode(PIN_START, OUTPUT);
pinMode(PIN_DRDY, INPUT);
digitalWrite(PIN_CS, HIGH);
digitalWrite(PIN_START, LOW);
delay(0.50);
}

void setup() {
Serial.begin(9600);

// start the SPI library:
SPI.begin();

//the important parmiter for SPI communication
// spi data mode
// sets clock polarity and phase
// CPOL = 0 (clock polarity, clock is idle when low)
// CPHA = 1 (clock phase , data is shifted in and out on the rising of the data clock signal )
SPI.setDataMode(SPI_MODE1);

// spi clock divider
// sets relative to the system clock
// n transitions per cycles (SPI_CLOCK_DIV2 = 1 transition / 2 cycles)
// DIV4 is arduino default, override to make faster
// needs to be at least 32, or the clock is too slow, 64 to be safe
SPI.setClockDivider(SPI_CLOCK_DIV16);

// spi bit order
// sets the order of the bits shifted in and out
// MSBFIRST = most-significant bit first
SPI.setBitOrder(MSBFIRST);

//Setting of DRDY for interrupt service routine
int pin = 6;
volatile int state = LOW;

void setup() {
pinMode(6, OUTPUT);
attachInterrupt(digitalPinToInterrupt(pin), blink, CHANGE);
}

void loop() {
digitalWrite(pin, state);
}

void blink() {
state = !state;
}

// don't do anything until the data ready pin is high:
if (digitalRead(PIN_CS) == HIGH) {
//Read the ss data
int LEADONE_LA= readRegister(0x11, 2);

Serial.print("left arm ECG=");
Serial.print(left arm ECG);

//Read the pressure data highest 3 bits:
byte pressure_data_high = readRegister(0x1F, 1);
pressure_data_high &= 0b00000111; //you only needs bits 2 to 0

//Read the pressure data lower 16 bits:
unsigned int pressure_data_low = readRegister(0x20, 2);
//combine the two parts into one 19-bit number:
long pressure = ((pressure_data_high << 16) | pressure_data_low) / 4;

// display the temperature:
Serial.println("\tPressure [Pa]=" + String(pressure));
}
}

//Read from or write to register from the ADAS1000:
unsigned int readRegister(byte thisRegister, int bytesToRead ) {
byte inByte = 0; // incoming byte from the SPI
unsigned int result = 0; // result to return
Serial.print(thisRegister, BIN);
Serial.print("\t");
// SCP1000 expects the register name in the upper 6 bits
// of the byte. So shift the bits left by two bits:
thisRegister = thisRegister << 2;
// now combine the address and the command into one byte
byte dataToSend = thisRegister & READ;
Serial.println(thisRegister, BIN);
// take the chip select low to select the device:
digitalWrite(chipSelectPin, LOW);
// send the device the register you want to read:
SPI.transfer(dataToSend);
// send a value of 0 to read the first byte returned:
result = SPI.transfer(0x00);
// decrement the number of bytes left to read:
bytesToRead--;
// if you still have another byte to read:
if (bytesToRead > 0) {
// shift the first byte left, then get the second byte:
result = result << 8;
inByte = SPI.transfer(0x00);
// combine the byte you just got with the previous one:
result = result | inByte;
// decrement the number of bytes left to read:
bytesToRead--;
}
// take the chip select high to de-select:
digitalWrite(chipSelectPin, HIGH);
// return the result:
return(result);
}

//Sends a write command to ADAS1000

void writeRegister(byte thisRegister, byte thisValue) {

// SCP1000 expects the register address in the upper 6 bits
// of the byte. So shift the bits left by two bits:
thisRegister = thisRegister << 2;
// now combine the register address and the command into one byte:
byte dataToSend = thisRegister | WRITE;

// take the chip select low to select the device:
digitalWrite(chipSelectPin, LOW);

SPI.transfer(dataToSend); //Send register location
SPI.transfer(thisValue); //Send value to record into register

// take the chip select high to de-select:
digitalWrite(chipSelectPin, HIGH);
}

I am also interested in using this IC. Have you had any luck getting anything to work?

Yes...I have read this device using ARM type MCU. Things are not easy due to complex protocol. :confused:

Hasaniirc:
Dear Sir,

Thank you a lot! I am really disappointing to write SPI code. I am a new arduino user.
Sorry for not able to attach big file. This is the datasheet link.

http://www.analog.com/media/en/technical-documentation/data-sheets/ADAS1000_1000-1_1000-2.pdf

It looks related register configuration is tough. One reference could give an idea,
http://www.mit.edu/~gari/CODE/ECG_lab/ecg_ads1292.ino

  1. What would be the buffer writing ?
    2.How to configure DRDY?
    3.It needs interrupt?

Kindly look at this code,
Circuit:
ADAS1000 ecg board attached to pins 6, 7, 10 - 13:
DRDY: pin 6
CSB: pin 7
MOSI: pin 11
MISO: pin 12
SCK: pin 13

// SPI
#define DOUT 11 //MOSI
#define DIN 12 //MISO
#define SPICK 13 //SCK

// pins
#define PIN_CS 10
#define PIN_DRDY 6

#include <SPI.h>

//ADAS1000's memory register addresses:
const int LEADONE_LA = 0x11; //3 most significant bits of left arm ECG
const int LEADTWO_LL = 0x12; //16 least significant bits of left leg ECG
const byte READ = 0x40 ; // ADAS1000's read command
const byte WRITE =0x81F804AE; // ADAS1000's write command

// pins used for the connection with ecg device
// initialization the data ready and chip select pins:

pinMode(SPICK, OUTPUT);
pinMode(DIN, INPUT);
pinMode(DOUT, OUTPUT);
pinMode(PIN_LED, OUTPUT);
pinMode(PIN_CS, OUTPUT);
pinMode(PIN_RESET, OUTPUT);
pinMode(PIN_START, OUTPUT);
pinMode(PIN_DRDY, INPUT);
digitalWrite(PIN_CS, HIGH);
digitalWrite(PIN_START, LOW);
delay(0.50);
}

void setup() {
Serial.begin(9600);

// start the SPI library:
SPI.begin();

//the important parmiter for SPI communication
// spi data mode
// sets clock polarity and phase
// CPOL = 0 (clock polarity, clock is idle when low)
// CPHA = 1 (clock phase , data is shifted in and out on the rising of the data clock signal )
SPI.setDataMode(SPI_MODE1);

// spi clock divider
// sets relative to the system clock
// n transitions per cycles (SPI_CLOCK_DIV2 = 1 transition / 2 cycles)
// DIV4 is arduino default, override to make faster
// needs to be at least 32, or the clock is too slow, 64 to be safe
SPI.setClockDivider(SPI_CLOCK_DIV16);

// spi bit order
// sets the order of the bits shifted in and out
// MSBFIRST = most-significant bit first
SPI.setBitOrder(MSBFIRST);

//Setting of DRDY for interrupt service routine
int pin = 6;
volatile int state = LOW;

void setup() {
pinMode(6, OUTPUT);
attachInterrupt(digitalPinToInterrupt(pin), blink, CHANGE);
}

void loop() {
digitalWrite(pin, state);
}

void blink() {
state = !state;
}

// don't do anything until the data ready pin is high:
if (digitalRead(PIN_CS) == HIGH) {
//Read the ss data
int LEADONE_LA= readRegister(0x11, 2);

Serial.print("left arm ECG=");
Serial.print(left arm ECG);

//Read the pressure data highest 3 bits:
byte pressure_data_high = readRegister(0x1F, 1);
pressure_data_high &= 0b00000111; //you only needs bits 2 to 0

//Read the pressure data lower 16 bits:
unsigned int pressure_data_low = readRegister(0x20, 2);
//combine the two parts into one 19-bit number:
long pressure = ((pressure_data_high << 16) | pressure_data_low) / 4;

// display the temperature:
Serial.println("\tPressure [Pa]=" + String(pressure));
}
}

//Read from or write to register from the ADAS1000:
unsigned int readRegister(byte thisRegister, int bytesToRead ) {
byte inByte = 0; // incoming byte from the SPI
unsigned int result = 0; // result to return
Serial.print(thisRegister, BIN);
Serial.print("\t");
// SCP1000 expects the register name in the upper 6 bits
// of the byte. So shift the bits left by two bits:
thisRegister = thisRegister << 2;
// now combine the address and the command into one byte
byte dataToSend = thisRegister & READ;
Serial.println(thisRegister, BIN);
// take the chip select low to select the device:
digitalWrite(chipSelectPin, LOW);
// send the device the register you want to read:
SPI.transfer(dataToSend);
// send a value of 0 to read the first byte returned:
result = SPI.transfer(0x00);
// decrement the number of bytes left to read:
bytesToRead--;
// if you still have another byte to read:
if (bytesToRead > 0) {
// shift the first byte left, then get the second byte:
result = result << 8;
inByte = SPI.transfer(0x00);
// combine the byte you just got with the previous one:
result = result | inByte;
// decrement the number of bytes left to read:
bytesToRead--;
}
// take the chip select high to de-select:
digitalWrite(chipSelectPin, HIGH);
// return the result:
return(result);
}

//Sends a write command to ADAS1000

void writeRegister(byte thisRegister, byte thisValue) {

// SCP1000 expects the register address in the upper 6 bits
// of the byte. So shift the bits left by two bits:
thisRegister = thisRegister << 2;
// now combine the register address and the command into one byte:
byte dataToSend = thisRegister | WRITE;

// take the chip select low to select the device:
digitalWrite(chipSelectPin, LOW);

SPI.transfer(dataToSend); //Send register location
SPI.transfer(thisValue); //Send value to record into register

// take the chip select high to de-select:
digitalWrite(chipSelectPin, HIGH);
}

hi hasan, im Gon. are you done with this program?
I'm interesting with this? can you share with me?